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 17

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