-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvgaDemo_tb.vhd
More file actions
264 lines (226 loc) · 6.29 KB
/
Copy pathvgaDemo_tb.vhd
File metadata and controls
264 lines (226 loc) · 6.29 KB
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 20:33:37 03/28/2012
-- Design Name:
-- Module Name: C:/Users/Brian/Documents/Xilnix/vgaDemo/vgaDemo_tb.vhd
-- Project Name: vgaDemo
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: vgaDemo
--
-- 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 vgaDemo_tb IS
END vgaDemo_tb;
ARCHITECTURE behavior OF vgaDemo_tb IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT vgaDemo
PORT(
clk_i : IN std_logic;
rstLow_i : IN std_logic;
spiSsel_i : in std_logic;
spiSck_i : in std_logic;
spiMosi_i : in std_logic;
spiMiso_o : out std_logic;
-- led_o : out std_logic;
hSync_o : OUT std_logic;
vSync_o : OUT std_logic;
r_o : OUT std_logic;
g_o : OUT std_logic;
b_o : OUT std_logic
);
END COMPONENT;
--Inputs
signal clk_i : std_logic := '0';
signal rst_i : std_logic := '1';
--Outputs
signal hSync_o : std_logic;
signal vSync_o : std_logic;
signal r_o : std_logic;
signal g_o : std_logic;
signal b_o : std_logic;
signal spiStart : std_logic := '0';
signal spiSsel : std_logic := '1';
signal spiSck : std_logic := '0';
signal spiMosi : std_logic := '0';
signal sendData : std_logic_vector(7 downto 0);
signal data : std_logic_vector(7 downto 0) := (others => '0');
-- Clock period definitions
constant clk_i_period : time := 31.125 ns;
constant SPI_PERIOD : time := 50.000 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: vgaDemo PORT MAP (
clk_i => clk_i,
rstLow_i => rst_i,
spiSsel_i => spiSsel,
spiSck_i => spiSck,
spiMosi_i => data(7),
spiMiso_o => open,
-- led_o => open,
hSync_o => hSync_o,
vSync_o => vSync_o,
r_o => r_o,
g_o => g_o,
b_o => b_o
);
-- Clock process definitions
clk_i_process :process
begin
clk_i <= '0';
wait for clk_i_period/2;
clk_i <= '1';
wait for clk_i_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
rst_i <= '0';
-- hold reset state for 100 ns.
wait for 500 ns;
rst_i <= '1';
wait for clk_i_period*16;
-- insert stimulus here
sendData <= x"01";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"02";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"91"; -- readback
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"5A";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"A5";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"04";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"00";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"05";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"0A";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"06";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"42";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"07";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"55";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"07";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"AA";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
wait for SPI_PERIOD*4;
sendData <= x"08";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
sendData <= x"37";
spiStart <= '1';
wait for 1 ns;
spiStart <= '0';
wait until rising_edge(spiSsel);
wait for SPI_PERIOD;
wait;
end process;
spi_send : process
begin
spiSsel <= '1';
spiSck <= '0';
wait until spiStart = '1';
data <= sendData;
spiSsel <= '0';
for i in data'range loop
wait for SPI_PERIOD/2;
spiSck <= '1';
wait for SPI_PERIOD/2;
spiSck <= '0';
data <= data(6 downto 0) & '0';
end loop;
wait for SPI_PERIOD/2;
spiSsel <= '1';
end process;
END;