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 14

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