-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_matrix_tb.vhd
213 lines (188 loc) · 5.75 KB
/
node_matrix_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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 12:42:33 05/16/2014
-- Design Name:
-- Module Name: /home/will/Code/VHDL/final/node_matrix_tb.vhd
-- Project Name: misc
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: node_matrix
--
-- 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 node_matrix_tb IS
END node_matrix_tb;
ARCHITECTURE behavior OF node_matrix_tb IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT node_matrix
PORT(
clk : IN std_logic;
disp_loc_in : IN std_logic_vector(7 downto 0);
data_tick : IN std_logic;
data_in : IN std_logic_vector(7 downto 0);
in_path : OUT std_logic;
weight_out : OUT std_logic_vector(7 downto 0)
);
END COMPONENT;
constant comm_header : std_logic_vector(7 downto 0) := "01010111";
constant comm_cell_w : std_logic_vector(7 downto 0) := "00000001";
constant comm_beg_addr : std_logic_vector(7 downto 0) := "00000010";
constant comm_end_addr : std_logic_vector(7 downto 0) := "00000011";
constant comm_prog_beg : std_logic_vector(7 downto 0) := "00000100";
constant comm_prog_end : std_logic_vector(7 downto 0) := "00000101";
--Inputs
signal clk : std_logic := '0';
signal disp_loc_in : std_logic_vector(7 downto 0) := (others => '0');
signal data_tick : std_logic := '0';
signal data_in : std_logic_vector(7 downto 0) := (others => '0');
signal count,jcount : unsigned(7 downto 0) := (others=>'0');
--Outputs
signal in_path : std_logic;
signal weight_out : std_logic_vector(7 downto 0);
-- Clock period definitions
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: node_matrix PORT MAP (
clk => clk,
disp_loc_in => disp_loc_in,
data_tick => data_tick,
data_in => data_in,
in_path => in_path,
weight_out => weight_out
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for clk_period*10;
wait for clk_period/2;
jcount<=(others=>'0');
for J in 0 to 1 loop
--send the end address
data_in<=comm_header;
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for 8*clk_period;
data_in<=comm_end_addr;
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for 8*clk_period;
data_in<="00000010";
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for 8*clk_period;
--send the start address
data_in<=comm_header;
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for 8*clk_period;
data_in<=comm_beg_addr;
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for 8*clk_period;
data_in<="00000001";
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for 8*clk_period;
--send the weights
for I in 0 to 255 loop
data_in<=comm_header;
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for 8*clk_period;
data_in<=comm_cell_w;
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for 8*clk_period;
data_in<=std_logic_vector(count);
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for 8*clk_period;
if (J=0) then
data_in<=std_logic_vector(count);
else
data_in<=std_logic_vector("11111111"-count);
end if;
data_tick<='1';
wait for clk_period;
data_tick<='0';
count<=count+"01";
wait for 8*clk_period;
-- insert stimulus here
end loop;
--send the start signal
data_in<=comm_header;
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for 8*clk_period;
data_in<=comm_prog_beg;
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for clk_period;
--send display indices
count<=(others=>'0');
disp_loc_in<=std_logic_vector(count);
wait for 3*clk_period;
for I in 0 to 255 loop
count<=count+"01";
wait for clk_period;
disp_loc_in<=std_logic_vector(count);
wait for 3*clk_period;
end loop;
--send the end signal
data_in<=comm_header;
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for clk_period;
data_in<=comm_prog_end;
data_tick<='1';
wait for clk_period;
data_tick<='0';
wait for clk_period;
wait for 300*clk_period;
end loop;
wait;
end process;
END;