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 16

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

powered by: WebSVN 2.1.0

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