-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtb_exam.vhd
164 lines (148 loc) · 3.64 KB
/
tb_exam.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 11:09:33 11/05/2016
-- Design Name:
-- Module Name: D:/labexam/tb_exam.vhd
-- Project Name: labexam
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: alu
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY tb_exam IS
END tb_exam;
ARCHITECTURE behavior OF tb_exam IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT alu
PORT(
cin : IN std_logic;
sel0 : IN std_logic;
sel1 : IN std_logic;
a0 : IN std_logic;
a1 : IN std_logic;
a2 : IN std_logic;
a3 : IN std_logic;
b0 : IN std_logic;
b1 : IN std_logic;
b2 : IN std_logic;
b3 : IN std_logic;
o0 : OUT std_logic;
o1 : OUT std_logic;
o2 : OUT std_logic;
o3 : OUT std_logic
);
END COMPONENT;
--Inputs
signal cin : std_logic := '0';
signal sel0 : std_logic := '0';
signal sel1 : std_logic := '0';
signal a0 : std_logic := '0';
signal a1 : std_logic := '0';
signal a2 : std_logic := '0';
signal a3 : std_logic := '0';
signal b0 : std_logic := '0';
signal b1 : std_logic := '0';
signal b2 : std_logic := '0';
signal b3 : std_logic := '0';
--Outputs
signal o0 : std_logic;
signal o1 : std_logic;
signal o2 : std_logic;
signal o3 : std_logic;
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
--constant <clock>_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: alu PORT MAP (
cin => cin,
sel0 => sel0,
sel1 => sel1,
a0 => a0,
a1 => a1,
a2 => a2,
a3 => a3,
b0 => b0,
b1 => b1,
b2 => b2,
b3 => b3,
o0 => o0,
o1 => o1,
o2 => o2,
o3 => o3
);
-- Clock process definitions
-- <clock>_process :process
-- begin
-- <clock> <= '0';
-- wait for <clock>_period/2;
-- <clock> <= '1';
-- wait for <clock>_period/2;
-- end process;
--
-- Stimulus process
stim_proc: process
begin
wait for 50 ns;
a0<='1';
a1<='0';
a2<='1';
a3<='0';
cin<='1';
b0<='0';
b1<='0';
b2<='1';
b3<='0';
--wait for 50 ns;
--A-B:
sel0<='0';
sel1<='0';
--A-1:
wait for 50 ns;
b0<='1';
b1<='0';
b2<='0';
b3<='0';
sel0<='0';
sel1<='0';
wait for 50 ns;
-- -A=not a +1;
a0<='1';
a1<='0';
a2<='0';
a3<='0';
cin<='0';
sel0<='1';
sel1<='1';
wait for 50 ns;
-- not a;
a0<='0';
a1<='0';
a2<='0';
a3<='0';
cin<='0';
sel0<='1';
sel1<='1';
end process;
END;