OpenCores
URL https://opencores.org/ocsvn/udp_ip_stack/udp_ip_stack/trunk

Subversion Repositories udp_ip_stack

[/] [udp_ip_stack/] [trunk/] [bench/] [vhdl/] [arpv2_tb.vhd] - Blame information for rev 10

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 pjf
--------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer:
4
--
5
-- Create Date:   12:35:50 05/31/2011
6
-- Design Name:   
7
-- Module Name:   C:/Users/pjf/Documents/projects/fpga/xilinx/Network/arp1/arp_tb.vhd
8
-- Project Name:  arp1
9
-- Target Device:  
10
-- Tool versions:  
11
-- Description:   
12
-- 
13
-- VHDL Test Bench Created by ISE for module: arp
14
-- 
15
-- Dependencies:
16
-- 
17
-- Revision:
18
-- Revision 0.01 - File Created
19
-- Revision 0.02 - Added tests for ARP timeout
20
-- Additional Comments:
21
--
22
-- Notes: 
23
-- This testbench has been automatically generated using types std_logic and
24
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends
25
-- that these types always be used for the top-level I/O of a design in order
26
-- to guarantee that the testbench will bind correctly to the post-implementation 
27
-- simulation model.
28
--------------------------------------------------------------------------------
29
LIBRARY ieee;
30
USE ieee.std_logic_1164.ALL;
31
USE ieee.numeric_std.ALL;
32
use work.arp_types.all;
33
 
34
ENTITY arpv2_tb IS
35
END arpv2_tb;
36
 
37
ARCHITECTURE behavior OF arpv2_tb IS
38
 
39
    -- Component Declaration for the Unit Under Test (UUT)
40
 
41
    COMPONENT arpv2
42
         generic (
43
                        CLOCK_FREQ                      : integer := 125000000;                                                 -- freq of data_in_clk -- needed to timout cntr
44
                        ARP_TIMEOUT                     : integer := 60;                                                                        -- ARP response timeout (s)
45
                        MAX_ARP_ENTRIES         : integer := 255                                                                        -- max entries in the arp store
46
                        );
47
    Port (
48
                        -- lookup request signals
49
                        arp_req_req                     : in arp_req_req_type;
50
                        arp_req_rslt            : out arp_req_rslt_type;
51
                        -- MAC layer RX signals
52
                        data_in_clk             : in  STD_LOGIC;
53
                        reset                           : in  STD_LOGIC;
54
                        data_in                                 : in  STD_LOGIC_VECTOR (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
55
                        data_in_valid           : in  STD_LOGIC;                                                                        -- indicates data_in valid on clock
56
                        data_in_last            : in  STD_LOGIC;                                                                        -- indicates last data in frame
57
                        -- MAC layer TX signals
58
                        mac_tx_req                      : out std_logic;                                                                        -- indicates that ip wants access to channel (stays up for as long as tx)
59
                        mac_tx_granted          : in std_logic;                                                                 -- indicates that access to channel has been granted            
60
                        data_out_clk            : in std_logic;
61
                        data_out_ready          : in std_logic;                                                                 -- indicates system ready to consume data
62
                        data_out_valid          : out std_logic;                                                                        -- indicates data out is valid
63
                        data_out_first          : out std_logic;                                                                        -- with data out valid indicates the first byte of a frame
64
                        data_out_last           : out std_logic;                                                                        -- with data out valid indicates the last byte of a frame
65
                        data_out                                : out std_logic_vector (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
66
                        -- system signals
67
                        our_mac_address         : in STD_LOGIC_VECTOR (47 downto 0);
68
                        our_ip_address  : in STD_LOGIC_VECTOR (31 downto 0);
69
                        control                         : in arp_control_type;
70
                        req_count                       : out STD_LOGIC_VECTOR(7 downto 0)                       -- count of arp pkts received
71
                        );
72
    END COMPONENT;
73
 
74
 
75
   --Inputs
76
   signal clk                                   : std_logic := '0';
77
   signal reset                                 : std_logic := '0';
78
   signal data_in                       : std_logic_vector(7 downto 0) := (others => '0');
79
   signal data_in_valid         : std_logic := '0';
80
   signal data_in_last          : std_logic := '0';
81
   signal our_mac_address       : std_logic_vector(47 downto 0) := (others => '0');
82
   signal our_ip_address        : std_logic_vector(31 downto 0) := (others => '0');
83
        signal data_out_ready   : std_logic;
84
        signal data_out_valid   : std_logic;
85
        signal data_out_first   : std_logic;
86
        signal data_out_last            : std_logic;
87
        signal data_out                 : std_logic_vector (7 downto 0);
88
        signal req_count                        : STD_LOGIC_VECTOR(7 downto 0);
89
        signal arp_req_req              : arp_req_req_type;
90
        signal arp_req_rslt             : arp_req_rslt_type;
91
        signal mac_tx_req                       : std_logic;
92
        signal mac_tx_granted   : std_logic;
93
        signal control                          : arp_control_type;
94
 
95
 
96
   -- Clock period definitions
97
   constant clk_period : time := 8 ns;
98
 
99
BEGIN
100
 
101
        -- Instantiate the Unit Under Test (UUT)
102
   uut: arpv2
103
                generic map (
104
                         CLOCK_FREQ                     => 10,                                          -- artificially low count to enable pragmatic testing
105
                         ARP_TIMEOUT            => 20
106
                         )
107
                PORT MAP (
108
                        -- lookup request mappings
109
                         arp_req_req            => arp_req_req,
110
                         arp_req_rslt           => arp_req_rslt,
111
                        -- rx mappings
112
          data_in_clk           => clk,
113
          reset                                 => reset,
114
          data_in                       => data_in,
115
          data_in_valid         => data_in_valid,
116
          data_in_last          => data_in_last,
117
                         -- tx mappings
118
                         mac_tx_req                     => mac_tx_req,
119
                         mac_tx_granted => mac_tx_granted,
120
                         data_out_clk           => clk,
121
                         data_out_ready         => data_out_ready,
122
                         data_out_valid         => data_out_valid,
123
                         data_out_first => data_out_first,
124
                         data_out_last          => data_out_last,
125
                         data_out                       => data_out,
126
                         -- system mappings
127
          our_mac_address       => our_mac_address,
128
          our_ip_address        => our_ip_address,
129
                         control                                => control,
130
                         req_count                      => req_count
131
        );
132
 
133
   -- Clock process definitions
134
   clk_process :process
135
   begin
136
                clk <= '0';
137
                wait for clk_period/2;
138
                clk <= '1';
139
                wait for clk_period/2;
140
   end process;
141
 
142
 
143
   -- Stimulus process
144
   stim_proc: process
145
   begin
146
      -- hold reset state for 100 ns.
147
      wait for 100 ns;
148
 
149
                our_ip_address <= x"c0a80509";          -- 192.168.5.9
150
                our_mac_address <= x"002320212223";
151
                mac_tx_granted <= '1'; -- FIXME 0
152
                control.clear_cache <= '0';
153
 
154
                reset <= '1';
155
      wait for clk_period*10;
156
                reset <= '0';
157
      wait for clk_period*5;
158
 
159
                assert mac_tx_req = '0'                                  report "mac_tx_req asserted on reset";
160
 
161
      -- insert stimulus here
162
                arp_req_req.lookup_req <= '0';
163
                arp_req_req.ip <= (others => '0');
164
                data_out_ready <= '1';
165
 
166
                report "T1:  Send an ARP request: who has 192.168.5.9? Tell 192.168.5.1";
167
                data_in_valid <= '1';
168
                -- dst MAC (bc)
169
                data_in <= x"ff"; wait for clk_period;
170
                data_in <= x"ff"; wait for clk_period;
171
                data_in <= x"ff"; wait for clk_period;
172
                data_in <= x"ff"; wait for clk_period;
173
                data_in <= x"ff"; wait for clk_period;
174
                data_in <= x"ff"; wait for clk_period;
175
                -- src MAC
176
                data_in <= x"00"; wait for clk_period;
177
                data_in <= x"23"; wait for clk_period;
178
                data_in <= x"18"; wait for clk_period;
179
                data_in <= x"29"; wait for clk_period;
180
                data_in <= x"26"; wait for clk_period;
181
                data_in <= x"7c"; wait for clk_period;
182
                -- type
183
                data_in <= x"08"; wait for clk_period;
184
                data_in <= x"06"; wait for clk_period;
185
                -- HW type
186
                data_in <= x"00"; wait for clk_period;
187
                data_in <= x"01"; wait for clk_period;
188
                -- Protocol type
189
                data_in <= x"08"; wait for clk_period;
190
                data_in <= x"00"; wait for clk_period;
191
                -- HW size
192
                data_in <= x"06"; wait for clk_period;
193
                -- protocol size
194
                data_in <= x"04"; wait for clk_period;
195
                -- Opcode
196
                data_in <= x"00"; wait for clk_period;
197
                data_in <= x"01"; wait for clk_period;
198
                -- Sender MAC
199
                data_in <= x"00"; wait for clk_period;
200
                data_in <= x"23"; wait for clk_period;
201
                data_in <= x"18"; wait for clk_period;
202
                data_in <= x"29"; wait for clk_period;
203
                data_in <= x"26"; wait for clk_period;
204
                data_in <= x"7c"; wait for clk_period;
205
                -- Sender IP
206
                data_in <= x"c0"; wait for clk_period;
207
                data_in <= x"a8"; wait for clk_period;
208
                data_in <= x"05"; wait for clk_period;
209
                data_in <= x"01"; wait for clk_period;
210
                -- Target MAC
211
                data_in <= x"00"; wait for clk_period;
212
                data_in <= x"00"; wait for clk_period;
213
                data_in <= x"00"; wait for clk_period;
214
                data_in <= x"00"; wait for clk_period;
215
                data_in <= x"00"; wait for clk_period;
216
                data_in <= x"00"; wait for clk_period;
217
                -- Target IP
218
                data_in <= x"c0"; wait for clk_period;
219
                data_in <= x"a8"; wait for clk_period;
220
                data_in <= x"05"; wait for clk_period;
221
                data_in <= x"09"; wait for clk_period;
222
                data_in <= x"00"; wait for clk_period;
223
                data_in <= x"00"; wait for clk_period;
224
                data_in <= x"00"; wait for clk_period;
225
                data_in_last <= '1';
226
                data_in <= x"00"; wait for clk_period;
227
                data_in_last <= '0';
228
                data_in_valid <= '0';
229
 
230
                report "T1:  Expect that we send an 'I have 192.168.5.9' msg";
231
 
232
                -- check tx arbitration signals
233
 
234
                report "T1: waiting for tx req";
235
                wait until mac_tx_req = '1';
236
 
237
                -- ready to tx
238
                data_out_ready <= '1';
239
                mac_tx_granted <= '1';
240
                report "T1: waiting for data_out_valid";
241
                wait until data_out_valid = '1';
242
                report "T1: got data_out_valid";
243
                wait for clk_period*10;
244
                data_out_ready <= '0';
245
                wait for clk_period*2;
246
                data_out_ready <= '1';
247
                wait for clk_period*12;
248
                assert data_out = x"02"                                 report "T1: expected opcode = 02 for reply 'I have'";
249
                -- expect our mac 00 23 20 21 22 23
250
                wait for clk_period;
251
                assert data_out = x"00"                                 report "T1: incorrect our mac.0";
252
                wait for clk_period;
253
                assert data_out = x"23"                                 report "T1: incorrect our mac.1";
254
                wait for clk_period;
255
                assert data_out = x"20"                                 report "T1: incorrect our mac.2";
256
                wait for clk_period;
257
                assert data_out = x"21"                                 report "T1: incorrect our mac.3";
258
                wait for clk_period;
259
                assert data_out = x"22"                                 report "T1: incorrect our mac.4";
260
                wait for clk_period;
261
                assert data_out = x"23"                                 report "T1: incorrect our mac.5";
262
                -- expect our IP c0 a8 05 05
263
                wait for clk_period;
264
                assert data_out = x"c0"                                 report "T1: incorrect our IP.0";
265
                wait for clk_period;
266
                assert data_out = x"a8"                                 report "T1: incorrect our IP.1";
267
                wait for clk_period;
268
                assert data_out = x"05"                                 report "T1: incorrect our IP.2";
269
                wait for clk_period;
270
                assert data_out = x"09"                                 report "T1: incorrect our IP.3";
271
 
272
                -- expect target mac 00 23 18 29 26 7c
273
                wait for clk_period;
274
                assert data_out = x"00"                                 report "T1: incorrect target mac.0";
275
                wait for clk_period;
276
                assert data_out = x"23"                                 report "T1: incorrect target mac.1";
277
                wait for clk_period;
278
                assert data_out = x"18"                                 report "T1: incorrect target mac.2";
279
                wait for clk_period;
280
                assert data_out = x"29"                                 report "T1: incorrect target mac.3";
281
                wait for clk_period;
282
                assert data_out = x"26"                                 report "T1: incorrect target mac.4";
283
                wait for clk_period;
284
                assert data_out = x"7c"                                 report "T1: incorrect target mac.5";
285
                -- expect target IP c0 a8 05 01
286
                wait for clk_period;
287
                assert data_out = x"c0"                                 report "T1: incorrect target IP.0";
288
                wait for clk_period;
289
                assert data_out = x"a8"                                 report "T1: incorrect target IP.1";
290
                wait for clk_period;
291
                assert data_out = x"05"                                 report "T1: incorrect target IP.2";
292
                assert data_out_last = '0'                               report "T1: data out last incorrectly set on target IP.2 byte";
293
                wait for clk_period;
294
                assert data_out = x"01"                                 report "T1: incorrect target IP.3";
295
                assert data_out_last = '1'                              report "T1: data out last should be set";
296
 
297
                wait for clk_period*10;
298
 
299
                report "T2: Send another ARP request: who has 192.168.5.8? Tell 192.168.5.1, holding off transmitter";
300
                data_out_ready <= '0';
301
                data_in_valid <= '1';
302
                -- dst MAC (bc)
303
                data_in <= x"ff"; wait for clk_period;
304
                data_in <= x"ff"; wait for clk_period;
305
                data_in <= x"ff"; wait for clk_period;
306
                data_in <= x"ff"; wait for clk_period;
307
                data_in <= x"ff"; wait for clk_period;
308
                data_in <= x"ff"; wait for clk_period;
309
                -- src MAC
310
                data_in <= x"00"; wait for clk_period;
311
                data_in <= x"23"; wait for clk_period;
312
                data_in <= x"18"; wait for clk_period;
313
                data_in <= x"29"; wait for clk_period;
314
                data_in <= x"26"; wait for clk_period;
315
                data_in <= x"7c"; wait for clk_period;
316
                -- type
317
                data_in <= x"08"; wait for clk_period;
318
                data_in <= x"06"; wait for clk_period;
319
                -- HW type
320
                data_in <= x"00"; wait for clk_period;
321
                data_in <= x"01"; wait for clk_period;
322
                -- Protocol type
323
                data_in <= x"08"; wait for clk_period;
324
                data_in <= x"00"; wait for clk_period;
325
                -- HW size
326
                data_in <= x"06"; wait for clk_period;
327
                -- protocol size
328
                data_in <= x"04"; wait for clk_period;
329
                -- Opcode
330
                data_in <= x"00"; wait for clk_period;
331
                data_in <= x"01"; wait for clk_period;
332
                -- Sender MAC
333
                data_in <= x"00"; wait for clk_period;
334
                data_in <= x"23"; wait for clk_period;
335
                data_in <= x"18"; wait for clk_period;
336
                data_in <= x"29"; wait for clk_period;
337
                data_in <= x"26"; wait for clk_period;
338
                data_in <= x"7c"; wait for clk_period;
339
                -- Sender IP
340
                data_in <= x"c0"; wait for clk_period;
341
                data_in <= x"a8"; wait for clk_period;
342
                data_in <= x"05"; wait for clk_period;
343
                data_in <= x"01"; wait for clk_period;
344
                -- Target MAC
345
                data_in <= x"00"; wait for clk_period;
346
                data_in <= x"00"; wait for clk_period;
347
                data_in <= x"00"; wait for clk_period;
348
                data_in <= x"00"; wait for clk_period;
349
                data_in <= x"00"; wait for clk_period;
350
                data_in <= x"00"; wait for clk_period;
351
                -- Target IP
352
                data_in <= x"c0"; wait for clk_period;
353
                data_in <= x"a8"; wait for clk_period;
354
                data_in <= x"05"; wait for clk_period;
355
                data_in <= x"09"; wait for clk_period;
356
                data_in <= x"00"; wait for clk_period;
357
                data_in <= x"00"; wait for clk_period;
358
                data_in <= x"00"; wait for clk_period;
359
                data_in_last <= '1';
360
                data_in <= x"00"; wait for clk_period;
361
                data_in_last <= '0';
362
                data_in_valid <= '0';
363
 
364
                -- ready to tx
365
                wait for clk_period*10;
366
                data_out_ready <= '1';
367
 
368
                wait for clk_period*50;
369
 
370
                report "T3: Send a request for the IP that is already in the store";
371
                arp_req_req.ip <= x"c0a80501";
372
                arp_req_req.lookup_req <= '1';
373
                wait for clk_period;
374
                arp_req_req.lookup_req <= '0';
375
                report "T3: wait for reply from store";
376
                wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1';
377
                assert arp_req_rslt.got_mac = '1'                       report "T3: expected got mac";
378
                assert arp_req_rslt.got_err = '0'                        report "T3: expected got err = 0";
379
                assert arp_req_rslt.mac = x"00231829267c"       report "T3: wrong mac value";
380
                wait for clk_period*2;
381
 
382
                -- the entry that was in the store should now be in the cache - check it
383
                report "T4: Send a request for the IP that is already in the cache";
384
                arp_req_req.ip <= x"c0a80501";
385
                arp_req_req.lookup_req <= '1';
386
                wait for clk_period;
387
                arp_req_req.lookup_req <= '0';
388
                assert arp_req_rslt.got_mac = '1'                       report "T4: expected got mac";
389
                assert arp_req_rslt.got_err = '0'                        report "T4: expected got err = 0";
390
                assert arp_req_rslt.mac = x"00231829267c"       report "T4: wrong mac value";
391
 
392
                wait for clk_period*50;
393
 
394
                report "T5 - Send a request for the IP that is not cached or in the store";
395
                arp_req_req.ip <= x"c0a80503";
396
                arp_req_req.lookup_req <= '1';
397
                wait for clk_period;
398
                arp_req_req.lookup_req <= '0';
399
                report "T5: waiting for data_out_valid";
400
                wait until data_out_valid = '1';
401
                report "T5: got data_out_valid";
402
                wait for clk_period*10;
403
                data_out_ready <= '0';
404
                wait for clk_period*2;
405
                data_out_ready <= '1';
406
                wait for clk_period*12;
407
                assert data_out = x"01"                                 report "T5: expected opcode = 01 for request 'who has'";
408
                -- expect our mac 00 23 20 21 22 23
409
                wait for clk_period;
410
                assert data_out = x"00"                                 report "T5: incorrect our mac.0";
411
                wait for clk_period;
412
                assert data_out = x"23"                                 report "T5: incorrect our mac.1";
413
                wait for clk_period;
414
                assert data_out = x"20"                                 report "T5: incorrect our mac.2";
415
                wait for clk_period;
416
                assert data_out = x"21"                                 report "T5: incorrect our mac.3";
417
                wait for clk_period;
418
                assert data_out = x"22"                                 report "T5: incorrect our mac.4";
419
                wait for clk_period;
420
                assert data_out = x"23"                                 report "T5: incorrect our mac.5";
421
                -- expect our IP c0 a8 05 05
422
                wait for clk_period;
423
                assert data_out = x"c0"                                 report "T5: incorrect our IP.0";
424
                wait for clk_period;
425
                assert data_out = x"a8"                                 report "T5: incorrect our IP.1";
426
                wait for clk_period;
427
                assert data_out = x"05"                                 report "T5: incorrect our IP.2";
428
                wait for clk_period;
429
                assert data_out = x"09"                                 report "T5: incorrect our IP.3";
430
 
431
                -- expect empty target mac 
432
                wait for clk_period;
433
                assert data_out = x"00"                                 report "T5: incorrect target mac.0";
434
                wait for clk_period;
435
                assert data_out = x"00"                                 report "T5: incorrect target mac.1";
436
                wait for clk_period;
437
                assert data_out = x"00"                                 report "T5: incorrect target mac.2";
438
                wait for clk_period;
439
                assert data_out = x"00"                                 report "T5: incorrect target mac.3";
440
                wait for clk_period;
441
                assert data_out = x"00"                                 report "T5: incorrect target mac.4";
442
                wait for clk_period;
443
                assert data_out = x"00"                                 report "T5: incorrect target mac.5";
444
                -- expect target IP c0 a8 05 01
445
                wait for clk_period;
446
                assert data_out = x"c0"                                 report "T5: incorrect target IP.0";
447
                wait for clk_period;
448
                assert data_out = x"a8"                                 report "T5: incorrect target IP.1";
449
                wait for clk_period;
450
                assert data_out = x"05"                                 report "T5: incorrect target IP.2";
451
                assert data_out_last = '0'                               report "T5: data out last incorrectly set on target IP.2 byte";
452
                wait for clk_period;
453
                assert data_out = x"03"                                 report "T5: incorrect target IP.3";
454
                assert data_out_last = '1'                              report "T5: data out last should be set";
455
 
456
                wait for clk_period*10;
457
 
458
                -- Send the reply
459
                data_out_ready <= '1';
460
 
461
                report "T5.2: Send an ARP reply: 192.168.5.3 has mac 02:12:03:23:04:54";
462
                data_in_valid <= '1';
463
                -- dst MAC (bc)
464
                data_in <= x"ff"; wait for clk_period;
465
                data_in <= x"ff"; wait for clk_period;
466
                data_in <= x"ff"; wait for clk_period;
467
                data_in <= x"ff"; wait for clk_period;
468
                data_in <= x"ff"; wait for clk_period;
469
                data_in <= x"ff"; wait for clk_period;
470
                -- src MAC
471
                data_in <= x"02"; wait for clk_period;
472
                data_in <= x"12"; wait for clk_period;
473
                data_in <= x"03"; wait for clk_period;
474
                data_in <= x"23"; wait for clk_period;
475
                data_in <= x"04"; wait for clk_period;
476
                data_in <= x"54"; wait for clk_period;
477
                -- type
478
                data_in <= x"08"; wait for clk_period;
479
                data_in <= x"06"; wait for clk_period;
480
                -- HW type
481
                data_in <= x"00"; wait for clk_period;
482
                data_in <= x"01"; wait for clk_period;
483
                -- Protocol type
484
                data_in <= x"08"; wait for clk_period;
485
                data_in <= x"00"; wait for clk_period;
486
                -- HW size
487
                data_in <= x"06"; wait for clk_period;
488
                -- protocol size
489
                data_in <= x"04"; wait for clk_period;
490
                -- Opcode
491
                data_in <= x"00"; wait for clk_period;
492
                data_in <= x"02"; wait for clk_period;
493
                -- Sender MAC
494
                data_in <= x"02"; wait for clk_period;
495
                data_in <= x"12"; wait for clk_period;
496
                data_in <= x"03"; wait for clk_period;
497
                data_in <= x"23"; wait for clk_period;
498
                data_in <= x"04"; wait for clk_period;
499
                data_in <= x"54"; wait for clk_period;
500
                -- Sender IP
501
                data_in <= x"c0"; wait for clk_period;
502
                data_in <= x"a8"; wait for clk_period;
503
                data_in <= x"05"; wait for clk_period;
504
                data_in <= x"03"; wait for clk_period;
505
                -- Target MAC
506
                data_in <= x"00"; wait for clk_period;
507
                data_in <= x"23"; wait for clk_period;
508
                data_in <= x"20"; wait for clk_period;
509
                data_in <= x"21"; wait for clk_period;
510
                data_in <= x"22"; wait for clk_period;
511
                data_in <= x"23"; wait for clk_period;
512
                -- Target IP
513
                data_in <= x"c0"; wait for clk_period;
514
                data_in <= x"a8"; wait for clk_period;
515
                data_in <= x"05"; wait for clk_period;
516
                data_in <= x"09"; wait for clk_period;
517
                data_in <= x"00"; wait for clk_period;
518
                data_in <= x"00"; wait for clk_period;
519
                assert arp_req_rslt.got_mac = '1'                       report "T5.2: expected got mac";
520
                assert arp_req_rslt.got_err = '0'                        report "T5.2: expected got err = 0";
521
                assert arp_req_rslt.mac = x"021203230454"       report "T5.2: wrong mac value";
522
                data_in <= x"00"; wait for clk_period;
523
                data_in_last <= '1';
524
                data_in <= x"00"; wait for clk_period;
525
                data_in_last <= '0';
526
                data_in_valid <= '0';
527
                wait for clk_period*4;
528
 
529
                report "T6: check that both these IPs remain in the store";
530
                arp_req_req.ip <= x"c0a80501";
531
                arp_req_req.lookup_req <= '1';
532
                wait for clk_period;
533
                arp_req_req.lookup_req <= '0';
534
                wait for clk_period;
535
                report "T6.1: wait for reply from store";
536
                wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1';
537
                assert arp_req_rslt.got_mac = '1'                       report "T6.1: expected got mac";
538
                assert arp_req_rslt.got_err = '0'                        report "T6.1: expected got err = 0";
539
                assert arp_req_rslt.mac = x"00231829267c"       report "T6.1: wrong mac value";
540
                wait for clk_period*2;
541
 
542
                arp_req_req.ip <= x"c0a80503";
543
                arp_req_req.lookup_req <= '1';
544
                wait for clk_period;
545
                arp_req_req.lookup_req <= '0';
546
                wait for clk_period;
547
                report "T6.2: wait for reply from store";
548
                wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1';
549
                assert arp_req_rslt.got_mac = '1'                       report "T6.2: expected got mac";
550
                assert arp_req_rslt.got_err = '0'                        report "T6.2: expected got err = 0";
551
                assert arp_req_rslt.mac = x"021203230454"       report "T6.2: wrong mac value";
552
                wait for clk_period*2;
553
 
554
                report "T7 - test that receipt of wrong I Have does not satisfy a current req";
555
                arp_req_req.ip <= x"c0a8050e";
556
                arp_req_req.lookup_req <= '1';
557
                wait for clk_period;
558
                arp_req_req.lookup_req <= '0';
559
                report "T7: waiting for data_out_valid";
560
                wait until data_out_valid = '1';
561
                report "T7: got data_out_valid";
562
                wait for clk_period*10;
563
                data_out_ready <= '0';
564
                wait for clk_period*2;
565
                data_out_ready <= '1';
566
                wait for clk_period*12;
567
                assert data_out = x"01"                                 report "T7: expected opcode = 01 for request 'who has'";
568
                -- expect our mac 00 23 20 21 22 23
569
                wait for clk_period;
570
                assert data_out = x"00"                                 report "T7: incorrect our mac.0";
571
                wait for clk_period;
572
                assert data_out = x"23"                                 report "T7: incorrect our mac.1";
573
                wait for clk_period;
574
                assert data_out = x"20"                                 report "T7: incorrect our mac.2";
575
                wait for clk_period;
576
                assert data_out = x"21"                                 report "T7: incorrect our mac.3";
577
                wait for clk_period;
578
                assert data_out = x"22"                                 report "T7: incorrect our mac.4";
579
                wait for clk_period;
580
                assert data_out = x"23"                                 report "T7: incorrect our mac.5";
581
                -- expect our IP c0 a8 05 05
582
                wait for clk_period;
583
                assert data_out = x"c0"                                 report "T7: incorrect our IP.0";
584
                wait for clk_period;
585
                assert data_out = x"a8"                                 report "T7: incorrect our IP.1";
586
                wait for clk_period;
587
                assert data_out = x"05"                                 report "T7: incorrect our IP.2";
588
                wait for clk_period;
589
                assert data_out = x"09"                                 report "T7: incorrect our IP.3";
590
 
591
                -- expect empty target mac
592
                wait for clk_period;
593
                assert data_out = x"00"                                 report "T7: incorrect target mac.0";
594
                wait for clk_period;
595
                assert data_out = x"00"                                 report "T7: incorrect target mac.1";
596
                wait for clk_period;
597
                assert data_out = x"00"                                 report "T7: incorrect target mac.2";
598
                wait for clk_period;
599
                assert data_out = x"00"                                 report "T7: incorrect target mac.3";
600
                wait for clk_period;
601
                assert data_out = x"00"                                 report "T7: incorrect target mac.4";
602
                wait for clk_period;
603
                assert data_out = x"00"                                 report "T7: incorrect target mac.5";
604
                -- expect target IP c0 a8 05 0e
605
                wait for clk_period;
606
                assert data_out = x"c0"                                 report "T7: incorrect target IP.0";
607
                wait for clk_period;
608
                assert data_out = x"a8"                                 report "T7: incorrect target IP.1";
609
                wait for clk_period;
610
                assert data_out = x"05"                                 report "T7: incorrect target IP.2";
611
                assert data_out_last = '0'                               report "T7: data out last incorrectly set on target IP.2 byte";
612
                wait for clk_period;
613
                assert data_out = x"0e"                                 report "T7: incorrect target IP.3";
614
                assert data_out_last = '1'                              report "T7: data out last should be set";
615
 
616
                wait for clk_period*10;
617
 
618
                -- Send the reply
619
                data_out_ready <= '1';
620
 
621
                report "T7.2: Send an arbitrary unwanted ARP reply: 192.168.7.3 has mac 57:12:34:19:23:9a";
622
                data_in_valid <= '1';
623
                -- dst MAC (bc)
624
                data_in <= x"ff"; wait for clk_period;
625
                data_in <= x"ff"; wait for clk_period;
626
                data_in <= x"ff"; wait for clk_period;
627
                data_in <= x"ff"; wait for clk_period;
628
                data_in <= x"ff"; wait for clk_period;
629
                data_in <= x"ff"; wait for clk_period;
630
                -- src MAC
631
                data_in <= x"57"; wait for clk_period;
632
                data_in <= x"12"; wait for clk_period;
633
                data_in <= x"34"; wait for clk_period;
634
                data_in <= x"19"; wait for clk_period;
635
                data_in <= x"23"; wait for clk_period;
636
                data_in <= x"9a"; wait for clk_period;
637
                -- type
638
                data_in <= x"08"; wait for clk_period;
639
                data_in <= x"06"; wait for clk_period;
640
                -- HW type
641
                data_in <= x"00"; wait for clk_period;
642
                data_in <= x"01"; wait for clk_period;
643
                -- Protocol type
644
                data_in <= x"08"; wait for clk_period;
645
                data_in <= x"00"; wait for clk_period;
646
                -- HW size
647
                data_in <= x"06"; wait for clk_period;
648
                -- protocol size
649
                data_in <= x"04"; wait for clk_period;
650
                -- Opcode
651
                data_in <= x"00"; wait for clk_period;
652
                data_in <= x"02"; wait for clk_period;
653
                -- Sender MAC
654
                data_in <= x"57"; wait for clk_period;
655
                data_in <= x"12"; wait for clk_period;
656
                data_in <= x"34"; wait for clk_period;
657
                data_in <= x"19"; wait for clk_period;
658
                data_in <= x"23"; wait for clk_period;
659
                data_in <= x"9a"; wait for clk_period;
660
                -- Sender IP
661
                data_in <= x"c0"; wait for clk_period;
662
                data_in <= x"a8"; wait for clk_period;
663
                data_in <= x"07"; wait for clk_period;
664
                data_in <= x"03"; wait for clk_period;
665
                -- Target MAC
666
                data_in <= x"00"; wait for clk_period;
667
                data_in <= x"23"; wait for clk_period;
668
                data_in <= x"20"; wait for clk_period;
669
                data_in <= x"21"; wait for clk_period;
670
                data_in <= x"22"; wait for clk_period;
671
                data_in <= x"23"; wait for clk_period;
672
                -- Target IP
673
                data_in <= x"c0"; wait for clk_period;
674
                data_in <= x"a8"; wait for clk_period;
675
                data_in <= x"05"; wait for clk_period;
676
                data_in <= x"09"; wait for clk_period;
677
                data_in <= x"00"; wait for clk_period;
678
                data_in <= x"00"; wait for clk_period;
679
                assert arp_req_rslt.got_mac = '0'                        report "T7.2: expected got mac = 0";
680
                assert arp_req_rslt.got_err = '0'                        report "T7.2: expected got err = 0";
681
                data_in <= x"00"; wait for clk_period;
682
                data_in_last <= '1';
683
                data_in <= x"00"; wait for clk_period;
684
                data_in_last <= '0';
685
                data_in_valid <= '0';
686
                wait for clk_period*4;
687
 
688
                -- Send the reply
689
                data_out_ready <= '1';
690
 
691
                report "T7.3: Send a wanted ARP reply: 192.168.5.e has mac 76:34:98:55:aa:37";
692
                data_in_valid <= '1';
693
                -- dst MAC (bc)
694
                data_in <= x"ff"; wait for clk_period;
695
                data_in <= x"ff"; wait for clk_period;
696
                data_in <= x"ff"; wait for clk_period;
697
                data_in <= x"ff"; wait for clk_period;
698
                data_in <= x"ff"; wait for clk_period;
699
                data_in <= x"ff"; wait for clk_period;
700
                -- src MAC
701
                data_in <= x"76"; wait for clk_period;
702
                data_in <= x"34"; wait for clk_period;
703
                data_in <= x"98"; wait for clk_period;
704
                data_in <= x"55"; wait for clk_period;
705
                data_in <= x"aa"; wait for clk_period;
706
                data_in <= x"37"; wait for clk_period;
707
                -- type
708
                data_in <= x"08"; wait for clk_period;
709
                data_in <= x"06"; wait for clk_period;
710
                -- HW type
711
                data_in <= x"00"; wait for clk_period;
712
                data_in <= x"01"; wait for clk_period;
713
                -- Protocol type
714
                data_in <= x"08"; wait for clk_period;
715
                data_in <= x"00"; wait for clk_period;
716
                -- HW size
717
                data_in <= x"06"; wait for clk_period;
718
                -- protocol size
719
                data_in <= x"04"; wait for clk_period;
720
                -- Opcode
721
                data_in <= x"00"; wait for clk_period;
722
                data_in <= x"02"; wait for clk_period;
723
                -- Sender MAC
724
                data_in <= x"76"; wait for clk_period;
725
                data_in <= x"34"; wait for clk_period;
726
                data_in <= x"98"; wait for clk_period;
727
                data_in <= x"55"; wait for clk_period;
728
                data_in <= x"aa"; wait for clk_period;
729
                data_in <= x"37"; wait for clk_period;
730
                -- Sender IP
731
                data_in <= x"c0"; wait for clk_period;
732
                data_in <= x"a8"; wait for clk_period;
733
                data_in <= x"05"; wait for clk_period;
734
                data_in <= x"0e"; wait for clk_period;
735
                -- Target MAC
736
                data_in <= x"00"; wait for clk_period;
737
                data_in <= x"23"; wait for clk_period;
738
                data_in <= x"20"; wait for clk_period;
739
                data_in <= x"21"; wait for clk_period;
740
                data_in <= x"22"; wait for clk_period;
741
                data_in <= x"23"; wait for clk_period;
742
                -- Target IP
743
                data_in <= x"c0"; wait for clk_period;
744
                data_in <= x"a8"; wait for clk_period;
745
                data_in <= x"05"; wait for clk_period;
746
                data_in <= x"09"; wait for clk_period;
747
                data_in <= x"00"; wait for clk_period;
748
                data_in <= x"00"; wait for clk_period;
749
                assert arp_req_rslt.got_mac = '1'                       report "T7.3: expected got mac";
750
                assert arp_req_rslt.got_err = '0'                        report "T7.3: expected got err = 0";
751
                assert arp_req_rslt.mac = x"76349855aa37"       report "T7.3: wrong mac value";
752
                data_in <= x"00"; wait for clk_period;
753
                data_in_last <= '1';
754
                data_in <= x"00"; wait for clk_period;
755
                data_in_last <= '0';
756
                data_in_valid <= '0';
757
                wait for clk_period*4;
758
 
759
 
760
                report "T8: Request 192.168.5.4 (not cached), dont send a reply and wait for timeout";
761
                arp_req_req.ip <= x"c0a80504";
762
                arp_req_req.lookup_req <= '1';
763
                wait for clk_period;
764
                arp_req_req.lookup_req <= '0';
765
                wait for clk_period*20;
766
                assert mac_tx_req = '1'                                         report "T8: should be requesting TX channel";
767
                wait for clk_period*220;
768
                assert arp_req_rslt.got_mac = '0'                report "T8: should not have got mac";
769
                assert arp_req_rslt.got_err = '1'               report "T8: should have got err";
770
 
771
                report "T9: Request 192.168.5.7 (not cached= and Send an ARP reply: 192.168.5.7 has mac 02:15:03:23:04:54";
772
                arp_req_req.ip <= x"c0a80507";
773
                arp_req_req.lookup_req <= '1';
774
                wait for clk_period;
775
                assert arp_req_rslt.got_mac = '0'                report "T9: should not yet have mac";
776
                assert arp_req_rslt.got_err = '0'                report "T9: should not have got err";
777
 
778
                arp_req_req.lookup_req <= '0';
779
                wait for clk_period*20;
780
                assert mac_tx_req = '1'                                         report "T9: should be requesting TX channel";
781
                wait for clk_period*50;
782
                -- Send the reply
783
                data_out_ready <= '1';
784
 
785
                data_in_valid <= '1';
786
                -- dst MAC (bc)
787
                data_in <= x"ff"; wait for clk_period;
788
                data_in <= x"ff"; wait for clk_period;
789
                data_in <= x"ff"; wait for clk_period;
790
                data_in <= x"ff"; wait for clk_period;
791
                data_in <= x"ff"; wait for clk_period;
792
                data_in <= x"ff"; wait for clk_period;
793
                -- src MAC
794
                data_in <= x"02"; wait for clk_period;
795
                data_in <= x"15"; wait for clk_period;
796
                data_in <= x"03"; wait for clk_period;
797
                data_in <= x"23"; wait for clk_period;
798
                data_in <= x"04"; wait for clk_period;
799
                data_in <= x"54"; wait for clk_period;
800
                -- type
801
                data_in <= x"08"; wait for clk_period;
802
                data_in <= x"06"; wait for clk_period;
803
                -- HW type
804
                data_in <= x"00"; wait for clk_period;
805
                data_in <= x"01"; wait for clk_period;
806
                -- Protocol type
807
                data_in <= x"08"; wait for clk_period;
808
                data_in <= x"00"; wait for clk_period;
809
                -- HW size
810
                data_in <= x"06"; wait for clk_period;
811
                -- protocol size
812
                data_in <= x"04"; wait for clk_period;
813
                -- Opcode
814
                data_in <= x"00"; wait for clk_period;
815
                data_in <= x"02"; wait for clk_period;
816
                -- Sender MAC
817
                data_in <= x"02"; wait for clk_period;
818
                data_in <= x"15"; wait for clk_period;
819
                data_in <= x"03"; wait for clk_period;
820
                data_in <= x"23"; wait for clk_period;
821
                data_in <= x"04"; wait for clk_period;
822
                data_in <= x"54"; wait for clk_period;
823
                -- Sender IP
824
                data_in <= x"c0"; wait for clk_period;
825
                data_in <= x"a8"; wait for clk_period;
826
                data_in <= x"05"; wait for clk_period;
827
                data_in <= x"07"; wait for clk_period;
828
                -- Target MAC
829
                data_in <= x"00"; wait for clk_period;
830
                data_in <= x"23"; wait for clk_period;
831
                data_in <= x"20"; wait for clk_period;
832
                data_in <= x"21"; wait for clk_period;
833
                data_in <= x"22"; wait for clk_period;
834
                data_in <= x"23"; wait for clk_period;
835
                -- Target IP
836
                data_in <= x"c0"; wait for clk_period;
837
                data_in <= x"a8"; wait for clk_period;
838
                data_in <= x"05"; wait for clk_period;
839
                data_in <= x"09"; wait for clk_period;
840
                data_in <= x"00"; wait for clk_period;
841
                data_in <= x"00"; wait for clk_period;
842
                data_in <= x"00"; wait for clk_period;
843
                data_in_last <= '1';
844
                data_in <= x"00"; wait for clk_period;
845
                data_in_last <= '0';
846
                data_in_valid <= '0';
847
                wait for clk_period;
848
                assert arp_req_rslt.got_mac = '1'                               report "T9: should have got mac";
849
                assert arp_req_rslt.mac = x"021503230454"               report "T9: incorrect mac";
850
                assert arp_req_rslt.got_err = '0'                                report "T9: should not have got err";
851
                wait for clk_period*10;
852
 
853
                report "T10: Request 192.168.5.7 again an expect it to be in the cache";
854
                arp_req_req.ip <= x"c0a80507";
855
                arp_req_req.lookup_req <= '1';
856
                wait for clk_period;
857
                assert arp_req_rslt.got_mac = '1'                               report "T10: should have mac";
858
                assert arp_req_rslt.got_err = '0'                                report "T10: should not have got err";
859
 
860
                arp_req_req.lookup_req <= '0';
861
                wait for clk_period*20;
862
 
863
                report "T11: Clear the cache, Request 192.168.5.7 again an expect a 'who has' to be sent";
864
                control.clear_cache <= '1';
865
                wait for clk_period;
866
                control.clear_cache <= '0';
867
                wait for clk_period;
868
 
869
                arp_req_req.ip <= x"c0a80507";
870
                arp_req_req.lookup_req <= '1';
871
                wait for clk_period;
872
                assert arp_req_rslt.got_mac = '0'                                report "T11: should not yet have mac";
873
                assert arp_req_rslt.got_err = '0'                                report "T11: should not have got err";
874
 
875
                arp_req_req.lookup_req <= '0';
876
                wait for clk_period*20;
877
 
878
 
879
                assert mac_tx_req = '1'                                                         report "T11: should be requesting TX channel";
880
                wait for clk_period*50;
881
                -- Send the reply
882
                data_out_ready <= '1';
883
 
884
                data_in_valid <= '1';
885
                -- dst MAC (bc)
886
                data_in <= x"ff"; wait for clk_period;
887
                data_in <= x"ff"; wait for clk_period;
888
                data_in <= x"ff"; wait for clk_period;
889
                data_in <= x"ff"; wait for clk_period;
890
                data_in <= x"ff"; wait for clk_period;
891
                data_in <= x"ff"; wait for clk_period;
892
                -- src MAC
893
                data_in <= x"02"; wait for clk_period;
894
                data_in <= x"15"; wait for clk_period;
895
                data_in <= x"03"; wait for clk_period;
896
                data_in <= x"23"; wait for clk_period;
897
                data_in <= x"04"; wait for clk_period;
898
                data_in <= x"54"; wait for clk_period;
899
                -- type
900
                data_in <= x"08"; wait for clk_period;
901
                data_in <= x"06"; wait for clk_period;
902
                -- HW type
903
                data_in <= x"00"; wait for clk_period;
904
                data_in <= x"01"; wait for clk_period;
905
                -- Protocol type
906
                data_in <= x"08"; wait for clk_period;
907
                data_in <= x"00"; wait for clk_period;
908
                -- HW size
909
                data_in <= x"06"; wait for clk_period;
910
                -- protocol size
911
                data_in <= x"04"; wait for clk_period;
912
                -- Opcode
913
                data_in <= x"00"; wait for clk_period;
914
                data_in <= x"02"; wait for clk_period;
915
                -- Sender MAC
916
                data_in <= x"02"; wait for clk_period;
917
                data_in <= x"15"; wait for clk_period;
918
                data_in <= x"03"; wait for clk_period;
919
                data_in <= x"23"; wait for clk_period;
920
                data_in <= x"55"; wait for clk_period;
921
                data_in <= x"54"; wait for clk_period;
922
                -- Sender IP
923
                data_in <= x"c0"; wait for clk_period;
924
                data_in <= x"a8"; wait for clk_period;
925
                data_in <= x"05"; wait for clk_period;
926
                data_in <= x"07"; wait for clk_period;
927
                -- Target MAC
928
                data_in <= x"00"; wait for clk_period;
929
                data_in <= x"23"; wait for clk_period;
930
                data_in <= x"20"; wait for clk_period;
931
                data_in <= x"21"; wait for clk_period;
932
                data_in <= x"22"; wait for clk_period;
933
                data_in <= x"23"; wait for clk_period;
934
                -- Target IP
935
                data_in <= x"c0"; wait for clk_period;
936
                data_in <= x"a8"; wait for clk_period;
937
                data_in <= x"05"; wait for clk_period;
938
                data_in <= x"09"; wait for clk_period;
939
                data_in <= x"00"; wait for clk_period;
940
                data_in <= x"00"; wait for clk_period;
941
                data_in <= x"00"; wait for clk_period;
942
                data_in_last <= '1';
943
                data_in <= x"00"; wait for clk_period;
944
                data_in_last <= '0';
945
                data_in_valid <= '0';
946
                wait for clk_period;
947
                assert arp_req_rslt.got_mac = '1'                               report "T11: should have got mac";
948
                assert arp_req_rslt.mac = x"021503235554"               report "T11: incorrect mac";
949
                assert arp_req_rslt.got_err = '0'                                report "T11: should not have got err";
950
                wait for clk_period*10;
951
 
952
                report "--- end of tests ---";
953
      wait;
954
   end process;
955
 
956
END;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.