-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtb_adder4.vhd
45 lines (40 loc) · 1.13 KB
/
tb_adder4.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- 4-bit adder subtractor testbench
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity tb_adder4 is
end tb_adder4;
architecture bhv of tb_adder4 is
-- declare addsub4 circut as a component
component adder4 is
port (
a, b : in std_logic_vector(3 downto 0);
cin : in std_logic;
s : out std_logic_vector(3 downto 0);
v, cout : out std_logic
);
end component;
signal a, b : std_logic_vector(3 downto 0);
signal s : std_logic_vector(3 downto 0);
signal cin, cout : std_logic;
begin
-- instantiate addsub4 component.
a0: adder4
port map (a => a, b => b, cin => cin, s => s, cout => cout);
process
begin
wait for 100 ns;
for i in 0 to 15 loop
for j in 0 to 15 loop
a <= std_logic_vector(to_unsigned(i, 4));
b <= std_logic_vector(to_unsigned(j, 4));
wait for 1 ns;
cin <= '1';
wait for 1 ns;
cin <= '0';
end loop;
end loop;
wait for 10 ns;
wait;
end process;
end bhv;