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

Subversion Repositories udp_ip_stack

[/] [udp_ip_stack/] [trunk/] [contrib/] [from_tim/] [udp_ip_stack/] [tags/] [v1.0/] [bench/] [vhdl/] [arp_tb.vhd] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 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
-- Additional Comments:
20
--
21
-- Notes: 
22
-- This testbench has been automatically generated using types std_logic and
23
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends
24
-- that these types always be used for the top-level I/O of a design in order
25
-- to guarantee that the testbench will bind correctly to the post-implementation 
26
-- simulation model.
27
--------------------------------------------------------------------------------
28
LIBRARY ieee;
29
USE ieee.std_logic_1164.ALL;
30
USE ieee.numeric_std.ALL;
31
use work.arp_types.all;
32
 
33
ENTITY arp_tb IS
34
END arp_tb;
35
 
36
ARCHITECTURE behavior OF arp_tb IS
37
 
38
    -- Component Declaration for the Unit Under Test (UUT)
39
 
40
    COMPONENT arp
41
    PORT(
42
                        -- lookup request signals
43
                        arp_req_req                     : in arp_req_req_type;
44
                        arp_req_rslt            : out arp_req_rslt_type;
45
                        -- MAC layer RX signals
46
                        data_in_clk             : in  STD_LOGIC;
47
                        reset                           : in  STD_LOGIC;
48
                        data_in                                 : in  STD_LOGIC_VECTOR (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
49
                        data_in_valid           : in  STD_LOGIC;                                                                        -- indicates data_in valid on clock
50
                        data_in_last            : in  STD_LOGIC;                                                                        -- indicates last data in frame
51
                        -- MAC layer TX signals
52
                        mac_tx_req                      : out std_logic;                                                                        -- indicates that ip wants access to channel (stays up for as long as tx)
53
                        mac_tx_granted          : in std_logic;                                                                 -- indicates that access to channel has been granted            
54
                        data_out_clk            : in std_logic;
55
                        data_out_ready          : in std_logic;                                                                 -- indicates system ready to consume data
56
                        data_out_valid          : out std_logic;                                                                        -- indicates data out is valid
57
                        data_out_last           : out std_logic;                                                                        -- with data out valid indicates the last byte of a frame
58
                        data_out                                : out std_logic_vector (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
59
                        -- system signals
60
                        our_mac_address         : in STD_LOGIC_VECTOR (47 downto 0);
61
                        our_ip_address  : in STD_LOGIC_VECTOR (31 downto 0);
62
                        req_count                       : out STD_LOGIC_VECTOR(7 downto 0)                       -- count of arp pkts received
63
        );
64
    END COMPONENT;
65
 
66
 
67
   --Inputs
68
   signal clk                                   : std_logic := '0';
69
   signal reset                                 : std_logic := '0';
70
   signal data_in                       : std_logic_vector(7 downto 0) := (others => '0');
71
   signal data_in_valid         : std_logic := '0';
72
   signal data_in_last          : std_logic := '0';
73
   signal our_mac_address       : std_logic_vector(47 downto 0) := (others => '0');
74
   signal our_ip_address        : std_logic_vector(31 downto 0) := (others => '0');
75
        signal data_out_ready   : std_logic;
76
        signal data_out_valid   : std_logic;
77
        signal data_out_last            : std_logic;
78
        signal data_out                 : std_logic_vector (7 downto 0);
79
        signal req_count                        : STD_LOGIC_VECTOR(7 downto 0);
80
        signal arp_req_req              : arp_req_req_type;
81
        signal arp_req_rslt             : arp_req_rslt_type;
82
        signal mac_tx_req                       : std_logic;
83
        signal mac_tx_granted   : std_logic;
84
 
85
 
86
   -- Clock period definitions
87
   constant clk_period : time := 8 ns;
88
 
89
BEGIN
90
 
91
        -- Instantiate the Unit Under Test (UUT)
92
   uut: arp PORT MAP (
93
                        -- lookup request mappings
94
                         arp_req_req            => arp_req_req,
95
                         arp_req_rslt           => arp_req_rslt,
96
                        -- rx mappings
97
          data_in_clk           => clk,
98
          reset                                 => reset,
99
          data_in                       => data_in,
100
          data_in_valid         => data_in_valid,
101
          data_in_last          => data_in_last,
102
                         -- tx mappings
103
                         mac_tx_req                     => mac_tx_req,
104
                         mac_tx_granted => mac_tx_granted,
105
                         data_out_clk           => clk,
106
                         data_out_ready         => data_out_ready,
107
                         data_out_valid         => data_out_valid,
108
                         data_out_last          => data_out_last,
109
                         data_out                       => data_out,
110
                         -- system mappings
111
          our_mac_address       => our_mac_address,
112
          our_ip_address        => our_ip_address,
113
                         req_count                      => req_count
114
        );
115
 
116
   -- Clock process definitions
117
   clk_process :process
118
   begin
119
                clk <= '0';
120
                wait for clk_period/2;
121
                clk <= '1';
122
                wait for clk_period/2;
123
   end process;
124
 
125
 
126
   -- Stimulus process
127
   stim_proc: process
128
   begin
129
      -- hold reset state for 100 ns.
130
      wait for 100 ns;
131
 
132
                our_ip_address <= x"c0a80509";          -- 192.168.5.9
133
                our_mac_address <= x"002320212223";
134
                mac_tx_granted <= '1'; -- FIXME 0
135
 
136
                reset <= '1';
137
      wait for clk_period*10;
138
                reset <= '0';
139
      wait for clk_period*5;
140
 
141
                assert mac_tx_req = '0'                                  report "mac_tx_req asserted on reset";
142
 
143
      -- insert stimulus here
144
                arp_req_req.lookup_req <= '0';
145
                arp_req_req.ip <= (others => '0');
146
                data_out_ready <= '1';
147
 
148
                report "T1:  Send an ARP request: who has 192.168.5.8? Tell 192.168.5.1";
149
                data_in_valid <= '1';
150
                -- dst MAC (bc)
151
                data_in <= x"ff"; wait for clk_period;
152
                data_in <= x"ff"; wait for clk_period;
153
                data_in <= x"ff"; wait for clk_period;
154
                data_in <= x"ff"; wait for clk_period;
155
                data_in <= x"ff"; wait for clk_period;
156
                data_in <= x"ff"; wait for clk_period;
157
                -- src MAC
158
                data_in <= x"00"; wait for clk_period;
159
                data_in <= x"23"; wait for clk_period;
160
                data_in <= x"18"; wait for clk_period;
161
                data_in <= x"29"; wait for clk_period;
162
                data_in <= x"26"; wait for clk_period;
163
                data_in <= x"7c"; wait for clk_period;
164
                -- type
165
                data_in <= x"08"; wait for clk_period;
166
                data_in <= x"06"; wait for clk_period;
167
                -- HW type
168
                data_in <= x"00"; wait for clk_period;
169
                data_in <= x"01"; wait for clk_period;
170
                -- Protocol type
171
                data_in <= x"08"; wait for clk_period;
172
                data_in <= x"00"; wait for clk_period;
173
                -- HW size
174
                data_in <= x"06"; wait for clk_period;
175
                -- protocol size
176
                data_in <= x"04"; wait for clk_period;
177
                -- Opcode
178
                data_in <= x"00"; wait for clk_period;
179
                data_in <= x"01"; wait for clk_period;
180
                -- Sender MAC
181
                data_in <= x"00"; wait for clk_period;
182
                data_in <= x"23"; wait for clk_period;
183
                data_in <= x"18"; wait for clk_period;
184
                data_in <= x"29"; wait for clk_period;
185
                data_in <= x"26"; wait for clk_period;
186
                data_in <= x"7c"; wait for clk_period;
187
                -- Sender IP
188
                data_in <= x"c0"; wait for clk_period;
189
                data_in <= x"a8"; wait for clk_period;
190
                data_in <= x"05"; wait for clk_period;
191
                data_in <= x"01"; wait for clk_period;
192
                -- Target MAC
193
                data_in <= x"00"; wait for clk_period;
194
                data_in <= x"00"; wait for clk_period;
195
                data_in <= x"00"; wait for clk_period;
196
                data_in <= x"00"; wait for clk_period;
197
                data_in <= x"00"; wait for clk_period;
198
                data_in <= x"00"; wait for clk_period;
199
                -- Target IP
200
                data_in <= x"c0"; wait for clk_period;
201
                data_in <= x"a8"; wait for clk_period;
202
                data_in <= x"05"; wait for clk_period;
203
                data_in <= x"09"; wait for clk_period;
204
                data_in <= x"00"; wait for clk_period;
205
                data_in <= x"00"; wait for clk_period;
206
                data_in <= x"00"; wait for clk_period;
207
                data_in_last <= '1';
208
                data_in <= x"00"; wait for clk_period;
209
                data_in_last <= '0';
210
                data_in_valid <= '0';
211
 
212
                -- check tx arbitration signals
213
 
214
                assert mac_tx_req = '1'                                 report "T1: mac_tx_req not set";
215
 
216
                -- ready to tx
217
                data_out_ready <= '1';
218
                mac_tx_granted <= '1';
219
                wait for clk_period*10;
220
                data_out_ready <= '0';
221
                wait for clk_period*2;
222
                data_out_ready <= '1';
223
                wait for clk_period*50;
224
 
225
                report "T2: Send another ARP request: who has 192.168.5.8? Tell 192.168.5.1, holding off transmitter";
226
                data_out_ready <= '0';
227
                data_in_valid <= '1';
228
                -- dst MAC (bc)
229
                data_in <= x"ff"; wait for clk_period;
230
                data_in <= x"ff"; wait for clk_period;
231
                data_in <= x"ff"; wait for clk_period;
232
                data_in <= x"ff"; wait for clk_period;
233
                data_in <= x"ff"; wait for clk_period;
234
                data_in <= x"ff"; wait for clk_period;
235
                -- src MAC
236
                data_in <= x"00"; wait for clk_period;
237
                data_in <= x"23"; wait for clk_period;
238
                data_in <= x"18"; wait for clk_period;
239
                data_in <= x"29"; wait for clk_period;
240
                data_in <= x"26"; wait for clk_period;
241
                data_in <= x"7c"; wait for clk_period;
242
                -- type
243
                data_in <= x"08"; wait for clk_period;
244
                data_in <= x"06"; wait for clk_period;
245
                -- HW type
246
                data_in <= x"00"; wait for clk_period;
247
                data_in <= x"01"; wait for clk_period;
248
                -- Protocol type
249
                data_in <= x"08"; wait for clk_period;
250
                data_in <= x"00"; wait for clk_period;
251
                -- HW size
252
                data_in <= x"06"; wait for clk_period;
253
                -- protocol size
254
                data_in <= x"04"; wait for clk_period;
255
                -- Opcode
256
                data_in <= x"00"; wait for clk_period;
257
                data_in <= x"01"; wait for clk_period;
258
                -- Sender MAC
259
                data_in <= x"00"; wait for clk_period;
260
                data_in <= x"23"; wait for clk_period;
261
                data_in <= x"18"; wait for clk_period;
262
                data_in <= x"29"; wait for clk_period;
263
                data_in <= x"26"; wait for clk_period;
264
                data_in <= x"7c"; wait for clk_period;
265
                -- Sender IP
266
                data_in <= x"c0"; wait for clk_period;
267
                data_in <= x"a8"; wait for clk_period;
268
                data_in <= x"05"; wait for clk_period;
269
                data_in <= x"01"; wait for clk_period;
270
                -- Target MAC
271
                data_in <= x"00"; wait for clk_period;
272
                data_in <= x"00"; wait for clk_period;
273
                data_in <= x"00"; wait for clk_period;
274
                data_in <= x"00"; wait for clk_period;
275
                data_in <= x"00"; wait for clk_period;
276
                data_in <= x"00"; wait for clk_period;
277
                -- Target IP
278
                data_in <= x"c0"; wait for clk_period;
279
                data_in <= x"a8"; wait for clk_period;
280
                data_in <= x"05"; wait for clk_period;
281
                data_in <= x"09"; wait for clk_period;
282
                data_in <= x"00"; wait for clk_period;
283
                data_in <= x"00"; wait for clk_period;
284
                data_in <= x"00"; wait for clk_period;
285
                data_in_last <= '1';
286
                data_in <= x"00"; wait for clk_period;
287
                data_in_last <= '0';
288
                data_in_valid <= '0';
289
 
290
                -- ready to tx
291
                wait for clk_period*10;
292
                data_out_ready <= '1';
293
 
294
                wait for clk_period*50;
295
 
296
                -- Send a request for the IP that is already cached
297
                arp_req_req.ip <= x"c0a80501";
298
                arp_req_req.lookup_req <= '1';
299
                wait for clk_period;
300
                arp_req_req.lookup_req <= '0';
301
 
302
                wait for clk_period*50;
303
 
304
                -- Send a request for the IP that is not cached
305
                arp_req_req.ip <= x"c0a80503";
306
                arp_req_req.lookup_req <= '1';
307
                wait for clk_period;
308
                arp_req_req.lookup_req <= '0';
309
                wait for clk_period*80;
310
                -- Send the reply
311
                data_out_ready <= '1';
312
 
313
                report "T3: Send an ARP reply: 192.168.5.3 has mac 02:12:03:23:04:54";
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"02"; wait for clk_period;
324
                data_in <= x"12"; wait for clk_period;
325
                data_in <= x"03"; wait for clk_period;
326
                data_in <= x"23"; wait for clk_period;
327
                data_in <= x"04"; wait for clk_period;
328
                data_in <= x"54"; 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"02"; wait for clk_period;
345
                -- Sender MAC
346
                data_in <= x"02"; wait for clk_period;
347
                data_in <= x"12"; wait for clk_period;
348
                data_in <= x"03"; wait for clk_period;
349
                data_in <= x"23"; wait for clk_period;
350
                data_in <= x"04"; wait for clk_period;
351
                data_in <= x"54"; 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"03"; wait for clk_period;
357
                -- Target MAC
358
                data_in <= x"00"; wait for clk_period;
359
                data_in <= x"23"; wait for clk_period;
360
                data_in <= x"20"; wait for clk_period;
361
                data_in <= x"21"; wait for clk_period;
362
                data_in <= x"22"; wait for clk_period;
363
                data_in <= x"23"; 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
 
377
                report "--- end of tests ---";
378
      wait;
379
   end process;
380
 
381
END;

powered by: WebSVN 2.1.0

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