1 |
11 |
arniml |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- Testbench for the
|
4 |
|
|
-- GCpad controller core
|
5 |
|
|
--
|
6 |
41 |
arniml |
-- $Id: tb.vhd 41 2009-04-01 19:58:04Z arniml $
|
7 |
11 |
arniml |
--
|
8 |
|
|
-- Copyright (c) 2004, Arnim Laeuger (arniml@opencores.org)
|
9 |
|
|
--
|
10 |
|
|
-- All rights reserved
|
11 |
|
|
--
|
12 |
|
|
-- Redistribution and use in source and synthezised forms, with or without
|
13 |
|
|
-- modification, are permitted provided that the following conditions are met:
|
14 |
|
|
--
|
15 |
|
|
-- Redistributions of source code must retain the above copyright notice,
|
16 |
|
|
-- this list of conditions and the following disclaimer.
|
17 |
|
|
--
|
18 |
|
|
-- Redistributions in synthesized form must reproduce the above copyright
|
19 |
|
|
-- notice, this list of conditions and the following disclaimer in the
|
20 |
|
|
-- documentation and/or other materials provided with the distribution.
|
21 |
|
|
--
|
22 |
|
|
-- Neither the name of the author nor the names of other contributors may
|
23 |
|
|
-- be used to endorse or promote products derived from this software without
|
24 |
|
|
-- specific prior written permission.
|
25 |
|
|
--
|
26 |
|
|
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
27 |
|
|
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
28 |
|
|
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
29 |
|
|
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
|
30 |
|
|
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
31 |
|
|
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
32 |
|
|
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
33 |
|
|
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
34 |
|
|
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
35 |
|
|
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
36 |
|
|
-- POSSIBILITY OF SUCH DAMAGE.
|
37 |
|
|
--
|
38 |
|
|
-- Please report bugs to the author, but before you do so, please
|
39 |
|
|
-- make sure that this is not a derivative work and that
|
40 |
|
|
-- you have the latest version of this file.
|
41 |
|
|
--
|
42 |
|
|
-- The latest version of this file can be found at:
|
43 |
|
|
-- http://www.opencores.org/cvsweb.shtml/gamepads/
|
44 |
|
|
--
|
45 |
|
|
-- The project homepage is located at:
|
46 |
|
|
-- http://www.opencores.org/projects.cgi/web/gamepads/overview
|
47 |
|
|
--
|
48 |
|
|
-------------------------------------------------------------------------------
|
49 |
|
|
|
50 |
|
|
library ieee;
|
51 |
|
|
use ieee.std_logic_1164.all;
|
52 |
|
|
|
53 |
|
|
entity tb is
|
54 |
|
|
|
55 |
|
|
end tb;
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
use work.gcpad_pack.all;
|
59 |
26 |
arniml |
use work.gcpad_comp.gcpad_basic;
|
60 |
|
|
use work.gcpad_comp.gcpad_full;
|
61 |
11 |
arniml |
|
62 |
|
|
architecture behav of tb is
|
63 |
|
|
|
64 |
30 |
arniml |
-----------------------------------------------------------------------------
|
65 |
|
|
-- Some known commands for the GC controller
|
66 |
|
|
-----------------------------------------------------------------------------
|
67 |
|
|
constant cmd_get_id_c : std_logic_vector(7 downto 0) := "00000000";
|
68 |
|
|
constant cmd_poll_c : std_logic_vector(7 downto 0) := "01000000";
|
69 |
|
|
|
70 |
|
|
|
71 |
26 |
arniml |
component gcpad_mod
|
72 |
11 |
arniml |
generic (
|
73 |
26 |
arniml |
clocks_per_1us_g : natural := 2
|
74 |
11 |
arniml |
);
|
75 |
|
|
port (
|
76 |
|
|
clk_i : in std_logic;
|
77 |
|
|
pad_data_io : inout std_logic;
|
78 |
26 |
arniml |
rx_data_i : in std_logic_vector(63 downto 0)
|
79 |
11 |
arniml |
);
|
80 |
|
|
end component;
|
81 |
|
|
|
82 |
26 |
arniml |
constant period_c : time := 100 ns;
|
83 |
|
|
constant reset_level_c : natural := 0;
|
84 |
|
|
constant clocks_per_1us_c : natural := 10;
|
85 |
|
|
|
86 |
11 |
arniml |
signal clk_s : std_logic;
|
87 |
|
|
signal reset_s : std_logic;
|
88 |
|
|
|
89 |
26 |
arniml |
-- signals for basic gcpad
|
90 |
30 |
arniml |
signal stimuli_1_end_s : boolean;
|
91 |
|
|
signal pad_data_1_s : std_logic;
|
92 |
|
|
signal buttons_1_s : std_logic_vector(64 downto 0);
|
93 |
|
|
signal pad_request_1_s : std_logic;
|
94 |
|
|
signal pad_avail_1_s : std_logic;
|
95 |
|
|
signal pad_model_data_1_s : std_logic_vector(63 downto 0);
|
96 |
11 |
arniml |
|
97 |
26 |
arniml |
-- signals for full gcpad
|
98 |
30 |
arniml |
signal stimuli_2_end_s : boolean;
|
99 |
|
|
signal pad_data_2_s : std_logic;
|
100 |
|
|
signal pad_request_2_s : std_logic;
|
101 |
|
|
signal pad_avail_2_s : std_logic;
|
102 |
|
|
signal pad_timeout_2_s : std_logic;
|
103 |
|
|
signal tx_size_2_s : std_logic_vector( 1 downto 0);
|
104 |
|
|
signal tx_command_2_s : std_logic_vector(23 downto 0);
|
105 |
|
|
signal rx_size_2_s : std_logic_vector( 3 downto 0);
|
106 |
|
|
signal rx_data_2_s : std_logic_vector(63 downto 0);
|
107 |
|
|
signal pad_model_data_2_s : std_logic_vector(63 downto 0);
|
108 |
11 |
arniml |
|
109 |
|
|
begin
|
110 |
|
|
|
111 |
|
|
basic_b : gcpad_basic
|
112 |
|
|
generic map (
|
113 |
|
|
reset_level_g => reset_level_c,
|
114 |
|
|
clocks_per_1us_g => clocks_per_1us_c
|
115 |
|
|
)
|
116 |
|
|
port map (
|
117 |
|
|
clk_i => clk_s,
|
118 |
|
|
reset_i => reset_s,
|
119 |
26 |
arniml |
pad_request_i => pad_request_1_s,
|
120 |
|
|
pad_avail_o => pad_avail_1_s,
|
121 |
|
|
pad_data_io => pad_data_1_s,
|
122 |
|
|
but_a_o => buttons_1_s(56),
|
123 |
|
|
but_b_o => buttons_1_s(57),
|
124 |
|
|
but_x_o => buttons_1_s(58),
|
125 |
|
|
but_y_o => buttons_1_s(59),
|
126 |
|
|
but_z_o => buttons_1_s(52),
|
127 |
|
|
but_start_o => buttons_1_s(60),
|
128 |
|
|
but_tl_o => buttons_1_s(54),
|
129 |
|
|
but_tr_o => buttons_1_s(53),
|
130 |
|
|
but_left_o => buttons_1_s(48),
|
131 |
|
|
but_right_o => buttons_1_s(49),
|
132 |
|
|
but_up_o => buttons_1_s(51),
|
133 |
|
|
but_down_o => buttons_1_s(50),
|
134 |
|
|
ana_joy_x_o => buttons_1_s(47 downto 40),
|
135 |
|
|
ana_joy_y_o => buttons_1_s(39 downto 32),
|
136 |
|
|
ana_c_x_o => buttons_1_s(31 downto 24),
|
137 |
|
|
ana_c_y_o => buttons_1_s(23 downto 16),
|
138 |
|
|
ana_l_o => buttons_1_s(15 downto 8),
|
139 |
|
|
ana_r_o => buttons_1_s( 7 downto 0)
|
140 |
11 |
arniml |
);
|
141 |
|
|
|
142 |
26 |
arniml |
buttons_1_s(64) <= '0';
|
143 |
|
|
buttons_1_s(63 downto 61) <= (others => '0');
|
144 |
|
|
buttons_1_s(55) <= '1';
|
145 |
11 |
arniml |
|
146 |
|
|
|
147 |
26 |
arniml |
full_b: gcpad_full
|
148 |
|
|
generic map (
|
149 |
|
|
reset_level_g => reset_level_c,
|
150 |
|
|
clocks_per_1us_g => clocks_per_1us_c
|
151 |
|
|
)
|
152 |
|
|
port map (
|
153 |
|
|
clk_i => clk_s,
|
154 |
|
|
reset_i => reset_s,
|
155 |
|
|
pad_request_i => pad_request_2_s,
|
156 |
|
|
pad_avail_o => pad_avail_2_s,
|
157 |
|
|
pad_timeout_o => pad_timeout_2_s,
|
158 |
|
|
tx_size_i => tx_size_2_s,
|
159 |
|
|
tx_command_i => tx_command_2_s,
|
160 |
|
|
rx_size_i => rx_size_2_s,
|
161 |
|
|
rx_data_o => rx_data_2_s,
|
162 |
|
|
pad_data_io => pad_data_2_s
|
163 |
|
|
);
|
164 |
11 |
arniml |
|
165 |
|
|
|
166 |
26 |
arniml |
pad_1 : gcpad_mod
|
167 |
|
|
generic map (
|
168 |
|
|
clocks_per_1us_g => clocks_per_1us_c
|
169 |
|
|
)
|
170 |
|
|
port map (
|
171 |
|
|
clk_i => clk_s,
|
172 |
|
|
pad_data_io => pad_data_1_s,
|
173 |
30 |
arniml |
rx_data_i => pad_model_data_1_s
|
174 |
26 |
arniml |
);
|
175 |
11 |
arniml |
|
176 |
30 |
arniml |
|
177 |
26 |
arniml |
-----------------------------------------------------------------------------
|
178 |
|
|
-- Process stimuli_pad_1
|
179 |
|
|
--
|
180 |
|
|
-- Executes test stimuli with Pad 1, the gcpad_basic flavour.
|
181 |
|
|
--
|
182 |
|
|
stimuli_pad_1: process
|
183 |
11 |
arniml |
|
184 |
30 |
arniml |
---------------------------------------------------------------------------
|
185 |
|
|
-- Procedure poll_pad
|
186 |
|
|
--
|
187 |
|
|
-- Requests the status of Pad 1 and checks the received data.
|
188 |
|
|
--
|
189 |
|
|
procedure poll_pad(packet : in std_logic_vector(63 downto 0)) is
|
190 |
11 |
arniml |
begin
|
191 |
21 |
arniml |
wait until clk_s'event and clk_s = '1';
|
192 |
|
|
wait for 1 ns;
|
193 |
26 |
arniml |
|
194 |
30 |
arniml |
pad_model_data_1_s <= packet;
|
195 |
26 |
arniml |
|
196 |
11 |
arniml |
-- send request;
|
197 |
26 |
arniml |
pad_request_1_s <= '1';
|
198 |
11 |
arniml |
wait for 1 * period_c;
|
199 |
26 |
arniml |
pad_request_1_s <= '0';
|
200 |
11 |
arniml |
|
201 |
|
|
wait for 10 * 40 * period_c;
|
202 |
|
|
|
203 |
26 |
arniml |
wait until pad_avail_1_s = '1';
|
204 |
11 |
arniml |
wait for 10 * period_c;
|
205 |
|
|
|
206 |
|
|
-- check result
|
207 |
30 |
arniml |
for i in 0 to packet'high loop
|
208 |
|
|
assert packet(i) = buttons_1_s(i)
|
209 |
|
|
report "Button mismatch on Pad 1!"
|
210 |
11 |
arniml |
severity error;
|
211 |
|
|
end loop;
|
212 |
|
|
|
213 |
30 |
arniml |
end poll_pad;
|
214 |
|
|
--
|
215 |
|
|
---------------------------------------------------------------------------
|
216 |
11 |
arniml |
|
217 |
|
|
|
218 |
30 |
arniml |
---------------------------------------------------------------------------
|
219 |
|
|
-- Procedure timeout_gcpad
|
220 |
|
|
--
|
221 |
|
|
-- Generates a timeout in gcpad_basic by disturbing the communication.
|
222 |
|
|
--
|
223 |
11 |
arniml |
procedure timeout_gcpad is
|
224 |
|
|
begin
|
225 |
30 |
arniml |
wait until clk_s'event and clk_s = '1';
|
226 |
|
|
wait for 1 ns;
|
227 |
|
|
|
228 |
11 |
arniml |
-- send request;
|
229 |
26 |
arniml |
pad_request_1_s <= '1';
|
230 |
11 |
arniml |
wait for 1 * period_c;
|
231 |
26 |
arniml |
pad_request_1_s <= '0';
|
232 |
11 |
arniml |
|
233 |
26 |
arniml |
wait for 2 * period_c;
|
234 |
11 |
arniml |
|
235 |
26 |
arniml |
-- disturb communication
|
236 |
|
|
pad_data_1_s <= 'X';
|
237 |
|
|
|
238 |
|
|
wait until pad_avail_1_s = '1';
|
239 |
11 |
arniml |
wait for 10 * period_c;
|
240 |
26 |
arniml |
pad_data_1_s <= 'H';
|
241 |
|
|
wait for 10 * period_c;
|
242 |
11 |
arniml |
|
243 |
|
|
end timeout_gcpad;
|
244 |
30 |
arniml |
--
|
245 |
|
|
---------------------------------------------------------------------------
|
246 |
11 |
arniml |
|
247 |
|
|
begin
|
248 |
26 |
arniml |
stimuli_1_end_s <= false;
|
249 |
11 |
arniml |
|
250 |
30 |
arniml |
pad_data_1_s <= 'H';
|
251 |
|
|
pad_request_1_s <= '0';
|
252 |
|
|
pad_model_data_1_s <= (others => '0');
|
253 |
26 |
arniml |
|
254 |
11 |
arniml |
wait until reset_s = '1';
|
255 |
|
|
wait for period_c * 4;
|
256 |
|
|
|
257 |
|
|
timeout_gcpad;
|
258 |
30 |
arniml |
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000000000");
|
259 |
11 |
arniml |
wait for clocks_per_1us_c * 100 * period_c;
|
260 |
30 |
arniml |
poll_pad(packet => "0001111111111111111111111111111111111111111111111111111111111111");
|
261 |
|
|
poll_pad(packet => "0001000010000000000000000000000000000000000000000000000000000000");
|
262 |
|
|
poll_pad(packet => "0000100010000000000000000000000000000000000000000000000000000000");
|
263 |
|
|
poll_pad(packet => "0000010010000000000000000000000000000000000000000000000000000000");
|
264 |
|
|
poll_pad(packet => "0000001010000000000000000000000000000000000000000000000000000000");
|
265 |
|
|
poll_pad(packet => "0000000110000000000000000000000000000000000000000000000000000000");
|
266 |
|
|
poll_pad(packet => "0000101010101010101010101010101010101010101010101010101010101010");
|
267 |
|
|
poll_pad(packet => "0001010111010101010101010101010101010101010101010101010101010101");
|
268 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000000000");
|
269 |
|
|
poll_pad(packet => "0000000011000000000000000000000000000000000000000000000000000000");
|
270 |
|
|
poll_pad(packet => "0000000010100000000000000000000000000000000000000000000000000000");
|
271 |
|
|
poll_pad(packet => "0000000010010000000000000000000000000000000000000000000000000000");
|
272 |
|
|
poll_pad(packet => "0000000010001000000000000000000000000000000000000000000000000000");
|
273 |
|
|
poll_pad(packet => "0000000010000100000000000000000000000000000000000000000000000000");
|
274 |
|
|
poll_pad(packet => "0000000010000010000000000000000000000000000000000000000000000000");
|
275 |
|
|
poll_pad(packet => "0000000010000001000000000000000000000000000000000000000000000000");
|
276 |
|
|
poll_pad(packet => "0000000010000000100000000000000000000000000000000000000000000000");
|
277 |
|
|
poll_pad(packet => "0000000010000000010000000000000000000000000000000000000000000000");
|
278 |
|
|
poll_pad(packet => "0000000010000000001000000000000000000000000000000000000000000000");
|
279 |
|
|
poll_pad(packet => "0000000010000000000100000000000000000000000000000000000000000000");
|
280 |
|
|
poll_pad(packet => "0000000010000000000010000000000000000000000000000000000000000000");
|
281 |
|
|
poll_pad(packet => "0000000010000000000001000000000000000000000000000000000000000000");
|
282 |
|
|
poll_pad(packet => "0000000010000000000000100000000000000000000000000000000000000000");
|
283 |
|
|
poll_pad(packet => "0000000010000000000000010000000000000000000000000000000000000000");
|
284 |
|
|
poll_pad(packet => "0000000010000000000000001000000000000000000000000000000000000000");
|
285 |
|
|
poll_pad(packet => "0000000010000000000000000100000000000000000000000000000000000000");
|
286 |
|
|
poll_pad(packet => "0000000010000000000000000010000000000000000000000000000000000000");
|
287 |
|
|
poll_pad(packet => "0000000010000000000000000001000000000000000000000000000000000000");
|
288 |
|
|
poll_pad(packet => "0000000010000000000000000000100000000000000000000000000000000000");
|
289 |
|
|
poll_pad(packet => "0000000010000000000000000000010000000000000000000000000000000000");
|
290 |
|
|
poll_pad(packet => "0000000010000000000000000000001000000000000000000000000000000000");
|
291 |
|
|
poll_pad(packet => "0000000010000000000000000000000100000000000000000000000000000000");
|
292 |
|
|
poll_pad(packet => "0000000010000000000000000000000010000000000000000000000000000000");
|
293 |
|
|
poll_pad(packet => "0000000010000000000000000000000001000000000000000000000000000000");
|
294 |
|
|
poll_pad(packet => "0000000010000000000000000000000000100000000000000000000000000000");
|
295 |
|
|
poll_pad(packet => "0000000010000000000000000000000000010000000000000000000000000000");
|
296 |
|
|
poll_pad(packet => "0000000010000000000000000000000000001000000000000000000000000000");
|
297 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000100000000000000000000000000");
|
298 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000010000000000000000000000000");
|
299 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000001000000000000000000000000");
|
300 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000100000000000000000000000");
|
301 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000010000000000000000000000");
|
302 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000001000000000000000000000");
|
303 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000100000000000000000000");
|
304 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000010000000000000000000");
|
305 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000001000000000000000000");
|
306 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000100000000000000000");
|
307 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000010000000000000000");
|
308 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000001000000000000000");
|
309 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000100000000000000");
|
310 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000010000000000000");
|
311 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000001000000000000");
|
312 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000100000000000");
|
313 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000010000000000");
|
314 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000001000000000");
|
315 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000100000000");
|
316 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000010000000");
|
317 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000001000000");
|
318 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000100000");
|
319 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000010000");
|
320 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000001000");
|
321 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000000100");
|
322 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000000010");
|
323 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000000001");
|
324 |
11 |
arniml |
|
325 |
|
|
|
326 |
|
|
wait for period_c * 2*40;
|
327 |
26 |
arniml |
stimuli_1_end_s <= true;
|
328 |
|
|
wait;
|
329 |
11 |
arniml |
|
330 |
26 |
arniml |
end process stimuli_pad_1;
|
331 |
|
|
--
|
332 |
|
|
-----------------------------------------------------------------------------
|
333 |
11 |
arniml |
|
334 |
|
|
|
335 |
26 |
arniml |
pad_2 : gcpad_mod
|
336 |
|
|
generic map (
|
337 |
|
|
clocks_per_1us_g => clocks_per_1us_c
|
338 |
|
|
)
|
339 |
|
|
port map (
|
340 |
|
|
clk_i => clk_s,
|
341 |
|
|
pad_data_io => pad_data_2_s,
|
342 |
30 |
arniml |
rx_data_i => pad_model_data_2_s
|
343 |
26 |
arniml |
);
|
344 |
11 |
arniml |
|
345 |
30 |
arniml |
|
346 |
11 |
arniml |
-----------------------------------------------------------------------------
|
347 |
26 |
arniml |
-- Process stimuli_pad_2
|
348 |
|
|
--
|
349 |
|
|
-- Executes test stimuli with Pad 2, the gcpad_full flavour.
|
350 |
|
|
--
|
351 |
|
|
stimuli_pad_2: process
|
352 |
|
|
|
353 |
30 |
arniml |
---------------------------------------------------------------------------
|
354 |
|
|
-- Procedure issue_command
|
355 |
|
|
--
|
356 |
|
|
-- Sets the transmitter command for Pad 2 and starts the request.
|
357 |
|
|
--
|
358 |
26 |
arniml |
procedure issue_command(cmd : in std_logic_vector(23 downto 0);
|
359 |
|
|
size : in std_logic_vector( 1 downto 0)) is
|
360 |
|
|
begin
|
361 |
|
|
wait until clk_s'event and clk_s = '1';
|
362 |
|
|
wait for 1 ns;
|
363 |
|
|
|
364 |
|
|
tx_command_2_s <= cmd;
|
365 |
|
|
tx_size_2_s <= size;
|
366 |
|
|
-- send request;
|
367 |
|
|
pad_request_2_s <= '1';
|
368 |
|
|
wait for 1 * period_c;
|
369 |
|
|
pad_request_2_s <= '0';
|
370 |
|
|
|
371 |
|
|
end issue_command;
|
372 |
30 |
arniml |
--
|
373 |
|
|
---------------------------------------------------------------------------
|
374 |
26 |
arniml |
|
375 |
30 |
arniml |
|
376 |
|
|
---------------------------------------------------------------------------
|
377 |
|
|
-- Procedure poll_pad
|
378 |
|
|
--
|
379 |
|
|
-- Requests the status of Pad 2 and checks the received data.
|
380 |
|
|
--
|
381 |
|
|
procedure poll_pad(packet : in std_logic_vector(63 downto 0)) is
|
382 |
|
|
variable cmd_v : std_logic_vector(23 downto 0);
|
383 |
|
|
begin
|
384 |
|
|
wait until clk_s'event and clk_s = '1';
|
385 |
|
|
wait for 1 ns;
|
386 |
|
|
|
387 |
|
|
-- set up model answer
|
388 |
|
|
pad_model_data_2_s <= packet;
|
389 |
|
|
-- set expected number of bytes for gcpad_full
|
390 |
|
|
rx_size_2_s <= "1000";
|
391 |
|
|
|
392 |
|
|
cmd_v(23 downto 16) := cmd_poll_c;
|
393 |
|
|
cmd_v(15 downto 0) := "0000001100000010";
|
394 |
|
|
issue_command(cmd => cmd_v,
|
395 |
|
|
size => "11");
|
396 |
|
|
|
397 |
|
|
wait until pad_avail_2_s = '1';
|
398 |
|
|
|
399 |
|
|
assert pad_timeout_2_s = '0'
|
400 |
|
|
report "Timout signalled on Pad 2 during status polling!"
|
401 |
|
|
severity error;
|
402 |
|
|
|
403 |
|
|
-- check result
|
404 |
|
|
for i in 0 to packet'high loop
|
405 |
|
|
assert packet(i) = rx_data_2_s(i)
|
406 |
|
|
report "Data mismatch on Pad 2!"
|
407 |
|
|
severity error;
|
408 |
|
|
end loop;
|
409 |
|
|
|
410 |
|
|
end poll_pad;
|
411 |
|
|
--
|
412 |
|
|
---------------------------------------------------------------------------
|
413 |
|
|
|
414 |
|
|
|
415 |
|
|
---------------------------------------------------------------------------
|
416 |
|
|
-- Procedure timeout_gcpad_x
|
417 |
|
|
--
|
418 |
|
|
-- Generates a timeout in gcpad_full by disturbing the communication.
|
419 |
|
|
--
|
420 |
|
|
procedure timeout_gcpad_x is
|
421 |
|
|
variable cmd_v : std_logic_vector(23 downto 0);
|
422 |
|
|
begin
|
423 |
|
|
wait until clk_s'event and clk_s = '1';
|
424 |
|
|
wait for 1 ns;
|
425 |
|
|
|
426 |
|
|
pad_model_data_2_s <= (others => '0');
|
427 |
|
|
rx_size_2_s <= "1000";
|
428 |
|
|
|
429 |
|
|
|
430 |
|
|
cmd_v(23 downto 16) := cmd_poll_c;
|
431 |
|
|
cmd_v(15 downto 0) := "0000001100000010";
|
432 |
|
|
issue_command(cmd => cmd_v,
|
433 |
|
|
size => "11");
|
434 |
|
|
|
435 |
|
|
-- disturb communication
|
436 |
|
|
pad_data_2_s <= 'X';
|
437 |
|
|
|
438 |
|
|
wait until pad_avail_1_s = '1';
|
439 |
|
|
wait for 10 * period_c;
|
440 |
|
|
pad_data_2_s <= 'H';
|
441 |
|
|
wait for 10 * period_c;
|
442 |
|
|
|
443 |
|
|
assert pad_timeout_2_s = '1'
|
444 |
|
|
report "No timeout indicated on Pad 2 when communication has been disturbed!"
|
445 |
|
|
severity error;
|
446 |
|
|
|
447 |
|
|
end timeout_gcpad_x;
|
448 |
|
|
--
|
449 |
|
|
---------------------------------------------------------------------------
|
450 |
|
|
|
451 |
|
|
|
452 |
|
|
---------------------------------------------------------------------------
|
453 |
|
|
-- Procedure timeout_gcpad_short
|
454 |
|
|
--
|
455 |
|
|
-- Generates a timeout in gcpad_full by requesting too many bytes for
|
456 |
|
|
-- a "get id" command.
|
457 |
|
|
--
|
458 |
|
|
procedure timeout_gcpad_short is
|
459 |
|
|
variable cmd_v : std_logic_vector(23 downto 0);
|
460 |
|
|
begin
|
461 |
|
|
wait until clk_s'event and clk_s = '1';
|
462 |
|
|
wait for 1 ns;
|
463 |
|
|
|
464 |
|
|
-- expect too many number of bytes
|
465 |
|
|
-- command is "get id", will yield 3 bytes, but 8 bytes are requested
|
466 |
|
|
rx_size_2_s <= "1000";
|
467 |
|
|
|
468 |
|
|
|
469 |
|
|
cmd_v(23 downto 16) := cmd_get_id_c;
|
470 |
|
|
cmd_v(15 downto 0) := (others => '1');
|
471 |
|
|
issue_command(cmd => cmd_v,
|
472 |
|
|
size => "01");
|
473 |
|
|
|
474 |
|
|
wait until pad_avail_2_s = '1';
|
475 |
|
|
|
476 |
|
|
assert pad_timeout_2_s = '1'
|
477 |
|
|
report "No timout indicated on Pad 2 when too many bytes requested!"
|
478 |
|
|
severity error;
|
479 |
|
|
|
480 |
|
|
end timeout_gcpad_short;
|
481 |
|
|
--
|
482 |
|
|
---------------------------------------------------------------------------
|
483 |
|
|
|
484 |
|
|
|
485 |
|
|
---------------------------------------------------------------------------
|
486 |
|
|
-- Procedure get_id
|
487 |
|
|
--
|
488 |
|
|
-- Requests the ID information from the GC controller model.
|
489 |
|
|
--
|
490 |
|
|
procedure get_id is
|
491 |
|
|
variable cmd_v : std_logic_vector(23 downto 0);
|
492 |
|
|
constant id_c : std_logic_vector(23 downto 0) := "000010010000000000000000";
|
493 |
|
|
begin
|
494 |
|
|
wait until clk_s'event and clk_s = '1';
|
495 |
|
|
wait for 1 ns;
|
496 |
|
|
|
497 |
|
|
rx_size_2_s <= "0011";
|
498 |
|
|
|
499 |
|
|
|
500 |
|
|
cmd_v(23 downto 16) := cmd_get_id_c;
|
501 |
|
|
cmd_v(15 downto 0) := (others => '1');
|
502 |
|
|
issue_command(cmd => cmd_v,
|
503 |
|
|
size => "01");
|
504 |
|
|
|
505 |
|
|
wait until pad_avail_2_s = '1';
|
506 |
|
|
|
507 |
|
|
assert pad_timeout_2_s = '0'
|
508 |
|
|
report "Timout signalled on Pad 2 during get id!"
|
509 |
|
|
severity error;
|
510 |
|
|
|
511 |
|
|
-- check result
|
512 |
|
|
for i in 0 to id_c'high loop
|
513 |
|
|
assert id_c(i) = rx_data_2_s(i)
|
514 |
|
|
report "ID mismatch on Pad 2!"
|
515 |
|
|
severity error;
|
516 |
|
|
end loop;
|
517 |
|
|
|
518 |
|
|
end get_id;
|
519 |
|
|
--
|
520 |
|
|
---------------------------------------------------------------------------
|
521 |
|
|
|
522 |
|
|
begin
|
523 |
26 |
arniml |
stimuli_2_end_s <= false;
|
524 |
|
|
|
525 |
30 |
arniml |
pad_data_2_s <= 'H';
|
526 |
|
|
pad_request_2_s <= '0';
|
527 |
|
|
tx_size_2_s <= (others => '0');
|
528 |
|
|
tx_command_2_s <= (others => '0');
|
529 |
|
|
rx_size_2_s <= (others => '0');
|
530 |
|
|
pad_model_data_2_s <= (others => '0');
|
531 |
26 |
arniml |
|
532 |
|
|
wait until reset_s = '1';
|
533 |
|
|
wait for period_c * 4;
|
534 |
|
|
|
535 |
|
|
|
536 |
30 |
arniml |
get_id;
|
537 |
|
|
timeout_gcpad_x;
|
538 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000000000");
|
539 |
|
|
wait for clocks_per_1us_c * 100 * period_c;
|
540 |
|
|
poll_pad(packet => "0001111111111111111111111111111111111111111111111111111111111111");
|
541 |
|
|
timeout_gcpad_short;
|
542 |
|
|
poll_pad(packet => "0001000010000000000000000000000000000000000000000000000000000000");
|
543 |
|
|
poll_pad(packet => "0000100010000000000000000000000000000000000000000000000000000000");
|
544 |
|
|
poll_pad(packet => "0000010010000000000000000000000000000000000000000000000000000000");
|
545 |
|
|
poll_pad(packet => "0000001010000000000000000000000000000000000000000000000000000000");
|
546 |
|
|
poll_pad(packet => "0000000110000000000000000000000000000000000000000000000000000000");
|
547 |
|
|
poll_pad(packet => "0000101010101010101010101010101010101010101010101010101010101010");
|
548 |
|
|
poll_pad(packet => "0001010111010101010101010101010101010101010101010101010101010101");
|
549 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000000000");
|
550 |
|
|
poll_pad(packet => "0000000011000000000000000000000000000000000000000000000000000000");
|
551 |
|
|
poll_pad(packet => "0000000010100000000000000000000000000000000000000000000000000000");
|
552 |
|
|
poll_pad(packet => "0000000010010000000000000000000000000000000000000000000000000000");
|
553 |
|
|
poll_pad(packet => "0000000010001000000000000000000000000000000000000000000000000000");
|
554 |
|
|
poll_pad(packet => "0000000010000100000000000000000000000000000000000000000000000000");
|
555 |
|
|
poll_pad(packet => "0000000010000010000000000000000000000000000000000000000000000000");
|
556 |
|
|
poll_pad(packet => "0000000010000001000000000000000000000000000000000000000000000000");
|
557 |
|
|
poll_pad(packet => "0000000010000000100000000000000000000000000000000000000000000000");
|
558 |
|
|
poll_pad(packet => "0000000010000000010000000000000000000000000000000000000000000000");
|
559 |
|
|
poll_pad(packet => "0000000010000000001000000000000000000000000000000000000000000000");
|
560 |
|
|
poll_pad(packet => "0000000010000000000100000000000000000000000000000000000000000000");
|
561 |
|
|
poll_pad(packet => "0000000010000000000010000000000000000000000000000000000000000000");
|
562 |
|
|
poll_pad(packet => "0000000010000000000001000000000000000000000000000000000000000000");
|
563 |
|
|
poll_pad(packet => "0000000010000000000000100000000000000000000000000000000000000000");
|
564 |
|
|
poll_pad(packet => "0000000010000000000000010000000000000000000000000000000000000000");
|
565 |
|
|
poll_pad(packet => "0000000010000000000000001000000000000000000000000000000000000000");
|
566 |
|
|
poll_pad(packet => "0000000010000000000000000100000000000000000000000000000000000000");
|
567 |
|
|
poll_pad(packet => "0000000010000000000000000010000000000000000000000000000000000000");
|
568 |
|
|
poll_pad(packet => "0000000010000000000000000001000000000000000000000000000000000000");
|
569 |
|
|
poll_pad(packet => "0000000010000000000000000000100000000000000000000000000000000000");
|
570 |
|
|
poll_pad(packet => "0000000010000000000000000000010000000000000000000000000000000000");
|
571 |
|
|
poll_pad(packet => "0000000010000000000000000000001000000000000000000000000000000000");
|
572 |
|
|
poll_pad(packet => "0000000010000000000000000000000100000000000000000000000000000000");
|
573 |
|
|
poll_pad(packet => "0000000010000000000000000000000010000000000000000000000000000000");
|
574 |
|
|
poll_pad(packet => "0000000010000000000000000000000001000000000000000000000000000000");
|
575 |
|
|
poll_pad(packet => "0000000010000000000000000000000000100000000000000000000000000000");
|
576 |
|
|
poll_pad(packet => "0000000010000000000000000000000000010000000000000000000000000000");
|
577 |
|
|
poll_pad(packet => "0000000010000000000000000000000000001000000000000000000000000000");
|
578 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000100000000000000000000000000");
|
579 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000010000000000000000000000000");
|
580 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000001000000000000000000000000");
|
581 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000100000000000000000000000");
|
582 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000010000000000000000000000");
|
583 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000001000000000000000000000");
|
584 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000100000000000000000000");
|
585 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000010000000000000000000");
|
586 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000001000000000000000000");
|
587 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000100000000000000000");
|
588 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000010000000000000000");
|
589 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000001000000000000000");
|
590 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000100000000000000");
|
591 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000010000000000000");
|
592 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000001000000000000");
|
593 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000100000000000");
|
594 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000010000000000");
|
595 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000001000000000");
|
596 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000100000000");
|
597 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000010000000");
|
598 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000001000000");
|
599 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000100000");
|
600 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000010000");
|
601 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000001000");
|
602 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000000100");
|
603 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000000010");
|
604 |
|
|
poll_pad(packet => "0000000010000000000000000000000000000000000000000000000000000001");
|
605 |
26 |
arniml |
|
606 |
|
|
|
607 |
|
|
wait for period_c * 2*40;
|
608 |
|
|
stimuli_2_end_s <= true;
|
609 |
|
|
wait;
|
610 |
|
|
|
611 |
|
|
end process stimuli_pad_2;
|
612 |
|
|
--
|
613 |
|
|
-----------------------------------------------------------------------------
|
614 |
|
|
|
615 |
|
|
|
616 |
|
|
-----------------------------------------------------------------------------
|
617 |
11 |
arniml |
-- Clock Generator
|
618 |
|
|
-----------------------------------------------------------------------------
|
619 |
|
|
clk: process
|
620 |
|
|
begin
|
621 |
|
|
clk_s <= '0';
|
622 |
|
|
wait for period_c / 2;
|
623 |
|
|
clk_s <= '1';
|
624 |
|
|
wait for period_c / 2;
|
625 |
|
|
end process clk;
|
626 |
|
|
|
627 |
|
|
|
628 |
|
|
-----------------------------------------------------------------------------
|
629 |
|
|
-- Reset Generator
|
630 |
|
|
-----------------------------------------------------------------------------
|
631 |
|
|
reset: process
|
632 |
|
|
begin
|
633 |
|
|
if reset_level_c = 0 then
|
634 |
|
|
reset_s <= '0';
|
635 |
|
|
else
|
636 |
|
|
reset_s <= '1';
|
637 |
|
|
end if;
|
638 |
|
|
|
639 |
|
|
wait for period_c * 4 + 10 ns;
|
640 |
|
|
|
641 |
|
|
reset_s <= not reset_s;
|
642 |
|
|
|
643 |
|
|
wait;
|
644 |
|
|
end process reset;
|
645 |
|
|
|
646 |
26 |
arniml |
|
647 |
|
|
-----------------------------------------------------------------------------
|
648 |
|
|
-- End of simulation detection
|
649 |
|
|
-----------------------------------------------------------------------------
|
650 |
|
|
eos: process (stimuli_1_end_s, stimuli_2_end_s)
|
651 |
|
|
begin
|
652 |
|
|
if stimuli_1_end_s and stimuli_2_end_s then
|
653 |
|
|
assert false
|
654 |
|
|
report "End of simulation reached."
|
655 |
|
|
severity failure;
|
656 |
|
|
end if;
|
657 |
|
|
end process eos;
|
658 |
|
|
|
659 |
11 |
arniml |
end behav;
|