-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCPU_tb.vhdl
197 lines (157 loc) · 4.22 KB
/
CPU_tb.vhdl
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use std.env.all;
entity CPU_tb is
end entity;
architecture testbench of CPU_tb is
-- Component declaration
component CPU
port (
CLK : in std_logic;
GO : in std_logic;
testing : in std_logic;
test_DATA_ADDR : in std_logic_vector(7 downto 0);
test_DATA_IP : in std_logic_vector(15 downto 0);
test_DATA_OP : in std_logic_vector(15 downto 0);
test_MW : in std_logic;
PSEUDO_OUT : out std_logic_vector(15 downto 0)
);
end component;
-- Signals for test bench
signal CLK : std_logic;
signal GO : std_logic;
signal testing : std_logic;
signal test_DATA_ADDR : std_logic_vector(7 downto 0);
signal test_DATA_IP : std_logic_vector(15 downto 0);
signal test_DATA_OP : std_logic_vector(15 downto 0);
signal test_MW : std_logic;
signal PSEUDO_OUT : std_logic_vector(15 downto 0);
begin
-- Instantiate the design under test
uut : CPU
port map(
CLK => CLK,
GO => GO,
testing => testing,
test_DATA_ADDR => test_DATA_ADDR,
test_DATA_IP => test_DATA_IP,
test_DATA_OP => test_DATA_OP,
test_MW => test_MW,
PSEUDO_OUT => PSEUDO_OUT
);
-- Stimulus process
clk_process : process
begin
-- Initialize clock signal
while now < 1000 ns loop
CLK <= '1';
wait for 5 ns;
CLK <= '0';
wait for 5 ns;
end loop;
wait;
end process;
counter_process : process
begin
GO <= '0';
testing <= '1';
test_MW <= '1';
-- test_DATA_ADDR <= "00000000";
-- test_DATA_IP <= "0000000000000000";
-- wait for 10 ns;
-- test_DATA_ADDR <= "00000001";
-- test_DATA_IP <= "0000000000000001";
-- wait for 10 ns;
-- test_DATA_ADDR <= "00000010";
-- test_DATA_IP <= "0000000000000010";
-- wait for 10 ns;
-- test_DATA_ADDR <= "00000011";
-- test_DATA_IP <= "0000000000000011";
-- wait for 10 ns;
-- test_DATA_ADDR <= "00000000";
-- test_DATA_IP <= "0010100110010101";
-- wait for 10 ns;
-- test_DATA_ADDR <= "00000001";
-- test_DATA_IP <= "100XXX1100111001";
-- wait for 10 ns;
-- test_DATA_ADDR <= "00000010";
-- test_DATA_IP <= "111111XXX0000101";
-- wait for 10 ns;
-- test_DATA_ADDR <= "00000011";
-- test_DATA_IP <= "001000XXX1001001";
-- wait for 10 ns;
-- test_DATA_ADDR <= "00000100";
-- test_DATA_IP <= "XXXXXX0110XXXXX0";
-- wait for 10 ns;
-- test_DATA_ADDR <= "00000101";
-- test_DATA_IP <= "100XXXXXXXXXXX11";
-- wait for 10 ns;
-- test_DATA_ADDR <= "00000110";
-- test_DATA_IP <= "1010000000101001";
-- wait for 10 ns;
GO <= '1';
testing <= '0';
test_MW <= '0';
wait for 10 ns;
wait for 10 ns;
wait for 10 ns;
wait for 10 ns;
wait for 10 ns;
wait for 10 ns;
wait for 10 ns;
wait for 10 ns;
wait for 10 ns;
wait for 10 ns;
wait for 10 ns;
wait for 10 ns;
-- initialize register 0
-- 0000000000000011
-- initialize register 1
-- 0010000000000011
-- initialize register 2
-- 0100000000000011
-- initialize register 3
-- 0110000000000011
-- initialize register 4
-- CONTROL_WORD <= "1000000000000011";
-- DATA_IP <= "00000100";
-- wait for 10 ns;
-- -- initialize register 5
-- CONTROL_WORD <= "1010000000000011";
-- DATA_IP <= "00000101";
-- wait for 10 ns;
-- -- initialize register 6
-- CONTROL_WORD <= "1100000000000011";
-- DATA_IP <= "00000110";
-- wait for 10 ns;
-- -- initialize register 7
-- CONTROL_WORD <= "1110000000000011";
-- DATA_IP <= "00000111";
-- wait for 10 ns;
wait for 10 ns;
stop(0);
end process;
end architecture;
-- 001 010 011 0 0101 0 1
-- 100 XXX 110 0 1110 0 1
-- 111 111 XXX 0 0001 0 1
-- 001 000 XXX 1 0010 0 1
-- XXX XXX 011 0 XXXX X 0
-- 100 XXX XXX X XXXX 1 1
-- 101 000 000 0 1010 0 1
-- 0010100110010101
-- 100XXX1100111001
-- 111111XXX0000101
-- 001000XXX1001001
-- XXXXXX0110XXXXX0
-- 100XXXXXXXXXXX11
-- 1010000000101001
-- 0010100110010101 2995
-- 1000001100111001 8339
-- 1111110000000101 FC05
-- 0010000001001001 2049
-- 0000000110000000 0180
-- 1000000000000011 8003
-- 1010000000101001 A029
--