-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtb_Full_Adder.vhd
119 lines (104 loc) · 2.55 KB
/
tb_Full_Adder.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 10:27:32 02/07/2018
-- Design Name:
-- Module Name: tb_Full_Adder - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity tb_Ripple_Carry_Adder is
end tb_Ripple_Carry_Adder;
architecture Behavioral of tb_Ripple_Carry_Adder is
component Ripple_Carry_Adder
port(
SUB : IN std_logic;
A : IN std_logic_vector(7 downto 0);
B : IN std_logic_vector(7 downto 0);
COUT : OUT std_logic;
S : OUT std_logic_vector(7 downto 0);
V : OUT std_logic
);
end component;
--Inputs
signal SUB : std_logic := '0';
signal A : std_logic_vector(7 downto 0) := "00000000";
signal B : std_logic_vector(7 downto 0) := "00000000";
signal CIN : std_logic := '0';
--Outputs
signal S : std_logic_vector(7 downto 0);
signal COUT : std_logic;
signal V : std_logic;
--Testbench Related
constant period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: Ripple_Carry_Adder PORT MAP (
SUB => SUB,
A => A,
B => B,
S => S,
COUT => COUT,
V => V
);
-- Clock process definitions
process1 :process
begin
-- Addition test:CIN=0
SUB <= '0';
A <= "00010000";
B <= "01000000";
wait for period;
-- Addition test:Intermediate Carry
A <= "00000111";
B <= "00000011";
wait for period;
-- Addition test:Intermediate Carry with Carry IN
A <= "00000111";
B <= "00000011";
wait for period;
-- Addition test:Intermediate Carry with Carry IN with overflow
A <= "11100111";
B <= "11100011";
wait for period;
-- Subtraction test:CIN=0
SUB <= '1';
A <= "00010000";
B <= "01000000";
wait for period;
-- Subtraction test:Intermediate Carry
A <= "00000111";
B <= "00000011";
wait for period;
-- Subtraction test:Intermediate Carry with Carry IN
A <= "00000111";
B <= "00000011";
wait for period;
-- Subtraction test:Intermediate Carry with Carry IN with overflow
A <= "10000111";
B <= "10000011";
wait for period;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for period*10;
-- insert stimulus here
wait;
end process;
END;