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 34

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 18 pjf
-- Revision 0.02 - Added tests for ARP timeout
20 10 pjf
-- 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 18 pjf
library ieee;
30
use ieee.std_logic_1164.all;
31
use ieee.numeric_std.all;
32 10 pjf
use work.arp_types.all;
33 18 pjf
 
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
      no_default_gateway : boolean := true;
44
      CLOCK_FREQ      : integer := 125000000;  -- freq of data_in_clk -- needed to timout cntr
45
      ARP_TIMEOUT     : integer := 60;  -- ARP response timeout (s)
46
      MAX_ARP_ENTRIES : integer := 255  -- max entries in the arp store
47
      );
48
    port (
49
      -- lookup request signals
50
      arp_req_req     : in  arp_req_req_type;
51
      arp_req_rslt    : out arp_req_rslt_type;
52
      -- MAC layer RX signals
53
      data_in_clk     : in  std_logic;
54
      reset           : in  std_logic;
55
      data_in         : in  std_logic_vector (7 downto 0);  -- ethernet frame (from dst mac addr through to last byte of frame)
56
      data_in_valid   : in  std_logic;  -- indicates data_in valid on clock
57
      data_in_last    : in  std_logic;  -- indicates last data in frame
58
      -- MAC layer TX signals
59
      mac_tx_req      : out std_logic;  -- indicates that ip wants access to channel (stays up for as long as tx)
60
      mac_tx_granted  : in  std_logic;  -- indicates that access to channel has been granted            
61
      data_out_clk    : in  std_logic;
62
      data_out_ready  : in  std_logic;  -- indicates system ready to consume data
63
      data_out_valid  : out std_logic;  -- indicates data out is valid
64
      data_out_first  : out std_logic;  -- with data out valid indicates the first byte of a frame
65
      data_out_last   : out std_logic;  -- with data out valid indicates the last byte of a frame
66
      data_out        : out std_logic_vector (7 downto 0);  -- ethernet frame (from dst mac addr through to last byte of frame)
67
      -- system signals
68
      our_mac_address : in  std_logic_vector (47 downto 0);
69
      our_ip_address  : in  std_logic_vector (31 downto 0);
70
      nwk_gateway     : in  std_logic_vector (31 downto 0);  -- IP address of default gateway
71
      nwk_mask        : in  std_logic_vector (31 downto 0);  -- Net mask
72
      control         : in  arp_control_type;
73
      req_count       : out std_logic_vector(7 downto 0)    -- count of arp pkts received
74
      );
75
  end component;
76
 
77
 
78
  --Inputs
79
  signal clk             : std_logic                     := '0';
80
  signal reset           : std_logic                     := '0';
81
  signal data_in         : std_logic_vector(7 downto 0)  := (others => '0');
82
  signal data_in_valid   : std_logic                     := '0';
83
  signal data_in_last    : std_logic                     := '0';
84
  signal our_mac_address : std_logic_vector(47 downto 0) := (others => '0');
85
  signal our_ip_address  : std_logic_vector(31 downto 0) := (others => '0');
86
  signal nwk_gateway     : std_logic_vector(31 downto 0) := (others => '0');
87
  signal nwk_mask        : std_logic_vector(31 downto 0) := (others => '0');
88
  signal data_out_ready  : std_logic;
89
  signal data_out_valid  : std_logic;
90
  signal data_out_first  : std_logic;
91
  signal data_out_last   : std_logic;
92
  signal data_out        : std_logic_vector (7 downto 0);
93
  signal req_count       : std_logic_vector(7 downto 0);
94
  signal arp_req_req     : arp_req_req_type;
95
  signal arp_req_rslt    : arp_req_rslt_type;
96
  signal mac_tx_req      : std_logic;
97
  signal mac_tx_granted  : std_logic;
98
  signal control         : arp_control_type;
99
 
100
  constant no_default_gateway : boolean := false;
101
 
102
  -- Clock period definitions
103
  constant clk_period : time := 8 ns;
104
 
105
begin
106
 
107
  -- Instantiate the Unit Under Test (UUT)
108
  uut : arpv2
109
    generic map (
110
      no_default_gateway => no_default_gateway,
111
      CLOCK_FREQ  => 10,                -- artificially low count to enable pragmatic testing
112
      ARP_TIMEOUT => 20
113
      )
114
    port map (
115
      -- lookup request mappings
116
      arp_req_req     => arp_req_req,
117
      arp_req_rslt    => arp_req_rslt,
118
      -- rx mappings
119
      data_in_clk     => clk,
120
      reset           => reset,
121
      data_in         => data_in,
122
      data_in_valid   => data_in_valid,
123
      data_in_last    => data_in_last,
124
      -- tx mappings
125
      mac_tx_req      => mac_tx_req,
126
      mac_tx_granted  => mac_tx_granted,
127
      data_out_clk    => clk,
128
      data_out_ready  => data_out_ready,
129
      data_out_valid  => data_out_valid,
130
      data_out_first  => data_out_first,
131
      data_out_last   => data_out_last,
132
      data_out        => data_out,
133
      -- system mappings
134
      our_mac_address => our_mac_address,
135
      our_ip_address  => our_ip_address,
136
      nwk_gateway     => nwk_gateway,
137
      nwk_mask        => nwk_mask,
138
      control         => control,
139
      req_count       => req_count
140
      );
141
 
142
  -- Clock process definitions
143
  clk_process : process
144
  begin
145
    clk <= '0';
146
    wait for clk_period/2;
147
    clk <= '1';
148
    wait for clk_period/2;
149
  end process;
150
 
151
 
152
  -- Stimulus process
153
  stim_proc : process
154
  begin
155
    -- hold reset state for 100 ns.
156
    wait for 100 ns;
157
 
158
    our_ip_address      <= x"c0a80509";  -- 192.168.5.9
159
    nwk_mask            <= x"FFFFFF00";
160
    nwk_gateway         <= x"c0a80501";  -- 192.168.5.9
161
    our_mac_address     <= x"002320212223";
162
    mac_tx_granted      <= '1';          -- FIXME 0
163
    control.clear_cache <= '0';
164
 
165
    reset <= '1';
166
    wait for clk_period*10;
167
    reset <= '0';
168
    wait for clk_period*5;
169
 
170
    assert mac_tx_req = '0' report "mac_tx_req asserted on reset";
171
 
172
    wait until clk = '1';
173 10 pjf
 
174 18 pjf
    -- insert stimulus here
175
    arp_req_req.lookup_req <= '0';
176
    arp_req_req.ip         <= (others => '0');
177
    data_out_ready         <= '1';
178 10 pjf
 
179 18 pjf
    report "T1:  Send an ARP request: who has 192.168.5.9? Tell 192.168.5.1";
180
    data_in_valid <= '1';
181
    -- dst MAC (bc)
182
    data_in       <= x"ff"; wait for clk_period;
183
    data_in       <= x"ff"; wait for clk_period;
184
    data_in       <= x"ff"; wait for clk_period;
185
    data_in       <= x"ff"; wait for clk_period;
186
    data_in       <= x"ff"; wait for clk_period;
187
    data_in       <= x"ff"; wait for clk_period;
188
    -- src MAC
189
    data_in       <= x"00"; wait for clk_period;
190
    data_in       <= x"23"; wait for clk_period;
191
    data_in       <= x"18"; wait for clk_period;
192
    data_in       <= x"29"; wait for clk_period;
193
    data_in       <= x"26"; wait for clk_period;
194
    data_in       <= x"7c"; wait for clk_period;
195
    -- type
196
    data_in       <= x"08"; wait for clk_period;
197
    data_in       <= x"06"; wait for clk_period;
198
    -- HW type
199
    data_in       <= x"00"; wait for clk_period;
200
    data_in       <= x"01"; wait for clk_period;
201
    -- Protocol type
202
    data_in       <= x"08"; wait for clk_period;
203
    data_in       <= x"00"; wait for clk_period;
204
    -- HW size
205
    data_in       <= x"06"; wait for clk_period;
206
    -- protocol size
207
    data_in       <= x"04"; wait for clk_period;
208
    -- Opcode
209
    data_in       <= x"00"; wait for clk_period;
210
    data_in       <= x"01"; wait for clk_period;
211
    -- Sender MAC
212
    data_in       <= x"00"; wait for clk_period;
213
    data_in       <= x"23"; wait for clk_period;
214
    data_in       <= x"18"; wait for clk_period;
215
    data_in       <= x"29"; wait for clk_period;
216
    data_in       <= x"26"; wait for clk_period;
217
    data_in       <= x"7c"; wait for clk_period;
218
    -- Sender IP
219
    data_in       <= x"c0"; wait for clk_period;
220
    data_in       <= x"a8"; wait for clk_period;
221
    data_in       <= x"05"; wait for clk_period;
222
    data_in       <= x"01"; wait for clk_period;
223
    -- Target MAC
224
    data_in       <= x"00"; wait for clk_period;
225
    data_in       <= x"00"; wait for clk_period;
226
    data_in       <= x"00"; wait for clk_period;
227
    data_in       <= x"00"; wait for clk_period;
228
    data_in       <= x"00"; wait for clk_period;
229
    data_in       <= x"00"; wait for clk_period;
230
    -- Target IP
231
    data_in       <= x"c0"; wait for clk_period;
232
    data_in       <= x"a8"; wait for clk_period;
233
    data_in       <= x"05"; wait for clk_period;
234
    data_in       <= x"09"; wait for clk_period;
235
    data_in       <= x"00"; wait for clk_period;
236
    data_in       <= x"00"; wait for clk_period;
237
    data_in       <= x"00"; wait for clk_period;
238
    data_in_last  <= '1';
239
    data_in       <= x"00"; wait for clk_period;
240
    data_in_last  <= '0';
241
    data_in_valid <= '0';
242 10 pjf
 
243 18 pjf
    report "T1:  Expect that we send an 'I have 192.168.5.9' msg";
244 10 pjf
 
245 18 pjf
    -- check tx arbitration signals
246 10 pjf
 
247 18 pjf
    report "T1: waiting for tx req";
248
    wait until mac_tx_req = '1';
249 10 pjf
 
250 18 pjf
    -- ready to tx
251
    data_out_ready <= '1';
252
    mac_tx_granted <= '1';
253
    report "T1: waiting for data_out_valid";
254
    wait until data_out_valid = '1';
255
    report "T1: got data_out_valid";
256
    wait for clk_period*10;
257
    data_out_ready <= '0';
258
    wait for clk_period*2;
259
    data_out_ready <= '1';
260
    wait for clk_period*12;
261
    assert data_out = x"02" report "T1: expected opcode = 02 for reply 'I have'";
262
    -- expect our mac 00 23 20 21 22 23
263
    wait for clk_period;
264
    assert data_out = x"00" report "T1: incorrect our mac.0";
265
    wait for clk_period;
266
    assert data_out = x"23" report "T1: incorrect our mac.1";
267
    wait for clk_period;
268
    assert data_out = x"20" report "T1: incorrect our mac.2";
269
    wait for clk_period;
270
    assert data_out = x"21" report "T1: incorrect our mac.3";
271
    wait for clk_period;
272
    assert data_out = x"22" report "T1: incorrect our mac.4";
273
    wait for clk_period;
274
    assert data_out = x"23" report "T1: incorrect our mac.5";
275
    -- expect our IP c0 a8 05 05
276
    wait for clk_period;
277
    assert data_out = x"c0" report "T1: incorrect our IP.0";
278
    wait for clk_period;
279
    assert data_out = x"a8" report "T1: incorrect our IP.1";
280
    wait for clk_period;
281
    assert data_out = x"05" report "T1: incorrect our IP.2";
282
    wait for clk_period;
283
    assert data_out = x"09" report "T1: incorrect our IP.3";
284 10 pjf
 
285 18 pjf
    -- expect target mac 00 23 18 29 26 7c
286
    wait for clk_period;
287
    assert data_out = x"00" report "T1: incorrect target mac.0";
288
    wait for clk_period;
289
    assert data_out = x"23" report "T1: incorrect target mac.1";
290
    wait for clk_period;
291
    assert data_out = x"18" report "T1: incorrect target mac.2";
292
    wait for clk_period;
293
    assert data_out = x"29" report "T1: incorrect target mac.3";
294
    wait for clk_period;
295
    assert data_out = x"26" report "T1: incorrect target mac.4";
296
    wait for clk_period;
297
    assert data_out = x"7c" report "T1: incorrect target mac.5";
298
    -- expect target IP c0 a8 05 01
299
    wait for clk_period;
300
    assert data_out = x"c0" report "T1: incorrect target IP.0";
301
    wait for clk_period;
302
    assert data_out = x"a8" report "T1: incorrect target IP.1";
303
    wait for clk_period;
304
    assert data_out = x"05" report "T1: incorrect target IP.2";
305
    assert data_out_last = '0' report "T1: data out last incorrectly set on target IP.2 byte";
306
    wait for clk_period;
307
    assert data_out = x"01" report "T1: incorrect target IP.3";
308
    assert data_out_last = '1' report "T1: data out last should be set";
309 10 pjf
 
310 18 pjf
    wait for clk_period*10;
311 10 pjf
 
312 18 pjf
    report "T2: Send another ARP request: who has 192.168.5.8? Tell 192.168.5.1, holding off transmitter";
313
    data_out_ready <= '0';
314
    data_in_valid  <= '1';
315
    -- dst MAC (bc)
316
    data_in        <= x"ff"; wait for clk_period;
317
    data_in        <= x"ff"; wait for clk_period;
318
    data_in        <= x"ff"; wait for clk_period;
319
    data_in        <= x"ff"; wait for clk_period;
320
    data_in        <= x"ff"; wait for clk_period;
321
    data_in        <= x"ff"; wait for clk_period;
322
    -- src MAC
323
    data_in        <= x"00"; wait for clk_period;
324
    data_in        <= x"23"; wait for clk_period;
325
    data_in        <= x"18"; wait for clk_period;
326
    data_in        <= x"29"; wait for clk_period;
327
    data_in        <= x"26"; wait for clk_period;
328
    data_in        <= x"7c"; wait for clk_period;
329
    -- type
330
    data_in        <= x"08"; wait for clk_period;
331
    data_in        <= x"06"; wait for clk_period;
332
    -- HW type
333
    data_in        <= x"00"; wait for clk_period;
334
    data_in        <= x"01"; wait for clk_period;
335
    -- Protocol type
336
    data_in        <= x"08"; wait for clk_period;
337
    data_in        <= x"00"; wait for clk_period;
338
    -- HW size
339
    data_in        <= x"06"; wait for clk_period;
340
    -- protocol size
341
    data_in        <= x"04"; wait for clk_period;
342
    -- Opcode
343
    data_in        <= x"00"; wait for clk_period;
344
    data_in        <= x"01"; wait for clk_period;
345
    -- Sender MAC
346
    data_in        <= x"00"; wait for clk_period;
347
    data_in        <= x"23"; wait for clk_period;
348
    data_in        <= x"18"; wait for clk_period;
349
    data_in        <= x"29"; wait for clk_period;
350
    data_in        <= x"26"; wait for clk_period;
351
    data_in        <= x"7c"; wait for clk_period;
352
    -- Sender IP
353
    data_in        <= x"c0"; wait for clk_period;
354
    data_in        <= x"a8"; wait for clk_period;
355
    data_in        <= x"05"; wait for clk_period;
356
    data_in        <= x"01"; wait for clk_period;
357
    -- Target MAC
358
    data_in        <= x"00"; wait for clk_period;
359
    data_in        <= x"00"; wait for clk_period;
360
    data_in        <= x"00"; wait for clk_period;
361
    data_in        <= x"00"; wait for clk_period;
362
    data_in        <= x"00"; wait for clk_period;
363
    data_in        <= x"00"; wait for clk_period;
364
    -- Target IP
365
    data_in        <= x"c0"; wait for clk_period;
366
    data_in        <= x"a8"; wait for clk_period;
367
    data_in        <= x"05"; wait for clk_period;
368
    data_in        <= x"09"; wait for clk_period;
369
    data_in        <= x"00"; wait for clk_period;
370
    data_in        <= x"00"; wait for clk_period;
371
    data_in        <= x"00"; wait for clk_period;
372
    data_in_last   <= '1';
373
    data_in        <= x"00"; wait for clk_period;
374
    data_in_last   <= '0';
375
    data_in_valid  <= '0';
376 10 pjf
 
377 18 pjf
    -- ready to tx
378
    wait for clk_period*10;
379
    data_out_ready <= '1';
380 10 pjf
 
381 18 pjf
    wait for clk_period*50;
382 10 pjf
 
383 18 pjf
    report "T3: Send a request for the IP that is already in the store";
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
    report "T3: wait for reply from store";
389
    wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1';
390
    assert arp_req_rslt.got_mac = '1' report "T3: expected got mac";
391
    assert arp_req_rslt.got_err = '0' report "T3: expected got err = 0";
392
    assert arp_req_rslt.mac = x"00231829267c" report "T3: wrong mac value";
393
    wait for clk_period*2;
394 10 pjf
 
395 18 pjf
    -- the entry that was in the store should now be in the cache - check it
396
    report "T4: Send a request for the IP that is already in the cache";
397
    arp_req_req.ip         <= x"c0a80501";
398
    arp_req_req.lookup_req <= '1';
399
    wait for clk_period;
400
    arp_req_req.lookup_req <= '0';
401
    assert arp_req_rslt.got_mac = '1' report "T4: expected got mac";
402
    assert arp_req_rslt.got_err = '0' report "T4: expected got err = 0";
403
    assert arp_req_rslt.mac = x"00231829267c" report "T4: wrong mac value";
404 10 pjf
 
405 18 pjf
    wait for clk_period*50;
406
 
407
    report "T5 - Send a request for the IP that is not cached or in the store";
408
    arp_req_req.ip         <= x"c0a80503";
409
    arp_req_req.lookup_req <= '1';
410
    wait for clk_period;
411
    arp_req_req.lookup_req <= '0';
412
    report "T5: waiting for data_out_valid";
413
    wait until data_out_valid = '1';
414
    report "T5: got data_out_valid";
415
    wait for clk_period*10;
416
    data_out_ready         <= '0';
417
    wait for clk_period*2;
418
    data_out_ready         <= '1';
419
    wait for clk_period*12;
420
    assert data_out = x"01" report "T5: expected opcode = 01 for request 'who has'";
421
    -- expect our mac 00 23 20 21 22 23
422
    wait for clk_period;
423
    assert data_out = x"00" report "T5: incorrect our mac.0";
424
    wait for clk_period;
425
    assert data_out = x"23" report "T5: incorrect our mac.1";
426
    wait for clk_period;
427
    assert data_out = x"20" report "T5: incorrect our mac.2";
428
    wait for clk_period;
429
    assert data_out = x"21" report "T5: incorrect our mac.3";
430
    wait for clk_period;
431
    assert data_out = x"22" report "T5: incorrect our mac.4";
432
    wait for clk_period;
433
    assert data_out = x"23" report "T5: incorrect our mac.5";
434
    -- expect our IP c0 a8 05 05
435
    wait for clk_period;
436
    assert data_out = x"c0" report "T5: incorrect our IP.0";
437
    wait for clk_period;
438
    assert data_out = x"a8" report "T5: incorrect our IP.1";
439
    wait for clk_period;
440
    assert data_out = x"05" report "T5: incorrect our IP.2";
441
    wait for clk_period;
442
    assert data_out = x"09" report "T5: incorrect our IP.3";
443
 
444
    -- expect empty target mac 
445
    wait for clk_period;
446
    assert data_out = x"ff" report "T5: incorrect target mac.0";
447
    wait for clk_period;
448
    assert data_out = x"ff" report "T5: incorrect target mac.1";
449
    wait for clk_period;
450
    assert data_out = x"ff" report "T5: incorrect target mac.2";
451
    wait for clk_period;
452
    assert data_out = x"ff" report "T5: incorrect target mac.3";
453
    wait for clk_period;
454
    assert data_out = x"ff" report "T5: incorrect target mac.4";
455
    wait for clk_period;
456
    assert data_out = x"ff" report "T5: incorrect target mac.5";
457
    -- expect target IP c0 a8 05 01
458
    wait for clk_period;
459
    assert data_out = x"c0" report "T5: incorrect target IP.0";
460
    wait for clk_period;
461
    assert data_out = x"a8" report "T5: incorrect target IP.1";
462
    wait for clk_period;
463
    assert data_out = x"05" report "T5: incorrect target IP.2";
464
    assert data_out_last = '0' report "T5: data out last incorrectly set on target IP.2 byte";
465
    wait for clk_period;
466
    assert data_out = x"03" report "T5: incorrect target IP.3";
467
    assert data_out_last = '1' report "T5: data out last should be set";
468
 
469
    wait for clk_period*10;
470
 
471
    -- Send the reply
472
    data_out_ready <= '1';
473
 
474
    report "T5.2: Send an ARP reply: 192.168.5.3 has mac 02:12:03:23:04:54";
475
    data_in_valid <= '1';
476
    -- dst MAC (bc)
477
    data_in       <= x"ff"; wait for clk_period;
478
    data_in       <= x"ff"; wait for clk_period;
479
    data_in       <= x"ff"; wait for clk_period;
480
    data_in       <= x"ff"; wait for clk_period;
481
    data_in       <= x"ff"; wait for clk_period;
482
    data_in       <= x"ff"; wait for clk_period;
483
    -- src MAC
484
    data_in       <= x"02"; wait for clk_period;
485
    data_in       <= x"12"; wait for clk_period;
486
    data_in       <= x"03"; wait for clk_period;
487
    data_in       <= x"23"; wait for clk_period;
488
    data_in       <= x"04"; wait for clk_period;
489
    data_in       <= x"54"; wait for clk_period;
490
    -- type
491
    data_in       <= x"08"; wait for clk_period;
492
    data_in       <= x"06"; wait for clk_period;
493
    -- HW type
494
    data_in       <= x"00"; wait for clk_period;
495
    data_in       <= x"01"; wait for clk_period;
496
    -- Protocol type
497
    data_in       <= x"08"; wait for clk_period;
498
    data_in       <= x"00"; wait for clk_period;
499
    -- HW size
500
    data_in       <= x"06"; wait for clk_period;
501
    -- protocol size
502
    data_in       <= x"04"; wait for clk_period;
503
    -- Opcode
504
    data_in       <= x"00"; wait for clk_period;
505
    data_in       <= x"02"; wait for clk_period;
506
    -- Sender MAC
507
    data_in       <= x"02"; wait for clk_period;
508
    data_in       <= x"12"; wait for clk_period;
509
    data_in       <= x"03"; wait for clk_period;
510
    data_in       <= x"23"; wait for clk_period;
511
    data_in       <= x"04"; wait for clk_period;
512
    data_in       <= x"54"; wait for clk_period;
513
    -- Sender IP
514
    data_in       <= x"c0"; wait for clk_period;
515
    data_in       <= x"a8"; wait for clk_period;
516
    data_in       <= x"05"; wait for clk_period;
517
    data_in       <= x"03"; wait for clk_period;
518
    -- Target MAC
519
    data_in       <= x"00"; wait for clk_period;
520
    data_in       <= x"23"; wait for clk_period;
521
    data_in       <= x"20"; wait for clk_period;
522
    data_in       <= x"21"; wait for clk_period;
523
    data_in       <= x"22"; wait for clk_period;
524
    data_in       <= x"23"; wait for clk_period;
525
    -- Target IP
526
    data_in       <= x"c0"; wait for clk_period;
527
    data_in       <= x"a8"; wait for clk_period;
528
    data_in       <= x"05"; wait for clk_period;
529
    data_in       <= x"09"; wait for clk_period;
530
    data_in       <= x"00"; wait for clk_period;
531
    data_in       <= x"00"; wait for clk_period;
532
    assert arp_req_rslt.got_mac = '1' report "T5.2: expected got mac";
533
    assert arp_req_rslt.got_err = '0' report "T5.2: expected got err = 0";
534
    assert arp_req_rslt.mac = x"021203230454" report "T5.2: wrong mac value";
535
    data_in       <= x"00"; wait for clk_period;
536
    data_in_last  <= '1';
537
    data_in       <= x"00"; wait for clk_period;
538
    data_in_last  <= '0';
539
    data_in_valid <= '0';
540
    wait for clk_period*4;
541
 
542
    report "T6: check that both these IPs remain in the store";
543
    arp_req_req.ip         <= x"c0a80501";
544
    arp_req_req.lookup_req <= '1';
545
    wait for clk_period;
546
    arp_req_req.lookup_req <= '0';
547
    wait for clk_period;
548
    report "T6.1: wait for reply from store";
549
    wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1';
550
    assert arp_req_rslt.got_mac = '1' report "T6.1: expected got mac";
551
    assert arp_req_rslt.got_err = '0' report "T6.1: expected got err = 0";
552
    assert arp_req_rslt.mac = x"00231829267c" report "T6.1: wrong mac value";
553
    wait for clk_period*2;
554
 
555
    arp_req_req.ip         <= x"c0a80503";
556
    arp_req_req.lookup_req <= '1';
557
    wait for clk_period;
558
    arp_req_req.lookup_req <= '0';
559
    wait for clk_period;
560
    report "T6.2: wait for reply from store";
561
    wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1';
562
    assert arp_req_rslt.got_mac = '1' report "T6.2: expected got mac";
563
    assert arp_req_rslt.got_err = '0' report "T6.2: expected got err = 0";
564
    assert arp_req_rslt.mac = x"021203230454" report "T6.2: wrong mac value";
565
    wait for clk_period*2;
566
 
567
    report "T7 - test that receipt of wrong I Have does not satisfy a current req";
568
    arp_req_req.ip         <= x"c0a8050e";
569
    arp_req_req.lookup_req <= '1';
570
    wait for clk_period;
571
    arp_req_req.lookup_req <= '0';
572
    report "T7: waiting for data_out_valid";
573
    wait until data_out_valid = '1';
574
    report "T7: got data_out_valid";
575
    wait for clk_period*10;
576
    data_out_ready         <= '0';
577
    wait for clk_period*2;
578
    data_out_ready         <= '1';
579
    wait for clk_period*12;
580
    assert data_out = x"01" report "T7: expected opcode = 01 for request 'who has'";
581
    -- expect our mac 00 23 20 21 22 23
582
    wait for clk_period;
583
    assert data_out = x"00" report "T7: incorrect our mac.0";
584
    wait for clk_period;
585
    assert data_out = x"23" report "T7: incorrect our mac.1";
586
    wait for clk_period;
587
    assert data_out = x"20" report "T7: incorrect our mac.2";
588
    wait for clk_period;
589
    assert data_out = x"21" report "T7: incorrect our mac.3";
590
    wait for clk_period;
591
    assert data_out = x"22" report "T7: incorrect our mac.4";
592
    wait for clk_period;
593
    assert data_out = x"23" report "T7: incorrect our mac.5";
594
    -- expect our IP c0 a8 05 05
595
    wait for clk_period;
596
    assert data_out = x"c0" report "T7: incorrect our IP.0";
597
    wait for clk_period;
598
    assert data_out = x"a8" report "T7: incorrect our IP.1";
599
    wait for clk_period;
600
    assert data_out = x"05" report "T7: incorrect our IP.2";
601
    wait for clk_period;
602
    assert data_out = x"09" report "T7: incorrect our IP.3";
603
 
604
    -- expect empty target mac
605
    wait for clk_period;
606
    assert data_out = x"ff" report "T7: incorrect target mac.0";
607
    wait for clk_period;
608
    assert data_out = x"ff" report "T7: incorrect target mac.1";
609
    wait for clk_period;
610
    assert data_out = x"ff" report "T7: incorrect target mac.2";
611
    wait for clk_period;
612
    assert data_out = x"ff" report "T7: incorrect target mac.3";
613
    wait for clk_period;
614
    assert data_out = x"ff" report "T7: incorrect target mac.4";
615
    wait for clk_period;
616
    assert data_out = x"ff" report "T7: incorrect target mac.5";
617
    -- expect target IP c0 a8 05 0e
618
    wait for clk_period;
619
    assert data_out = x"c0" report "T7: incorrect target IP.0";
620
    wait for clk_period;
621
    assert data_out = x"a8" report "T7: incorrect target IP.1";
622
    wait for clk_period;
623
    assert data_out = x"05" report "T7: incorrect target IP.2";
624
    assert data_out_last = '0' report "T7: data out last incorrectly set on target IP.2 byte";
625
    wait for clk_period;
626
    assert data_out = x"0e" report "T7: incorrect target IP.3";
627
    assert data_out_last = '1' report "T7: data out last should be set";
628
 
629
    wait for clk_period*10;
630
 
631
    -- Send the reply
632
    data_out_ready <= '1';
633
 
634
    report "T7.2: Send an arbitrary unwanted ARP reply: 192.168.5.143 has mac 57:12:34:19:23:9a";
635
    data_in_valid <= '1';
636
    -- dst MAC (bc)
637
    data_in       <= x"ff"; wait for clk_period;
638
    data_in       <= x"ff"; wait for clk_period;
639
    data_in       <= x"ff"; wait for clk_period;
640
    data_in       <= x"ff"; wait for clk_period;
641
    data_in       <= x"ff"; wait for clk_period;
642
    data_in       <= x"ff"; wait for clk_period;
643
    -- src MAC
644
    data_in       <= x"57"; wait for clk_period;
645
    data_in       <= x"12"; wait for clk_period;
646
    data_in       <= x"34"; wait for clk_period;
647
    data_in       <= x"19"; wait for clk_period;
648
    data_in       <= x"23"; wait for clk_period;
649
    data_in       <= x"9a"; wait for clk_period;
650
    -- type
651
    data_in       <= x"08"; wait for clk_period;
652
    data_in       <= x"06"; wait for clk_period;
653
    -- HW type
654
    data_in       <= x"00"; wait for clk_period;
655
    data_in       <= x"01"; wait for clk_period;
656
    -- Protocol type
657
    data_in       <= x"08"; wait for clk_period;
658
    data_in       <= x"00"; wait for clk_period;
659
    -- HW size
660
    data_in       <= x"06"; wait for clk_period;
661
    -- protocol size
662
    data_in       <= x"04"; wait for clk_period;
663
    -- Opcode
664
    data_in       <= x"00"; wait for clk_period;
665
    data_in       <= x"02"; wait for clk_period;
666
    -- Sender MAC
667
    data_in       <= x"57"; wait for clk_period;
668
    data_in       <= x"12"; wait for clk_period;
669
    data_in       <= x"34"; wait for clk_period;
670
    data_in       <= x"19"; wait for clk_period;
671
    data_in       <= x"23"; wait for clk_period;
672
    data_in       <= x"9a"; wait for clk_period;
673
    -- Sender IP
674
    data_in       <= x"c0"; wait for clk_period;
675
    data_in       <= x"a8"; wait for clk_period;
676
    data_in       <= x"25"; wait for clk_period;
677
    data_in       <= x"93"; wait for clk_period;
678
    -- Target MAC
679
    data_in       <= x"00"; wait for clk_period;
680
    data_in       <= x"23"; wait for clk_period;
681
    data_in       <= x"20"; wait for clk_period;
682
    data_in       <= x"21"; wait for clk_period;
683
    data_in       <= x"22"; wait for clk_period;
684
    data_in       <= x"23"; wait for clk_period;
685
    -- Target IP
686
    data_in       <= x"c0"; wait for clk_period;
687
    data_in       <= x"a8"; wait for clk_period;
688
    data_in       <= x"05"; wait for clk_period;
689
    data_in       <= x"09"; wait for clk_period;
690
    data_in       <= x"00"; wait for clk_period;
691
    data_in       <= x"00"; wait for clk_period;
692
    data_in       <= x"00"; wait for clk_period;
693
    data_in_last  <= '1';
694
    data_in       <= x"00"; wait for clk_period;
695
    assert arp_req_rslt.got_mac = '0' report "T7.2: expected got mac = 0";
696
    assert arp_req_rslt.got_err = '0' report "T7.2: expected got err = 0";
697
    data_in_last  <= '0';
698
    data_in_valid <= '0';
699
    wait for clk_period*4;
700
 
701
    -- Send the reply
702
    data_out_ready <= '1';
703
 
704
    report "T7.3: Send a wanted ARP reply: 192.168.5.e has mac 76:34:98:55:aa:37";
705
    data_in_valid <= '1';
706
    -- dst MAC (bc)
707
    data_in       <= x"ff"; wait for clk_period;
708
    data_in       <= x"ff"; wait for clk_period;
709
    data_in       <= x"ff"; wait for clk_period;
710
    data_in       <= x"ff"; wait for clk_period;
711
    data_in       <= x"ff"; wait for clk_period;
712
    data_in       <= x"ff"; wait for clk_period;
713
    -- src MAC
714
    data_in       <= x"76"; wait for clk_period;
715
    data_in       <= x"34"; wait for clk_period;
716
    data_in       <= x"98"; wait for clk_period;
717
    data_in       <= x"55"; wait for clk_period;
718
    data_in       <= x"aa"; wait for clk_period;
719
    data_in       <= x"37"; wait for clk_period;
720
    -- type
721
    data_in       <= x"08"; wait for clk_period;
722
    data_in       <= x"06"; wait for clk_period;
723
    -- HW type
724
    data_in       <= x"00"; wait for clk_period;
725
    data_in       <= x"01"; wait for clk_period;
726
    -- Protocol type
727
    data_in       <= x"08"; wait for clk_period;
728
    data_in       <= x"00"; wait for clk_period;
729
    -- HW size
730
    data_in       <= x"06"; wait for clk_period;
731
    -- protocol size
732
    data_in       <= x"04"; wait for clk_period;
733
    -- Opcode
734
    data_in       <= x"00"; wait for clk_period;
735
    data_in       <= x"02"; wait for clk_period;
736
    -- Sender MAC
737
    data_in       <= x"76"; wait for clk_period;
738
    data_in       <= x"34"; wait for clk_period;
739
    data_in       <= x"98"; wait for clk_period;
740
    data_in       <= x"55"; wait for clk_period;
741
    data_in       <= x"aa"; wait for clk_period;
742
    data_in       <= x"37"; wait for clk_period;
743
    -- Sender IP
744
    data_in       <= x"c0"; wait for clk_period;
745
    data_in       <= x"a8"; wait for clk_period;
746
    data_in       <= x"05"; wait for clk_period;
747
    data_in       <= x"0e"; wait for clk_period;
748
    -- Target MAC
749
    data_in       <= x"00"; wait for clk_period;
750
    data_in       <= x"23"; wait for clk_period;
751
    data_in       <= x"20"; wait for clk_period;
752
    data_in       <= x"21"; wait for clk_period;
753
    data_in       <= x"22"; wait for clk_period;
754
    data_in       <= x"23"; wait for clk_period;
755
    -- Target IP
756
    data_in       <= x"c0"; wait for clk_period;
757
    data_in       <= x"a8"; wait for clk_period;
758
    data_in       <= x"05"; wait for clk_period;
759
    data_in       <= x"09"; wait for clk_period;
760
    data_in       <= x"00"; wait for clk_period;
761
    data_in       <= x"00"; wait for clk_period;
762
    assert arp_req_rslt.got_mac = '1' report "T7.3: expected got mac";
763
    assert arp_req_rslt.got_err = '0' report "T7.3: expected got err = 0";
764
    assert arp_req_rslt.mac = x"76349855aa37" report "T7.3: wrong mac value";
765
    data_in       <= x"00"; wait for clk_period;
766
    data_in_last  <= '1';
767
    data_in       <= x"00"; wait for clk_period;
768
    data_in_last  <= '0';
769
    data_in_valid <= '0';
770
    wait for clk_period*4;
771
 
772
 
773
    report "T8: Request 192.168.5.4 (not cached), dont send a reply and wait for timeout";
774
    arp_req_req.ip         <= x"c0a80504";
775
    arp_req_req.lookup_req <= '1';
776
    wait for clk_period;
777
    arp_req_req.lookup_req <= '0';
778
    wait for clk_period*20;
779
    assert mac_tx_req = '1' report "T8: should be requesting TX channel";
780
    wait for clk_period*220;
781
    assert arp_req_rslt.got_mac = '0' report "T8: should not have got mac";
782
    assert arp_req_rslt.got_err = '1' report "T8: should have got err";
783
 
784
    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";
785
    arp_req_req.ip         <= x"c0a80507";
786
    arp_req_req.lookup_req <= '1';
787
    wait for clk_period;
788
    assert arp_req_rslt.got_mac = '0' report "T9: should not yet have mac";
789
    assert arp_req_rslt.got_err = '0' report "T9: should not have got err";
790
 
791
    arp_req_req.lookup_req <= '0';
792
    wait for clk_period*20;
793
    assert mac_tx_req = '1' report "T9: should be requesting TX channel";
794
    wait for clk_period*50;
795
    -- Send the reply
796
    data_out_ready         <= '1';
797
 
798
    data_in_valid <= '1';
799
    -- dst MAC (bc)
800
    data_in       <= x"ff"; wait for clk_period;
801
    data_in       <= x"ff"; wait for clk_period;
802
    data_in       <= x"ff"; wait for clk_period;
803
    data_in       <= x"ff"; wait for clk_period;
804
    data_in       <= x"ff"; wait for clk_period;
805
    data_in       <= x"ff"; wait for clk_period;
806
    -- src MAC
807
    data_in       <= x"02"; wait for clk_period;
808
    data_in       <= x"15"; wait for clk_period;
809
    data_in       <= x"03"; wait for clk_period;
810
    data_in       <= x"23"; wait for clk_period;
811
    data_in       <= x"04"; wait for clk_period;
812
    data_in       <= x"54"; wait for clk_period;
813
    -- type
814
    data_in       <= x"08"; wait for clk_period;
815
    data_in       <= x"06"; wait for clk_period;
816
    -- HW type
817
    data_in       <= x"00"; wait for clk_period;
818
    data_in       <= x"01"; wait for clk_period;
819
    -- Protocol type
820
    data_in       <= x"08"; wait for clk_period;
821
    data_in       <= x"00"; wait for clk_period;
822
    -- HW size
823
    data_in       <= x"06"; wait for clk_period;
824
    -- protocol size
825
    data_in       <= x"04"; wait for clk_period;
826
    -- Opcode
827
    data_in       <= x"00"; wait for clk_period;
828
    data_in       <= x"02"; wait for clk_period;
829
    -- Sender MAC
830
    data_in       <= x"02"; wait for clk_period;
831
    data_in       <= x"15"; wait for clk_period;
832
    data_in       <= x"03"; wait for clk_period;
833
    data_in       <= x"23"; wait for clk_period;
834
    data_in       <= x"04"; wait for clk_period;
835
    data_in       <= x"54"; wait for clk_period;
836
    -- Sender IP
837
    data_in       <= x"c0"; wait for clk_period;
838
    data_in       <= x"a8"; wait for clk_period;
839
    data_in       <= x"05"; wait for clk_period;
840
    data_in       <= x"07"; wait for clk_period;
841
    -- Target MAC
842
    data_in       <= x"00"; wait for clk_period;
843
    data_in       <= x"23"; wait for clk_period;
844
    data_in       <= x"20"; wait for clk_period;
845
    data_in       <= x"21"; wait for clk_period;
846
    data_in       <= x"22"; wait for clk_period;
847
    data_in       <= x"23"; wait for clk_period;
848
    -- Target IP
849
    data_in       <= x"c0"; wait for clk_period;
850
    data_in       <= x"a8"; wait for clk_period;
851
    data_in       <= x"05"; wait for clk_period;
852
    data_in       <= x"09"; wait for clk_period;
853
    data_in       <= x"00"; wait for clk_period;
854
    data_in       <= x"00"; wait for clk_period;
855
    data_in       <= x"00"; wait for clk_period;
856
    data_in_last  <= '1';
857
    data_in       <= x"00"; wait for clk_period;
858
    data_in_last  <= '0';
859
    data_in_valid <= '0';
860
    wait for clk_period;
861
    assert arp_req_rslt.got_mac = '1' report "T9: should have got mac";
862
    assert arp_req_rslt.mac = x"021503230454" report "T9: incorrect mac";
863
    assert arp_req_rslt.got_err = '0' report "T9: should not have got err";
864
    wait for clk_period*10;
865
 
866
    report "T10: Request 192.168.5.7 again an expect it to be in the cache";
867
    arp_req_req.ip         <= x"c0a80507";
868
    arp_req_req.lookup_req <= '1';
869
    wait for clk_period;
870
    assert arp_req_rslt.got_mac = '1' report "T10: should have mac";
871
    assert arp_req_rslt.got_err = '0' report "T10: should not have got err";
872
 
873
    arp_req_req.lookup_req <= '0';
874
    wait for clk_period*20;
875
 
876
--
877
    wait until clk = '1';
878
    report "T11 - Send a request for the IP that is not on the local network";
879
    arp_req_req.ip         <= x"0a000003";  --c0a80501
880
    arp_req_req.lookup_req <= '1';
881
    wait until clk = '1';               --for clk_period
882
    arp_req_req.lookup_req <= '0';
883
    report "T11: wait for reply from store";
884
    wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1';
885
    assert arp_req_rslt.got_mac = '1' report "T11: expected got mac";
886
    assert arp_req_rslt.got_err = '0' report "T11: expected got err = 0";
887
    assert arp_req_rslt.mac = x"00231829267c" report "T11: wrong mac value";-- severity failure;
888
    wait for clk_period*2;
889
--
890
 
891
    report "T12: Clear the cache, Request 192.168.5.7 again an expect a 'who has' to be sent";
892
    control.clear_cache <= '1';
893
    wait for clk_period;
894
    control.clear_cache <= '0';
895
    wait for clk_period;
896
 
897
    arp_req_req.ip         <= x"c0a80507";
898
    arp_req_req.lookup_req <= '1';
899
    wait for clk_period;
900
    assert arp_req_rslt.got_mac = '0' report "T12: should not yet have mac";
901
    assert arp_req_rslt.got_err = '0' report "T12: should not have got err";
902
 
903
    arp_req_req.lookup_req <= '0';
904
    wait for clk_period*20;
905
 
906
 
907
    assert mac_tx_req = '1' report "T12: should be requesting TX channel";
908
    wait for clk_period*50;
909
    -- Send the reply
910
    data_out_ready <= '1';
911
 
912
    data_in_valid <= '1';
913
    -- dst MAC (bc)
914
    data_in       <= x"ff"; wait for clk_period;
915
    data_in       <= x"ff"; wait for clk_period;
916
    data_in       <= x"ff"; wait for clk_period;
917
    data_in       <= x"ff"; wait for clk_period;
918
    data_in       <= x"ff"; wait for clk_period;
919
    data_in       <= x"ff"; wait for clk_period;
920
    -- src MAC
921
    data_in       <= x"02"; wait for clk_period;
922
    data_in       <= x"15"; wait for clk_period;
923
    data_in       <= x"03"; wait for clk_period;
924
    data_in       <= x"23"; wait for clk_period;
925
    data_in       <= x"04"; wait for clk_period;
926
    data_in       <= x"54"; wait for clk_period;
927
    -- type
928
    data_in       <= x"08"; wait for clk_period;
929
    data_in       <= x"06"; wait for clk_period;
930
    -- HW type
931
    data_in       <= x"00"; wait for clk_period;
932
    data_in       <= x"01"; wait for clk_period;
933
    -- Protocol type
934
    data_in       <= x"08"; wait for clk_period;
935
    data_in       <= x"00"; wait for clk_period;
936
    -- HW size
937
    data_in       <= x"06"; wait for clk_period;
938
    -- protocol size
939
    data_in       <= x"04"; wait for clk_period;
940
    -- Opcode
941
    data_in       <= x"00"; wait for clk_period;
942
    data_in       <= x"02"; wait for clk_period;
943
    -- Sender MAC
944
    data_in       <= x"02"; wait for clk_period;
945
    data_in       <= x"15"; wait for clk_period;
946
    data_in       <= x"03"; wait for clk_period;
947
    data_in       <= x"23"; wait for clk_period;
948
    data_in       <= x"55"; wait for clk_period;
949
    data_in       <= x"54"; wait for clk_period;
950
    -- Sender IP
951
    data_in       <= x"c0"; wait for clk_period;
952
    data_in       <= x"a8"; wait for clk_period;
953
    data_in       <= x"05"; wait for clk_period;
954
    data_in       <= x"07"; wait for clk_period;
955
    -- Target MAC
956
    data_in       <= x"00"; wait for clk_period;
957
    data_in       <= x"23"; wait for clk_period;
958
    data_in       <= x"20"; wait for clk_period;
959
    data_in       <= x"21"; wait for clk_period;
960
    data_in       <= x"22"; wait for clk_period;
961
    data_in       <= x"23"; wait for clk_period;
962
    -- Target IP
963
    data_in       <= x"c0"; wait for clk_period;
964
    data_in       <= x"a8"; wait for clk_period;
965
    data_in       <= x"05"; wait for clk_period;
966
    data_in       <= x"09"; wait for clk_period;
967
    data_in       <= x"00"; wait for clk_period;
968
    data_in       <= x"00"; wait for clk_period;
969
    data_in       <= x"00"; wait for clk_period;
970
    data_in_last  <= '1';
971
    data_in       <= x"00"; wait for clk_period;
972
    data_in_last  <= '0';
973
    data_in_valid <= '0';
974
    wait for clk_period;
975
    assert arp_req_rslt.got_mac = '1' report "T12: should have got mac";
976
    assert arp_req_rslt.mac = x"021503235554" report "T12: incorrect mac";
977
    assert arp_req_rslt.got_err = '0' report "T12: should not have got err";
978
    wait for clk_period*10;
979
 
980
--    
981
    report "T13 - Send a request for the IP that is not on the local network";
982
    arp_req_req.ip         <= x"0a000003";
983
    arp_req_req.lookup_req <= '1';
984
    wait for clk_period;
985
    arp_req_req.lookup_req <= '0';
986
    report "T13: waiting for data_out_valid";
987
    wait until data_out_valid = '1';
988
    report "T13: got data_out_valid";
989
    wait for clk_period*10;
990
    data_out_ready         <= '0';
991
    wait for clk_period*2;
992
    data_out_ready         <= '1';
993
    wait for clk_period*12;
994
    assert data_out = x"01" report "T13: expected opcode = 01 for request 'who has'";
995
    -- expect our mac 00 23 20 21 22 23
996
    wait for clk_period;
997
    assert data_out = x"00" report "T13: incorrect our mac.0";
998
    wait for clk_period;
999
    assert data_out = x"23" report "T13: incorrect our mac.1";
1000
    wait for clk_period;
1001
    assert data_out = x"20" report "T13: incorrect our mac.2";
1002
    wait for clk_period;
1003
    assert data_out = x"21" report "T13: incorrect our mac.3";
1004
    wait for clk_period;
1005
    assert data_out = x"22" report "T13: incorrect our mac.4";
1006
    wait for clk_period;
1007
    assert data_out = x"23" report "T13: incorrect our mac.5";
1008
    -- expect our IP c0 a8 05 05
1009
    wait for clk_period;
1010
    assert data_out = x"c0" report "T13: incorrect our IP.0";
1011
    wait for clk_period;
1012
    assert data_out = x"a8" report "T13: incorrect our IP.1";
1013
    wait for clk_period;
1014
    assert data_out = x"05" report "T13: incorrect our IP.2";
1015
    wait for clk_period;
1016
    assert data_out = x"09" report "T13: incorrect our IP.3";
1017
 
1018
    -- expect empty target mac 
1019
    wait for clk_period;
1020
    assert data_out = x"ff" report "T13: incorrect target mac.0";
1021
    wait for clk_period;
1022
    assert data_out = x"ff" report "T13: incorrect target mac.1";
1023
    wait for clk_period;
1024
    assert data_out = x"ff" report "T13: incorrect target mac.2";
1025
    wait for clk_period;
1026
    assert data_out = x"ff" report "T13: incorrect target mac.3";
1027
    wait for clk_period;
1028
    assert data_out = x"ff" report "T13: incorrect target mac.4";
1029
    wait for clk_period;
1030
    assert data_out = x"ff" report "T13: incorrect target mac.5";
1031
    -- expect target IP c0 a8 05 01
1032
    wait for clk_period;
1033
    assert data_out = x"c0" report "T13: incorrect target IP.0";
1034
    wait for clk_period;
1035
    assert data_out = x"a8" report "T13: incorrect target IP.1";
1036
    wait for clk_period;
1037
    assert data_out = x"05" report "T13: incorrect target IP.2";
1038
    assert data_out_last = '0' report "T13: data out last incorrectly set on target IP.2 byte";
1039
    wait for clk_period;
1040
    assert data_out = x"01" report "T13: incorrect target IP.3";
1041
    assert data_out_last = '1' report "T13: data out last should be set";
1042
 
1043
    wait for clk_period*10;
1044
 
1045
    -- Send the reply
1046
    data_out_ready <= '1';
1047
 
1048
    report "T13.2: Send an ARP reply: 192.168.5.1 has mac 02:12:03:23:04:54";
1049
    data_in_valid <= '1';
1050
    -- dst MAC (bc)
1051
    data_in       <= x"ff"; wait for clk_period;
1052
    data_in       <= x"ff"; wait for clk_period;
1053
    data_in       <= x"ff"; wait for clk_period;
1054
    data_in       <= x"ff"; wait for clk_period;
1055
    data_in       <= x"ff"; wait for clk_period;
1056
    data_in       <= x"ff"; wait for clk_period;
1057
    -- src MAC
1058
    data_in       <= x"02"; wait for clk_period;
1059
    data_in       <= x"12"; wait for clk_period;
1060
    data_in       <= x"03"; wait for clk_period;
1061
    data_in       <= x"23"; wait for clk_period;
1062
    data_in       <= x"04"; wait for clk_period;
1063
    data_in       <= x"54"; wait for clk_period;
1064
    -- type
1065
    data_in       <= x"08"; wait for clk_period;
1066
    data_in       <= x"06"; wait for clk_period;
1067
    -- HW type
1068
    data_in       <= x"00"; wait for clk_period;
1069
    data_in       <= x"01"; wait for clk_period;
1070
    -- Protocol type
1071
    data_in       <= x"08"; wait for clk_period;
1072
    data_in       <= x"00"; wait for clk_period;
1073
    -- HW size
1074
    data_in       <= x"06"; wait for clk_period;
1075
    -- protocol size
1076
    data_in       <= x"04"; wait for clk_period;
1077
    -- Opcode
1078
    data_in       <= x"00"; wait for clk_period;
1079
    data_in       <= x"02"; wait for clk_period;
1080
    -- Sender MAC
1081
    data_in       <= x"02"; wait for clk_period;
1082
    data_in       <= x"12"; wait for clk_period;
1083
    data_in       <= x"03"; wait for clk_period;
1084
    data_in       <= x"23"; wait for clk_period;
1085
    data_in       <= x"04"; wait for clk_period;
1086
    data_in       <= x"54"; wait for clk_period;
1087
    -- Sender IP
1088
    data_in       <= x"c0"; wait for clk_period;
1089
    data_in       <= x"a8"; wait for clk_period;
1090
    data_in       <= x"05"; wait for clk_period;
1091
    data_in       <= x"01"; wait for clk_period;
1092
    -- Target MAC
1093
    data_in       <= x"00"; wait for clk_period;
1094
    data_in       <= x"23"; wait for clk_period;
1095
    data_in       <= x"20"; wait for clk_period;
1096
    data_in       <= x"21"; wait for clk_period;
1097
    data_in       <= x"22"; wait for clk_period;
1098
    data_in       <= x"23"; wait for clk_period;
1099
    -- Target IP
1100
    data_in       <= x"c0"; wait for clk_period;
1101
    data_in       <= x"a8"; wait for clk_period;
1102
    data_in       <= x"05"; wait for clk_period;
1103
    data_in       <= x"09"; wait for clk_period;
1104
    data_in       <= x"00"; wait for clk_period;
1105
    data_in       <= x"00"; wait for clk_period;
1106
    assert arp_req_rslt.got_mac = '1' report "T13.2: expected got mac";
1107
    assert arp_req_rslt.got_err = '0' report "T13.2: expected got err = 0";
1108
    assert arp_req_rslt.mac = x"021203230454" report "T13.2: wrong mac value";
1109
    data_in       <= x"00"; wait for clk_period;
1110
    data_in_last  <= '1';
1111
    data_in       <= x"00"; wait for clk_period;
1112
    data_in_last  <= '0';
1113
    data_in_valid <= '0';
1114
    wait for clk_period*4;
1115
 
1116
    report "T14 - Send a request for an other IP that is not on the local network";
1117
    arp_req_req.ip         <= x"0a000204";
1118
    arp_req_req.lookup_req <= '1';
1119
    wait for clk_period;
1120
    arp_req_req.lookup_req <= '0';
1121
    report "T14: reply should be from cache";
1122
--    wait until arp_req_rslt.got_mac = '1' or arp_req_rslt.got_err = '1';
1123
    assert arp_req_rslt.got_mac = '1' report "T14: expected got mac";
1124
    assert arp_req_rslt.got_err = '0' report "T14: expected got err = 0";
1125
    assert arp_req_rslt.mac = x"021203230454" report "T14: wrong mac value";
1126
    wait for clk_period*2;
1127
--    
1128
 
1129
 
1130
    report "--- end of tests ---";
1131
    wait;
1132
  end process;
1133
 
1134
end;

powered by: WebSVN 2.1.0

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