-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ripple_Carry_Adder_TB.vhd
79 lines (60 loc) · 1.33 KB
/
Ripple_Carry_Adder_TB.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY Ripple_Carry_Adder_TB IS
GENERIC(
WIDTH: integer:= 4
);
END Ripple_Carry_Adder_TB;
ARCHITECTURE behavior OF Ripple_Carry_Adder_TB IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT Ripple_Carry_Adder
GENERIC(
N: integer
);
PORT(
OP: IN std_logic;
A : IN std_logic_vector(N-1 downto 0);
B : IN std_logic_vector(N-1 downto 0);
S : OUT std_logic_vector(N downto 0)
);
END COMPONENT;
--Inputs
signal L_OP : std_logic;
signal L_A : std_logic_vector(WIDTH-1 downto 0);
signal L_B : std_logic_vector(WIDTH-1 downto 0);
--Outputs
signal L_S : std_logic_vector(WIDTH downto 0);
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: Ripple_Carry_Adder
GENERIC MAP(
N => WIDTH
)
PORT MAP (
OP => L_OP,
A => L_A,
B => L_B,
S => L_S
);
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
L_OP <= '0'; -- add
L_A <= "0001";
L_B <= "0101";
wait for 20 ns;
L_A <= "1011";
L_B <= "0101";
wait for 20 ns;
L_OP <= '1'; -- sub (7-5=2)
L_A <= "1011"; -- 7
L_B <= "0101"; -- 5
wait for 20 ns;
L_OP <= '1'; -- sub (3-7=-4)
L_A <= "0011"; -- 3
L_B <= "0111"; -- 7
wait;
end process;
END;