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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [test/] [uart_test.svh] - Blame information for rev 13

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

Line No. Rev Author Line
1 3 HanySalah
//-------------------------------------------------------------------------------------------------
2 2 HanySalah
//
3
//                             UART2BUS VERIFICATION
4
//
5 3 HanySalah
//-------------------------------------------------------------------------------------------------
6 2 HanySalah
// CREATOR    : HANY SALAH
7
// PROJECT    : UART2BUS UVM TEST BENCH
8
// UNIT       : TEST
9 3 HanySalah
//-------------------------------------------------------------------------------------------------
10 2 HanySalah
// TITLE      : UART TEST
11 3 HanySalah
// DESCRIPTION: THIS COMPONENT INCLUDES THE MAIN TESTS THAT WILL BE FORCED TO THE DUT. IT INCLUDES
12
//              VIRTUAL BASE TEST FUNCTION THAT SHARES THE MOST COMMON ATTRIBUTES OF ALL TESTS.
13
//              THE TESTS IMPLEMENTED THROUGH BELOW ARE RELATED TO THE TESTBENCH SPECIFICATIONS
14
//              DOCUMENT. YOU CAN DOWNLOAD IT DIRECTLY THROUGH OPENCORES.COM OR FIND IT IN THE DOC
15
//              DIRECTORY.
16
//-------------------------------------------------------------------------------------------------
17 2 HanySalah
// LOG DETAILS
18
//-------------
19
// VERSION      NAME        DATE        DESCRIPTION
20
//    1       HANY SALAH    10012016    FILE CREATION
21 3 HanySalah
//    2       HANY SALAH    20012016    ADD BINARY MODE TESTS AND INVALID TESTS
22
//    3       HANY SALAH    12022016    IMPROVE BLOCK DESCRIPTION & ADD COMMENTS
23
//-------------------------------------------------------------------------------------------------
24
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR OPENCORES MEMBERS
25
// ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE CREATOR'S PERMISSION
26
//-------------------------------------------------------------------------------------------------
27
 
28
//  The base test class that includes the uvm printer and establish the whole environment.
29
//  It also responsible for setting the environment configurations described in details through the
30
//  testbench specifications document.
31
//  The environment configurations are set during the end of elaboration phase. It includes:
32
//    ----------------------------------------------------------------------------------------
33
//  - The active edge   : The active clock edge at which, the data is changed on the UART buses.
34
//                        It could be positive edge or negative edge.
35
//    ----------------------------------------------------------------------------------------
36
//  - The start bit     : Represent the sequence through which the byte is serialized; either to
37
//                        start with the most significant bit or the least significant bit.
38
//    ----------------------------------------------------------------------------------------
39
//  - The data format   : The data representation through the text commands either to be ASCII
40
//                        format or ordinary binary format.
41
//    ----------------------------------------------------------------------------------------
42
//  - The number of stop: The number of stop bits sent after the latest bit of each byte. It
43
//    bit(s)              would be either one or two bits
44
//    ----------------------------------------------------------------------------------------
45
//  - The number of bits: The number of bits within each transferred field. It would be either
46
//    in the field        7 or 8 bits per field.
47
//    ----------------------------------------------------------------------------------------
48
//  - The parity mode   : The used parity type of each field. It would be either no parity bit,
49
//                        odd parity or even parity.
50
//    ----------------------------------------------------------------------------------------
51
//  - The response time : Represent the maximum allowable time within which DUT should respond
52
//                        to the driven request.
53
//    ----------------------------------------------------------------------------------------
54
//  - The false data    : Enable force false data on the output port within the read command
55
//    enable              through the both modes; text or binary.
56
//    ----------------------------------------------------------------------------------------
57
virtual class uart_base_test extends uvm_test;
58
 
59 2 HanySalah
  uart_env          env;
60
 
61
  uvm_table_printer printer;
62
 
63
  uart_config       _config;
64
 
65 9 HanySalah
  int               matched ;
66 10 HanySalah
 
67
  uvm_report_server    report_server;
68 9 HanySalah
 
69
  `uvm_component_utils_begin(uart_base_test)
70
     `uvm_field_int(matched,UVM_ALL_ON)
71
  `uvm_component_utils_end
72 2 HanySalah
 
73
  function new (string name,uvm_component parent);
74
    super.new(name,parent);
75
  endfunction:new
76
 
77
  function void build_phase (uvm_phase phase);
78
    super.build_phase(phase);
79
 
80
    env = uart_env::type_id::create("env",this);
81
 
82
    _config = uart_config::type_id::create("_config",this);
83 9 HanySalah
 
84 2 HanySalah
    printer = new();
85 10 HanySalah
    report_server = new();
86 8 HanySalah
    env_configuration();
87 10 HanySalah
    TE_configuration();
88 13 HanySalah
    uvm_config_db#(uart_config)::set(this,"*","UART_CONFIGURATION",_config);
89
    uvm_resource_db #(int)::set("coverage_cloud","text_coverage",0,null);
90 2 HanySalah
  endfunction:build_phase
91
 
92
  function void connect_phase (uvm_phase phase);
93
    super.connect_phase(phase);
94
  endfunction:connect_phase
95
 
96 8 HanySalah
  function void env_configuration ();
97 2 HanySalah
    _config._edge         = pos_edge;
98
    _config._start        = lsb;
99
    _config._datamode     = ascii;
100
    _config.num_stop_bits = 1;
101
    _config.num_of_bits   = 8;
102
    _config._paritymode   = parity_off;
103 3 HanySalah
    _config.response_time = 8680;
104
    _config.use_false_data= no;
105 8 HanySalah
  endfunction:env_configuration
106 2 HanySalah
 
107 10 HanySalah
 function void TE_configuration();
108
    report_server.set_server(report_server);
109
    printer.knobs.depth = 3;
110
    uvm_resource_db#(int)::set("Reporting","matched_packets",0,null);
111
    uvm_root::get().set_timeout(10s);
112 13 HanySalah
    //uvm_root::get().finish_on_completion=1'b0;
113 10 HanySalah
 endfunction // TE_configuration
114
 
115 2 HanySalah
  task run_phase (uvm_phase phase);
116
    phase.phase_done.set_drain_time(this,5000);
117
  endtask:run_phase
118 9 HanySalah
 
119
  function void report_phase (uvm_phase phase);
120 10 HanySalah
     int num_errors;
121
     string status;
122
     num_errors = report_server.get_severity_count(UVM_ERROR);
123 9 HanySalah
     uvm_resource_db#(int)::read_by_name("Reporting","matched_packets",matched);
124 10 HanySalah
     if(num_errors == 0) status =  "PASSED";
125
     else status = "FAILED";
126
     $display("--------------------------------------------------\n");
127
     $display("\t\t SIMULATION %s \n",status);
128
     $display("--------------------------------------------------");
129 9 HanySalah
     `uvm_info("FINAL STATUS",$sformatf("The number of matched packets are %0d",matched),UVM_NONE);
130
  endfunction // report_phase
131 11 HanySalah
 
132 2 HanySalah
endclass:uart_base_test
133
 
134 3 HanySalah
//-------------------------------------------------------------------------------------------------
135
//
136
//                          PURE TEXT MODE TESTS
137
//
138
//-------------------------------------------------------------------------------------------------
139 2 HanySalah
 
140 3 HanySalah
  //  This test apply thirteen successive tests of UART write request using text communication mode.
141
  //  Refer to test plan section in the testbench specifications document for more details.
142
  class write_text_mode extends uart_base_test;
143
 
144
    seq_1p1   seq1;
145
    seq_1p2   seq2;
146
    seq_1p3   seq3;
147
    seq_1p4   seq4;
148
    seq_1p5   seq5;
149
    seq_1p6   seq6;
150
    seq_1p7   seq7;
151
    seq_1p8   seq8;
152
    seq_1p9   seq9;
153
    seq_1p10  seq10;
154
    seq_1p11  seq11;
155
    seq_1p12  seq12;
156
    seq_1p13  seq13;
157 2 HanySalah
 
158 3 HanySalah
    `uvm_component_utils(write_text_mode)
159 2 HanySalah
 
160 3 HanySalah
    function new (string name,uvm_component parent);
161
      super.new(name,parent);
162
    endfunction:new
163 2 HanySalah
 
164 3 HanySalah
    function void build_phase (uvm_phase phase);
165
      super.build_phase (phase);
166
      seq1  = seq_1p1::type_id::create("seq1");
167
      seq2  = seq_1p2::type_id::create("seq2");
168
      seq3  = seq_1p3::type_id::create("seq3");
169
      seq4  = seq_1p4::type_id::create("seq4");
170
      seq5  = seq_1p5::type_id::create("seq5");
171
      seq6  = seq_1p6::type_id::create("seq6");
172
      seq7  = seq_1p7::type_id::create("seq7");
173
      seq8  = seq_1p8::type_id::create("seq8");
174
      seq9  = seq_1p9::type_id::create("seq9");
175
      seq10 = seq_1p10::type_id::create("seq10");
176
      seq11 = seq_1p11::type_id::create("seq11");
177
      seq12 = seq_1p12::type_id::create("seq12");
178
      seq13 = seq_1p13::type_id::create("seq13");
179
    endfunction:build_phase
180 2 HanySalah
 
181
 
182 3 HanySalah
    task run_phase (uvm_phase phase);
183
      super.run_phase(phase);
184
      phase.raise_objection(this);
185
      seq1.start(env.agent._seq,null);
186
      seq2.start(env.agent._seq,null);
187
      seq3.start(env.agent._seq,null);
188
      seq4.start(env.agent._seq,null);
189
      seq5.start(env.agent._seq,null);
190
      seq6.start(env.agent._seq,null);
191
      seq7.start(env.agent._seq,null);
192
      seq8.start(env.agent._seq,null);
193
      seq9.start(env.agent._seq,null);
194
      seq10.start(env.agent._seq,null);
195
      seq11.start(env.agent._seq,null);
196
      seq12.start(env.agent._seq,null);
197
      seq13.start(env.agent._seq,null);
198
      phase.drop_objection(this);
199
    endtask:run_phase
200
  endclass:write_text_mode
201 2 HanySalah
 
202 3 HanySalah
  //  This test apply thirteen successive tests of UART read request using text communication mode.
203
  //  Refer to test plan section in the testbench specifications document for more details.
204
  class read_text_mode extends uart_base_test;
205
 
206
    seq_2p1   seq1;
207
    seq_2p2   seq2;
208
    seq_2p3   seq3;
209
    seq_2p4   seq4;
210
    seq_2p5   seq5;
211
    seq_2p6   seq6;
212
    seq_2p7   seq7;
213
    seq_2p8   seq8;
214
    seq_2p9   seq9;
215
    seq_2p10  seq10;
216
    seq_2p11  seq11;
217
    seq_2p12  seq12;
218
    seq_2p13  seq13;
219 2 HanySalah
 
220
 
221 3 HanySalah
    `uvm_component_utils(read_text_mode)
222 2 HanySalah
 
223 3 HanySalah
    function new (string name,uvm_component parent);
224
      super.new(name,parent);
225
    endfunction:new
226 2 HanySalah
 
227 3 HanySalah
    function void build_phase (uvm_phase phase);
228
      super.build_phase(phase);
229
      seq1  = seq_2p1::type_id::create("seq1");
230
      seq2  = seq_2p2::type_id::create("seq2");
231
      seq3  = seq_2p3::type_id::create("seq3");
232
      seq4  = seq_2p4::type_id::create("seq4");
233
      seq5  = seq_2p5::type_id::create("seq5");
234
      seq6  = seq_2p6::type_id::create("seq6");
235
      seq7  = seq_2p7::type_id::create("seq7");
236
      seq8  = seq_2p8::type_id::create("seq8");
237
      seq9  = seq_2p9::type_id::create("seq9");
238
      seq10 = seq_2p10::type_id::create("seq10");
239
      seq11 = seq_2p11::type_id::create("seq11");
240
      seq12 = seq_2p12::type_id::create("seq12");
241
      seq13 = seq_2p13::type_id::create("seq13");
242
    endfunction:build_phase
243 2 HanySalah
 
244 3 HanySalah
    task run_phase (uvm_phase phase);
245
      super.run_phase(phase);
246
      phase.raise_objection(this);
247
      seq1.start(env.agent._seq,null);
248
      seq2.start(env.agent._seq,null);
249
      seq3.start(env.agent._seq,null);
250
      seq4.start(env.agent._seq,null);
251
      seq5.start(env.agent._seq,null);
252
      seq6.start(env.agent._seq,null);
253
      seq7.start(env.agent._seq,null);
254
      seq8.start(env.agent._seq,null);
255
      seq9.start(env.agent._seq,null);
256
      seq10.start(env.agent._seq,null);
257
      seq11.start(env.agent._seq,null);
258
      seq12.start(env.agent._seq,null);
259
      seq13.start(env.agent._seq,null);
260
      phase.drop_objection(this);
261
    endtask:run_phase
262
  endclass:read_text_mode
263 2 HanySalah
 
264 3 HanySalah
//-------------------------------------------------------------------------------------------------
265
//
266
//                          PURE BINARY MODE TESTS
267
//
268
//-------------------------------------------------------------------------------------------------
269 2 HanySalah
 
270 3 HanySalah
  //  This test apply six successive tests of UART nop request using binary communication mode.
271
  //  Refer to test plan section in the testbench specifications document for more details.
272
  class nop_command_mode extends uart_base_test;
273
 
274
    seq_3p1   seq1;
275
    seq_3p2   seq2;
276
    seq_3p3   seq3;
277
    seq_4p1   seq4;
278
    seq_4p2   seq5;
279
    seq_4p3   seq6;
280 2 HanySalah
 
281 3 HanySalah
    `uvm_component_utils(nop_command_mode)
282 2 HanySalah
 
283 3 HanySalah
    function new (string name,uvm_component parent);
284
      super.new(name,parent);
285
    endfunction:new
286 2 HanySalah
 
287 3 HanySalah
    function void build_phase (uvm_phase phase);
288
      super.build_phase(phase);
289
      seq1  = seq_3p1::type_id::create("seq1");
290
      seq2  = seq_3p2::type_id::create("seq2");
291
      seq3  = seq_3p3::type_id::create("seq3");
292
      seq4  = seq_4p1::type_id::create("seq4");
293
      seq5  = seq_4p2::type_id::create("seq5");
294
      seq6  = seq_4p3::type_id::create("seq6");
295
    endfunction:build_phase
296 2 HanySalah
 
297 3 HanySalah
    task run_phase(uvm_phase phase);
298
      super.run_phase(phase);
299
      phase.raise_objection(this);
300
      seq1.start(env.agent._seq,null);
301
      seq2.start(env.agent._seq,null);
302
      seq3.start(env.agent._seq,null);
303
      seq4.start(env.agent._seq,null);
304
      seq5.start(env.agent._seq,null);
305
      seq6.start(env.agent._seq,null);
306
      phase.drop_objection(this);
307
    endtask:run_phase
308
  endclass:nop_command_mode
309 2 HanySalah
 
310
 
311 3 HanySalah
  //  This test apply ten successive tests of UART write request using binary communication mode.
312
  //  Refer to test plan section in the testbench specifications document for more details.
313
  class write_command_mode extends uart_base_test;
314
 
315
    seq_5p1   seq1;
316
    seq_5p2   seq2;
317
    seq_5p3   seq3;
318
    seq_5p4   seq4;
319
    seq_5p5   seq5;
320
    seq_5p6   seq6;
321
    seq_5p7   seq7;
322
    seq_5p8   seq8;
323
    seq_5p9   seq9;
324
    seq_5p10  seq10;
325 2 HanySalah
 
326 3 HanySalah
    `uvm_component_utils(write_command_mode)
327 2 HanySalah
 
328 3 HanySalah
    function new (string name,uvm_component parent);
329
      super.new(name,parent);
330
    endfunction:new
331 2 HanySalah
 
332 3 HanySalah
    function void build_phase (uvm_phase phase);
333
      super.build_phase(phase);
334
      seq1  = seq_5p1::type_id::create("seq1");
335
      seq2  = seq_5p2::type_id::create("seq2");
336
      seq3  = seq_5p3::type_id::create("seq3");
337
      seq4  = seq_5p4::type_id::create("seq4");
338
      seq5  = seq_5p5::type_id::create("seq5");
339
      seq6  = seq_5p6::type_id::create("seq6");
340
      seq7  = seq_5p7::type_id::create("seq7");
341
      seq8  = seq_5p8::type_id::create("seq8");
342
      seq9  = seq_5p9::type_id::create("seq9");
343
      seq10 = seq_5p10::type_id::create("seq10");
344
    endfunction:build_phase
345 2 HanySalah
 
346 3 HanySalah
    task run_phase (uvm_phase phase);
347
      super.run_phase(phase);
348
      phase.raise_objection(this);
349
      uvm_test_done.set_drain_time(this,5000);
350
      //seq1.start(env.agent._seq,null);
351
      seq2.start(env.agent._seq,null);
352
      seq3.start(env.agent._seq,null);
353
      seq4.start(env.agent._seq,null);
354
      seq5.start(env.agent._seq,null);
355
      seq6.start(env.agent._seq,null);
356
      seq7.start(env.agent._seq,null);
357
      seq8.start(env.agent._seq,null);
358
      seq9.start(env.agent._seq,null);
359
      seq10.start(env.agent._seq,null);
360
      phase.drop_objection(this);
361
    endtask:run_phase
362
  endclass: write_command_mode
363 2 HanySalah
 
364
 
365 3 HanySalah
  //  This test apply ten successive tests of UART read request using binary communication mode.
366
  //  Refer to test plan section in the testbench specifications document for more details.
367
  class read_command_mode extends uart_base_test;
368
 
369
    seq_6p1   seq1;
370
    seq_6p2   seq2;
371
    seq_6p3   seq3;
372
    seq_6p4   seq4;
373
    seq_6p5   seq5;
374
    seq_6p6   seq6;
375
    seq_6p7   seq7;
376
    seq_6p8   seq8;
377
    seq_6p9   seq9;
378
    seq_6p10  seq10;
379 2 HanySalah
 
380 3 HanySalah
    `uvm_component_utils(read_command_mode)
381 2 HanySalah
 
382 3 HanySalah
    function new (string name,uvm_component parent);
383
      super.new(name,parent);
384
      seq1  = seq_6p1::type_id::create("seq1");
385
      seq2  = seq_6p2::type_id::create("seq2");
386
      seq3  = seq_6p3::type_id::create("seq3");
387
      seq4  = seq_6p4::type_id::create("seq4");
388
      seq5  = seq_6p5::type_id::create("seq5");
389
      seq6  = seq_6p6::type_id::create("seq6");
390
      seq7  = seq_6p7::type_id::create("seq7");
391
      seq8  = seq_6p8::type_id::create("seq8");
392
      seq9  = seq_6p9::type_id::create("seq9");
393
      seq10 = seq_6p10::type_id::create("seq10");
394
    endfunction:new
395 2 HanySalah
 
396 3 HanySalah
    function void build_phase (uvm_phase phase);
397
      super.build_phase(phase);
398
 
399
    endfunction:build_phase
400
 
401
    task run_phase (uvm_phase phase);
402
      super.run_phase(phase);
403
      phase.raise_objection(this);
404
      //seq1.start(env.agent._seq,null);
405
      seq2.start(env.agent._seq,null);
406
      seq3.start(env.agent._seq,null);
407
      seq4.start(env.agent._seq,null);
408
      seq5.start(env.agent._seq,null);
409
      seq6.start(env.agent._seq,null);
410
      seq7.start(env.agent._seq,null);
411
      seq8.start(env.agent._seq,null);
412
      seq9.start(env.agent._seq,null);
413
      seq10.start(env.agent._seq,null);
414
      phase.drop_objection(this);
415
    endtask:run_phase
416
  endclass:read_command_mode
417
 
418
//-------------------------------------------------------------------------------------------------
419
//
420
//                        COMBINED COMMAND TESTS
421
//
422
//-------------------------------------------------------------------------------------------------
423
 
424
  // this test randomly apply series of 100 text mode commands. They would be either read or write
425
  // sequences described in text mode tests in the testbench specifications document.
426
  class text_mode_test extends uart_base_test;
427
 
428
    rand int unsigned command_number;
429
 
430 11 HanySalah
    bit coverage_hit = 1'b0;
431
 
432 3 HanySalah
    seq_1p1   seq1;
433
    seq_1p2   seq2;
434
    seq_1p3   seq3;
435
    seq_1p4   seq4;
436
    seq_1p5   seq5;
437
    seq_1p6   seq6;
438
    seq_1p7   seq7;
439
    seq_1p8   seq8;
440
    seq_1p9   seq9;
441
    seq_1p10  seq10;
442
    seq_1p11  seq11;
443
    seq_1p12  seq12;
444
    seq_1p13  seq13;
445
 
446
 
447
    seq_2p1   seq14;
448
    seq_2p2   seq15;
449
    seq_2p3   seq16;
450
    seq_2p4   seq17;
451
    seq_2p5   seq18;
452
    seq_2p6   seq19;
453
    seq_2p7   seq20;
454
    seq_2p8   seq21;
455
    seq_2p9   seq22;
456
    seq_2p10  seq23;
457
    seq_2p11  seq24;
458
    seq_2p12  seq25;
459
    seq_2p13  seq26;
460
 
461
    `uvm_component_utils(text_mode_test)
462
 
463
    constraint limit {
464
        command_number inside {[1:26]};
465
    }
466
 
467
    function new (string name , uvm_component parent);
468
      super.new(name,parent);
469
    endfunction:new
470
 
471
    function void build_phase (uvm_phase phase);
472
      super.build_phase(phase);
473
      seq1  = seq_1p1::type_id::create("seq1");
474
      seq2  = seq_1p2::type_id::create("seq2");
475
      seq3  = seq_1p3::type_id::create("seq3");
476
      seq4  = seq_1p4::type_id::create("seq4");
477
      seq5  = seq_1p5::type_id::create("seq5");
478
      seq6  = seq_1p6::type_id::create("seq6");
479
      seq7  = seq_1p7::type_id::create("seq7");
480
      seq8  = seq_1p8::type_id::create("seq8");
481
      seq9  = seq_1p9::type_id::create("seq9");
482
      seq10 = seq_1p10::type_id::create("seq10");
483
      seq11 = seq_1p11::type_id::create("seq11");
484
      seq12 = seq_1p12::type_id::create("seq12");
485
      seq13 = seq_1p13::type_id::create("seq13");
486
      seq14 = seq_2p1::type_id::create("seq14");
487
      seq15 = seq_2p2::type_id::create("seq15");
488
      seq16 = seq_2p3::type_id::create("seq16");
489
      seq17 = seq_2p4::type_id::create("seq17");
490
      seq18 = seq_2p5::type_id::create("seq18");
491
      seq19 = seq_2p6::type_id::create("seq19");
492
      seq20 = seq_2p7::type_id::create("seq20");
493
      seq21 = seq_2p8::type_id::create("seq21");
494
      seq22 = seq_2p9::type_id::create("seq22");
495
      seq23 = seq_2p10::type_id::create("seq23");
496
      seq24 = seq_2p11::type_id::create("seq24");
497
      seq25 = seq_2p12::type_id::create("seq25");
498
      seq26 = seq_2p13::type_id::create("seq26");
499 11 HanySalah
      uvm_resource_db #(int)::set("coverage_cloud","text_coverage",0,null);
500
      //uvm_resource_db #(int)::set("coverage_cloud","text_coverage",0,null);
501 3 HanySalah
    endfunction:build_phase
502
 
503
    task run_phase (uvm_phase phase);
504
      super.run_phase(phase);
505
      phase.raise_objection(this);
506 11 HanySalah
      while (coverage_hit==1'b0)
507 3 HanySalah
        begin
508
        randomize();
509
        case (command_number)
510
          1:
511
            begin
512
            seq1.start(env.agent._seq,null);
513
            end
514
          2:
515
            begin
516
            seq2.start(env.agent._seq,null);
517
            end
518
          3:
519
            begin
520
            seq3.start(env.agent._seq,null);
521
            end
522
          4:
523
            begin
524
            seq4.start(env.agent._seq,null);
525
            end
526
          5:
527
            begin
528
            seq5.start(env.agent._seq,null);
529
            end
530
          6:
531
            begin
532
            seq6.start(env.agent._seq,null);
533
            end
534
          7:
535
            begin
536
            seq7.start(env.agent._seq,null);
537
            end
538
          8:
539
            begin
540
            seq8.start(env.agent._seq,null);
541
            end
542
          9:
543
            begin
544
            seq9.start(env.agent._seq,null);
545
            end
546
          10:
547
            begin
548
            seq10.start(env.agent._seq,null);
549
            end
550
          11:
551
            begin
552
            seq11.start(env.agent._seq,null);
553
            end
554
          12:
555
            begin
556
            seq12.start(env.agent._seq,null);
557
            end
558
          13:
559
            begin
560
            seq13.start(env.agent._seq,null);
561
            end
562
          14:
563
            begin
564
            seq14.start(env.agent._seq,null);
565
            end
566
          15:
567
            begin
568
            seq15.start(env.agent._seq,null);
569
            end
570
          16:
571
            begin
572
            seq16.start(env.agent._seq,null);
573
            end
574
          17:
575
            begin
576
            seq17.start(env.agent._seq,null);
577
            end
578
          18:
579
            begin
580
            seq18.start(env.agent._seq,null);
581
            end
582
          19:
583
            begin
584
            seq19.start(env.agent._seq,null);
585
            end
586
          20:
587
            begin
588
            seq20.start(env.agent._seq,null);
589
            end
590
          21:
591
            begin
592
            seq21.start(env.agent._seq,null);
593
            end
594
          22:
595
            begin
596
            seq22.start(env.agent._seq,null);
597
            end
598
          23:
599
            begin
600
            seq23.start(env.agent._seq,null);
601
            end
602
          24:
603
            begin
604
            seq24.start(env.agent._seq,null);
605
            end
606
          25:
607
            begin
608
            seq25.start(env.agent._seq,null);
609
            end
610
          26:
611
            begin
612
            seq26.start(env.agent._seq,null);
613
            end
614
          default:
615
            begin
616
            `uvm_fatal("OUT OF RANGE","Command Number is Out of Range")
617
            end
618 11 HanySalah
        endcase // case (command_number)
619
        evaluate_coverage();
620 3 HanySalah
        end
621
        phase.drop_objection(this);
622
    endtask:run_phase
623 11 HanySalah
 
624
    function void evaluate_coverage();
625
       int text_coverage;
626
       uvm_resource_db#(int)::read_by_name("coverage_cloud","text_coverage",text_coverage);
627
       if(text_coverage >= 95) coverage_hit=1'b1;
628
    endfunction // evaluate_coverage
629
 
630 13 HanySalah
 endclass:text_mode_test
631
 
632
//-------------------------------------------------------------------------------------------------
633
//
634
//                        Coverage Driven Test
635
//
636
//-------------------------------------------------------------------------------------------------
637
 
638
class all_tests extends uart_base_test;
639
 
640
   rand int unsigned testnumber;
641
 
642
   bit     coverage_hit=1'b0;
643
 
644
   int     iteration=0;
645
 
646
   parameter MAX_ITER=10000;
647
 
648
   // Text write tests
649
    seq_1p1   seq1;
650
    seq_1p2   seq2;
651
    seq_1p3   seq3;
652
    seq_1p4   seq4;
653
    seq_1p5   seq5;
654
    seq_1p8   seq6;
655
    seq_1p9   seq7;
656
    seq_1p10  seq8;
657
    seq_1p11  seq9;
658
    seq_1p12  seq10;
659
 
660
   // Text read tests
661
    seq_2p1   seq11;
662
    seq_2p2   seq12;
663
    seq_2p3   seq13;
664
   // seq_2p4   seq17;
665
    seq_2p5   seq14;
666
    seq_2p8   seq15;
667
    seq_2p9   seq16;
668
    seq_2p10  seq17;
669
    seq_2p11  seq18;
670
    seq_2p12  seq19;
671
 
672
   // NOP
673
   seq_3p1    seq20;
674
   seq_3p2    seq21;
675
   seq_3p3    seq22;
676
   seq_4p1    seq23;
677
   seq_4p2    seq24;
678
   seq_4p3    seq25;
679
 
680
   // Write Command Mode
681
   seq_5p2    seq26;
682
   seq_5p3    seq27;
683
   seq_5p4    seq28;
684
   seq_5p5    seq29;
685
   seq_5p6    seq30;
686
   seq_5p7    seq31;
687
   seq_5p8    seq32;
688
   seq_5p9    seq33;
689
   seq_5p10   seq34;
690
 
691
   // Read Command Mode
692
   seq_6p2    seq35;
693
   seq_6p3    seq36;
694
   seq_6p4    seq37;
695
   seq_6p5    seq38;
696
   seq_6p6    seq39;
697
   seq_6p7    seq40;
698
   seq_6p8    seq41;
699
   seq_6p9    seq42;
700
   seq_6p10   seq43;
701
 
702
   // GRANT test
703
   seq_7p1    seq44;
704
   seq_7p2    seq45;
705
 
706
 
707
   `uvm_component_utils(all_tests)
708
 
709
   constraint validtest{testnumber inside{[0:45]};
710
                        testnumber != 13;}
711
 
712
   function new (string name,uvm_component parent);
713
      super.new(name,parent);
714
   endfunction // new
715
 
716
   function void build_phase (uvm_phase phase);
717
      super.build_phase(phase);
718
      seq1      = seq_1p1::type_id::create("seq1");
719
      seq2      = seq_1p2::type_id::create("seq2");
720
      seq3      = seq_1p3::type_id::create("seq3");
721
      seq4      = seq_1p4::type_id::create("seq4");
722
      seq5      = seq_1p5::type_id::create("seq5");
723
      seq6      = seq_1p8::type_id::create("seq6");
724
      seq7      = seq_1p9::type_id::create("seq7");
725
      seq8      = seq_1p10::type_id::create("seq8");
726
      seq9      = seq_1p11::type_id::create("seq9");
727
      seq10     = seq_1p12::type_id::create("seq10");
728
      seq11     = seq_2p1::type_id::create("seq11");
729
      seq12     = seq_2p2::type_id::create("seq12");
730
      seq13     = seq_2p3::type_id::create("seq13");
731
      //seq17   = seq_2p4::type_id::create("seq17");
732
      seq14     = seq_2p5::type_id::create("seq14");
733
      seq15     = seq_2p8::type_id::create("seq15");
734
      seq16     = seq_2p9::type_id::create("seq16");
735
      seq17     = seq_2p10::type_id::create("seq17");
736
      seq18     = seq_2p11::type_id::create("seq18");
737
      seq19     = seq_2p12::type_id::create("seq19");
738
      seq20     = seq_3p1::type_id::create("seq20");
739
      seq21     = seq_3p2::type_id::create("seq21");
740
      seq22     = seq_3p3::type_id::create("seq22");
741
      seq23     = seq_4p1::type_id::create("seq23");
742
      seq24     = seq_4p2::type_id::create("seq24");
743
      seq25     = seq_4p3::type_id::create("seq25");
744
      seq26     = seq_5p2::type_id::create("seq26");
745
      seq27     = seq_5p3::type_id::create("seq27");
746
      seq28     = seq_5p4::type_id::create("seq28");
747
      seq29     = seq_5p5::type_id::create("seq29");
748
      seq30     = seq_5p6::type_id::create("seq30");
749
      seq31     = seq_5p7::type_id::create("seq31");
750
      seq32     = seq_5p8::type_id::create("seq32");
751
      seq33     = seq_5p9::type_id::create("seq33");
752
      seq34     = seq_5p10::type_id::create("seq34");
753
      seq35     = seq_6p2::type_id::create("seq35");
754
      seq36     = seq_6p3::type_id::create("seq36");
755
      seq37     = seq_6p4::type_id::create("seq37");
756
      seq38     = seq_6p5::type_id::create("seq38");
757
      seq39     = seq_6p6::type_id::create("seq39");
758
      seq40     = seq_6p7::type_id::create("seq40");
759
      seq41     = seq_6p8::type_id::create("seq41");
760
      seq42     = seq_6p9::type_id::create("seq42");
761
      seq43     = seq_6p10::type_id::create("seq43");
762
      seq44     = seq_7p1::type_id::create("seq44");
763
      seq45     = seq_7p2::type_id::create("seq45");
764
   endfunction // build_phase
765
 
766
   task run_phase (uvm_phase phase);
767
      super.run_phase(phase);
768
      phase.raise_objection(this);
769
      while(coverage_hit==1'b0 && (iteration < MAX_ITER) ) begin
770
         iteration++;
771
         randomize();
772
         case(testnumber)
773
           0:
774
             begin
775
                seq1.start(env.agent._seq,null);
776
             end
777
           1:
778
             begin
779
                seq2.start(env.agent._seq,null);
780
             end
781
           2:
782
             begin
783
                seq3.start(env.agent._seq,null);
784
             end
785
           3:
786
             begin
787
                seq4.start(env.agent._seq,null);
788
             end
789
           4:
790
             begin
791
                seq5.start(env.agent._seq,null);
792
             end
793
           5:
794
             begin
795
                seq6.start(env.agent._seq,null);
796
             end
797
           6:
798
             begin
799
                seq7.start(env.agent._seq,null);
800
             end
801
           7:
802
             begin
803
                seq8.start(env.agent._seq,null);
804
             end
805
           8:
806
             begin
807
                seq9.start(env.agent._seq,null);
808
             end
809
           9:
810
             begin
811
                seq10.start(env.agent._seq,null);
812
             end
813
           10:
814
             begin
815
                seq11.start(env.agent._seq,null);
816
             end
817
           11:
818
             begin
819
                seq12.start(env.agent._seq,null);
820
             end
821
           12:
822
             begin
823
                seq13.start(env.agent._seq,null);
824
             end
825
          /* 13:
826
             begin
827
                seq17.start(env.agent._seq,null);
828
             end*/
829
           14:
830
             begin
831
                seq14.start(env.agent._seq,null);
832
             end
833
           15:
834
             begin
835
                seq15.start(env.agent._seq,null);
836
             end
837
           16:
838
             begin
839
                seq16.start(env.agent._seq,null);
840
             end
841
           17:
842
             begin
843
                seq17.start(env.agent._seq,null);
844
             end
845
           18:
846
             begin
847
                seq18.start(env.agent._seq,null);
848
             end
849
           19:
850
             begin
851
                seq19.start(env.agent._seq,null);
852
             end
853
           20:
854
             begin
855
                seq20.start(env.agent._seq,null);
856
             end
857
           21:
858
             begin
859
                seq21.start(env.agent._seq,null);
860
             end
861
           22:
862
             begin
863
                seq22.start(env.agent._seq,null);
864
             end
865
           23:
866
             begin
867
                seq23.start(env.agent._seq,null);
868
             end
869
           24:
870
             begin
871
                seq24.start(env.agent._seq,null);
872
             end
873
           25:
874
             begin
875
                seq25.start(env.agent._seq,null);
876
             end
877
           26:
878
             begin
879
                seq26.start(env.agent._seq,null);
880
             end
881
           27:
882
             begin
883
                seq27.start(env.agent._seq,null);
884
             end
885
           28:
886
             begin
887
                seq28.start(env.agent._seq,null);
888
             end
889
           29:
890
             begin
891
                seq29.start(env.agent._seq,null);
892
             end
893
           30:
894
             begin
895
                seq30.start(env.agent._seq,null);
896
             end
897
           31:
898
             begin
899
                seq31.start(env.agent._seq,null);
900
             end
901
           32:
902
             begin
903
                seq32.start(env.agent._seq,null);
904
             end
905
           33:
906
             begin
907
                seq33.start(env.agent._seq,null);
908
             end
909
           34:
910
             begin
911
                seq34.start(env.agent._seq,null);
912
             end
913
           35:
914
             begin
915
                seq35.start(env.agent._seq,null);
916
             end
917
           36:
918
             begin
919
                seq36.start(env.agent._seq,null);
920
             end
921
           37:
922
             begin
923
                seq37.start(env.agent._seq,null);
924
             end
925
           38:
926
             begin
927
                seq38.start(env.agent._seq,null);
928
             end
929
           39:
930
             begin
931
                seq39.start(env.agent._seq,null);
932
             end
933
           40:
934
             begin
935
                seq40.start(env.agent._seq,null);
936
             end
937
           41:
938
             begin
939
                seq41.start(env.agent._seq,null);
940
             end
941
           42:
942
             begin
943
                seq42.start(env.agent._seq,null);
944
             end
945
           43:
946
             begin
947
                seq43.start(env.agent._seq,null);
948
             end
949
           44:
950
             begin
951
                seq44.start(env.agent._seq,null);
952
             end
953
           45:
954
             begin
955
                seq45.start(env.agent._seq,null);
956
             end
957
           default:
958
             begin
959
                `uvm_error("TE","Invalid_test")
960
             end
961
         endcase // case (testnumber)
962
         evaluate_coverage();
963
      end // while (coverage_hit==1'b0)
964
      phase.drop_objection(this);
965
   endtask // run_phase
966
 
967
   function void evaluate_coverage();
968
       int text_coverage;
969
       uvm_resource_db#(int)::read_by_name("coverage_cloud","text_coverage",text_coverage);
970
       if(text_coverage >= 80) coverage_hit=1'b1;
971
   endfunction // evaluate_coverage
972
 
973
   function void report_phase(uvm_phase phase);
974
      int  coverage;
975
      super.report_phase(phase);
976
     if(!(iteration
977
       begin
978
        uvm_resource_db#(int)::read_by_name("coverage_cloud","text_coverage",coverage);
979
        `uvm_warning("SIM",$sformatf("coverage not hit and reached %0d",coverage));
980
       end
981
   endfunction // report_phase
982
 
983
endclass // all_tests

powered by: WebSVN 2.1.0

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