arkoudinos
Newbie level 4
I am trying to test a simple compare circuit. I want this comparator to initialize its ouptut on reset, because it is needed by another part of the circuit. I've came up writing something like this:
It seems to work on simulation, however I'm concerned about the process I wrote. Could you please tell me if my approach is correct, and if not why?
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity X16Comparator is
port (
sad_cur, sad : in std_logic_vector(15 downto 0);
pos_cur, pos : in std_logic_vector(10 downto 0);
minSAD : out std_logic_vector(15 downto 0);
minPOS : out std_logic_vector(10 downto 0);
clk, rst : in std_logic
);
end X16Comparator;
architecture Behavioral of X16Comparator is
signal aeqb, altb, agtb: std_logic;
begin
aeqb <= '1' when (sad_cur = sad) else '0';
altb <= '1' when (sad_cur < sad) else '0';
agtb <= '1' when (sad_cur > sad) else '0';
process(aeqb, altb, agtb, clk, rst)
begin
if (rst = '1' AND rising_edge(clk)) then
minSAD <= (others => '1');
minPOS <= (others => '1');
end if;
if (aeqb = '1' or agtb = '1') then
minSAD <= sad;
minPOS <= pos;
else
minSAD <= sad_cur;
minPOS <= pos_cur;
end if;
end process;
end Behavioral;
It seems to work on simulation, however I'm concerned about the process I wrote. Could you please tell me if my approach is correct, and if not why?