Last active
December 16, 2015 15:39
-
-
Save tonussi/5457393 to your computer and use it in GitHub Desktop.
n bit comp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--n bit_vector comparador | |
--tabela | |
-- = igualdade | |
-- /= ~ igualdade | |
-- < menor que | |
-- <= menor ou igual | |
-- > maior | |
-- >= maior ou igual | |
-- not negado | |
-- and e | |
-- or ou | |
-- xor exclusao mutua | |
library ieee; | |
use ieee.std_logic_1164.all; | |
entity comparador is generic (nBits: natural := 3); | |
port ( | |
a: in std_logic_vector(nBits - 1 downto 0); | |
b: in std_logic_vector(nBits - 1 downto 0); | |
maior: out std_logic; | |
menor: out std_logic; | |
igual: out std_logic); | |
end comparador; | |
architecture bhv of comparador is begin | |
process (a, b) begin | |
maior <= '0'; | |
igual <= '0'; | |
menor <= '0'; | |
if (a > b) then | |
maior <= '1'; | |
elsif (a = b) then | |
igual <= '1'; | |
elsif (a < b) then | |
menor <= '1'; | |
end if; | |
end process; | |
end bhv; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
force /a 000 0ns, 001 10ns, 010 20ns, 011 30ns, 100 35ns, 101 60ns, 110 70ns, 111 80ns | |
force /b 000 0 ns, 001 20ns, 010 40ns, 011 60ns, 100 80ns, 101 100ns, 110 120ns, 111 140ns |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment