Created
October 10, 2020 15:34
-
-
Save moaminsharifi/3c7afa8c281e4afdef042cc2ae2b32e3 to your computer and use it in GitHub Desktop.
Half Adder Module in VHDL (from: www.nandland.com)
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
library ieee; | |
use ieee.std_logic_1164.all; | |
use ieee.numeric_std.all; | |
entity half_adder is | |
port ( | |
i_bit1 : in std_logic; | |
i_bit2 : in std_logic; | |
-- | |
o_sum : out std_logic; | |
o_carry : out std_logic | |
); | |
end half_adder; | |
architecture rtl of half_adder is | |
begin | |
o_sum <= i_bit1 xor i_bit2; | |
o_carry <= i_bit1 and i_bit2; | |
end rtl; |
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
library ieee; | |
use ieee.std_logic_1164.all; | |
use ieee.numeric_std.all; | |
entity half_adder_tb is | |
end half_adder_tb; | |
architecture behave of half_adder_tb is | |
signal r_BIT1 : std_logic := '0'; | |
signal r_BIT2 : std_logic := '0'; | |
signal w_SUM : std_logic; | |
signal w_CARRY : std_logic; | |
begin | |
UUT : entity work.half_adder -- uses default binding | |
port map ( | |
i_bit1 => r_BIT1, | |
i_bit2 => r_BIT2, | |
o_sum => w_SUM, | |
o_carry => w_CARRY | |
); | |
process is | |
begin | |
r_BIT1 <= '0'; | |
r_BIT2 <= '0'; | |
wait for 10 ns; | |
r_BIT1 <= '0'; | |
r_BIT2 <= '1'; | |
wait for 10 ns; | |
r_BIT1 <= '1'; | |
r_BIT2 <= '0'; | |
wait for 10 ns; | |
r_BIT1 <= '1'; | |
r_BIT2 <= '1'; | |
wait for 10 ns; | |
end process; | |
end behave; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment