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

Subversion Repositories xge_mac

[/] [xge_mac/] [trunk/] [tbench/] [systemc/] [sc_testcases.cpp] - Blame information for rev 29

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 antanguay
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "sc_testcases.cpp"                                ////
4
////                                                              ////
5
////  This file is part of the "10GE MAC" project                 ////
6
////  http://www.opencores.org/cores/xge_mac/                     ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - A. Tanguay (antanguay@opencores.org)                  ////
10
////                                                              ////
11
//////////////////////////////////////////////////////////////////////
12
////                                                              ////
13
//// Copyright (C) 2008 AUTHORS. All rights reserved.             ////
14
////                                                              ////
15
//// This source file may be used and distributed without         ////
16
//// restriction provided that this copyright statement is not    ////
17
//// removed from the file and that any derivative work contains  ////
18
//// the original copyright notice and the associated disclaimer. ////
19
////                                                              ////
20
//// This source file is free software; you can redistribute it   ////
21
//// and/or modify it under the terms of the GNU Lesser General   ////
22
//// Public License as published by the Free Software Foundation; ////
23
//// either version 2.1 of the License, or (at your option) any   ////
24
//// later version.                                               ////
25
////                                                              ////
26
//// This source is distributed in the hope that it will be       ////
27
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
28
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
29
//// PURPOSE.  See the GNU Lesser General Public License for more ////
30
//// details.                                                     ////
31
////                                                              ////
32
//// You should have received a copy of the GNU Lesser General    ////
33
//// Public License along with this source; if not, download it   ////
34
//// from http://www.opencores.org/lgpl.shtml                     ////
35
////                                                              ////
36
//////////////////////////////////////////////////////////////////////
37
 
38
#include "sc_testcases.h"
39
 
40
 
41
void testcases::connect_testbench(testbench* tbptr) {
42
    tb = tbptr;
43
}
44
 
45
void testcases::run_tests(void) {
46
 
47
    //---
48
    // Init
49
 
50
    tb->pkt_if0.init();
51
    tb->xgm_if0.init();
52
    tb->cpu_if0.init();
53
    tb->pif_gen0.init();
54
    tb->xgm_gen0.init();
55
    tb->sb.init();
56
 
57
    wait(300, SC_NS);
58
 
59
    tb->cpu_if0.enable_all_interrupts();
60
 
61
 
62
 
63
 
64
//    done = true;
65
//    return;
66
    //---
67
    // Testcases
68
 
69 29 antanguay
    test_noise();
70
 
71
    test_packet_size(50, 90, 500);
72 2 antanguay
    test_packet_size(9000, 9020, 20);
73 21 antanguay
    test_packet_size(9599, 9601, 10);
74 2 antanguay
 
75
    test_deficit_idle_count();
76
 
77
    test_crc_errors(50, 90, 300, 2);
78
    test_crc_errors(9000, 9020, 20, 1);
79
 
80
    test_txdfifo_ovflow();
81
    test_rxdfifo_ovflow();
82
 
83
    test_rx_fragments(55, 90, 300, 2);
84 29 antanguay
    test_rx_lenght(20, 3);
85 2 antanguay
    test_rx_coding_err(400, 4);
86
 
87
    test_rx_local_fault(55, 90, 600, 15);
88
    test_rx_remote_fault(55, 90, 600, 15);
89
 
90
    test_rx_pause(64, 70, 600, 5);
91
 
92
    test_interrupt_mask();
93
 
94
    done = true;
95
 
96
}
97
 
98
 
99
void testcases::test_deficit_idle_count(void) {
100
 
101
    int range;
102
    int size;
103
 
104
    cout << "-----------------------" << endl;
105
    cout << "Deficit IDLE count" << endl;
106
    cout << "-----------------------" << endl;
107
 
108
    for (range = 0; range < 8; range++) {
109
        for (size = 60; size < 68; size++) {
110
            packet_dic(size, size + range);
111
        }
112
    }
113
 
114
}
115
 
116
 
117
void testcases::packet_dic(int minsize, int maxsize) {
118
 
119
    sbStats_t* pif_stats;
120
    sbStats_t* xgm_stats;
121
 
122
    int cnt = 6;
123
    float delta;
124
    float cycletime = 6.4;
125
    float rate;
126
 
127
    //---
128
    // Setup parameters
129
 
130
    tb->sb.clear_stats();
131
 
132
    tb->pif_gen0.set_pkt_size(minsize, maxsize);
133
    tb->xgm_gen0.set_pkt_size(minsize, maxsize);
134
 
135
    //---
136
    // Enable traffic
137
 
138
    tb->pif_gen0.set_tx_bucket(cnt);
139
    tb->xgm_gen0.set_tx_bucket(cnt);
140
 
141
    //---
142
    // Wait for test to complete
143
 
144
    while (tb->pif_gen0.get_tx_bucket() != 0) {
145
        wait(10, SC_NS);
146
    }
147
 
148
    //---
149
    // Check traffic
150
 
151
    wait(1000, SC_NS);
152
 
153
    pif_stats = tb->sb.get_pif_stats();
154
    xgm_stats = tb->sb.get_xgm_stats();
155
 
156
    if (pif_stats->rx_pkt_cnt != cnt || xgm_stats->rx_pkt_cnt != cnt) {
157
        cout << "ERROR: Not all packets received." << endl;
158
        sc_stop();
159
    }
160
 
161
}
162
 
163
 
164
void testcases::test_packet_size(int min, int max, int cnt) {
165
 
166
    sbStats_t* pif_stats;
167
    sbStats_t* xgm_stats;
168 29 antanguay
    rmonStats_t rmon_stats;
169 2 antanguay
 
170
    cout << "-----------------------" << endl;
171
    cout << "Packet size" << endl;
172
    cout << "-----------------------" << endl;
173
 
174
    //---
175
    // Setup parameters
176
 
177
    tb->sb.clear_stats();
178
 
179
    tb->pif_gen0.set_pkt_size(min, max);
180
    tb->xgm_gen0.set_pkt_size(min, max);
181
 
182
    //---
183
    // Enable traffic
184
 
185
    tb->pif_gen0.set_tx_bucket(cnt);
186
    tb->xgm_gen0.set_tx_bucket(cnt);
187
 
188
    //---
189
    // Wait for test to complete
190
 
191
    while (tb->pif_gen0.get_tx_bucket() != 0) {
192
        wait(10, SC_NS);
193
    }
194
 
195
    //---
196
    // Check traffic
197
 
198
    wait(30000, SC_NS);
199
 
200
    pif_stats = tb->sb.get_pif_stats();
201
    xgm_stats = tb->sb.get_xgm_stats();
202
 
203
    if (pif_stats->rx_pkt_cnt != cnt) {
204
        cout << "ERROR: Not all packets received by PIF." << endl;
205
        cout << pif_stats->rx_pkt_cnt << " " << cnt << endl;
206
        sc_stop();
207
    }
208
 
209
    if (xgm_stats->rx_pkt_cnt != cnt) {
210
        cout << "ERROR: Not all packets received by XGM." << endl;
211
        cout << xgm_stats->rx_pkt_cnt << " " << cnt << endl;
212
        sc_stop();
213
    }
214 29 antanguay
 
215
    //---
216
    // Check stats
217
 
218
    tb->cpu_if0.get_rmon_stats(&rmon_stats);
219
 
220
    if (rmon_stats.tx_pkt_cnt != cnt) {
221
        cout << "ERROR: Not all TX packets counted by MAC." << endl;
222
        cout << rmon_stats.tx_pkt_cnt << " " << cnt << endl;
223
        sc_stop();
224
    }
225
 
226
    if (rmon_stats.rx_pkt_cnt != cnt) {
227
        cout << "ERROR: Not all RX packets counted by MAC." << endl;
228
        cout << rmon_stats.rx_pkt_cnt << " " << cnt << endl;
229
        sc_stop();
230
    }
231
 
232
    if (rmon_stats.tx_octets_cnt != xgm_stats->rx_octets_cnt) {
233
        cout << "ERROR: Not all TX octets counted by MAC." << endl;
234
        cout << rmon_stats.tx_octets_cnt << " " << xgm_stats->rx_octets_cnt << endl;
235
        sc_stop();
236
    }
237
 
238
    if (rmon_stats.rx_octets_cnt != pif_stats->rx_octets_cnt) {
239
        cout << "ERROR: Not all RX octets counted by MAC." << endl;
240
        cout << rmon_stats.rx_octets_cnt << " " << pif_stats->rx_octets_cnt << endl;
241
        sc_stop();
242
    }
243 2 antanguay
}
244
 
245
void testcases::test_crc_errors(int min, int max, int cnt, int interval) {
246
 
247
    sbStats_t* pif_stats;
248
    sbCpuStats_t* cpu_stats;
249
 
250
    cout << "-----------------------" << endl;
251
    cout << "CRC errors" << endl;
252
    cout << "-----------------------" << endl;
253
 
254
    //---
255
    // Setup parameters
256
 
257
    tb->sb.clear_stats();
258
 
259
    tb->xgm_gen0.set_pkt_size(min, max);
260
    tb->xgm_gen0.set_crc_errors(interval);
261
    tb->sb.disable_signal_check = true;
262
 
263
    //---
264
    // Enable traffic
265
 
266
    tb->xgm_gen0.set_tx_bucket(cnt);
267
 
268
    //---
269
    // Wait for test to complete
270
 
271
    while (tb->xgm_gen0.get_tx_bucket() != 0) {
272
        wait(10, SC_NS);
273
    }
274
 
275
    //---
276
    // Check traffic
277
 
278
    wait(30000, SC_NS);
279
 
280
    pif_stats = tb->sb.get_pif_stats();
281
    cpu_stats = tb->sb.get_cpu_stats();
282
 
283
    if (pif_stats->rx_pkt_cnt != cnt) {
284
        cout << "ERROR: Not all packets received by PIF." << endl;
285
        cout << pif_stats->rx_pkt_cnt << " " << cnt << endl;
286
        sc_stop();
287
    }
288
 
289
    if (cpu_stats->crc_error_cnt != pif_stats->crc_error_cnt) {
290
        cout << "ERROR: Not all CRC errors reported to cpu" << endl;
291
        sc_stop();
292
    }
293
 
294
    //---
295
    // Return parameters to default state
296
 
297
    tb->xgm_gen0.set_crc_errors(0);
298
    tb->sb.disable_signal_check = false;
299
}
300
 
301
void testcases::test_txdfifo_ovflow() {
302
 
303
    sbStats_t* xgm_stats;
304
    sbCpuStats_t* cpu_stats;
305
 
306
    cout << "-----------------------" << endl;
307
    cout << "TXD FIFO overflow" << endl;
308
    cout << "-----------------------" << endl;
309
 
310
    //---
311
    // Setup parameters
312
 
313
    tb->sb.clear_stats();
314
 
315 25 antanguay
    tb->pif_gen0.set_pkt_size(500, 500);
316 17 antanguay
 
317 2 antanguay
    tb->cpu_if0.set_param(cpu_if::TX_ENABLE, 0);
318
    tb->sb.disable_signal_check = true;
319
 
320
    //---
321
    // Enable traffic
322
 
323
    tb->pif_gen0.set_tx_bucket(2);
324
 
325
    //---
326
    // Wait for packets to be sent
327
 
328
    while (tb->pif_gen0.get_tx_bucket() != 0) {
329
        wait(10, SC_NS);
330
    }
331
 
332
    wait(30000, SC_NS);
333
 
334
    //---
335
    // Check errors reported
336
 
337
    cpu_stats = tb->sb.get_cpu_stats();
338
    cout << "Count: " << cpu_stats->txd_fifo_ovflow_cnt << endl;
339
    sc_assert(cpu_stats->txd_fifo_ovflow_cnt == 1);
340
 
341
    //---
342
    // Flush out bad packets
343
 
344
    tb->xgm_if0.allow_idle_errors = true;
345
    tb->sb.disable_packet_check = true;
346
    tb->cpu_if0.set_param(cpu_if::TX_ENABLE, 1);
347
 
348
    wait(30000, SC_NS);
349
    tb->xgm_if0.allow_idle_errors = false;
350
    tb->sb.disable_packet_check = false;
351
 
352
    //---
353
    // Check errors reported
354
 
355
    cpu_stats = tb->sb.get_cpu_stats();
356 17 antanguay
 
357 2 antanguay
    //---
358
    // Enable traffic
359
 
360
    tb->pif_gen0.set_tx_bucket(2);
361
 
362
    //---
363
    // Wait for packets to be sent
364
 
365
    while (tb->pif_gen0.get_tx_bucket() != 0) {
366
        wait(10, SC_NS);
367
    }
368
 
369
    wait(30000, SC_NS);
370
 
371
    xgm_stats = tb->sb.get_xgm_stats();
372
    sc_assert(xgm_stats->rx_pkt_cnt == 4);
373
 
374
    //---
375
    // Return parameters to default state
376
 
377
    tb->cpu_if0.set_param(cpu_if::TX_ENABLE, 1);
378
    tb->sb.disable_signal_check = false;
379
}
380
 
381
void testcases::test_rxdfifo_ovflow() {
382
 
383
    sbStats_t* pif_stats;
384
    sbCpuStats_t* cpu_stats;
385
 
386
    cout << "-----------------------" << endl;
387
    cout << "RXD FIFO overflow" << endl;
388
    cout << "-----------------------" << endl;
389
 
390
    //---
391
    // Setup parameters
392
 
393
    tb->sb.clear_stats();
394
 
395 25 antanguay
    tb->xgm_gen0.set_pkt_size(500, 500);
396 17 antanguay
 
397 2 antanguay
    tb->pkt_if0.disable_rx = true;
398
    tb->pkt_if0.allow_rx_sop_err = true;
399
    tb->sb.disable_flags_check = true;
400
    tb->sb.disable_packet_check = true;
401
    tb->sb.disable_signal_check = true;
402
 
403
    //---
404
    // Enable traffic
405
 
406
    tb->xgm_gen0.set_tx_bucket(3);
407
 
408
    //---
409
    // Wait for packets to be sent
410
 
411
    while (tb->xgm_gen0.get_tx_bucket() != 0) {
412
        wait(10, SC_NS);
413
    }
414
 
415
    wait(30000, SC_NS);
416
 
417
    //---
418
    // Check errors reported
419
 
420
    cpu_stats = tb->sb.get_cpu_stats();
421
    sc_assert(cpu_stats->rxd_fifo_ovflow_cnt == 2);
422
 
423
    //---
424
    // Flush out bad packets
425
 
426
    tb->pkt_if0.disable_rx = false;
427
 
428
    wait(30000, SC_NS);
429
 
430
    //---
431
    // Check errors reported
432
 
433
    cpu_stats = tb->sb.get_cpu_stats();
434
    tb->sb.clear_stats();
435
    tb->sb.disable_flags_check = false;
436
    tb->sb.disable_packet_check = false;
437
 
438
    //---
439
    // Enable traffic
440
 
441
    tb->xgm_gen0.set_tx_bucket(2);
442
 
443
    //---
444
    // Wait for packets to be sent
445
 
446
    while (tb->xgm_gen0.get_tx_bucket() != 0) {
447
        wait(10, SC_NS);
448
    }
449
 
450
    wait(30000, SC_NS);
451
 
452
    pif_stats = tb->sb.get_pif_stats();
453
    sc_assert(pif_stats->rx_pkt_cnt == 2);
454
 
455
    //---
456
    // Return parameters to default state
457
 
458
    tb->pkt_if0.allow_rx_sop_err = false;
459
    tb->sb.disable_signal_check = false;
460
}
461
 
462
void testcases::test_rx_fragments(int min, int max, int cnt, int interval) {
463
 
464
    sbStats_t* pif_stats;
465
    sbCpuStats_t* cpu_stats;
466
 
467
    cout << "-----------------------" << endl;
468
    cout << "Fragments errors" << endl;
469
    cout << "-----------------------" << endl;
470
 
471
    //---
472
    // Setup parameters
473
 
474
    tb->sb.clear_stats();
475
 
476
    tb->xgm_gen0.set_pkt_size(min, max);
477
    tb->xgm_gen0.set_fragment_errors(interval);
478
    tb->sb.disable_signal_check = true;
479
 
480
    //---
481
    // Enable traffic
482
 
483
    tb->xgm_gen0.set_tx_bucket(cnt);
484
 
485
    //---
486
    // Wait for test to complete
487
 
488
    while (tb->xgm_gen0.get_tx_bucket() != 0) {
489
        wait(10, SC_NS);
490
    }
491
 
492
    //---
493
    // Check traffic
494
 
495
    wait(30000, SC_NS);
496
 
497
    pif_stats = tb->sb.get_pif_stats();
498
    cpu_stats = tb->sb.get_cpu_stats();
499
 
500
    if (pif_stats->rx_pkt_cnt != cnt) {
501
        cout << "ERROR: Not all packets received by PIF." << endl;
502
        cout << pif_stats->rx_pkt_cnt << " " << cnt << endl;
503
        sc_stop();
504
    }
505
 
506
    if ((cpu_stats->fragment_error_cnt + cpu_stats->crc_error_cnt)
507
                != pif_stats->fragment_error_cnt) {
508
        cout << "ERROR: Not all fragment errors reported to cpu" << endl;
509
        sc_stop();
510
    }
511
 
512
    //---
513
    // Return parameters to default state
514
 
515
    tb->xgm_gen0.set_fragment_errors(0);
516
    tb->sb.disable_signal_check = false;
517
}
518
 
519 29 antanguay
void testcases::test_rx_lenght(int cnt, int interval) {
520
 
521
    sbStats_t* pif_stats;
522
    sbCpuStats_t* cpu_stats;
523
 
524
    cout << "-----------------------" << endl;
525
    cout << "Lenght errors" << endl;
526
    cout << "-----------------------" << endl;
527
 
528
    //---
529
    // Setup parameters
530
 
531
    tb->sb.clear_stats();
532
 
533
    tb->xgm_gen0.set_pkt_size(16000-4, 16000-4);
534
    tb->xgm_gen0.set_lenght_errors(interval, 16000-3);
535
    tb->sb.disable_signal_check = true;
536
 
537
    //---
538
    // Enable traffic
539
 
540
    tb->xgm_gen0.set_tx_bucket(cnt);
541
 
542
    //---
543
    // Wait for test to complete
544
 
545
    while (tb->xgm_gen0.get_tx_bucket() != 0) {
546
        wait(10, SC_NS);
547
    }
548
 
549
    //---
550
    // Check traffic
551
 
552
    wait(60000, SC_NS);
553
 
554
    pif_stats = tb->sb.get_pif_stats();
555
    cpu_stats = tb->sb.get_cpu_stats();
556
 
557
    if (pif_stats->rx_pkt_cnt != cnt) {
558
        cout << "ERROR: Not all packets received by PIF." << endl;
559
        cout << pif_stats->rx_pkt_cnt << " " << cnt << endl;
560
        sc_stop();
561
    }
562
 
563
    if (cpu_stats->lenght_error_cnt + cpu_stats->crc_error_cnt
564
        != pif_stats->lenght_error_cnt) {
565
        cout << "ERROR: Not all lenght errors reported to cpu" << endl;
566
        cout << cpu_stats->lenght_error_cnt << endl;
567
        cout << pif_stats->lenght_error_cnt << endl;
568
        sc_stop();
569
    }
570
 
571
    //---
572
    // Return parameters to default state
573
 
574
    tb->sb.disable_signal_check = false;
575
    tb->xgm_gen0.set_lenght_errors(0, 16000-3);
576
}
577
 
578 2 antanguay
void testcases::test_rx_coding_err(int cnt, int interval) {
579
 
580
    sbStats_t* pif_stats;
581
    sbStats_t* xgm_stats;
582
    sbCpuStats_t* cpu_stats;
583
 
584
    cout << "-----------------------" << endl;
585
    cout << "Coding errors" << endl;
586
    cout << "-----------------------" << endl;
587
 
588
    //---
589
    // Setup parameters
590
 
591
    tb->sb.clear_stats();
592
 
593
    tb->xgm_gen0.set_pkt_size(64, 69);
594
    tb->xgm_gen0.set_coding_errors(interval);
595
    tb->sb.disable_signal_check = true;
596
 
597
    //---
598
    // Enable traffic
599
 
600
    tb->xgm_gen0.set_tx_bucket(cnt);
601
 
602
    //---
603
    // Wait for test to complete
604
 
605
    while (tb->xgm_gen0.get_tx_bucket() != 0) {
606
        wait(10, SC_NS);
607
    }
608
 
609
    //---
610
    // Check traffic
611
 
612
    wait(30000, SC_NS);
613
 
614
    pif_stats = tb->sb.get_pif_stats();
615
    xgm_stats = tb->sb.get_xgm_stats();
616
    cpu_stats = tb->sb.get_cpu_stats();
617
 
618
    if (pif_stats->rx_pkt_cnt != xgm_stats->tx_pkt_cnt) {
619
        cout << "ERROR: Not all packets received by PIF." << endl;
620
        cout << pif_stats->rx_pkt_cnt << " " << xgm_stats->tx_pkt_cnt << endl;
621
        sc_stop();
622
    }
623
 
624
    if (cpu_stats->crc_error_cnt != xgm_stats->crc_error_cnt) {
625
        cout << "ERROR: Not all coding errors reported to cpu" << endl;
626
        sc_stop();
627
    }
628
 
629
    //---
630
    // Return parameters to default state
631
 
632
    tb->xgm_gen0.set_coding_errors(0);
633
    tb->sb.disable_signal_check = false;
634
}
635
 
636
void testcases::test_rx_local_fault(int min, int max, int cnt, int interval) {
637
 
638
    sbStats_t* pif_stats;
639
 
640
    cout << "-----------------------" << endl;
641
    cout << "Local fault" << endl;
642
    cout << "-----------------------" << endl;
643
 
644
    //---
645
    // Setup parameters
646
 
647
    tb->sb.clear_stats();
648
 
649
    tb->pif_gen0.set_pkt_size(min, max);
650
    tb->xgm_gen0.set_pkt_size(min, max);
651
 
652
    tb->xgm_gen0.set_local_fault(interval);
653
    tb->sb.disable_signal_check = true;
654
    tb->xgm_if0.allow_idle_errors = true;
655
    tb->xgm_if0.disable_receive = true;
656
 
657
    //---
658
    // Enable traffic
659
 
660
    tb->pif_gen0.set_tx_bucket(cnt);
661
    tb->xgm_gen0.set_tx_bucket(cnt);
662
 
663
    //---
664
    // Wait for test to complete
665
 
666
    while (tb->xgm_gen0.get_tx_bucket() != 0) {
667
        wait(10, SC_NS);
668
    }
669
 
670
    //---
671
    // Check traffic
672
 
673
    wait(30000, SC_NS);
674
 
675
    pif_stats = tb->sb.get_pif_stats();
676
 
677
    if (pif_stats->rx_pkt_cnt != cnt) {
678
        cout << "ERROR: Not all packets received by PIF." << endl;
679
        cout << pif_stats->rx_pkt_cnt << " " << cnt << endl;
680
        sc_stop();
681
    }
682
 
683
    //---
684
    // Return parameters to default state
685
 
686
    tb->xgm_gen0.set_local_fault(0);
687
    tb->sb.disable_signal_check = false;
688
    tb->xgm_if0.allow_idle_errors = false;
689
    tb->xgm_if0.disable_receive = false;
690
}
691
 
692
void testcases::test_rx_remote_fault(int min, int max, int cnt, int interval) {
693
 
694
    sbStats_t* pif_stats;
695
 
696
    cout << "-----------------------" << endl;
697
    cout << "Remote fault" << endl;
698
    cout << "-----------------------" << endl;
699
 
700
    //---
701
    // Setup parameters
702
 
703
    tb->sb.clear_stats();
704
 
705
    tb->pif_gen0.set_pkt_size(min, max);
706
    tb->xgm_gen0.set_pkt_size(min, max);
707
 
708
    tb->xgm_gen0.set_remote_fault(interval);
709
    tb->sb.disable_signal_check = true;
710
    tb->xgm_if0.allow_idle_errors = true;
711
    tb->xgm_if0.disable_receive = true;
712
 
713
    //---
714
    // Enable traffic
715
 
716
    tb->pif_gen0.set_tx_bucket(cnt);
717
    tb->xgm_gen0.set_tx_bucket(cnt);
718
 
719
    //---
720
    // Wait for test to complete
721
 
722
    while (tb->xgm_gen0.get_tx_bucket() != 0) {
723
        wait(10, SC_NS);
724
    }
725
 
726
    //---
727
    // Check traffic
728
 
729
    wait(30000, SC_NS);
730
 
731
    pif_stats = tb->sb.get_pif_stats();
732
 
733
    if (pif_stats->rx_pkt_cnt != cnt) {
734
        cout << "ERROR: Not all packets received by PIF." << endl;
735
        cout << pif_stats->rx_pkt_cnt << " " << cnt << endl;
736
        sc_stop();
737
    }
738
 
739
    //---
740
    // Return parameters to default state
741
 
742
    tb->xgm_gen0.set_remote_fault(0);
743
    tb->sb.disable_signal_check = false;
744
    tb->xgm_if0.allow_idle_errors = false;
745
    tb->xgm_if0.disable_receive = false;
746
}
747
 
748
void testcases::test_rx_pause(int min, int max, int cnt, int interval) {
749
 
750
    sbCpuStats_t* cpu_stats;
751
 
752
    cout << "-----------------------" << endl;
753
    cout << "Receive Pause" << endl;
754
    cout << "-----------------------" << endl;
755
 
756
    //---
757
    // Setup parameters
758
 
759
    tb->sb.clear_stats();
760
 
761
    tb->xgm_gen0.set_pkt_size(min, max);
762
 
763
    tb->xgm_gen0.set_inject_pause(interval);
764
    tb->sb.disable_signal_check = true;
765
 
766
    //---
767
    // Enable traffic
768
 
769
    tb->xgm_gen0.set_tx_bucket(cnt);
770
 
771
    //---
772
    // Wait for test to complete
773
 
774
    while (tb->xgm_gen0.get_tx_bucket() != 0) {
775
        wait(10, SC_NS);
776
    }
777
 
778
    //---
779
    // Check traffic
780
 
781
    wait(30000, SC_NS);
782
 
783
    cpu_stats = tb->sb.get_cpu_stats();
784
 
785
    if (cpu_stats->rx_pause_frame_cnt == 0) {
786
        cout << "ERROR: No pause frames received." << endl;
787
        sc_stop();
788
    }
789
 
790
    //---
791
    // Return parameters to default state
792
 
793
    tb->xgm_gen0.set_inject_pause(0);
794
    tb->sb.disable_signal_check = false;
795
}
796
 
797
void testcases::test_interrupt_mask() {
798
 
799
    sbCpuStats_t* cpu_stats;
800
 
801
    cout << "-----------------------" << endl;
802
    cout << "Interrupt Mask" << endl;
803
    cout << "-----------------------" << endl;
804
 
805
    //---
806
    // Setup parameters
807
 
808
    tb->sb.clear_stats();
809
    tb->sb.disable_signal_check = true;
810
 
811
 
812
    //---
813
    // Test unmasked
814
 
815
    tb->cpu_if0.set_interrupt(cpu_if::INT_CRC_ERROR);
816
 
817
    wait(300, SC_NS);
818
 
819
    cpu_stats = tb->sb.get_cpu_stats();
820
    sc_assert(cpu_stats->crc_error_cnt == 1);
821
 
822
 
823
    //---
824
    // Test masked
825
 
826
    tb->cpu_if0.set_interrupt_mask(cpu_if::INT_CRC_ERROR, 0);
827
    tb->cpu_if0.set_interrupt(cpu_if::INT_CRC_ERROR);
828
 
829
    wait(300, SC_NS);
830
 
831
    cpu_stats = tb->sb.get_cpu_stats();
832
    sc_assert(cpu_stats->crc_error_cnt == 1);
833
 
834
 
835
    //---
836
    // Return parameters to default state
837 17 antanguay
 
838 2 antanguay
    tb->sb.disable_signal_check = false;
839
    tb->cpu_if0.set_interrupt_mask(cpu_if::INT_CRC_ERROR, 1);
840
}
841 29 antanguay
 
842
void testcases::test_noise() {
843
 
844
    cout << "-----------------------" << endl;
845
    cout << "XGMII Noise" << endl;
846
    cout << "-----------------------" << endl;
847
 
848
    //---
849
    // Setup parameters
850
 
851
    tb->sb.disable_signal_check = true;
852
    tb->pkt_if0.flush_rx = true;
853
 
854
    //---
855
    // Inject noise
856
 
857
    tb->xgm_if0.inject_noise = true;
858
 
859
    while (tb->xgm_if0.inject_noise) {
860
        wait(100, SC_NS);
861
    }
862
 
863
    wait(30000, SC_NS);
864
 
865
    //---
866
    // Return parameters to default state
867
 
868
    tb->sb.disable_signal_check = true;
869
    tb->pkt_if0.flush_rx = false;
870
 
871
    wait(30000, SC_NS);
872
}

powered by: WebSVN 2.1.0

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