4-Bit Comparator using IF-ELSE Statements (Behavior Modeling Style)
CODES :-
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity comparator_4bit is
port(
a : in STD_LOGIC_VECTOR(3 downto 0);
b : in STD_LOGIC_VECTOR(3 downto 0);
equal : out STD_LOGIC;
greater : out STD_LOGIC;
lower : out STD_LOGIC
);
end comparator_4bit;
architecture comparator_4bit_arc of comparator_4bit is
begin
comparator : process (a,b) is
begin
if (a=b) then
equal <= '1';
greater <= '0';
lower <= '0';
elsif (a<b) then
equal <= '0';
greater <= '0';
lower <= '1';
else
equal <= '0';
greater <= '1';
lower <= '0';
end if;
end process comparator;
end comparator_4bit_arc
Result : -
0 Comments