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

Subversion Repositories udp_ip_stack

[/] [udp_ip_stack/] [trunk/] [bench/] [vhdl/] [arp_STORE_tb.vhd] - Blame information for rev 26

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:   07:38:43 02/13/2012
6
-- Design Name:   
7
-- Module Name:   arp_STORE_tb.vhd
8
-- Project Name:  udp3
9
-- Target Device:  
10
-- Tool versions:  
11
-- Description:   
12
-- 
13
-- VHDL Test Bench Created by ISE for module: arp_STORE_br
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 ieee.std_logic_unsigned.all;
32
use work.arp_types.all;
33
 
34
ENTITY arp_STORE_tb IS
35
END arp_STORE_tb;
36
 
37
ARCHITECTURE behavior OF arp_STORE_tb IS
38
 
39
    -- Component Declaration for the Unit Under Test (UUT)
40
 
41
    COMPONENT arp_STORE_br
42
         generic (
43
                        MAX_ARP_ENTRIES : integer := 256                                                        -- max entries in the store
44
                        );
45
    PORT(
46
                        -- read signals
47
                        read_req                                : in arp_store_rdrequest_t;             -- requesting a '1' or store
48
                        read_result                     : out arp_store_result_t;                       -- the result
49
                        -- write signals
50
                        write_req                       : in arp_store_wrrequest_t;             -- requesting a '1' or store
51
                        -- control and status signals
52
                        clear_store                     : in std_logic;                                         -- erase all entries
53
                        entry_count                     : out unsigned(7 downto 0);              -- how many entries currently in store
54
                        -- system signals
55
                        clk                                     : in std_logic;
56
                        reset                           : in  STD_LOGIC
57
        );
58
    END COMPONENT;
59
 
60
 
61
   --Inputs
62
   signal read_req : arp_store_rdrequest_t;
63
   signal write_req : arp_store_wrrequest_t;
64
   signal clear_store : std_logic := '0';
65
   signal clk : std_logic := '0';
66
   signal reset : std_logic := '0';
67
 
68
        --Outputs
69
   signal read_result : arp_store_result_t;
70
        signal entry_count : unsigned(7 downto 0);               -- how many entries currently in store
71
 
72
   -- Clock period definitions
73
   constant clk_period : time := 8 ns;
74
 
75
BEGIN
76
 
77
        -- Instantiate the Unit Under Test (UUT)
78
   uut: arp_STORE_br
79
                        generic map (
80
                                MAX_ARP_ENTRIES => 4
81
                                )
82
                        PORT MAP (
83
          read_req => read_req,
84
          read_result => read_result,
85
          write_req => write_req,
86
                         clear_store => clear_store,
87
                         entry_count => entry_count,
88
          clk => clk,
89
          reset => reset
90
        );
91
 
92
   -- Clock process definitions
93
   clk_process :process
94
   begin
95
                clk <= '0';
96
                wait for clk_period/2;
97
                clk <= '1';
98
                wait for clk_period/2;
99
   end process;
100
 
101
 
102
   -- Stimulus process
103
   stim_proc: process
104
   begin
105
                read_req.req <= '0';
106
                read_req.ip <= (others => '0');
107
                write_req.req <= '0';
108
                write_req.entry.ip <= (others => '0');
109
                write_req.entry.mac <= (others => '0');
110
                reset <= '1';
111
      -- hold reset state
112
      wait for clk_period*10;
113
                reset <= '0';
114
 
115
      -- insert stimulus here 
116
                report "T1 - look for something when store is empty";
117
                read_req.ip <= x"12345678";
118
                read_req.req <= '1';
119
      wait for clk_period*4;
120
                assert read_result.status = NOT_FOUND           report "T1: expected NOT_FOUND";
121
                wait for clk_period;
122
                read_req.req <= '0';
123 18 pjf
                wait for clk_period*2;
124 10 pjf
                assert read_result.status = IDLE                report "T1: expected IDLE";
125
                assert entry_count = x"00"                              report "T1: wrong entry count";
126
 
127
                report "T2 - insert first entry into store";
128
                write_req.entry.ip <= x"12345678";
129
                write_req.entry.mac <= x"002398127645";
130
                write_req.req <= '1';
131
      wait for clk_period;
132
                write_req.req <= '0';
133
                wait until read_result.status = IDLE;
134
      wait for clk_period;
135
                assert entry_count = x"01"                              report "T2: wrong entry count";
136
 
137
                report "T3 - check if can find this single entry";
138
                read_req.ip <= x"12345678";
139
                read_req.req <= '1';
140
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
141
      wait for clk_period;
142
                assert read_result.status = FOUND                                               report "T3: expected FOUND";
143
                assert read_result.entry.ip = x"12345678"                               report "T3: wrong ip addr";
144
                assert read_result.entry.mac = x"002398127645"          report "T3: wrong mac addr";
145
                wait for clk_period;
146
                read_req.req <= '0';
147 18 pjf
                wait for clk_period*3;
148 10 pjf
                assert read_result.status = IDLE                report "T3: expected IDLE";
149
 
150
                report "T4 - check unable to find missing entry with one entry in store";
151
                read_req.ip <= x"12345679";
152
                read_req.req <= '1';
153
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
154
      wait for clk_period;
155
                assert read_result.status = NOT_FOUND           report "T4: expected NOT_FOUND";
156
                wait for clk_period;
157
                read_req.req <= '0';
158 18 pjf
                wait for clk_period*3;
159 10 pjf
                assert read_result.status = IDLE                report "T4: expected IDLE";
160
 
161
                report "T5 - insert 2nd entry into store and check can find both entries";
162
                write_req.entry.ip <= x"12345679";
163
                write_req.entry.mac <= x"101202303404";
164
                write_req.req <= '1';
165
      wait for clk_period;
166
                write_req.req <= '0';
167
                wait until read_result.status = IDLE;
168
      wait for clk_period;
169
                assert entry_count = x"02"                              report "T4: wrong entry count";
170
                read_req.ip <= x"12345678";
171
                read_req.req <= '1';
172
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
173
      wait for clk_period;
174
                assert read_result.status = FOUND                                               report "T5.1: expected FOUND";
175
                assert read_result.entry.ip = x"12345678"                               report "T5.1: wrong ip addr";
176
                assert read_result.entry.mac = x"002398127645"          report "T5.1: wrong mac addr";
177
                read_req.req <= '0';
178 18 pjf
                wait for clk_period*3;
179 10 pjf
                assert read_result.status = IDLE                report "T5.1: expected IDLE";
180
                read_req.ip <= x"12345679";
181
                read_req.req <= '1';
182
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
183
      wait for clk_period;
184
                assert read_result.status = FOUND                                               report "T5.2: expected FOUND";
185
                assert read_result.entry.ip = x"12345679"                               report "T5.2: wrong ip addr";
186
                assert read_result.entry.mac = x"101202303404"          report "T5.2: wrong mac addr";
187
                read_req.req <= '0';
188 18 pjf
                wait for clk_period*3;
189 10 pjf
                assert read_result.status = IDLE                report "T5.2: expected IDLE";
190
 
191
                report "T6 - insert 2 more entries so that the store is full. check can find all";
192
                write_req.entry.ip <= x"1234567a";
193
                write_req.entry.mac <= x"10120230340a";
194
                write_req.req <= '1';
195
      wait for clk_period;
196
                write_req.req <= '0';
197
                wait until read_result.status = IDLE;
198
      wait for clk_period;
199
                write_req.entry.ip <= x"1234567b";
200
                write_req.entry.mac <= x"10120230340b";
201
                write_req.req <= '1';
202
      wait for clk_period;
203
                write_req.req <= '0';
204
                wait until read_result.status = IDLE;
205
      wait for clk_period;
206
                assert entry_count = x"04"                              report "T6: wrong entry count";
207
                read_req.ip <= x"12345678";
208
                read_req.req <= '1';
209
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
210
      wait for clk_period;
211
                assert read_result.status = FOUND                                               report "T6.1: expected FOUND";
212
                assert read_result.entry.ip = x"12345678"                               report "T6.1: wrong ip addr";
213
                assert read_result.entry.mac = x"002398127645"          report "T6.1: wrong mac addr";
214
                read_req.req <= '0';
215 18 pjf
                wait for clk_period*3;
216 10 pjf
                assert read_result.status = IDLE                                                        report "T6.1: expected IDLE";
217
                read_req.ip <= x"12345679";
218
                read_req.req <= '1';
219
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
220
      wait for clk_period;
221
                assert read_result.status = FOUND                                               report "T6.2: expected FOUND";
222
                assert read_result.entry.ip = x"12345679"                               report "T6.2: wrong ip addr";
223
                assert read_result.entry.mac = x"101202303404"          report "T6.2: wrong mac addr";
224
                read_req.req <= '0';
225 18 pjf
                wait for clk_period*3;
226 10 pjf
                assert read_result.status = IDLE                                                        report "T6.2: expected IDLE";
227
                read_req.ip <= x"1234567a";
228
                read_req.req <= '1';
229
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
230
      wait for clk_period;
231
                assert read_result.status = FOUND                                               report "T6.3: expected FOUND";
232
                assert read_result.entry.ip = x"1234567a"                               report "T6.3: wrong ip addr";
233
                assert read_result.entry.mac = x"10120230340a"          report "T6.3: wrong mac addr";
234
                read_req.req <= '0';
235 18 pjf
                wait for clk_period*3;
236 10 pjf
                assert read_result.status = IDLE                                                        report "T6.3: expected IDLE";
237
                read_req.ip <= x"1234567b";
238
                read_req.req <= '1';
239
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
240
      wait for clk_period;
241
                assert read_result.status = FOUND                                               report "T6.4: expected FOUND";
242
                assert read_result.entry.ip = x"1234567b"                               report "T6.4: wrong ip addr";
243
                assert read_result.entry.mac = x"10120230340b"          report "T6.4: wrong mac addr";
244
                read_req.req <= '0';
245 18 pjf
                wait for clk_period*3;
246 10 pjf
                assert read_result.status = IDLE                                                        report "T6.4: expected IDLE";
247
 
248
                report "T7 - with store full, check that we dont find missing item";
249
                read_req.ip <= x"1233367b";
250
                read_req.req <= '1';
251
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
252
      wait for clk_period;
253
                assert read_result.status = NOT_FOUND                                   report "T7: expected NOT_FOUND";
254
                read_req.req <= '0';
255 18 pjf
                wait for clk_period*3;
256 10 pjf
                assert read_result.status = IDLE                                                        report "T7: expected IDLE";
257
 
258
                report "T8 - insert additional entry into store - will erase one of the others";
259
                write_req.entry.ip <= x"12345699";
260
                write_req.entry.mac <= x"992398127699";
261
                write_req.req <= '1';
262
      wait for clk_period;
263
                write_req.req <= '0';
264
                wait until read_result.status = IDLE;
265
      wait for clk_period;
266
                assert entry_count = x"04"                                                                      report "T8: wrong entry count";
267
                read_req.ip <= x"12345699";
268
                read_req.req <= '1';
269
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
270
      wait for clk_period;
271
                assert read_result.status = FOUND                                               report "T8: expected FOUND";
272
                assert read_result.entry.ip = x"12345699"                               report "T8: wrong ip addr";
273
                assert read_result.entry.mac = x"992398127699"          report "T8: wrong mac addr";
274
                read_req.req <= '0';
275 18 pjf
                wait for clk_period*3;
276 10 pjf
                assert read_result.status = IDLE                                                        report "T8: expected IDLE";
277
 
278
                report "T9 - clear the store and ensure cant find something that was there";
279
                clear_store <= '1';
280
      wait for clk_period;
281
                clear_store <= '0';
282
      wait for clk_period;
283
                assert entry_count = x"00"                                                                      report "T9: wrong entry count";
284
                read_req.ip <= x"12345699";
285
                read_req.req <= '1';
286
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
287
      wait for clk_period;
288
                assert read_result.status = NOT_FOUND                                   report "T9: expected NOT_FOUND";
289
                read_req.req <= '0';
290 18 pjf
                wait for clk_period*3;
291 10 pjf
                assert read_result.status = IDLE                                                        report "T9: expected IDLE";
292
 
293
                report "T10 - refill the store with three entries";
294
                write_req.entry.ip <= x"12345675";
295
                write_req.entry.mac <= x"10120230340a";
296
                write_req.req <= '1';
297
      wait for clk_period;
298
                write_req.req <= '0';
299
                wait until read_result.status = IDLE;
300
      wait for clk_period;
301
                write_req.entry.ip <= x"12345676";
302
                write_req.entry.mac <= x"10120230340b";
303
                write_req.req <= '1';
304
      wait for clk_period;
305
                write_req.req <= '0';
306
                wait until read_result.status = IDLE;
307
      wait for clk_period;
308
                write_req.entry.ip <= x"12345677";
309
                write_req.entry.mac <= x"10120230340c";
310
                write_req.req <= '1';
311
      wait for clk_period;
312
                write_req.req <= '0';
313
                wait until read_result.status = IDLE;
314
      wait for clk_period;
315
                assert entry_count = x"03"                                                                      report "T10: wrong entry count";
316
 
317
                report "T11 - check middle entry, then change it and check again";
318
                read_req.ip <= x"12345676";
319
                read_req.req <= '1';
320
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
321
      wait for clk_period;
322
                assert read_result.status = FOUND                                               report "T11.1: expected FOUND";
323
                assert read_result.entry.ip = x"12345676"                               report "T11.1: wrong ip addr";
324
                assert read_result.entry.mac = x"10120230340b"          report "T11.1: wrong mac addr";
325
                read_req.req <= '0';
326 18 pjf
                wait for clk_period*3;
327 10 pjf
                assert read_result.status = IDLE                                                        report "T11.1: expected IDLE";
328
                write_req.entry.ip <= x"12345676";
329
                write_req.entry.mac <= x"10120990340b";
330
                write_req.req <= '1';
331
      wait for clk_period;
332
                write_req.req <= '0';
333
      wait for clk_period;
334
                assert entry_count = x"03"                                                                      report "T11: wrong entry count";
335
                read_req.ip <= x"12345676";
336
                read_req.req <= '1';
337
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
338
      wait for clk_period;
339
                assert read_result.status = FOUND                                               report "T11.2: expected FOUND";
340
                assert read_result.entry.ip = x"12345676"                               report "T11.2: wrong ip addr";
341
                assert read_result.entry.mac = x"10120990340b"          report "T11.2: wrong mac addr";
342
                read_req.req <= '0';
343 18 pjf
                wait for clk_period*3;
344 10 pjf
                assert read_result.status = IDLE                                                        report "T11.2: expected IDLE";
345
 
346
                report "T12 - check 2nd write at beginning";
347
                -- clear store, write 1st entry, overwrite the entry, and check
348
                clear_store <= '1';
349
      wait for clk_period;
350
                clear_store <= '0';
351
      wait for clk_period;
352
                assert entry_count = x"00"                                                                      report "T12.1: wrong entry count";
353
                write_req.entry.ip <= x"12345678";
354
                write_req.entry.mac <= x"002398127645";
355
                write_req.req <= '1';
356
      wait for clk_period;
357
                write_req.req <= '0';
358
                wait until read_result.status = IDLE;
359
      wait for clk_period;
360
                assert entry_count = x"01"                                                                      report "T12.2: wrong entry count";
361
                write_req.entry.ip <= x"12345678";
362
                write_req.entry.mac <= x"002398127647";
363
                write_req.req <= '1';
364
      wait for clk_period;
365
                write_req.req <= '0';
366
                wait until read_result.status = IDLE;
367
      wait for clk_period;
368
                assert entry_count = x"01"                                                                      report "T12.3: wrong entry count";
369
                read_req.ip <= x"12345678";
370
                read_req.req <= '1';
371
      wait until read_result.status = FOUND or read_result.status = NOT_FOUND;
372
      wait for clk_period;
373
                assert read_result.status = FOUND                                               report "T12.4: expected FOUND";
374
                assert read_result.entry.ip = x"12345678"                               report "T12.4: wrong ip addr";
375
                assert read_result.entry.mac = x"002398127647"          report "T12.4: wrong mac addr";
376
                read_req.req <= '0';
377 18 pjf
                wait for clk_period*3;
378 10 pjf
                assert read_result.status = IDLE                                                        report "T12.5: expected IDLE";
379
 
380
                report "--- end of tests ---";
381
      wait;
382
   end process;
383
 
384
END;

powered by: WebSVN 2.1.0

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