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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [uvm_src/] [base/] [uvm_component.svh] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 HanySalah
//
2
//------------------------------------------------------------------------------
3
//   Copyright 2007-2011 Mentor Graphics Corporation
4
//   Copyright 2007-2011 Cadence Design Systems, Inc.
5
//   Copyright 2010-2011 Synopsys, Inc.
6
//   Copyright 2013      NVIDIA Corporation
7
//   All Rights Reserved Worldwide
8
//
9
//   Licensed under the Apache License, Version 2.0 (the
10
//   "License"); you may not use this file except in
11
//   compliance with the License.  You may obtain a copy of
12
//   the License at
13
//
14
//       http://www.apache.org/licenses/LICENSE-2.0
15
//
16
//   Unless required by applicable law or agreed to in
17
//   writing, software distributed under the License is
18
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19
//   CONDITIONS OF ANY KIND, either express or implied.  See
20
//   the License for the specific language governing
21
//   permissions and limitations under the License.
22
//------------------------------------------------------------------------------
23
 
24
typedef class uvm_objection;
25
typedef class uvm_sequence_base;
26
typedef class uvm_sequence_item;
27
 
28
//------------------------------------------------------------------------------
29
//
30
// CLASS: uvm_component
31
//
32
// The uvm_component class is the root base class for UVM components. In
33
// addition to the features inherited from  and ,
34
// uvm_component provides the following interfaces:
35
//
36
// Hierarchy - provides methods for searching and traversing the component
37
//     hierarchy.
38
//
39
// Phasing - defines a phased test flow that all components follow, with a
40
//     group of standard phase methods and an API for custom phases and
41
//     multiple independent phasing domains to mirror DUT behavior e.g. power
42
//
43
// Reporting - provides a convenience interface to the . All
44
//     messages, warnings, and errors are processed through this interface.
45
//
46
// Transaction recording - provides methods for recording the transactions
47
//     produced or consumed by the component to a transaction database (vendor
48
//     specific).
49
//
50
// Factory - provides a convenience interface to the . The factory
51
//     is used to create new components and other objects based on type-wide and
52
//     instance-specific configuration.
53
//
54
// The uvm_component is automatically seeded during construction using UVM
55
// seeding, if enabled. All other objects must be manually reseeded, if
56
// appropriate. See  for more information.
57
//
58
//------------------------------------------------------------------------------
59
 
60
virtual class uvm_component extends uvm_report_object;
61
 
62
  // Function: new
63
  //
64
  // Creates a new component with the given leaf instance ~name~ and handle
65
  // to its ~parent~.  If the component is a top-level component (i.e. it is
66
  // created in a static module or interface), ~parent~ should be ~null~.
67
  //
68
  // The component will be inserted as a child of the ~parent~ object, if any.
69
  // If ~parent~ already has a child by the given ~name~, an error is produced.
70
  //
71
  // If ~parent~ is ~null~, then the component will become a child of the
72
  // implicit top-level component, ~uvm_top~.
73
  //
74
  // All classes derived from uvm_component must call super.new(name,parent).
75
 
76
  extern function new (string name, uvm_component parent);
77
 
78
 
79
  //----------------------------------------------------------------------------
80
  // Group: Hierarchy Interface
81
  //----------------------------------------------------------------------------
82
  //
83
  // These methods provide user access to information about the component
84
  // hierarchy, i.e., topology.
85
  //
86
  //----------------------------------------------------------------------------
87
 
88
  // Function: get_parent
89
  //
90
  // Returns a handle to this component's parent, or ~null~ if it has no parent.
91
 
92
  extern virtual function uvm_component get_parent ();
93
 
94
 
95
  // Function: get_full_name
96
  //
97
  // Returns the full hierarchical name of this object. The default
98
  // implementation concatenates the hierarchical name of the parent, if any,
99
  // with the leaf name of this object, as given by .
100
 
101
  extern virtual function string get_full_name ();
102
 
103
 
104
  // Function: get_children
105
  //
106
  // This function populates the end of the ~children~ array with the
107
  // list of this component's children.
108
  //
109
  //|   uvm_component array[$];
110
  //|   my_comp.get_children(array);
111
  //|   foreach(array[i])
112
  //|     do_something(array[i]);
113
 
114
  extern function void get_children(ref uvm_component children[$]);
115
 
116
 
117
  // Function: get_child
118
  extern function uvm_component get_child (string name);
119
 
120
  // Function: get_next_child
121
  extern function int get_next_child (ref string name);
122
 
123
  // Function: get_first_child
124
  //
125
  // These methods are used to iterate through this component's children, if
126
  // any. For example, given a component with an object handle, ~comp~, the
127
  // following code calls  for each child:
128
  //
129
  //|    string name;
130
  //|    uvm_component child;
131
  //|    if (comp.get_first_child(name))
132
  //|      do begin
133
  //|        child = comp.get_child(name);
134
  //|        child.print();
135
  //|      end while (comp.get_next_child(name));
136
 
137
  extern function int get_first_child (ref string name);
138
 
139
 
140
  // Function: get_num_children
141
  //
142
  // Returns the number of this component's children.
143
 
144
  extern function int get_num_children ();
145
 
146
 
147
  // Function: has_child
148
  //
149
  // Returns 1 if this component has a child with the given ~name~, 0 otherwise.
150
 
151
  extern function int has_child (string name);
152
 
153
 
154
  // Function - set_name
155
  //
156
  // Renames this component to ~name~ and recalculates all descendants'
157
  // full names. This is an internal function for now.
158
 
159
  extern virtual function void set_name (string name);
160
 
161
 
162
  // Function: lookup
163
  //
164
  // Looks for a component with the given hierarchical ~name~ relative to this
165
  // component. If the given ~name~ is preceded with a '.' (dot), then the search
166
  // begins relative to the top level (absolute lookup). The handle of the
167
  // matching component is returned, else ~null~. The name must not contain
168
  // wildcards.
169
 
170
  extern function uvm_component lookup (string name);
171
 
172
 
173
  // Function: get_depth
174
  //
175
  // Returns the component's depth from the root level. uvm_top has a
176
  // depth of 0. The test and any other top level components have a depth
177
  // of 1, and so on.
178
 
179
  extern function int unsigned get_depth();
180
 
181
 
182
  //----------------------------------------------------------------------------
183
  // Group: Phasing Interface
184
  //----------------------------------------------------------------------------
185
  //
186
  // These methods implement an interface which allows all components to step
187
  // through a standard schedule of phases, or a customized schedule, and
188
  // also an API to allow independent phase domains which can jump like state
189
  // machines to reflect behavior e.g. power domains on the DUT in different
190
  // portions of the testbench. The phase tasks and functions are the phase
191
  // name with the _phase suffix. For example, the build phase function is
192
  // .
193
  //
194
  // All processes associated with a task-based phase are killed when the phase
195
  // ends. See  for more details.
196
  //----------------------------------------------------------------------------
197
 
198
 
199
  // Function: build_phase
200
  //
201
  // The  phase implementation method.
202
  //
203
  // Any override should call super.build_phase(phase) to execute the automatic
204
  // configuration of fields registered in the component by calling
205
  // .
206
  // To turn off automatic configuration for a component,
207
  // do not call super.build_phase(phase).
208
  //
209
  // This method should never be called directly.
210
 
211
  extern virtual function void build_phase(uvm_phase phase);
212
 
213
  // For backward compatibility the base  method calls .
214
  extern virtual function void build();
215
 
216
 
217
  // Function: connect_phase
218
  //
219
  // The  phase implementation method.
220
  //
221
  // This method should never be called directly.
222
 
223
  extern virtual function void connect_phase(uvm_phase phase);
224
 
225
  // For backward compatibility the base connect_phase method calls connect.
226
  extern virtual function void connect();
227
 
228
  // Function: end_of_elaboration_phase
229
  //
230
  // The  phase implementation method.
231
  //
232
  // This method should never be called directly.
233
 
234
  extern virtual function void end_of_elaboration_phase(uvm_phase phase);
235
 
236
  // For backward compatibility the base  method calls .
237
  extern virtual function void end_of_elaboration();
238
 
239
  // Function: start_of_simulation_phase
240
  //
241
  // The  phase implementation method.
242
  //
243
  // This method should never be called directly.
244
 
245
  extern virtual function void start_of_simulation_phase(uvm_phase phase);
246
 
247
  // For backward compatibility the base  method calls .
248
  extern virtual function void start_of_simulation();
249
 
250
  // Task: run_phase
251
  //
252
  // The  phase implementation method.
253
  //
254
  // This task returning or not does not indicate the end
255
  // or persistence of this phase.
256
  // Thus the phase will automatically
257
  // end once all objections are dropped using ~phase.drop_objection()~.
258
  //
259
  // Any processes forked by this task continue to run
260
  // after the task returns,
261
  // but they will be killed once the phase ends.
262
  //
263
  // The run_phase task should never be called directly.
264
 
265
  extern virtual task run_phase(uvm_phase phase);
266
 
267
  // For backward compatibility the base  method calls .
268
  extern virtual task run();
269
 
270
  // Task: pre_reset_phase
271
  //
272
  // The  phase implementation method.
273
  //
274
  // This task returning or not does not indicate the end
275
  // or persistence of this phase.
276
  // It is necessary to raise an objection
277
  // using ~phase.raise_objection()~ to cause the phase to persist.
278
  // Once all components have dropped their respective objection
279
  // using ~phase.drop_objection()~, or if no components raises an
280
  // objection, the phase is ended.
281
  //
282
  // Any processes forked by this task continue to run
283
  // after the task returns,
284
  // but they will be killed once the phase ends.
285
  //
286
  // This method should not be called directly.
287
 
288
  extern virtual task pre_reset_phase(uvm_phase phase);
289
 
290
  // Task: reset_phase
291
  //
292
  // The  phase implementation method.
293
  //
294
  // This task returning or not does not indicate the end
295
  // or persistence of this phase.
296
  // It is necessary to raise an objection
297
  // using ~phase.raise_objection()~ to cause the phase to persist.
298
  // Once all components have dropped their respective objection
299
  // using ~phase.drop_objection()~, or if no components raises an
300
  // objection, the phase is ended.
301
  //
302
  // Any processes forked by this task continue to run
303
  // after the task returns,
304
  // but they will be killed once the phase ends.
305
  //
306
  // This method should not be called directly.
307
 
308
  extern virtual task reset_phase(uvm_phase phase);
309
 
310
  // Task: post_reset_phase
311
  //
312
  // The  phase implementation method.
313
  //
314
  // This task returning or not does not indicate the end
315
  // or persistence of this phase.
316
  // It is necessary to raise an objection
317
  // using ~phase.raise_objection()~ to cause the phase to persist.
318
  // Once all components have dropped their respective objection
319
  // using ~phase.drop_objection()~, or if no components raises an
320
  // objection, the phase is ended.
321
  //
322
  // Any processes forked by this task continue to run
323
  // after the task returns,
324
  // but they will be killed once the phase ends.
325
  //
326
  // This method should not be called directly.
327
 
328
  extern virtual task post_reset_phase(uvm_phase phase);
329
 
330
  // Task: pre_configure_phase
331
  //
332
  // The  phase implementation method.
333
  //
334
  // This task returning or not does not indicate the end
335
  // or persistence of this phase.
336
  // It is necessary to raise an objection
337
  // using ~phase.raise_objection()~ to cause the phase to persist.
338
  // Once all components have dropped their respective objection
339
  // using ~phase.drop_objection()~, or if no components raises an
340
  // objection, the phase is ended.
341
  //
342
  // Any processes forked by this task continue to run
343
  // after the task returns,
344
  // but they will be killed once the phase ends.
345
  //
346
  // This method should not be called directly.
347
 
348
  extern virtual task pre_configure_phase(uvm_phase phase);
349
 
350
  // Task: configure_phase
351
  //
352
  // The  phase implementation method.
353
  //
354
  // This task returning or not does not indicate the end
355
  // or persistence of this phase.
356
  // It is necessary to raise an objection
357
  // using ~phase.raise_objection()~ to cause the phase to persist.
358
  // Once all components have dropped their respective objection
359
  // using ~phase.drop_objection()~, or if no components raises an
360
  // objection, the phase is ended.
361
  //
362
  // Any processes forked by this task continue to run
363
  // after the task returns,
364
  // but they will be killed once the phase ends.
365
  //
366
  // This method should not be called directly.
367
 
368
  extern virtual task configure_phase(uvm_phase phase);
369
 
370
  // Task: post_configure_phase
371
  //
372
  // The  phase implementation method.
373
  //
374
  // This task returning or not does not indicate the end
375
  // or persistence of this phase.
376
  // It is necessary to raise an objection
377
  // using ~phase.raise_objection()~ to cause the phase to persist.
378
  // Once all components have dropped their respective objection
379
  // using ~phase.drop_objection()~, or if no components raises an
380
  // objection, the phase is ended.
381
  //
382
  // Any processes forked by this task continue to run
383
  // after the task returns,
384
  // but they will be killed once the phase ends.
385
  //
386
  // This method should not be called directly.
387
 
388
  extern virtual task post_configure_phase(uvm_phase phase);
389
 
390
  // Task: pre_main_phase
391
  //
392
  // The  phase implementation method.
393
  //
394
  // This task returning or not does not indicate the end
395
  // or persistence of this phase.
396
  // It is necessary to raise an objection
397
  // using ~phase.raise_objection()~ to cause the phase to persist.
398
  // Once all components have dropped their respective objection
399
  // using ~phase.drop_objection()~, or if no components raises an
400
  // objection, the phase is ended.
401
  //
402
  // Any processes forked by this task continue to run
403
  // after the task returns,
404
  // but they will be killed once the phase ends.
405
  //
406
  // This method should not be called directly.
407
 
408
  extern virtual task pre_main_phase(uvm_phase phase);
409
 
410
  // Task: main_phase
411
  //
412
  // The  phase implementation method.
413
  //
414
  // This task returning or not does not indicate the end
415
  // or persistence of this phase.
416
  // It is necessary to raise an objection
417
  // using ~phase.raise_objection()~ to cause the phase to persist.
418
  // Once all components have dropped their respective objection
419
  // using ~phase.drop_objection()~, or if no components raises an
420
  // objection, the phase is ended.
421
  //
422
  // Any processes forked by this task continue to run
423
  // after the task returns,
424
  // but they will be killed once the phase ends.
425
  //
426
  // This method should not be called directly.
427
 
428
  extern virtual task main_phase(uvm_phase phase);
429
 
430
  // Task: post_main_phase
431
  //
432
  // The  phase implementation method.
433
  //
434
  // This task returning or not does not indicate the end
435
  // or persistence of this phase.
436
  // It is necessary to raise an objection
437
  // using ~phase.raise_objection()~ to cause the phase to persist.
438
  // Once all components have dropped their respective objection
439
  // using ~phase.drop_objection()~, or if no components raises an
440
  // objection, the phase is ended.
441
  //
442
  // Any processes forked by this task continue to run
443
  // after the task returns,
444
  // but they will be killed once the phase ends.
445
  //
446
  // This method should not be called directly.
447
 
448
  extern virtual task post_main_phase(uvm_phase phase);
449
 
450
  // Task: pre_shutdown_phase
451
  //
452
  // The  phase implementation method.
453
  //
454
  // This task returning or not does not indicate the end
455
  // or persistence of this phase.
456
  // It is necessary to raise an objection
457
  // using ~phase.raise_objection()~ to cause the phase to persist.
458
  // Once all components have dropped their respective objection
459
  // using ~phase.drop_objection()~, or if no components raises an
460
  // objection, the phase is ended.
461
  //
462
  // Any processes forked by this task continue to run
463
  // after the task returns,
464
  // but they will be killed once the phase ends.
465
  //
466
  // This method should not be called directly.
467
 
468
  extern virtual task pre_shutdown_phase(uvm_phase phase);
469
 
470
  // Task: shutdown_phase
471
  //
472
  // The  phase implementation method.
473
  //
474
  // This task returning or not does not indicate the end
475
  // or persistence of this phase.
476
  // It is necessary to raise an objection
477
  // using ~phase.raise_objection()~ to cause the phase to persist.
478
  // Once all components have dropped their respective objection
479
  // using ~phase.drop_objection()~, or if no components raises an
480
  // objection, the phase is ended.
481
  //
482
  // Any processes forked by this task continue to run
483
  // after the task returns,
484
  // but they will be killed once the phase ends.
485
  //
486
  // This method should not be called directly.
487
 
488
  extern virtual task shutdown_phase(uvm_phase phase);
489
 
490
  // Task: post_shutdown_phase
491
  //
492
  // The  phase implementation method.
493
  //
494
  // This task returning or not does not indicate the end
495
  // or persistence of this phase.
496
  // It is necessary to raise an objection
497
  // using ~phase.raise_objection()~ to cause the phase to persist.
498
  // Once all components have dropped their respective objection
499
  // using ~phase.drop_objection()~, or if no components raises an
500
  // objection, the phase is ended.
501
  //
502
  // Any processes forked by this task continue to run
503
  // after the task returns,
504
  // but they will be killed once the phase ends.
505
  //
506
  // This method should not be called directly.
507
 
508
  extern virtual task post_shutdown_phase(uvm_phase phase);
509
 
510
  // Function: extract_phase
511
  //
512
  // The  phase implementation method.
513
  //
514
  // This method should never be called directly.
515
 
516
  extern virtual function void extract_phase(uvm_phase phase);
517
 
518
  // For backward compatibility the base extract_phase method calls extract.
519
  extern virtual function void extract();
520
 
521
  // Function: check_phase
522
  //
523
  // The  phase implementation method.
524
  //
525
  // This method should never be called directly.
526
 
527
  extern virtual function void check_phase(uvm_phase phase);
528
 
529
  // For backward compatibility the base check_phase method calls check.
530
  extern virtual function void check();
531
 
532
  // Function: report_phase
533
  //
534
  // The  phase implementation method.
535
  //
536
  // This method should never be called directly.
537
 
538
  extern virtual function void report_phase(uvm_phase phase);
539
 
540
  // For backward compatibility the base report_phase method calls report.
541
  extern virtual function void report();
542
 
543
  // Function: final_phase
544
  //
545
  // The  phase implementation method.
546
  //
547
  // This method should never be called directly.
548
 
549
  extern virtual function void final_phase(uvm_phase phase);
550
 
551
  // Function: phase_started
552
  //
553
  // Invoked at the start of each phase. The ~phase~ argument specifies
554
  // the phase being started. Any threads spawned in this callback are
555
  // not affected when the phase ends.
556
 
557
  extern virtual function void phase_started (uvm_phase phase);
558
 
559
  // Function: phase_ready_to_end
560
  //
561
  // Invoked when all objections to ending the given ~phase~ and all
562
  // sibling phases have been dropped, thus indicating that ~phase~ is
563
  // ready to begin a clean exit. Sibling phases are any phases that
564
  // have a common successor phase in the schedule plus any phases that
565
  // sync'd to the current phase. Components needing to consume delta
566
  // cycles or advance time to perform a clean exit from the phase
567
  // may raise the phase's objection.
568
  //
569
  // |phase.raise_objection(this,"Reason");
570
  //
571
  // It is the responsibility of this component to drop the objection
572
  // once it is ready for this phase to end (and processes killed).
573
  // If no objection to the given ~phase~ or sibling phases are raised,
574
  // then phase_ended() is called after a delta cycle.  If any objection
575
  // is raised, then when all objections to ending the given ~phase~
576
  // and siblings are dropped, another iteration of phase_ready_to_end
577
  // is called.  To prevent endless iterations due to coding error,
578
  // after 20 iterations, phase_ended() is called regardless of whether
579
  // previous iteration had any objections raised.
580
 
581
  extern virtual function void phase_ready_to_end (uvm_phase phase);
582
 
583
 
584
  // Function: phase_ended
585
  //
586
  // Invoked at the end of each phase. The ~phase~ argument specifies
587
  // the phase that is ending.  Any threads spawned in this callback are
588
  // not affected when the phase ends.
589
 
590
  extern virtual function void phase_ended (uvm_phase phase);
591
 
592
 
593
  //--------------------------------------------------------------------
594
  // phase / schedule / domain API
595
  //--------------------------------------------------------------------
596
 
597
 
598
  // Function: set_domain
599
  //
600
  // Apply a phase domain to this component and, if ~hier~ is set,
601
  // recursively to all its children.
602
  //
603
  // Calls the virtual  method, which derived components can
604
  // override to augment or replace the domain definition of its base class.
605
  //
606
 
607
  extern function void set_domain(uvm_domain domain, int hier=1);
608
 
609
 
610
  // Function: get_domain
611
  //
612
  // Return handle to the phase domain set on this component
613
 
614
  extern function uvm_domain get_domain();
615
 
616
 
617
  // Function: define_domain
618
  //
619
  // Builds custom phase schedules into the provided ~domain~ handle.
620
  //
621
  // This method is called by , which integrators use to specify
622
  // this component belongs in a domain apart from the default 'uvm' domain.
623
  //
624
  // Custom component base classes requiring a custom phasing schedule can
625
  // augment or replace the domain definition they inherit by overriding
626
  // their ~defined_domain~. To augment, overrides would call super.define_domain().
627
  // To replace, overrides would not call super.define_domain().
628
  //
629
  // The default implementation adds a copy of the ~uvm~ phasing schedule to
630
  // the given ~domain~, if one doesn't already exist, and only if the domain
631
  // is currently empty.
632
  //
633
  // Calling 
634
  // with the default ~uvm~ domain (i.e.  ) on
635
  // a component with no ~define_domain~ override effectively reverts the
636
  // that component to using the default ~uvm~ domain. This may be useful
637
  // if a branch of the testbench hierarchy defines a custom domain, but
638
  // some child sub-branch should remain in the default ~uvm~ domain,
639
  // call  with a new domain instance handle with ~hier~ set.
640
  // Then, in the sub-branch, call  with the default ~uvm~ domain handle,
641
  // obtained via .
642
  //
643
  // Alternatively, the integrator may define the graph in a new domain externally,
644
  // then call  to apply it to a component.
645
 
646
 
647
  extern virtual protected function void define_domain(uvm_domain domain);
648
 
649
 
650
  // Function: set_phase_imp
651
  //
652
  // Override the default implementation for a phase on this component (tree) with a
653
  // custom one, which must be created as a singleton object extending the default
654
  // one and implementing required behavior in exec and traverse methods
655
  //
656
  // The ~hier~ specifies whether to apply the custom functor to the whole tree or
657
  // just this component.
658
 
659
  extern function void set_phase_imp(uvm_phase phase, uvm_phase imp, int hier=1);
660
 
661
 
662
  // Task: suspend
663
  //
664
  // Suspend this component.
665
  //
666
  // This method must be implemented by the user to suspend the
667
  // component according to the protocol and functionality it implements.
668
  // A suspended component can be subsequently resumed using .
669
 
670
  extern virtual task suspend ();
671
 
672
 
673
  // Task: resume
674
  //
675
  // Resume this component.
676
  //
677
  // This method must be implemented by the user to resume a component
678
  // that was previously suspended using .
679
  // Some component may start in the suspended state and
680
  // may need to be explicitly resumed.
681
 
682
  extern virtual task resume ();
683
 
684
 
685
`ifndef UVM_NO_DEPRECATED
686
  // Function- status  - DEPRECATED
687
  //
688
  // Returns the status of this component.
689
  //
690
  // Returns a string that describes the current status of the
691
  // components. Possible values include, but are not limited to
692
  //
693
  // ""   - Status is unknown (default)
694
  // "FINISHED"    - Component has stopped on its own accord. May be resumed.
695
  // "RUNNING"     - Component is running.
696
  //                 May be suspended after normal completion
697
  //                 of operation in progress.
698
  // "WAITING"     - Component is waiting. May be suspended immediately.
699
  // "SUSPENDED"   - Component is suspended. May be resumed.
700
  // "KILLED"      - Component has been killed and is unable to operate
701
  //                 any further. It cannot be resumed.
702
 
703
 
704
  extern function string status ();
705
 
706
 
707
  // Function- kill  - DEPRECATED
708
  //
709
  // Kills the process tree associated with this component's currently running
710
  // task-based phase, e.g., run.
711
 
712
  extern virtual function void kill ();
713
 
714
 
715
  // Function- do_kill_all  - DEPRECATED
716
  //
717
  // Recursively calls  on this component and all its descendants,
718
  // which abruptly ends the currently running task-based phase, e.g., run.
719
  // See  for better options to ending a task-based phase.
720
 
721
  extern virtual  function void  do_kill_all ();
722
 
723
 
724
  // Task- stop_phase  -- DEPRECATED
725
  //
726
  // The stop_phase task is called when this component's 
727
  // bit is set and  is called during a task-based phase,
728
  // e.g., run.
729
  //
730
  // Before a phase is abruptly ended, e.g., when a test deems the simulation
731
  // complete, some components may need extra time to shut down cleanly. Such
732
  // components may implement stop_phase to finish the currently executing
733
  // transaction, flush the queue, or perform other cleanup. Upon return from
734
  // stop_phase, a component signals it is ready to be stopped.
735
  //
736
  // The ~stop_phase~ method will not be called if  is 0.
737
  //
738
  // The default implementation is empty, i.e., it will return immediately.
739
  //
740
  // This method should never be called directly.
741
 
742
  extern virtual task stop_phase(uvm_phase phase);
743
 
744
  // backward compat
745
  extern virtual task stop (string ph_name);
746
 
747
 
748
  // Variable- enable_stop_interrupt  - DEPRECATED
749
  //
750
  // This bit allows a component to raise an objection to the stopping of the
751
  // current phase. It affects only time consuming phases (such as the run
752
  // phase).
753
  //
754
  // When this bit is set, the  task in the component is called as a result
755
  // of a call to . Components that are sensitive to an
756
  // immediate killing of its run-time processes should set this bit and
757
  // implement the stop task to prepare for shutdown.
758
 
759
  int enable_stop_interrupt;
760
`endif
761
 
762
 
763
  // Function: resolve_bindings
764
  //
765
  // Processes all port, export, and imp connections. Checks whether each port's
766
  // min and max connection requirements are met.
767
  //
768
  // It is called just before the end_of_elaboration phase.
769
  //
770
  // Users should not call directly.
771
 
772
  extern virtual function void resolve_bindings ();
773
 
774
  extern function string massage_scope(string scope);
775
 
776
 
777
  //----------------------------------------------------------------------------
778
  // Group: Configuration Interface
779
  //----------------------------------------------------------------------------
780
  //
781
  // Components can be designed to be user-configurable in terms of its
782
  // topology (the type and number of children it has), mode of operation, and
783
  // run-time parameters (knobs). The configuration interface accommodates
784
  // this common need, allowing component composition and state to be modified
785
  // without having to derive new classes or new class hierarchies for
786
  // every configuration scenario.
787
  //
788
  //----------------------------------------------------------------------------
789
 
790
`ifndef UVM_NO_DEPRECATED
791
 
792
  static bit m_config_deprecated_warned;
793
 
794
  // Used for caching config settings
795
  static bit m_config_set = 1;
796
 
797
  // Function- set_config_int
798
 
799
  extern virtual function void set_config_int (string inst_name,
800
                                               string field_name,
801
                                               uvm_bitstream_t value);
802
 
803
  // Function- set_config_string
804
 
805
  extern virtual function void set_config_string (string inst_name,
806
                                                  string field_name,
807
                                                  string value);
808
 
809
  // Function- set_config_object
810
  //
811
  // Calling set_config_* causes configuration settings to be created and
812
  // placed in a table internal to this component. There are similar global
813
  // methods that store settings in a global table. Each setting stores the
814
  // supplied ~inst_name~, ~field_name~, and ~value~ for later use by descendent
815
  // components during their construction. (The global table applies to
816
  // all components and takes precedence over the component tables.)
817
  //
818
  // When a descendant component calls a get_config_* method, the ~inst_name~
819
  // and ~field_name~ provided in the get call are matched against all the
820
  // configuration settings stored in the global table and then in each
821
  // component in the parent hierarchy, top-down. Upon the first match, the
822
  // value stored in the configuration setting is returned. Thus, precedence is
823
  // global, following by the top-level component, and so on down to the
824
  // descendent component's parent.
825
  //
826
  // These methods work in conjunction with the get_config_* methods to
827
  // provide a configuration setting mechanism for integral, string, and
828
  // uvm_object-based types. Settings of other types, such as virtual interfaces
829
  // and arrays, can be indirectly supported by defining a class that contains
830
  // them.
831
  //
832
  // Both ~inst_name~ and ~field_name~ may contain wildcards.
833
  //
834
  // - For set_config_int, ~value~ is an integral value that can be anything
835
  //   from 1 bit to 4096 bits.
836
  //
837
  // - For set_config_string, ~value~ is a string.
838
  //
839
  // - For set_config_object, ~value~ must be an -based object or
840
  //   ~null~.  Its clone argument specifies whether the object should be cloned.
841
  //   If set, the object is cloned both going into the table (during the set)
842
  //   and coming out of the table (during the get), so that multiple components
843
  //   matched to the same setting (by way of wildcards) do not end up sharing
844
  //   the same object.
845
  //
846
  //
847
  // See , , and  for
848
  // information on getting the configurations set by these methods.
849
 
850
 
851
  extern virtual function void set_config_object (string inst_name,
852
                                                  string field_name,
853
                                                  uvm_object value,
854
                                                  bit clone=1);
855
 
856
 
857
  // Function- get_config_int
858
 
859
  extern virtual function bit get_config_int (string field_name,
860
                                              inout uvm_bitstream_t value);
861
 
862
  // Function- get_config_string
863
 
864
  extern virtual function bit get_config_string (string field_name,
865
                                                 inout string value);
866
 
867
  // Function- get_config_object
868
  //
869
  // These methods retrieve configuration settings made by previous calls to
870
  // their set_config_* counterparts. As the methods' names suggest, there is
871
  // direct support for integral types, strings, and objects.  Settings of other
872
  // types can be indirectly supported by defining an object to contain them.
873
  //
874
  // Configuration settings are stored in a global table and in each component
875
  // instance. With each call to a get_config_* method, a top-down search is
876
  // made for a setting that matches this component's full name and the given
877
  // ~field_name~. For example, say this component's full instance name is
878
  // top.u1.u2. First, the global configuration table is searched. If that
879
  // fails, then it searches the configuration table in component 'top',
880
  // followed by top.u1.
881
  //
882
  // The first instance/field that matches causes ~value~ to be written with the
883
  // value of the configuration setting and 1 is returned. If no match
884
  // is found, then ~value~ is unchanged and the 0 returned.
885
  //
886
  // Calling the get_config_object method requires special handling. Because
887
  // ~value~ is an output of type , you must provide a uvm_object
888
  // handle to assign to (_not_ a derived class handle). After the call, you can
889
  // then $cast to the actual type.
890
  //
891
  // For example, the following code illustrates how a component designer might
892
  // call upon the configuration mechanism to assign its ~data~ object property,
893
  // whose type myobj_t derives from uvm_object.
894
  //
895
  //|  class mycomponent extends uvm_component;
896
  //|
897
  //|    local myobj_t data;
898
  //|
899
  //|    function void build_phase(uvm_phase phase);
900
  //|      uvm_object tmp;
901
  //|      super.build_phase(phase);
902
  //|      if(get_config_object("data", tmp))
903
  //|        if (!$cast(data, tmp))
904
  //|          `uvm_error("CFGERR","error! config setting for 'data' not of type myobj_t")
905
  //|        endfunction
906
  //|      ...
907
  //
908
  // The above example overrides the  method. If you want to retain
909
  // any base functionality, you must call super.build_phase(uvm_phase phase).
910
  //
911
  // The ~clone~ bit clones the data inbound. The get_config_object method can
912
  // also clone the data outbound.
913
  //
914
  // See Members for information on setting the global configuration table.
915
 
916
  extern virtual function bit get_config_object (string field_name,
917
                                                 inout uvm_object value,
918
                                                 input bit clone=1);
919
`endif
920
 
921
 
922
  // Function: check_config_usage
923
  //
924
  // Check all configuration settings in a components configuration table
925
  // to determine if the setting has been used, overridden or not used.
926
  // When ~recurse~ is 1 (default), configuration for this and all child
927
  // components are recursively checked. This function is automatically
928
  // called in the check phase, but can be manually called at any time.
929
  //
930
  // To get all configuration information prior to the run phase, do something
931
  // like this in your top object:
932
  //|  function void start_of_simulation_phase(uvm_phase phase);
933
  //|    check_config_usage();
934
  //|  endfunction
935
 
936
  extern function void check_config_usage (bit recurse=1);
937
 
938
 
939
  // Function: apply_config_settings
940
  //
941
  // Searches for all config settings matching this component's instance path.
942
  // For each match, the appropriate set_*_local method is called using the
943
  // matching config setting's field_name and value. Provided the set_*_local
944
  // method is implemented, the component property associated with the
945
  // field_name is assigned the given value.
946
  //
947
  // This function is called by .
948
  //
949
  // The apply_config_settings method determines all the configuration
950
  // settings targeting this component and calls the appropriate set_*_local
951
  // method to set each one. To work, you must override one or more set_*_local
952
  // methods to accommodate setting of your component's specific properties.
953
  // Any properties registered with the optional `uvm_*_field macros do not
954
  // require special handling by the set_*_local methods; the macros provide
955
  // the set_*_local functionality for you.
956
  //
957
  // If you do not want apply_config_settings to be called for a component,
958
  // then the build_phase() method should be overloaded and you should not call
959
  // super.build_phase(phase). Likewise, apply_config_settings can be overloaded to
960
  // customize automated configuration.
961
  //
962
  // When the ~verbose~ bit is set, all overrides are printed as they are
963
  // applied. If the component's  property is set, then
964
  // apply_config_settings is automatically called with ~verbose~ = 1.
965
 
966
  extern virtual function void apply_config_settings (bit verbose = 0);
967
 
968
 
969
  // Function: print_config_settings
970
  //
971
  // Called without arguments, print_config_settings prints all configuration
972
  // information for this component, as set by previous calls to .
973
  // The settings are printing in the order of their precedence.
974
  //
975
  // If ~field~ is specified and non-empty, then only configuration settings
976
  // matching that field, if any, are printed. The field may not contain
977
  // wildcards.
978
  //
979
  // If ~comp~ is specified and non-~null~, then the configuration for that
980
  // component is printed.
981
  //
982
  // If ~recurse~ is set, then configuration information for all ~comp~'s
983
  // children and below are printed as well.
984
  //
985
  // This function has been deprecated.  Use print_config instead.
986
 
987
  extern function void print_config_settings (string field="",
988
                                              uvm_component comp=null,
989
                                              bit recurse=0);
990
 
991
  // Function: print_config
992
  //
993
  // Print_config_settings prints all configuration information for this
994
  // component, as set by previous calls to  and exports to
995
  // the resources pool.  The settings are printing in the order of
996
  // their precedence.
997
  //
998
  // If ~recurse~ is set, then configuration information for all
999
  // children and below are printed as well.
1000
  //
1001
  // if ~audit~ is set then the audit trail for each resource is printed
1002
  // along with the resource name and value
1003
 
1004
  extern function void print_config(bit recurse = 0, bit audit = 0);
1005
 
1006
  // Function: print_config_with_audit
1007
  //
1008
  // Operates the same as print_config except that the audit bit is
1009
  // forced to 1.  This interface makes user code a bit more readable as
1010
  // it avoids multiple arbitrary bit settings in the argument list.
1011
  //
1012
  // If ~recurse~ is set, then configuration information for all
1013
  // children and below are printed as well.
1014
 
1015
  extern function void print_config_with_audit(bit recurse = 0);
1016
 
1017
  // Variable: print_config_matches
1018
  //
1019
  // Setting this static variable causes uvm_config_db::get() to print info about
1020
  // matching configuration settings as they are being applied.
1021
 
1022
  static bit print_config_matches;
1023
 
1024
 
1025
  //----------------------------------------------------------------------------
1026
  // Group: Objection Interface
1027
  //----------------------------------------------------------------------------
1028
  //
1029
  // These methods provide object level hooks into the 
1030
  // mechanism.
1031
  //
1032
  //----------------------------------------------------------------------------
1033
 
1034
 
1035
  // Function: raised
1036
  //
1037
  // The ~raised~ callback is called when this or a descendant of this component
1038
  // instance raises the specified ~objection~. The ~source_obj~ is the object
1039
  // that originally raised the objection.
1040
  // The ~description~ is optionally provided by the ~source_obj~ to give a
1041
  // reason for raising the objection. The ~count~ indicates the number of
1042
  // objections raised by the ~source_obj~.
1043
 
1044
  virtual function void raised (uvm_objection objection, uvm_object source_obj,
1045
      string description, int count);
1046
  endfunction
1047
 
1048
 
1049
  // Function: dropped
1050
  //
1051
  // The ~dropped~ callback is called when this or a descendant of this component
1052
  // instance drops the specified ~objection~. The ~source_obj~ is the object
1053
  // that originally dropped the objection.
1054
  // The ~description~ is optionally provided by the ~source_obj~ to give a
1055
  // reason for dropping the objection. The ~count~ indicates the number of
1056
  // objections dropped by the ~source_obj~.
1057
 
1058
  virtual function void dropped (uvm_objection objection, uvm_object source_obj,
1059
      string description, int count);
1060
  endfunction
1061
 
1062
 
1063
  // Task: all_dropped
1064
  //
1065
  // The ~all_droppped~ callback is called when all objections have been
1066
  // dropped by this component and all its descendants.  The ~source_obj~ is the
1067
  // object that dropped the last objection.
1068
  // The ~description~ is optionally provided by the ~source_obj~ to give a
1069
  // reason for raising the objection. The ~count~ indicates the number of
1070
  // objections dropped by the ~source_obj~.
1071
 
1072
  virtual task all_dropped (uvm_objection objection, uvm_object source_obj,
1073
      string description, int count);
1074
  endtask
1075
 
1076
 
1077
  //----------------------------------------------------------------------------
1078
  // Group: Factory Interface
1079
  //----------------------------------------------------------------------------
1080
  //
1081
  // The factory interface provides convenient access to a portion of UVM's
1082
  //  interface. For creating new objects and components, the
1083
  // preferred method of accessing the factory is via the object or component
1084
  // wrapper (see  and
1085
  // ). The wrapper also provides functions
1086
  // for setting type and instance overrides.
1087
  //
1088
  //----------------------------------------------------------------------------
1089
 
1090
  // Function: create_component
1091
  //
1092
  // A convenience function for ,
1093
  // this method calls upon the factory to create a new child component
1094
  // whose type corresponds to the preregistered type name, ~requested_type_name~,
1095
  // and instance name, ~name~. This method is equivalent to:
1096
  //
1097
  //|  factory.create_component_by_name(requested_type_name,
1098
  //|                                   get_full_name(), name, this);
1099
  //
1100
  // If the factory determines that a type or instance override exists, the type
1101
  // of the component created may be different than the requested type. See
1102
  //  and . See also  for
1103
  // details on factory operation.
1104
 
1105
  extern function uvm_component create_component (string requested_type_name,
1106
                                                  string name);
1107
 
1108
 
1109
  // Function: create_object
1110
  //
1111
  // A convenience function for ,
1112
  // this method calls upon the factory to create a new object
1113
  // whose type corresponds to the preregistered type name,
1114
  // ~requested_type_name~, and instance name, ~name~. This method is
1115
  // equivalent to:
1116
  //
1117
  //|  factory.create_object_by_name(requested_type_name,
1118
  //|                                get_full_name(), name);
1119
  //
1120
  // If the factory determines that a type or instance override exists, the
1121
  // type of the object created may be different than the requested type.  See
1122
  //  for details on factory operation.
1123
 
1124
  extern function uvm_object create_object (string requested_type_name,
1125
                                            string name="");
1126
 
1127
 
1128
  // Function: set_type_override_by_type
1129
  //
1130
  // A convenience function for , this
1131
  // method registers a factory override for components and objects created at
1132
  // this level of hierarchy or below. This method is equivalent to:
1133
  //
1134
  //|  factory.set_type_override_by_type(original_type, override_type,replace);
1135
  //
1136
  // The ~relative_inst_path~ is relative to this component and may include
1137
  // wildcards. The ~original_type~ represents the type that is being overridden.
1138
  // In subsequent calls to  or
1139
  // , if the requested_type matches the
1140
  // ~original_type~ and the instance paths match, the factory will produce
1141
  // the ~override_type~.
1142
  //
1143
  // The original and override type arguments are lightweight proxies to the
1144
  // types they represent. See  for information
1145
  // on usage.
1146
 
1147
  extern static function void set_type_override_by_type
1148
                                             (uvm_object_wrapper original_type,
1149
                                              uvm_object_wrapper override_type,
1150
                                              bit replace=1);
1151
 
1152
 
1153
  // Function: set_inst_override_by_type
1154
  //
1155
  // A convenience function for , this
1156
  // method registers a factory override for components and objects created at
1157
  // this level of hierarchy or below. In typical usage, this method is
1158
  // equivalent to:
1159
  //
1160
  //|  factory.set_inst_override_by_type( original_type,
1161
  //|                                     override_type,
1162
  //|                                     {get_full_name(),".",
1163
  //|                                      relative_inst_path});
1164
  //
1165
  // The ~relative_inst_path~ is relative to this component and may include
1166
  // wildcards. The ~original_type~ represents the type that is being overridden.
1167
  // In subsequent calls to  or
1168
  // , if the requested_type matches the
1169
  // ~original_type~ and the instance paths match, the factory will produce the
1170
  // ~override_type~.
1171
  //
1172
  // The original and override types are lightweight proxies to the types they
1173
  // represent. They can be obtained by calling ~type::get_type()~, if
1174
  // implemented by ~type~, or by directly calling ~type::type_id::get()~, where
1175
  // ~type~ is the user type and ~type_id~ is the name of the typedef to
1176
  //  or .
1177
  //
1178
  // If you are employing the `uvm_*_utils macros, the typedef and the get_type
1179
  // method will be implemented for you. For details on the utils macros
1180
  // refer to .
1181
  //
1182
  // The following example shows `uvm_*_utils usage:
1183
  //
1184
  //|  class comp extends uvm_component;
1185
  //|    `uvm_component_utils(comp)
1186
  //|    ...
1187
  //|  endclass
1188
  //|
1189
  //|  class mycomp extends uvm_component;
1190
  //|    `uvm_component_utils(mycomp)
1191
  //|    ...
1192
  //|  endclass
1193
  //|
1194
  //|  class block extends uvm_component;
1195
  //|    `uvm_component_utils(block)
1196
  //|    comp c_inst;
1197
  //|    virtual function void build_phase(uvm_phase phase);
1198
  //|      set_inst_override_by_type("c_inst",comp::get_type(),
1199
  //|                                         mycomp::get_type());
1200
  //|    endfunction
1201
  //|    ...
1202
  //|  endclass
1203
 
1204
  extern function void set_inst_override_by_type(string relative_inst_path,
1205
                                                 uvm_object_wrapper original_type,
1206
                                                 uvm_object_wrapper override_type);
1207
 
1208
 
1209
  // Function: set_type_override
1210
  //
1211
  // A convenience function for ,
1212
  // this method configures the factory to create an object of type
1213
  // ~override_type_name~ whenever the factory is asked to produce a type
1214
  // represented by ~original_type_name~.  This method is equivalent to:
1215
  //
1216
  //|  factory.set_type_override_by_name(original_type_name,
1217
  //|                                    override_type_name, replace);
1218
  //
1219
  // The ~original_type_name~ typically refers to a preregistered type in the
1220
  // factory. It may, however, be any arbitrary string. Subsequent calls to
1221
  // create_component or create_object with the same string and matching
1222
  // instance path will produce the type represented by override_type_name.
1223
  // The ~override_type_name~ must refer to a preregistered type in the factory.
1224
 
1225
  extern static function void set_type_override(string original_type_name,
1226
                                                string override_type_name,
1227
                                                bit    replace=1);
1228
 
1229
 
1230
  // Function: set_inst_override
1231
  //
1232
  // A convenience function for , this
1233
  // method registers a factory override for components created at this level
1234
  // of hierarchy or below. In typical usage, this method is equivalent to:
1235
  //
1236
  //|  factory.set_inst_override_by_name(original_type_name,
1237
  //|                                    override_type_name,
1238
  //|                                    {get_full_name(),".",
1239
  //|                                     relative_inst_path}
1240
  //|                                     );
1241
  //
1242
  // The ~relative_inst_path~ is relative to this component and may include
1243
  // wildcards. The ~original_type_name~ typically refers to a preregistered type
1244
  // in the factory. It may, however, be any arbitrary string. Subsequent calls
1245
  // to create_component or create_object with the same string and matching
1246
  // instance path will produce the type represented by ~override_type_name~.
1247
  // The ~override_type_name~ must refer to a preregistered type in the factory.
1248
 
1249
  extern function void set_inst_override(string relative_inst_path,
1250
                                         string original_type_name,
1251
                                         string override_type_name);
1252
 
1253
 
1254
  // Function: print_override_info
1255
  //
1256
  // This factory debug method performs the same lookup process as create_object
1257
  // and create_component, but instead of creating an object, it prints
1258
  // information about what type of object would be created given the
1259
  // provided arguments.
1260
 
1261
  extern function void print_override_info(string requested_type_name,
1262
                                           string name="");
1263
 
1264
 
1265
  //----------------------------------------------------------------------------
1266
  // Group: Hierarchical Reporting Interface
1267
  //----------------------------------------------------------------------------
1268
  //
1269
  // This interface provides versions of the set_report_* methods in the
1270
  //  base class that are applied recursively to this
1271
  // component and all its children.
1272
  //
1273
  // When a report is issued and its associated action has the LOG bit set, the
1274
  // report will be sent to its associated FILE descriptor.
1275
  //----------------------------------------------------------------------------
1276
 
1277
  // Function: set_report_id_verbosity_hier
1278
 
1279
  extern function void set_report_id_verbosity_hier (string id,
1280
                                                  int verbosity);
1281
 
1282
  // Function: set_report_severity_id_verbosity_hier
1283
  //
1284
  // These methods recursively associate the specified verbosity with reports of
1285
  // the given ~severity~, ~id~, or ~severity-id~ pair. A verbosity associated
1286
  // with a particular severity-id pair takes precedence over a verbosity
1287
  // associated with id, which takes precedence over a verbosity associated
1288
  // with a severity.
1289
  //
1290
  // For a list of severities and their default verbosities, refer to
1291
  // .
1292
 
1293
  extern function void set_report_severity_id_verbosity_hier(uvm_severity severity,
1294
                                                          string id,
1295
                                                          int verbosity);
1296
 
1297
 
1298
  // Function: set_report_severity_action_hier
1299
 
1300
  extern function void set_report_severity_action_hier (uvm_severity severity,
1301
                                                        uvm_action action);
1302
 
1303
 
1304
  // Function: set_report_id_action_hier
1305
 
1306
  extern function void set_report_id_action_hier (string id,
1307
                                                  uvm_action action);
1308
 
1309
  // Function: set_report_severity_id_action_hier
1310
  //
1311
  // These methods recursively associate the specified action with reports of
1312
  // the given ~severity~, ~id~, or ~severity-id~ pair. An action associated
1313
  // with a particular severity-id pair takes precedence over an action
1314
  // associated with id, which takes precedence over an action associated
1315
  // with a severity.
1316
  //
1317
  // For a list of severities and their default actions, refer to
1318
  // .
1319
 
1320
  extern function void set_report_severity_id_action_hier(uvm_severity severity,
1321
                                                          string id,
1322
                                                          uvm_action action);
1323
 
1324
 
1325
 
1326
  // Function: set_report_default_file_hier
1327
 
1328
  extern function void set_report_default_file_hier (UVM_FILE file);
1329
 
1330
  // Function: set_report_severity_file_hier
1331
 
1332
  extern function void set_report_severity_file_hier (uvm_severity severity,
1333
                                                      UVM_FILE file);
1334
 
1335
  // Function: set_report_id_file_hier
1336
 
1337
  extern function void set_report_id_file_hier (string id,
1338
                                                UVM_FILE file);
1339
 
1340
  // Function: set_report_severity_id_file_hier
1341
  //
1342
  // These methods recursively associate the specified FILE descriptor with
1343
  // reports of the given ~severity~, ~id~, or ~severity-id~ pair. A FILE
1344
  // associated with a particular severity-id pair takes precedence over a FILE
1345
  // associated with id, which take precedence over an a FILE associated with a
1346
  // severity, which takes precedence over the default FILE descriptor.
1347
  //
1348
  // For a list of severities and other information related to the report
1349
  // mechanism, refer to .
1350
 
1351
  extern function void set_report_severity_id_file_hier(uvm_severity severity,
1352
                                                        string id,
1353
                                                        UVM_FILE file);
1354
 
1355
 
1356
  // Function: set_report_verbosity_level_hier
1357
  //
1358
  // This method recursively sets the maximum verbosity level for reports for
1359
  // this component and all those below it. Any report from this component
1360
  // subtree whose verbosity exceeds this maximum will be ignored.
1361
  //
1362
  // See  for a list of predefined message verbosity levels
1363
  // and their meaning.
1364
 
1365
    extern function void set_report_verbosity_level_hier (int verbosity);
1366
 
1367
 
1368
  // Function: pre_abort
1369
  //
1370
  // This callback is executed when the message system is executing a
1371
  //  action. The exit action causes an immediate termination of
1372
  // the simulation, but the pre_abort callback hook gives components an
1373
  // opportunity to provide additional information to the user before
1374
  // the termination happens. For example, a test may want to executed
1375
  // the report function of a particular component even when an error
1376
  // condition has happened to force a premature termination you would
1377
  // write a function like:
1378
  //
1379
  //| function void mycomponent::pre_abort();
1380
  //|   report();
1381
  //| endfunction
1382
  //
1383
  // The pre_abort() callback hooks are called in a bottom-up fashion.
1384
 
1385
  virtual function void pre_abort;
1386
  endfunction
1387
 
1388
  //----------------------------------------------------------------------------
1389
  // Group: Recording Interface
1390
  //----------------------------------------------------------------------------
1391
  // These methods comprise the component-based transaction recording
1392
  // interface. The methods can be used to record the transactions that
1393
  // this component "sees", i.e. produces or consumes.
1394
  //
1395
  // The API and implementation are subject to change once a vendor-independent
1396
  // use-model is determined.
1397
  //----------------------------------------------------------------------------
1398
 
1399
  // Function: accept_tr
1400
  //
1401
  // This function marks the acceptance of a transaction, ~tr~, by this
1402
  // component. Specifically, it performs the following actions:
1403
  //
1404
  // - Calls the ~tr~'s  method, passing to it the
1405
  //   ~accept_time~ argument.
1406
  //
1407
  // - Calls this component's  method to allow for any post-begin
1408
  //   action in derived classes.
1409
  //
1410
  // - Triggers the component's internal accept_tr event. Any processes waiting
1411
  //   on this event will resume in the next delta cycle.
1412
 
1413
  extern function void accept_tr (uvm_transaction tr, time accept_time = 0);
1414
 
1415
 
1416
  // Function: do_accept_tr
1417
  //
1418
  // The  method calls this function to accommodate any user-defined
1419
  // post-accept action. Implementations should call super.do_accept_tr to
1420
  // ensure correct operation.
1421
 
1422
  extern virtual protected function void do_accept_tr (uvm_transaction tr);
1423
 
1424
 
1425
  // Function: begin_tr
1426
  //
1427
  // This function marks the start of a transaction, ~tr~, by this component.
1428
  // Specifically, it performs the following actions:
1429
  //
1430
  // - Calls ~tr~'s  method, passing to it the
1431
  //   ~begin_time~ argument. The ~begin_time~ should be greater than or equal
1432
  //   to the accept time. By default, when ~begin_time~ = 0, the current
1433
  //   simulation time is used.
1434
  //
1435
  //   If recording is enabled (recording_detail != UVM_OFF), then a new
1436
  //   database-transaction is started on the component's transaction stream
1437
  //   given by the stream argument. No transaction properties are recorded at
1438
  //   this time.
1439
  //
1440
  // - Calls the component's  method to allow for any post-begin
1441
  //   action in derived classes.
1442
  //
1443
  // - Triggers the component's internal begin_tr event. Any processes waiting
1444
  //   on this event will resume in the next delta cycle.
1445
  //
1446
  // A handle to the transaction is returned. The meaning of this handle, as
1447
  // well as the interpretation of the arguments ~stream_name~, ~label~, and
1448
  // ~desc~ are vendor specific.
1449
 
1450
   extern function integer begin_tr (uvm_transaction tr,
1451
                                     string stream_name="main",
1452
                                     string label="",
1453
                                     string desc="",
1454
                                     time begin_time=0,
1455
                                     integer parent_handle=0);
1456
 
1457
 
1458
  // Function: begin_child_tr
1459
  //
1460
  // This function marks the start of a child transaction, ~tr~, by this
1461
  // component. Its operation is identical to that of , except that
1462
  // an association is made between this transaction and the provided parent
1463
  // transaction. This association is vendor-specific.
1464
 
1465
  extern function integer begin_child_tr (uvm_transaction tr,
1466
                                          integer parent_handle=0,
1467
                                          string stream_name="main",
1468
                                          string label="",
1469
                                          string desc="",
1470
                                          time begin_time=0);
1471
 
1472
 
1473
  // Function: do_begin_tr
1474
  //
1475
  // The  and  methods call this function to
1476
  // accommodate any user-defined post-begin action. Implementations should call
1477
  // super.do_begin_tr to ensure correct operation.
1478
 
1479
  extern virtual protected
1480
    function void do_begin_tr (uvm_transaction tr,
1481
                               string stream_name,
1482
                               integer tr_handle);
1483
 
1484
 
1485
  // Function: end_tr
1486
  //
1487
  // This function marks the end of a transaction, ~tr~, by this component.
1488
  // Specifically, it performs the following actions:
1489
  //
1490
  // - Calls ~tr~'s  method, passing to it the
1491
  //   ~end_time~ argument. The ~end_time~ must at least be greater than the
1492
  //   begin time. By default, when ~end_time~ = 0, the current simulation time
1493
  //   is used.
1494
  //
1495
  //   The transaction's properties are recorded to the database-transaction on
1496
  //   which it was started, and then the transaction is ended. Only those
1497
  //   properties handled by the transaction's do_record method (and optional
1498
  //   `uvm_*_field macros) are recorded.
1499
  //
1500
  // - Calls the component's  method to accommodate any post-end
1501
  //   action in derived classes.
1502
  //
1503
  // - Triggers the component's internal end_tr event. Any processes waiting on
1504
  //   this event will resume in the next delta cycle.
1505
  //
1506
  // The ~free_handle~ bit indicates that this transaction is no longer needed.
1507
  // The implementation of free_handle is vendor-specific.
1508
 
1509
  extern function void end_tr (uvm_transaction tr,
1510
                               time end_time=0,
1511
                               bit free_handle=1);
1512
 
1513
 
1514
  // Function: do_end_tr
1515
  //
1516
  // The  method calls this function to accommodate any user-defined
1517
  // post-end action. Implementations should call super.do_end_tr to ensure
1518
  // correct operation.
1519
 
1520
  extern virtual protected function void do_end_tr (uvm_transaction tr,
1521
                                                    integer tr_handle);
1522
 
1523
 
1524
  // Function: record_error_tr
1525
  //
1526
  // This function marks an error transaction by a component. Properties of the
1527
  // given uvm_object, ~info~, as implemented in its  method,
1528
  // are recorded to the transaction database.
1529
  //
1530
  // An ~error_time~ of 0 indicates to use the current simulation time. The
1531
  // ~keep_active~ bit determines if the handle should remain active. If 0,
1532
  // then a zero-length error transaction is recorded. A handle to the
1533
  // database-transaction is returned.
1534
  //
1535
  // Interpretation of this handle, as well as the strings ~stream_name~,
1536
  // ~label~, and ~desc~, are vendor-specific.
1537
 
1538
  extern function integer record_error_tr (string stream_name="main",
1539
                                           uvm_object info=null,
1540
                                           string label="error_tr",
1541
                                           string desc="",
1542
                                           time   error_time=0,
1543
                                           bit    keep_active=0);
1544
 
1545
 
1546
  // Function: record_event_tr
1547
  //
1548
  // This function marks an event transaction by a component.
1549
  //
1550
  // An ~event_time~ of 0 indicates to use the current simulation time.
1551
  //
1552
  // A handle to the transaction is returned. The ~keep_active~ bit determines
1553
  // if the handle may be used for other vendor-specific purposes.
1554
  //
1555
  // The strings for ~stream_name~, ~label~, and ~desc~ are vendor-specific
1556
  // identifiers for the transaction.
1557
 
1558
  extern function integer record_event_tr (string stream_name="main",
1559
                                           uvm_object info=null,
1560
                                           string label="event_tr",
1561
                                           string desc="",
1562
                                           time   event_time=0,
1563
                                           bit    keep_active=0);
1564
 
1565
  // Function: get_tr_stream
1566
  // Returns a tr stream with ~this~ component's full name as a scope.
1567
  //
1568
  // Streams which are retrieved via this method will be stored internally,
1569
  // such that later calls to ~get_tr_stream~ will return the same stream
1570
  // reference.
1571
  //
1572
  // The stream can be removed from the internal storage via a call
1573
  // to .
1574
  //
1575
  // Parameters:
1576
  // name - Name for the stream
1577
  // stream_type_name - Type name for the stream (Default = "")
1578
  extern virtual function uvm_tr_stream get_tr_stream(string name,
1579
                                                      string stream_type_name="");
1580
 
1581
  // Function: free_tr_stream
1582
  // Frees the internal references associated with ~stream~.
1583
  //
1584
  // The next call to  will result in a newly created
1585
  // .  If the current stream is open (or closed),
1586
  // then it will be freed.
1587
  extern virtual function void free_tr_stream(uvm_tr_stream stream);
1588
 
1589
  // Variable: print_enabled
1590
  //
1591
  // This bit determines if this component should automatically be printed as a
1592
  // child of its parent object.
1593
  //
1594
  // By default, all children are printed. However, this bit allows a parent
1595
  // component to disable the printing of specific children.
1596
 
1597
  bit print_enabled = 1;
1598
 
1599
  // Variable: tr_database
1600
  //
1601
  // Specifies the  object to use for 
1602
  // and other methods in the .
1603
  // Default is .
1604
  uvm_tr_database tr_database;
1605
  extern virtual function uvm_tr_database m_get_tr_database();
1606
 
1607
  //----------------------------------------------------------------------------
1608
  //                     PRIVATE or PSUEDO-PRIVATE members
1609
  //                      *** Do not call directly ***
1610
  //         Implementation and even existence are subject to change.
1611
  //----------------------------------------------------------------------------
1612
  // Most local methods are prefixed with m_, indicating they are not
1613
  // user-level methods. SystemVerilog does not support friend classes,
1614
  // which forces some otherwise internal methods to be exposed (i.e. not
1615
  // be protected via 'local' keyword). These methods are also prefixed
1616
  // with m_ to indicate they are not intended for public use.
1617
  //
1618
  // Internal methods will not be documented, although their implementa-
1619
  // tions are freely available via the open-source license.
1620
  //----------------------------------------------------------------------------
1621
 
1622
  protected uvm_domain m_domain;    // set_domain stores our domain handle
1623
 
1624
  /*protected*/ uvm_phase  m_phase_imps[uvm_phase];    // functors to override ovm_root defaults
1625
 
1626
  //TND review protected, provide read-only accessor.
1627
  uvm_phase            m_current_phase;            // the most recently executed phase
1628
  protected process    m_phase_process;
1629
 
1630
  /*protected*/ bit  m_build_done;
1631
  /*protected*/ int  m_phasing_active;
1632
 
1633
  extern                   function void set_int_local(string field_name,
1634
                                                       uvm_bitstream_t value,
1635
                                                       bit recurse=1);
1636
 
1637
  /*protected*/ uvm_component m_parent;
1638
  protected     uvm_component m_children[string];
1639
  protected     uvm_component m_children_by_handle[uvm_component];
1640
  extern protected virtual function bit  m_add_child(uvm_component child);
1641
  extern local     virtual function void m_set_full_name();
1642
 
1643
  extern                   function void do_resolve_bindings();
1644
  extern                   function void do_flush();
1645
 
1646
  extern virtual           function void flush ();
1647
 
1648
  extern local             function void m_extract_name(string name ,
1649
                                                        output string leaf ,
1650
                                                        output string remainder );
1651
 
1652
  // overridden to disable
1653
  extern virtual function uvm_object create (string name="");
1654
  extern virtual function uvm_object clone  ();
1655
 
1656
  local uvm_tr_stream m_main_stream;
1657
  local uvm_tr_stream m_streams[string][string];
1658
  local uvm_recorder m_tr_h[uvm_transaction];
1659
  extern protected function integer m_begin_tr (uvm_transaction tr,
1660
                                                integer parent_handle=0,
1661
                                                string stream_name="main", string label="",
1662
                                                string desc="", time begin_time=0);
1663
 
1664
  string m_name;
1665
 
1666
  const static string type_name = "uvm_component";
1667
  virtual function string get_type_name();
1668
    return type_name;
1669
  endfunction
1670
 
1671
  protected uvm_event_pool event_pool;
1672
 
1673
  int unsigned recording_detail = UVM_NONE;
1674
  extern         function void   do_print(uvm_printer printer);
1675
 
1676
  // Internal methods for setting up command line messaging stuff
1677
  extern function void m_set_cl_msg_args;
1678
  extern function void m_set_cl_verb;
1679
  extern function void m_set_cl_action;
1680
  extern function void m_set_cl_sev;
1681
  extern function void m_apply_verbosity_settings(uvm_phase phase);
1682
 
1683
  // The verbosity settings may have a specific phase to start at.
1684
  // We will do this work in the phase_started callback.
1685
 
1686
  typedef struct {
1687
    string comp;
1688
    string phase;
1689
    time   offset;
1690
    uvm_verbosity verbosity;
1691
    string id;
1692
  } m_verbosity_setting;
1693
 
1694
  m_verbosity_setting m_verbosity_settings[$];
1695
  static m_verbosity_setting m_time_settings[$];
1696
 
1697
  // does the pre abort callback hierarchically
1698
  extern /*local*/ function void m_do_pre_abort;
1699
 
1700
 
1701
typedef struct  {
1702
        string arg;
1703
        string args[$];
1704
        int unsigned used;
1705
} uvm_cmdline_parsed_arg_t;
1706
 
1707
static uvm_cmdline_parsed_arg_t m_uvm_applied_cl_action[$];
1708
static uvm_cmdline_parsed_arg_t m_uvm_applied_cl_sev[$];
1709
 
1710
endclass : uvm_component
1711
 
1712
`include "base/uvm_root.svh"
1713
 
1714
//------------------------------------------------------------------------------
1715
// IMPLEMENTATION
1716
//------------------------------------------------------------------------------
1717
 
1718
//------------------------------------------------------------------------------
1719
//
1720
// CLASS- uvm_component
1721
//
1722
//------------------------------------------------------------------------------
1723
 
1724
 
1725
// new
1726
// ---
1727
 
1728
function uvm_component::new (string name, uvm_component parent);
1729
  string error_str;
1730
  uvm_root top;
1731
  uvm_coreservice_t cs;
1732
 
1733
  super.new(name);
1734
 
1735
  // If uvm_top, reset name to "" so it doesn't show in full paths then return
1736
  if (parent==null && name == "__top__") begin
1737
    set_name(""); // *** VIRTUAL
1738
    return;
1739
  end
1740
 
1741
  cs = uvm_coreservice_t::get();
1742
  top = cs.get_root();
1743
 
1744
  // Check that we're not in or past end_of_elaboration
1745
  begin
1746
    uvm_phase bld;
1747
    uvm_domain common;
1748
    common = uvm_domain::get_common_domain();
1749
    bld = common.find(uvm_build_phase::get());
1750
    if (bld == null)
1751
      uvm_report_fatal("COMP/INTERNAL",
1752
                       "attempt to find build phase object failed",UVM_NONE);
1753
    if (bld.get_state() == UVM_PHASE_DONE) begin
1754
      uvm_report_fatal("ILLCRT", {"It is illegal to create a component ('",
1755
                name,"' under '",
1756
                (parent == null ? top.get_full_name() : parent.get_full_name()),
1757
               "') after the build phase has ended."},
1758
                       UVM_NONE);
1759
    end
1760
  end
1761
 
1762
  if (name == "") begin
1763
    name.itoa(m_inst_count);
1764
    name = {"COMP_", name};
1765
  end
1766
 
1767
  if(parent == this) begin
1768
    `uvm_fatal("THISPARENT", "cannot set the parent of a component to itself")
1769
  end
1770
 
1771
  if (parent == null)
1772
    parent = top;
1773
 
1774
  if(uvm_report_enabled(UVM_MEDIUM+1, UVM_INFO, "NEWCOMP"))
1775
    `uvm_info("NEWCOMP", {"Creating ",
1776
      (parent==top?"uvm_top":parent.get_full_name()),".",name},UVM_MEDIUM+1)
1777
 
1778
  if (parent.has_child(name) && this != parent.get_child(name)) begin
1779
    if (parent == top) begin
1780
      error_str = {"Name '",name,"' is not unique to other top-level ",
1781
      "instances. If parent is a module, build a unique name by combining the ",
1782
      "the module name and component name: $sformatf(\"\%m.\%s\",\"",name,"\")."};
1783
      `uvm_fatal("CLDEXT",error_str)
1784
    end
1785
    else
1786
      `uvm_fatal("CLDEXT",
1787
        $sformatf("Cannot set '%s' as a child of '%s', %s",
1788
                  name, parent.get_full_name(),
1789
                  "which already has a child by that name."))
1790
    return;
1791
  end
1792
 
1793
  m_parent = parent;
1794
 
1795
  set_name(name); // *** VIRTUAL
1796
 
1797
  if (!m_parent.m_add_child(this))
1798
    m_parent = null;
1799
 
1800
  event_pool = new("event_pool");
1801
 
1802
  m_domain = parent.m_domain;     // by default, inherit domains from parents
1803
 
1804
  // Now that inst name is established, reseed (if use_uvm_seeding is set)
1805
  reseed();
1806
 
1807
  // Do local configuration settings
1808
  if (!uvm_config_db #(uvm_bitstream_t)::get(this, "", "recording_detail", recording_detail))
1809
        void'(uvm_config_db #(int)::get(this, "", "recording_detail", recording_detail));
1810
 
1811
  m_rh.set_name(get_full_name());
1812
  set_report_verbosity_level(parent.get_report_verbosity_level());
1813
 
1814
  m_set_cl_msg_args();
1815
 
1816
endfunction
1817
 
1818
 
1819
// m_add_child
1820
// -----------
1821
 
1822
function bit uvm_component::m_add_child(uvm_component child);
1823
 
1824
  if (m_children.exists(child.get_name()) &&
1825
      m_children[child.get_name()] != child) begin
1826
      `uvm_warning("BDCLD",
1827
        $sformatf("A child with the name '%0s' (type=%0s) already exists.",
1828
           child.get_name(), m_children[child.get_name()].get_type_name()))
1829
      return 0;
1830
  end
1831
 
1832
  if (m_children_by_handle.exists(child)) begin
1833
      `uvm_warning("BDCHLD",
1834
        $sformatf("A child with the name '%0s' %0s %0s'",
1835
                  child.get_name(),
1836
                  "already exists in parent under name '",
1837
                  m_children_by_handle[child].get_name()))
1838
      return 0;
1839
    end
1840
 
1841
  m_children[child.get_name()] = child;
1842
  m_children_by_handle[child] = child;
1843
  return 1;
1844
endfunction
1845
 
1846
 
1847
 
1848
//------------------------------------------------------------------------------
1849
//
1850
// Hierarchy Methods
1851
//
1852
//------------------------------------------------------------------------------
1853
 
1854
 
1855
// get_children
1856
// ------------
1857
 
1858
function void uvm_component::get_children(ref uvm_component children[$]);
1859
  foreach(m_children[i])
1860
    children.push_back(m_children[i]);
1861
endfunction
1862
 
1863
 
1864
// get_first_child
1865
// ---------------
1866
 
1867
function int uvm_component::get_first_child(ref string name);
1868
  return m_children.first(name);
1869
endfunction
1870
 
1871
 
1872
// get_next_child
1873
// --------------
1874
 
1875
function int uvm_component::get_next_child(ref string name);
1876
  return m_children.next(name);
1877
endfunction
1878
 
1879
 
1880
// get_child
1881
// ---------
1882
 
1883
function uvm_component uvm_component::get_child(string name);
1884
  if (m_children.exists(name))
1885
    return m_children[name];
1886
  `uvm_warning("NOCHILD",{"Component with name '",name,
1887
       "' is not a child of component '",get_full_name(),"'"})
1888
  return null;
1889
endfunction
1890
 
1891
 
1892
// has_child
1893
// ---------
1894
 
1895
function int uvm_component::has_child(string name);
1896
  return m_children.exists(name);
1897
endfunction
1898
 
1899
 
1900
// get_num_children
1901
// ----------------
1902
 
1903
function int uvm_component::get_num_children();
1904
  return m_children.num();
1905
endfunction
1906
 
1907
 
1908
// get_full_name
1909
// -------------
1910
 
1911
function string uvm_component::get_full_name ();
1912
  // Note- Implementation choice to construct full name once since the
1913
  // full name may be used often for lookups.
1914
  if(m_name == "")
1915
    return get_name();
1916
  else
1917
    return m_name;
1918
endfunction
1919
 
1920
 
1921
// get_parent
1922
// ----------
1923
 
1924
function uvm_component uvm_component::get_parent ();
1925
  return  m_parent;
1926
endfunction
1927
 
1928
 
1929
// set_name
1930
// --------
1931
 
1932
function void uvm_component::set_name (string name);
1933
  if(m_name != "") begin
1934
    `uvm_error("INVSTNM", $sformatf("It is illegal to change the name of a component. The component name will not be changed to \"%s\"", name))
1935
    return;
1936
  end
1937
  super.set_name(name);
1938
  m_set_full_name();
1939
 
1940
endfunction
1941
 
1942
 
1943
// m_set_full_name
1944
// ---------------
1945
 
1946
function void uvm_component::m_set_full_name();
1947
  uvm_root top;
1948
  top = uvm_top;
1949
  if (m_parent == top || m_parent==null)
1950
    m_name = get_name();
1951
  else
1952
    m_name = {m_parent.get_full_name(), ".", get_name()};
1953
 
1954
  foreach (m_children[c]) begin
1955
    uvm_component tmp;
1956
    tmp = m_children[c];
1957
    tmp.m_set_full_name();
1958
  end
1959
 
1960
endfunction
1961
 
1962
 
1963
// lookup
1964
// ------
1965
 
1966
function uvm_component uvm_component::lookup( string name );
1967
 
1968
  string leaf , remainder;
1969
  uvm_component comp;
1970
  uvm_root top;
1971
  uvm_coreservice_t cs;
1972
  cs = uvm_coreservice_t::get();
1973
  top = cs.get_root();
1974
 
1975
  comp = this;
1976
 
1977
  m_extract_name(name, leaf, remainder);
1978
 
1979
  if (leaf == "") begin
1980
    comp = top; // absolute lookup
1981
    m_extract_name(remainder, leaf, remainder);
1982
  end
1983
 
1984
  if (!comp.has_child(leaf)) begin
1985
    `uvm_warning("Lookup Error",
1986
       $sformatf("Cannot find child %0s",leaf))
1987
    return null;
1988
  end
1989
 
1990
  if( remainder != "" )
1991
    return comp.m_children[leaf].lookup(remainder);
1992
 
1993
  return comp.m_children[leaf];
1994
 
1995
endfunction
1996
 
1997
 
1998
// get_depth
1999
// ---------
2000
 
2001
function int unsigned uvm_component::get_depth();
2002
  if(m_name == "") return 0;
2003
  get_depth = 1;
2004
  foreach(m_name[i])
2005
    if(m_name[i] == ".") ++get_depth;
2006
endfunction
2007
 
2008
 
2009
// m_extract_name
2010
// --------------
2011
 
2012
function void uvm_component::m_extract_name(input string name ,
2013
                                            output string leaf ,
2014
                                            output string remainder );
2015
  int i , len;
2016
  string extract_str;
2017
  len = name.len();
2018
 
2019
  for( i = 0; i < name.len(); i++ ) begin
2020
    if( name[i] == "." ) begin
2021
      break;
2022
    end
2023
  end
2024
 
2025
  if( i == len ) begin
2026
    leaf = name;
2027
    remainder = "";
2028
    return;
2029
  end
2030
 
2031
  leaf = name.substr( 0 , i - 1 );
2032
  remainder = name.substr( i + 1 , len - 1 );
2033
 
2034
  return;
2035
endfunction
2036
 
2037
 
2038
// flush
2039
// -----
2040
 
2041
function void uvm_component::flush();
2042
  return;
2043
endfunction
2044
 
2045
 
2046
// do_flush  (flush_hier?)
2047
// --------
2048
 
2049
function void uvm_component::do_flush();
2050
  foreach( m_children[s] )
2051
    m_children[s].do_flush();
2052
  flush();
2053
endfunction
2054
 
2055
 
2056
 
2057
//------------------------------------------------------------------------------
2058
//
2059
// Factory Methods
2060
//
2061
//------------------------------------------------------------------------------
2062
 
2063
 
2064
// create
2065
// ------
2066
 
2067
function uvm_object  uvm_component::create (string name ="");
2068
  `uvm_error("ILLCRT",
2069
    "create cannot be called on a uvm_component. Use create_component instead.")
2070
  return null;
2071
endfunction
2072
 
2073
 
2074
// clone
2075
// ------
2076
 
2077
function uvm_object  uvm_component::clone ();
2078
  `uvm_error("ILLCLN", $sformatf("Attempting to clone '%s'.  Clone cannot be called on a uvm_component.  The clone target variable will be set to null.", get_full_name()))
2079
  return null;
2080
endfunction
2081
 
2082
 
2083
// print_override_info
2084
// -------------------
2085
 
2086
function void  uvm_component::print_override_info (string requested_type_name,
2087
                                                   string name="");
2088
  uvm_coreservice_t cs = uvm_coreservice_t::get();
2089
  uvm_factory factory=cs.get_factory();
2090
  factory.debug_create_by_name(requested_type_name, get_full_name(), name);
2091
endfunction
2092
 
2093
 
2094
// create_component
2095
// ----------------
2096
 
2097
function uvm_component uvm_component::create_component (string requested_type_name,
2098
                                                        string name);
2099
  uvm_coreservice_t cs = uvm_coreservice_t::get();
2100
  uvm_factory factory=cs.get_factory();
2101
  return factory.create_component_by_name(requested_type_name, get_full_name(),
2102
                                          name, this);
2103
endfunction
2104
 
2105
 
2106
// create_object
2107
// -------------
2108
 
2109
function uvm_object uvm_component::create_object (string requested_type_name,
2110
                                                  string name="");
2111
  uvm_coreservice_t cs = uvm_coreservice_t::get();
2112
  uvm_factory factory=cs.get_factory();
2113
  return factory.create_object_by_name(requested_type_name,
2114
                                       get_full_name(), name);
2115
endfunction
2116
 
2117
 
2118
// set_type_override (static)
2119
// -----------------
2120
 
2121
function void uvm_component::set_type_override (string original_type_name,
2122
                                                string override_type_name,
2123
                                                bit    replace=1);
2124
   uvm_coreservice_t cs = uvm_coreservice_t::get();
2125
   uvm_factory factory=cs.get_factory();
2126
   factory.set_type_override_by_name(original_type_name,override_type_name, replace);
2127
endfunction
2128
 
2129
 
2130
// set_type_override_by_type (static)
2131
// -------------------------
2132
 
2133
function void uvm_component::set_type_override_by_type (uvm_object_wrapper original_type,
2134
                                                        uvm_object_wrapper override_type,
2135
                                                        bit    replace=1);
2136
  uvm_coreservice_t cs = uvm_coreservice_t::get();
2137
  uvm_factory factory=cs.get_factory();
2138
   factory.set_type_override_by_type(original_type, override_type, replace);
2139
endfunction
2140
 
2141
 
2142
// set_inst_override
2143
// -----------------
2144
 
2145
function void  uvm_component::set_inst_override (string relative_inst_path,
2146
                                                 string original_type_name,
2147
                                                 string override_type_name);
2148
  string full_inst_path;
2149
  uvm_coreservice_t cs = uvm_coreservice_t::get();
2150
  uvm_factory factory=cs.get_factory();
2151
 
2152
  if (relative_inst_path == "")
2153
    full_inst_path = get_full_name();
2154
  else
2155
    full_inst_path = {get_full_name(), ".", relative_inst_path};
2156
 
2157
  factory.set_inst_override_by_name(
2158
                            original_type_name,
2159
                            override_type_name,
2160
                            full_inst_path);
2161
endfunction
2162
 
2163
 
2164
// set_inst_override_by_type
2165
// -------------------------
2166
 
2167
function void uvm_component::set_inst_override_by_type (string relative_inst_path,
2168
                                                        uvm_object_wrapper original_type,
2169
                                                        uvm_object_wrapper override_type);
2170
  string full_inst_path;
2171
  uvm_coreservice_t cs = uvm_coreservice_t::get();
2172
  uvm_factory factory=cs.get_factory();
2173
 
2174
  if (relative_inst_path == "")
2175
    full_inst_path = get_full_name();
2176
  else
2177
    full_inst_path = {get_full_name(), ".", relative_inst_path};
2178
 
2179
  factory.set_inst_override_by_type(original_type, override_type, full_inst_path);
2180
 
2181
endfunction
2182
 
2183
 
2184
 
2185
//------------------------------------------------------------------------------
2186
//
2187
// Hierarchical report configuration interface
2188
//
2189
//------------------------------------------------------------------------------
2190
 
2191
// set_report_id_verbosity_hier
2192
// -------------------------
2193
 
2194
function void uvm_component::set_report_id_verbosity_hier( string id, int verbosity);
2195
  set_report_id_verbosity(id, verbosity);
2196
  foreach( m_children[c] )
2197
    m_children[c].set_report_id_verbosity_hier(id, verbosity);
2198
endfunction
2199
 
2200
 
2201
// set_report_severity_id_verbosity_hier
2202
// ----------------------------------
2203
 
2204
function void uvm_component::set_report_severity_id_verbosity_hier( uvm_severity severity,
2205
                                                                 string id,
2206
                                                                 int verbosity);
2207
  set_report_severity_id_verbosity(severity, id, verbosity);
2208
  foreach( m_children[c] )
2209
    m_children[c].set_report_severity_id_verbosity_hier(severity, id, verbosity);
2210
endfunction
2211
 
2212
 
2213
// set_report_severity_action_hier
2214
// -------------------------
2215
 
2216
function void uvm_component::set_report_severity_action_hier( uvm_severity severity,
2217
                                                           uvm_action action);
2218
  set_report_severity_action(severity, action);
2219
  foreach( m_children[c] )
2220
    m_children[c].set_report_severity_action_hier(severity, action);
2221
endfunction
2222
 
2223
 
2224
// set_report_id_action_hier
2225
// -------------------------
2226
 
2227
function void uvm_component::set_report_id_action_hier( string id, uvm_action action);
2228
  set_report_id_action(id, action);
2229
  foreach( m_children[c] )
2230
    m_children[c].set_report_id_action_hier(id, action);
2231
endfunction
2232
 
2233
 
2234
// set_report_severity_id_action_hier
2235
// ----------------------------------
2236
 
2237
function void uvm_component::set_report_severity_id_action_hier( uvm_severity severity,
2238
                                                                 string id,
2239
                                                                 uvm_action action);
2240
  set_report_severity_id_action(severity, id, action);
2241
  foreach( m_children[c] )
2242
    m_children[c].set_report_severity_id_action_hier(severity, id, action);
2243
endfunction
2244
 
2245
 
2246
// set_report_severity_file_hier
2247
// -----------------------------
2248
 
2249
function void uvm_component::set_report_severity_file_hier( uvm_severity severity,
2250
                                                            UVM_FILE file);
2251
  set_report_severity_file(severity, file);
2252
  foreach( m_children[c] )
2253
    m_children[c].set_report_severity_file_hier(severity, file);
2254
endfunction
2255
 
2256
 
2257
// set_report_default_file_hier
2258
// ----------------------------
2259
 
2260
function void uvm_component::set_report_default_file_hier( UVM_FILE file);
2261
  set_report_default_file(file);
2262
  foreach( m_children[c] )
2263
    m_children[c].set_report_default_file_hier(file);
2264
endfunction
2265
 
2266
 
2267
// set_report_id_file_hier
2268
// -----------------------
2269
 
2270
function void uvm_component::set_report_id_file_hier( string id, UVM_FILE file);
2271
  set_report_id_file(id, file);
2272
  foreach( m_children[c] )
2273
    m_children[c].set_report_id_file_hier(id, file);
2274
endfunction
2275
 
2276
 
2277
// set_report_severity_id_file_hier
2278
// --------------------------------
2279
 
2280
function void uvm_component::set_report_severity_id_file_hier ( uvm_severity severity,
2281
                                                                string id,
2282
                                                                UVM_FILE file);
2283
  set_report_severity_id_file(severity, id, file);
2284
  foreach( m_children[c] )
2285
    m_children[c].set_report_severity_id_file_hier(severity, id, file);
2286
endfunction
2287
 
2288
 
2289
// set_report_verbosity_level_hier
2290
// -------------------------------
2291
 
2292
function void uvm_component::set_report_verbosity_level_hier(int verbosity);
2293
  set_report_verbosity_level(verbosity);
2294
  foreach( m_children[c] )
2295
    m_children[c].set_report_verbosity_level_hier(verbosity);
2296
endfunction
2297
 
2298
 
2299
 
2300
//------------------------------------------------------------------------------
2301
//
2302
// Phase interface
2303
//
2304
//------------------------------------------------------------------------------
2305
 
2306
 
2307
// phase methods
2308
//--------------
2309
// these are prototypes for the methods to be implemented in user components
2310
// build_phase() has a default implementation, the others have an empty default
2311
 
2312
function void uvm_component::build_phase(uvm_phase phase);
2313
  m_build_done = 1;
2314
  build();
2315
endfunction
2316
 
2317
// Backward compatibility build function
2318
 
2319
function void uvm_component::build();
2320
  m_build_done = 1;
2321
  apply_config_settings(print_config_matches);
2322
  if(m_phasing_active == 0) begin
2323
    uvm_report_warning("UVM_DEPRECATED", "build()/build_phase() has been called explicitly, outside of the phasing system. This usage of build is deprecated and may lead to unexpected behavior.");
2324
  end
2325
endfunction
2326
 
2327
// these phase methods are common to all components in UVM. For backward
2328
// compatibility, they call the old style name (without the _phse)
2329
 
2330
function void uvm_component::connect_phase(uvm_phase phase);
2331
  connect();
2332
  return;
2333
endfunction
2334
function void uvm_component::start_of_simulation_phase(uvm_phase phase);
2335
  start_of_simulation();
2336
  return;
2337
endfunction
2338
function void uvm_component::end_of_elaboration_phase(uvm_phase phase);
2339
  end_of_elaboration();
2340
  return;
2341
endfunction
2342
task          uvm_component::run_phase(uvm_phase phase);
2343
  run();
2344
  return;
2345
endtask
2346
function void uvm_component::extract_phase(uvm_phase phase);
2347
  extract();
2348
  return;
2349
endfunction
2350
function void uvm_component::check_phase(uvm_phase phase);
2351
  check();
2352
  return;
2353
endfunction
2354
function void uvm_component::report_phase(uvm_phase phase);
2355
  report();
2356
  return;
2357
endfunction
2358
 
2359
 
2360
// These are the old style phase names. In order for runtime phase names
2361
// to not conflict with user names, the _phase postfix was added.
2362
 
2363
function void uvm_component::connect();             return; endfunction
2364
function void uvm_component::start_of_simulation(); return; endfunction
2365
function void uvm_component::end_of_elaboration();  return; endfunction
2366
task          uvm_component::run();                 return; endtask
2367
function void uvm_component::extract();             return; endfunction
2368
function void uvm_component::check();               return; endfunction
2369
function void uvm_component::report();              return; endfunction
2370
function void uvm_component::final_phase(uvm_phase phase);         return; endfunction
2371
 
2372
// these runtime phase methods are only called if a set_domain() is done
2373
 
2374
task uvm_component::pre_reset_phase(uvm_phase phase);      return; endtask
2375
task uvm_component::reset_phase(uvm_phase phase);          return; endtask
2376
task uvm_component::post_reset_phase(uvm_phase phase);     return; endtask
2377
task uvm_component::pre_configure_phase(uvm_phase phase);  return; endtask
2378
task uvm_component::configure_phase(uvm_phase phase);      return; endtask
2379
task uvm_component::post_configure_phase(uvm_phase phase); return; endtask
2380
task uvm_component::pre_main_phase(uvm_phase phase);       return; endtask
2381
task uvm_component::main_phase(uvm_phase phase);           return; endtask
2382
task uvm_component::post_main_phase(uvm_phase phase);      return; endtask
2383
task uvm_component::pre_shutdown_phase(uvm_phase phase);   return; endtask
2384
task uvm_component::shutdown_phase(uvm_phase phase);       return; endtask
2385
task uvm_component::post_shutdown_phase(uvm_phase phase);  return; endtask
2386
 
2387
 
2388
//------------------------------
2389
// current phase convenience API
2390
//------------------------------
2391
 
2392
 
2393
// phase_started
2394
// -------------
2395
// phase_started() and phase_ended() are extra callbacks called at the
2396
// beginning and end of each phase, respectively.  Since they are
2397
// called for all phases the phase is passed in as an argument so the
2398
// extender can decide what to do, if anything, for each phase.
2399
 
2400
function void uvm_component::phase_started(uvm_phase phase);
2401
endfunction
2402
 
2403
// phase_ended
2404
// -----------
2405
 
2406
function void uvm_component::phase_ended(uvm_phase phase);
2407
endfunction
2408
 
2409
 
2410
// phase_ready_to_end
2411
// ------------------
2412
 
2413
function void uvm_component::phase_ready_to_end (uvm_phase phase);
2414
endfunction
2415
 
2416
//------------------------------
2417
// phase / schedule / domain API
2418
//------------------------------
2419
// methods for VIP creators and integrators to use to set up schedule domains
2420
// - a schedule is a named, organized group of phases for a component base type
2421
// - a domain is a named instance of a schedule in the master phasing schedule
2422
 
2423
 
2424
// define_domain
2425
// -------------
2426
 
2427
function void uvm_component::define_domain(uvm_domain domain);
2428
  uvm_phase schedule;
2429
  //schedule = domain.find(uvm_domain::get_uvm_schedule());
2430
  schedule = domain.find_by_name("uvm_sched");
2431
  if (schedule == null) begin
2432
    uvm_domain common;
2433
    schedule = new("uvm_sched", UVM_PHASE_SCHEDULE);
2434
    uvm_domain::add_uvm_phases(schedule);
2435
    domain.add(schedule);
2436
    common = uvm_domain::get_common_domain();
2437
    if (common.find(domain,0) == null)
2438
      common.add(domain,.with_phase(uvm_run_phase::get()));
2439
  end
2440
 
2441
endfunction
2442
 
2443
 
2444
// set_domain
2445
// ----------
2446
// assigns this component [tree] to a domain. adds required schedules into graph
2447
// If called from build, ~hier~ won't recurse into all chilren (which don't exist yet)
2448
// If we have components inherit their parent's domain by default, then ~hier~
2449
// isn't needed and we need a way to prevent children from inheriting this component's domain
2450
 
2451
function void uvm_component::set_domain(uvm_domain domain, int hier=1);
2452
 
2453
  // build and store the custom domain
2454
  m_domain = domain;
2455
  define_domain(domain);
2456
  if (hier)
2457
    foreach (m_children[c])
2458
      m_children[c].set_domain(domain);
2459
endfunction
2460
 
2461
// get_domain
2462
// ----------
2463
//
2464
function uvm_domain uvm_component::get_domain();
2465
  return m_domain;
2466
endfunction
2467
 
2468
 
2469
// set_phase_imp
2470
// -------------
2471
 
2472
function void uvm_component::set_phase_imp(uvm_phase phase, uvm_phase imp, int hier=1);
2473
  m_phase_imps[phase] = imp;
2474
  if (hier)
2475
    foreach (m_children[c])
2476
      m_children[c].set_phase_imp(phase,imp,hier);
2477
endfunction
2478
 
2479
 
2480
//--------------------------
2481
// phase runtime control API
2482
//--------------------------
2483
 
2484
`ifndef UVM_NO_DEPRECATED
2485
// do_kill_all
2486
// -----------
2487
 
2488
function void uvm_component::do_kill_all();
2489
  foreach(m_children[c])
2490
    m_children[c].do_kill_all();
2491
  kill();
2492
endfunction
2493
 
2494
 
2495
// kill
2496
// ----
2497
 
2498
function void uvm_component::kill();
2499
    if (m_phase_process != null) begin
2500
      m_phase_process.kill;
2501
      m_phase_process = null;
2502
    end
2503
endfunction
2504
`endif
2505
 
2506
// suspend
2507
// -------
2508
 
2509
task uvm_component::suspend();
2510
   `uvm_warning("COMP/SPND/UNIMP", "suspend() not implemented")
2511
endtask
2512
 
2513
 
2514
// resume
2515
// ------
2516
 
2517
task uvm_component::resume();
2518
   `uvm_warning("COMP/RSUM/UNIMP", "resume() not implemented")
2519
endtask
2520
 
2521
 
2522
// status
2523
//-------
2524
 
2525
`ifndef UVM_NO_DEPRECATED
2526
function string uvm_component::status();
2527
 
2528
  `ifdef UVM_USE_SUSPEND_RESUME
2529
   `ifdef UVM_USE_PROCESS_STATE
2530
    process::state ps;
2531
 
2532
    if(m_phase_process == null)
2533
      return "";
2534
 
2535
    ps = m_phase_process.status();
2536
 
2537
    return ps.name();
2538
  `else
2539
    if(m_phase_process == null)
2540
      return "";
2541
 
2542
    case(m_phase_process.status())
2543
      0: return "FINISHED";
2544
      1: return "RUNNING";
2545
      2: return "WAITING";
2546
      3: return "SUSPENDED";
2547
      4: return "KILLED";
2548
      default: return "";
2549
    endcase
2550
  `endif
2551
  `endif
2552
 
2553
   return "";
2554
 
2555
endfunction
2556
 
2557
// stop
2558
// ----
2559
 
2560
task uvm_component::stop(string ph_name);
2561
  return;
2562
endtask
2563
 
2564
 
2565
// stop_phase
2566
// ----------
2567
 
2568
task uvm_component::stop_phase(uvm_phase phase);
2569
  stop(phase.get_name());
2570
  return;
2571
endtask
2572
`endif
2573
 
2574
 
2575
// resolve_bindings
2576
// ----------------
2577
 
2578
function void uvm_component::resolve_bindings();
2579
  return;
2580
endfunction
2581
 
2582
 
2583
// do_resolve_bindings
2584
// -------------------
2585
 
2586
function void uvm_component::do_resolve_bindings();
2587
  foreach( m_children[s] )
2588
    m_children[s].do_resolve_bindings();
2589
  resolve_bindings();
2590
endfunction
2591
 
2592
 
2593
 
2594
//------------------------------------------------------------------------------
2595
//
2596
// Recording interface
2597
//
2598
//------------------------------------------------------------------------------
2599
 
2600
// accept_tr
2601
// ---------
2602
 
2603
function void uvm_component::accept_tr (uvm_transaction tr,
2604
                                        time accept_time=0);
2605
  uvm_event#(uvm_object) e;
2606
  tr.accept_tr(accept_time);
2607
  do_accept_tr(tr);
2608
  e = event_pool.get("accept_tr");
2609
  if(e!=null)
2610
    e.trigger();
2611
endfunction
2612
 
2613
// begin_tr
2614
// --------
2615
 
2616
function integer uvm_component::begin_tr (uvm_transaction tr,
2617
                                          string stream_name="main",
2618
                                          string label="",
2619
                                          string desc="",
2620
                                          time begin_time=0,
2621
                                          integer parent_handle=0);
2622
   return m_begin_tr(tr, parent_handle, stream_name, label, desc, begin_time);
2623
endfunction
2624
 
2625
// begin_child_tr
2626
// --------------
2627
 
2628
function integer uvm_component::begin_child_tr (uvm_transaction tr,
2629
                                                integer parent_handle=0,
2630
                                                string stream_name="main",
2631
                                                string label="",
2632
                                                string desc="",
2633
                                                time begin_time=0);
2634
  return m_begin_tr(tr, parent_handle, stream_name, label, desc, begin_time);
2635
endfunction
2636
 
2637
// m_get_tr_database
2638
// ---------------------
2639
   function uvm_tr_database uvm_component::m_get_tr_database();
2640
      if (tr_database == null) begin
2641
         uvm_coreservice_t cs = uvm_coreservice_t::get();
2642
         tr_database = cs.get_default_tr_database();
2643
      end
2644
      return tr_database;
2645
   endfunction : m_get_tr_database
2646
 
2647
// get_tr_stream
2648
// ------------
2649
function uvm_tr_stream uvm_component::get_tr_stream( string name,
2650
                                                      string stream_type_name="" );
2651
   uvm_tr_database db = m_get_tr_database();
2652
   if (!m_streams.exists(name) || !m_streams[name].exists(stream_type_name))
2653
     m_streams[name][stream_type_name] = db.open_stream(name, this.get_full_name(), stream_type_name);
2654
   return m_streams[name][stream_type_name];
2655
endfunction : get_tr_stream
2656
 
2657
// free_tr_stream
2658
// --------------
2659
function void uvm_component::free_tr_stream(uvm_tr_stream stream);
2660
   // Check the null case...
2661
   if (stream == null)
2662
     return;
2663
 
2664
   // Then make sure this name/type_name combo exists
2665
   if (!m_streams.exists(stream.get_name()) ||
2666
       !m_streams[stream.get_name()].exists(stream.get_stream_type_name()))
2667
     return;
2668
 
2669
   // Then make sure this name/type_name combo is THIS stream
2670
   if (m_streams[stream.get_name()][stream.get_stream_type_name()] != stream)
2671
     return;
2672
 
2673
   // Then delete it from the arrays
2674
   m_streams[stream.get_name()].delete(stream.get_type_name());
2675
   if (m_streams[stream.get_name()].size() == 0)
2676
     m_streams.delete(stream.get_name());
2677
 
2678
   // Finally, free the stream if necessary
2679
   if (stream.is_open() || stream.is_closed()) begin
2680
      stream.free();
2681
   end
2682
endfunction : free_tr_stream
2683
 
2684
// m_begin_tr
2685
// ----------
2686
 
2687
function integer uvm_component::m_begin_tr (uvm_transaction tr,
2688
                                            integer parent_handle=0,
2689
                                            string stream_name="main",
2690
                                            string label="",
2691
                                            string desc="",
2692
                                            time begin_time=0);
2693
   uvm_event#(uvm_object) e;
2694
   string    name;
2695
   string    kind;
2696
   uvm_tr_database db;
2697
   integer   handle, link_handle;
2698
   uvm_tr_stream stream;
2699
   uvm_recorder recorder, parent_recorder, link_recorder;
2700
 
2701
   if (tr == null)
2702
     return 0;
2703
 
2704
   db = m_get_tr_database();
2705
 
2706
   if (parent_handle != 0)
2707
     parent_recorder = uvm_recorder::get_recorder_from_handle(parent_handle);
2708
 
2709
   if (parent_recorder == null) begin
2710
      uvm_sequence_item seq;
2711
      if ($cast(seq,tr)) begin
2712
         uvm_sequence_base parent_seq = seq.get_parent_sequence();
2713
         if (parent_seq != null) begin
2714
            parent_recorder = parent_seq.m_tr_recorder;
2715
         end
2716
      end
2717
   end
2718
 
2719
   if(parent_recorder != null) begin
2720
      link_handle = tr.begin_child_tr(begin_time, parent_recorder.get_handle());
2721
   end
2722
   else begin
2723
      link_handle = tr.begin_tr(begin_time);
2724
   end
2725
 
2726
   if (link_handle != 0)
2727
     link_recorder = uvm_recorder::get_recorder_from_handle(link_handle);
2728
 
2729
 
2730
   if (tr.get_name() != "")
2731
     name = tr.get_name();
2732
   else
2733
     name = tr.get_type_name();
2734
 
2735
   if (uvm_verbosity'(recording_detail) != UVM_NONE) begin
2736
      if ((stream_name == "") || (stream_name == "main")) begin
2737
        if (m_main_stream == null)
2738
           m_main_stream = db.open_stream("main", this.get_full_name(), "TVM");
2739
         stream = m_main_stream;
2740
      end
2741
      else
2742
        stream = get_tr_stream(stream_name);
2743
 
2744
      if (stream != null ) begin
2745
         kind = (parent_recorder == null) ? "Begin_No_Parent, Link" : "Begin_End, Link";
2746
 
2747
         recorder = stream.open_recorder(name, begin_time, kind);
2748
 
2749
         if (recorder != null) begin
2750
            if (label != "")
2751
              recorder.record_string("label", label);
2752
            if (desc != "")
2753
              recorder.record_string("desc", desc);
2754
 
2755
            if (parent_recorder != null) begin
2756
               tr_database.establish_link(uvm_parent_child_link::get_link(parent_recorder,
2757
                                                                          recorder));
2758
            end
2759
 
2760
            if (link_recorder != null) begin
2761
               tr_database.establish_link(uvm_related_link::get_link(recorder,
2762
                                                                     link_recorder));
2763
            end
2764
            m_tr_h[tr] = recorder;
2765
         end
2766
      end
2767
 
2768
      handle = (recorder == null) ? 0 : recorder.get_handle();
2769
      do_begin_tr(tr, stream_name, handle);
2770
 
2771
   end
2772
 
2773
   e = event_pool.get("begin_tr");
2774
   if (e!=null)
2775
     e.trigger(tr);
2776
 
2777
   return handle;
2778
 
2779
endfunction
2780
 
2781
 
2782
// end_tr
2783
// ------
2784
 
2785
function void uvm_component::end_tr (uvm_transaction tr,
2786
                                     time end_time=0,
2787
                                     bit free_handle=1);
2788
   uvm_event#(uvm_object) e;
2789
   uvm_recorder recorder;
2790
   uvm_tr_database db = m_get_tr_database();
2791
 
2792
   if (tr == null)
2793
     return;
2794
 
2795
   tr.end_tr(end_time,free_handle);
2796
 
2797
   if (uvm_verbosity'(recording_detail) != UVM_NONE) begin
2798
 
2799
      if (m_tr_h.exists(tr)) begin
2800
 
2801
         recorder = m_tr_h[tr];
2802
 
2803
         do_end_tr(tr, recorder.get_handle()); // callback
2804
 
2805
         m_tr_h.delete(tr);
2806
 
2807
         tr.record(recorder);
2808
 
2809
         recorder.close(end_time);
2810
 
2811
         if (free_handle)
2812
           recorder.free();
2813
 
2814
      end
2815
      else begin
2816
         do_end_tr(tr, 0); // callback
2817
      end
2818
 
2819
   end
2820
 
2821
   e = event_pool.get("end_tr");
2822
   if(e!=null)
2823
     e.trigger();
2824
 
2825
endfunction
2826
 
2827
 
2828
// record_error_tr
2829
// ---------------
2830
 
2831
function integer uvm_component::record_error_tr (string stream_name="main",
2832
                                                 uvm_object info=null,
2833
                                                 string label="error_tr",
2834
                                                 string desc="",
2835
                                                 time   error_time=0,
2836
                                                 bit    keep_active=0);
2837
   uvm_recorder recorder;
2838
   string etype;
2839
   uvm_tr_stream stream;
2840
   uvm_tr_database db = m_get_tr_database();
2841
   integer handle;
2842
 
2843
   if(keep_active) etype = "Error, Link";
2844
   else etype = "Error";
2845
 
2846
   if(error_time == 0) error_time = $realtime;
2847
 
2848
   if ((stream_name=="") || (stream_name=="main")) begin
2849
      if (m_main_stream == null)
2850
        m_main_stream = tr_database.open_stream("main", this.get_full_name(), "TVM");
2851
      stream = m_main_stream;
2852
   end
2853
   else
2854
     stream = get_tr_stream(stream_name);
2855
 
2856
   handle = 0;
2857
   if (stream != null) begin
2858
 
2859
      recorder = stream.open_recorder(label,
2860
                                    error_time,
2861
                                    etype);
2862
 
2863
      if (recorder != null) begin
2864
         if (label != "")
2865
           recorder.record_string("label", label);
2866
         if (desc != "")
2867
           recorder.record_string("desc", desc);
2868
         if (info!=null)
2869
           info.record(recorder);
2870
 
2871
         recorder.close(error_time);
2872
 
2873
         if (keep_active == 0) begin
2874
            recorder.free();
2875
         end
2876
         else begin
2877
            handle = recorder.get_handle();
2878
         end
2879
      end // if (recorder != null)
2880
   end // if (stream != null)
2881
 
2882
   return handle;
2883
endfunction
2884
 
2885
 
2886
// record_event_tr
2887
// ---------------
2888
 
2889
function integer uvm_component::record_event_tr (string stream_name="main",
2890
                                                 uvm_object info=null,
2891
                                                 string label="event_tr",
2892
                                                 string desc="",
2893
                                                 time   event_time=0,
2894
                                                 bit    keep_active=0);
2895
   uvm_recorder recorder;
2896
   string etype;
2897
   integer handle;
2898
   uvm_tr_stream stream;
2899
   uvm_tr_database db = m_get_tr_database();
2900
 
2901
  if(keep_active) etype = "Event, Link";
2902
  else etype = "Event";
2903
 
2904
   if(event_time == 0) event_time = $realtime;
2905
 
2906
   if ((stream_name=="") || (stream_name=="main")) begin
2907
      if (m_main_stream == null)
2908
        m_main_stream = tr_database.open_stream("main", this.get_full_name(), "TVM");
2909
      stream = m_main_stream;
2910
   end
2911
   else
2912
     stream = get_tr_stream(stream_name);
2913
 
2914
   handle = 0;
2915
   if (stream != null) begin
2916
      recorder = stream.open_recorder(label,
2917
                                    event_time,
2918
                                    etype);
2919
 
2920
      if (recorder != null) begin
2921
         if (label != "")
2922
           recorder.record_string("label", label);
2923
         if (desc != "")
2924
           recorder.record_string("desc", desc);
2925
         if (info!=null)
2926
           info.record(recorder);
2927
 
2928
         recorder.close(event_time);
2929
 
2930
         if (keep_active == 0) begin
2931
            recorder.free();
2932
         end
2933
         else begin
2934
            handle = recorder.get_handle();
2935
         end
2936
      end // if (recorder != null)
2937
   end // if (stream != null)
2938
 
2939
   return handle;
2940
endfunction
2941
 
2942
// do_accept_tr
2943
// ------------
2944
 
2945
function void uvm_component::do_accept_tr (uvm_transaction tr);
2946
  return;
2947
endfunction
2948
 
2949
 
2950
// do_begin_tr
2951
// -----------
2952
 
2953
function void uvm_component::do_begin_tr (uvm_transaction tr,
2954
                                          string stream_name,
2955
                                          integer tr_handle);
2956
  return;
2957
endfunction
2958
 
2959
 
2960
// do_end_tr
2961
// ---------
2962
 
2963
function void uvm_component::do_end_tr (uvm_transaction tr,
2964
                                        integer tr_handle);
2965
  return;
2966
endfunction
2967
 
2968
 
2969
//------------------------------------------------------------------------------
2970
//
2971
// Configuration interface
2972
//
2973
//------------------------------------------------------------------------------
2974
 
2975
 
2976
function string uvm_component::massage_scope(string scope);
2977
 
2978
  // uvm_top
2979
  if(scope == "")
2980
    return "^$";
2981
 
2982
  if(scope == "*")
2983
    return {get_full_name(), ".*"};
2984
 
2985
  // absolute path to the top-level test
2986
  if(scope == "uvm_test_top")
2987
    return "uvm_test_top";
2988
 
2989
  // absolute path to uvm_root
2990
  if(scope[0] == ".")
2991
    return {get_full_name(), scope};
2992
 
2993
  return {get_full_name(), ".", scope};
2994
 
2995
endfunction
2996
 
2997
 
2998
// Undocumented struct for storing clone bit along w/
2999
// object on set_config_object(...) calls
3000
class uvm_config_object_wrapper;
3001
   uvm_object obj;
3002
   bit clone;
3003
endclass : uvm_config_object_wrapper
3004
 
3005
 
3006
`ifndef UVM_NO_DEPRECATED
3007
//
3008
// set_config_int
3009
//
3010
function void uvm_component::set_config_int(string inst_name,
3011
                                           string field_name,
3012
                                           uvm_bitstream_t value);
3013
 
3014
  if (!m_config_deprecated_warned) begin
3015
     `uvm_warning("UVM/CFG/SET/DPR", "get/set_config_* API has been deprecated. Use uvm_config_db instead.")
3016
     m_config_deprecated_warned = 1;
3017
  end
3018
  uvm_config_int::set(this, inst_name, field_name, value);
3019
endfunction
3020
 
3021
//
3022
// set_config_string
3023
//
3024
function void uvm_component::set_config_string(string inst_name,
3025
                                               string field_name,
3026
                                               string value);
3027
 
3028
  if (!m_config_deprecated_warned) begin
3029
     `uvm_warning("UVM/CFG/SET/DPR", "get/set_config_* API has been deprecated. Use uvm_config_db instead.")
3030
     m_config_deprecated_warned = 1;
3031
  end
3032
  uvm_config_string::set(this, inst_name, field_name, value);
3033
endfunction
3034
 
3035
//
3036
// set_config_object
3037
//
3038
function void uvm_component::set_config_object(string inst_name,
3039
                                               string field_name,
3040
                                               uvm_object value,
3041
                                               bit clone = 1);
3042
  uvm_object tmp;
3043
  uvm_config_object_wrapper wrapper;
3044
 
3045
  if (!m_config_deprecated_warned) begin
3046
     `uvm_warning("UVM/CFG/SET/DPR", "get/set_config_* API has been deprecated. Use uvm_config_db instead.")
3047
     m_config_deprecated_warned = 1;
3048
  end
3049
 
3050
  if(value == null)
3051
    `uvm_warning("NULLCFG", {"A null object was provided as a ",
3052
       $sformatf("configuration object for set_config_object(\"%s\",\"%s\")",
3053
       inst_name, field_name), ". Verify that this is intended."})
3054
 
3055
  if(clone && (value != null)) begin
3056
    tmp = value.clone();
3057
    if(tmp == null) begin
3058
      uvm_component comp;
3059
      if ($cast(comp,value)) begin
3060
        `uvm_error("INVCLNC", {"Clone failed during set_config_object ",
3061
          "with an object that is a uvm_component. Components cannot be cloned."})
3062
        return;
3063
      end
3064
      else begin
3065
        `uvm_warning("INVCLN", {"Clone failed during set_config_object, ",
3066
          "the original reference will be used for configuration. Check that ",
3067
          "the create method for the object type is defined properly."})
3068
      end
3069
    end
3070
    else
3071
      value = tmp;
3072
  end
3073
 
3074
 
3075
  uvm_config_object::set(this, inst_name, field_name, value);
3076
 
3077
  wrapper = new;
3078
  wrapper.obj = value;
3079
  wrapper.clone = clone;
3080
  uvm_config_db#(uvm_config_object_wrapper)::set(this, inst_name, field_name, wrapper);
3081
endfunction
3082
 
3083
//
3084
// get_config_int
3085
//
3086
function bit uvm_component::get_config_int (string field_name,
3087
                                            inout uvm_bitstream_t value);
3088
 
3089
  if (!m_config_deprecated_warned) begin
3090
     `uvm_warning("UVM/CFG/GET/DPR", "get/set_config_* API has been deprecated. Use uvm_config_db instead.")
3091
     m_config_deprecated_warned = 1;
3092
  end
3093
  return uvm_config_int::get(this, "", field_name, value);
3094
endfunction
3095
 
3096
//
3097
// get_config_string
3098
//
3099
function bit uvm_component::get_config_string(string field_name,
3100
                                              inout string value);
3101
 
3102
  if (!m_config_deprecated_warned) begin
3103
     `uvm_warning("UVM/CFG/GET/DPR", "get/set_config_* API has been deprecated. Use uvm_config_db instead.")
3104
     m_config_deprecated_warned = 1;
3105
  end
3106
  return uvm_config_string::get(this, "", field_name, value);
3107
endfunction
3108
 
3109
//
3110
// get_config_object
3111
//
3112
//
3113
// Note that this does not honor the set_config_object clone bit
3114
function bit uvm_component::get_config_object (string field_name,
3115
                                               inout uvm_object value,
3116
                                               input bit clone=1);
3117
  if (!m_config_deprecated_warned) begin
3118
     `uvm_warning("UVM/CFG/GET/DPR", "get/set_config_* API has been deprecated. Use uvm_config_db instead.")
3119
     m_config_deprecated_warned = 1;
3120
  end
3121
 
3122
  if(!uvm_config_object::get(this, "", field_name, value)) begin
3123
    return 0;
3124
  end
3125
 
3126
  if(clone && value != null) begin
3127
    value = value.clone();
3128
  end
3129
 
3130
  return 1;
3131
endfunction
3132
`endif
3133
 
3134
// check_config_usage
3135
// ------------------
3136
 
3137
function void uvm_component::check_config_usage ( bit recurse=1 );
3138
  uvm_resource_pool rp = uvm_resource_pool::get();
3139
  uvm_queue#(uvm_resource_base) rq;
3140
 
3141
  rq = rp.find_unused_resources();
3142
 
3143
  if(rq.size() == 0)
3144
    return;
3145
 
3146
  uvm_report_info("CFGNRD"," ::: The following resources have at least one write and no reads :::",UVM_INFO);
3147
  rp.print_resources(rq, 1);
3148
endfunction
3149
 
3150
 
3151
// apply_config_settings
3152
// ---------------------
3153
 
3154
function void uvm_component::apply_config_settings (bit verbose=0);
3155
 
3156
  uvm_resource_pool rp = uvm_resource_pool::get();
3157
  uvm_queue#(uvm_resource_base) rq;
3158
  uvm_resource_base r;
3159
  string name;
3160
  string search_name;
3161
  int unsigned i;
3162
  int unsigned j;
3163
 
3164
  // populate an internal 'field_array' with list of
3165
  // fields declared with `uvm_field macros (checking
3166
  // that there aren't any duplicates along the way)
3167
  __m_uvm_field_automation (null, UVM_CHECK_FIELDS, "");
3168
 
3169
  // if no declared fields, nothing to do.
3170
  if (__m_uvm_status_container.field_array.size() == 0)
3171
    return;
3172
 
3173
  if(verbose)
3174
    uvm_report_info("CFGAPL","applying configuration settings", UVM_NONE);
3175
 
3176
  // The following is VERY expensive. Needs refactoring. Should
3177
  // get config only for the specific field names in 'field_array'.
3178
  // That's because the resource pool is organized first by field name.
3179
  // Can further optimize by encoding the value for each 'field_array'
3180
  // entry to indicate string, uvm_bitstream_t, or object. That way,
3181
  // we call 'get' for specific fields of specific types rather than
3182
  // the search-and-cast approach here.
3183
  rq = rp.lookup_scope(get_full_name());
3184
  rp.sort_by_precedence(rq);
3185
 
3186
  // rq is in precedence order now, so we have to go through in reverse
3187
  // order to do the settings.
3188
  for(int i=rq.size()-1; i>=0; --i) begin
3189
 
3190
    r = rq.get(i);
3191
    name = r.get_name();
3192
 
3193
    // does name have brackets [] in it?
3194
    for(j = 0; j < name.len(); j++)
3195
      if(name[j] == "[" || name[j] == ".")
3196
        break;
3197
 
3198
    // If it does have brackets then we'll use the name
3199
    // up to the brackets to search __m_uvm_status_container.field_array
3200
    if(j < name.len())
3201
      search_name = name.substr(0, j-1);
3202
    else
3203
      search_name = name;
3204
 
3205
    if(!__m_uvm_status_container.field_array.exists(search_name) &&
3206
       search_name != "recording_detail")
3207
      continue;
3208
 
3209
    if(verbose)
3210
      uvm_report_info("CFGAPL",$sformatf("applying configuration to field %s", name),UVM_NONE);
3211
 
3212
    begin
3213
       uvm_resource#(uvm_integral_t) rit;
3214
       if ($cast(rit, r))
3215
         set_int_local(name, rit.read(this));
3216
       else begin
3217
          uvm_resource#(uvm_bitstream_t) rbs;
3218
          if($cast(rbs, r))
3219
            set_int_local(name, rbs.read(this));
3220
          else begin
3221
             uvm_resource#(int) ri;
3222
             if($cast(ri, r))
3223
               set_int_local(name, ri.read(this));
3224
             else begin
3225
                uvm_resource#(int unsigned) riu;
3226
                if($cast(riu, r))
3227
                  set_int_local(name, riu.read(this));
3228
                else begin
3229
                   uvm_resource#(uvm_active_passive_enum) rap;
3230
                   if ($cast(rap, r))
3231
                     set_int_local(name, rap.read(this));
3232
                   else begin
3233
                      uvm_resource#(string) rs;
3234
                      if($cast(rs, r))
3235
                        set_string_local(name, rs.read(this));
3236
                      else begin
3237
                         uvm_resource#(uvm_config_object_wrapper) rcow;
3238
                         if ($cast(rcow, r)) begin
3239
                         uvm_config_object_wrapper cow = rcow.read();
3240
                            set_object_local(name, cow.obj, cow.clone);
3241
                         end
3242
                         else begin
3243
                            uvm_resource#(uvm_object) ro;
3244
                            if($cast(ro, r)) begin
3245
                               set_object_local(name, ro.read(this), 0);
3246
                            end
3247
                            else if (verbose) begin
3248
                               uvm_report_info("CFGAPL", $sformatf("field %s has an unsupported type", name), UVM_NONE);
3249
                            end
3250
                         end // else: !if($cast(rcow, r))
3251
                      end // else: !if($cast(rs, r))
3252
                   end // else: !if($cast(rap, r))
3253
                end // else: !if($cast(riu, r))
3254
             end // else: !if($cast(ri, r))
3255
          end // else: !if($cast(rbs, r))
3256
       end // else: !if($cast(rit, r))
3257
    end
3258
  end
3259
 
3260
  __m_uvm_status_container.field_array.delete();
3261
 
3262
endfunction
3263
 
3264
 
3265
// print_config
3266
// ------------
3267
 
3268
function void uvm_component::print_config(bit recurse = 0, audit = 0);
3269
 
3270
  uvm_resource_pool rp = uvm_resource_pool::get();
3271
 
3272
  uvm_report_info("CFGPRT","visible resources:",UVM_INFO);
3273
  rp.print_resources(rp.lookup_scope(get_full_name()), audit);
3274
 
3275
  if(recurse) begin
3276
    uvm_component c;
3277
    foreach(m_children[name]) begin
3278
      c = m_children[name];
3279
      c.print_config(recurse, audit);
3280
    end
3281
  end
3282
 
3283
endfunction
3284
 
3285
 
3286
// print_config_settings
3287
// ---------------------
3288
 
3289
function void uvm_component::print_config_settings (string field="",
3290
                                                    uvm_component comp=null,
3291
                                                    bit recurse=0);
3292
  static bit have_been_warned;
3293
  if(!have_been_warned) begin
3294
    uvm_report_warning("deprecated", "uvm_component::print_config_settings has been deprecated.  Use print_config() instead");
3295
    have_been_warned = 1;
3296
  end
3297
 
3298
  print_config(recurse, 1);
3299
endfunction
3300
 
3301
 
3302
// print_config_with_audit
3303
// -----------------------
3304
 
3305
function void uvm_component::print_config_with_audit(bit recurse = 0);
3306
  print_config(recurse, 1);
3307
endfunction
3308
 
3309
 
3310
// do_print (override)
3311
// --------
3312
 
3313
function void uvm_component::do_print(uvm_printer printer);
3314
  string v;
3315
  super.do_print(printer);
3316
 
3317
  // It is printed only if its value is other than the default (UVM_NONE)
3318
  if(uvm_verbosity'(recording_detail) != UVM_NONE)
3319
    case (recording_detail)
3320
      UVM_LOW : printer.print_generic("recording_detail", "uvm_verbosity",
3321
        $bits(recording_detail), "UVM_LOW");
3322
      UVM_MEDIUM : printer.print_generic("recording_detail", "uvm_verbosity",
3323
        $bits(recording_detail), "UVM_MEDIUM");
3324
      UVM_HIGH : printer.print_generic("recording_detail", "uvm_verbosity",
3325
        $bits(recording_detail), "UVM_HIGH");
3326
      UVM_FULL : printer.print_generic("recording_detail", "uvm_verbosity",
3327
        $bits(recording_detail), "UVM_FULL");
3328
      default : printer.print_field_int("recording_detail", recording_detail,
3329
        $bits(recording_detail), UVM_DEC, , "integral");
3330
    endcase
3331
 
3332
`ifndef UVM_NO_DEPRECATED
3333
  if (enable_stop_interrupt != 0) begin
3334
    printer.print_field_int("enable_stop_interrupt", enable_stop_interrupt,
3335
                        $bits(enable_stop_interrupt), UVM_BIN, ".", "bit");
3336
  end
3337
 `endif
3338
endfunction
3339
 
3340
 
3341
// set_int_local (override)
3342
// -------------
3343
 
3344
function void uvm_component::set_int_local (string field_name,
3345
                             uvm_bitstream_t value,
3346
                             bit recurse=1);
3347
 
3348
  //call the super function to get child recursion and any registered fields
3349
  super.set_int_local(field_name, value, recurse);
3350
 
3351
  //set the local properties
3352
  if(uvm_is_match(field_name, "recording_detail"))
3353
    recording_detail = value;
3354
 
3355
endfunction
3356
 
3357
 
3358
// Internal methods for setting messagin parameters from command line switches
3359
 
3360
typedef class uvm_cmdline_processor;
3361
 
3362
 
3363
// m_set_cl_msg_args
3364
// -----------------
3365
 
3366
function void uvm_component::m_set_cl_msg_args;
3367
  m_set_cl_verb();
3368
  m_set_cl_action();
3369
  m_set_cl_sev();
3370
endfunction
3371
 
3372
 
3373
// m_set_cl_verb
3374
// -------------
3375
function void uvm_component::m_set_cl_verb;
3376
  // _ALL_ can be used for ids
3377
  // +uvm_set_verbosity=,,,,
3378
  // +uvm_set_verbosity=uvm_test_top.env0.agent1.*,_ALL_,UVM_FULL,time,800
3379
 
3380
  static string values[$];
3381
  static bit first = 1;
3382
  string args[$];
3383
  uvm_cmdline_processor clp = uvm_cmdline_processor::get_inst();
3384
  uvm_root top;
3385
  uvm_coreservice_t cs;
3386
  cs = uvm_coreservice_t::get();
3387
  top = cs.get_root();
3388
 
3389
  if(!values.size())
3390
    void'(uvm_cmdline_proc.get_arg_values("+uvm_set_verbosity=",values));
3391
 
3392
  foreach(values[i]) begin
3393
    m_verbosity_setting setting;
3394
    args.delete();
3395
    uvm_split_string(values[i], ",", args);
3396
 
3397
    // Warning is already issued in uvm_root, so just don't keep it
3398
    if(first && ( ((args.size() != 4) && (args.size() != 5)) ||
3399
                  (clp.m_convert_verb(args[2], setting.verbosity) == 0))  )
3400
    begin
3401
      values.delete(i);
3402
    end
3403
    else begin
3404
      setting.comp = args[0];
3405
      setting.id = args[1];
3406
      void'(clp.m_convert_verb(args[2],setting.verbosity));
3407
      setting.phase = args[3];
3408
      setting.offset = 0;
3409
      if(args.size() == 5) setting.offset = args[4].atoi();
3410
      if((setting.phase == "time") && (this == top)) begin
3411
        m_time_settings.push_back(setting);
3412
      end
3413
 
3414
      if (uvm_is_match(setting.comp, get_full_name()) ) begin
3415
        if((setting.phase == "" || setting.phase == "build" || setting.phase == "time") &&
3416
           (setting.offset == 0) )
3417
        begin
3418
          if(setting.id == "_ALL_")
3419
            set_report_verbosity_level(setting.verbosity);
3420
          else
3421
            set_report_id_verbosity(setting.id, setting.verbosity);
3422
        end
3423
        else begin
3424
          if(setting.phase != "time") begin
3425
            m_verbosity_settings.push_back(setting);
3426
          end
3427
        end
3428
      end
3429
    end
3430
  end
3431
  // do time based settings
3432
  if(this == top) begin
3433
    fork begin
3434
      time last_time = 0;
3435
      if (m_time_settings.size() > 0)
3436
        m_time_settings.sort() with ( item.offset );
3437
      foreach(m_time_settings[i]) begin
3438
        uvm_component comps[$];
3439
        top.find_all(m_time_settings[i].comp,comps);
3440
        #(m_time_settings[i].offset - last_time);
3441
        last_time = m_time_settings[i].offset;
3442
        if(m_time_settings[i].id == "_ALL_") begin
3443
           foreach(comps[j]) begin
3444
             comps[j].set_report_verbosity_level(m_time_settings[i].verbosity);
3445
           end
3446
        end
3447
        else begin
3448
          foreach(comps[j]) begin
3449
            comps[j].set_report_id_verbosity(m_time_settings[i].id, m_time_settings[i].verbosity);
3450
          end
3451
        end
3452
      end
3453
    end join_none // fork begin
3454
  end
3455
 
3456
  first = 0;
3457
endfunction
3458
 
3459
// m_set_cl_action
3460
// ---------------
3461
 
3462
function void uvm_component::m_set_cl_action;
3463
  // _ALL_ can be used for ids or severities
3464
  // +uvm_set_action=,,,
3465
  // +uvm_set_action=uvm_test_top.env0.*,_ALL_,UVM_ERROR,UVM_NO_ACTION
3466
 
3467
  static bit initialized = 0;
3468
  uvm_severity sev;
3469
  uvm_action action;
3470
 
3471
  if(!initialized) begin
3472
        string values[$];
3473
    void'(uvm_cmdline_proc.get_arg_values("+uvm_set_action=",values));
3474
        foreach(values[idx]) begin
3475
                uvm_cmdline_parsed_arg_t t;
3476
                string args[$];
3477
                uvm_split_string(values[idx], ",", args);
3478
 
3479
                if(args.size() != 4) begin
3480
                        `uvm_warning("INVLCMDARGS", $sformatf("+uvm_set_action requires 4 arguments, but %0d given for command +uvm_set_action=%s, Usage: +uvm_set_action=,,,", args.size(), values[idx]))
3481
                        continue;
3482
                end
3483
                if((args[2] != "_ALL_") && !uvm_string_to_severity(args[2], sev)) begin
3484
                        `uvm_warning("INVLCMDARGS", $sformatf("Bad severity argument \"%s\" given to command +uvm_set_action=%s, Usage: +uvm_set_action=,,,", args[2], values[idx]))
3485
                        continue;
3486
                end
3487
                if(!uvm_string_to_action(args[3], action)) begin
3488
                        `uvm_warning("INVLCMDARGS", $sformatf("Bad action argument \"%s\" given to command +uvm_set_action=%s, Usage: +uvm_set_action=,,,", args[3], values[idx]))
3489
                        continue;
3490
                end
3491
                t.args=args;
3492
                t.arg=values[idx];
3493
                m_uvm_applied_cl_action.push_back(t);
3494
        end
3495
        initialized=1;
3496
  end
3497
 
3498
  foreach(m_uvm_applied_cl_action[i]) begin
3499
        string args[$] = m_uvm_applied_cl_action[i].args;
3500
 
3501
        if (!uvm_is_match(args[0], get_full_name()) ) continue;
3502
 
3503
        void'(uvm_string_to_severity(args[2], sev));
3504
        void'(uvm_string_to_action(args[3], action));
3505
 
3506
    m_uvm_applied_cl_action[i].used++;
3507
    if(args[1] == "_ALL_") begin
3508
      if(args[2] == "_ALL_") begin
3509
        set_report_severity_action(UVM_INFO, action);
3510
        set_report_severity_action(UVM_WARNING, action);
3511
        set_report_severity_action(UVM_ERROR, action);
3512
        set_report_severity_action(UVM_FATAL, action);
3513
      end
3514
      else begin
3515
        set_report_severity_action(sev, action);
3516
      end
3517
    end
3518
    else begin
3519
      if(args[2] == "_ALL_") begin
3520
        set_report_id_action(args[1], action);
3521
      end
3522
      else begin
3523
        set_report_severity_id_action(sev, args[1], action);
3524
      end
3525
    end
3526
  end
3527
 
3528
endfunction
3529
 
3530
 
3531
// m_set_cl_sev
3532
// ------------
3533
 
3534
function void uvm_component::m_set_cl_sev;
3535
  // _ALL_ can be used for ids or severities
3536
  //  +uvm_set_severity=,,,
3537
  //  +uvm_set_severity=uvm_test_top.env0.*,BAD_CRC,UVM_ERROR,UVM_WARNING
3538
 
3539
  static bit initialized;
3540
  uvm_severity orig_sev, sev;
3541
 
3542
  if(!initialized) begin
3543
        string values[$];
3544
    void'(uvm_cmdline_proc.get_arg_values("+uvm_set_severity=",values));
3545
        foreach(values[idx]) begin
3546
                uvm_cmdline_parsed_arg_t t;
3547
                string args[$];
3548
                uvm_split_string(values[idx], ",", args);
3549
                if(args.size() != 4) begin
3550
                `uvm_warning("INVLCMDARGS", $sformatf("+uvm_set_severity requires 4 arguments, but %0d given for command +uvm_set_severity=%s, Usage: +uvm_set_severity=,,,", args.size(), values[idx]))
3551
                continue;
3552
        end
3553
        if(args[2] != "_ALL_" && !uvm_string_to_severity(args[2], orig_sev)) begin
3554
                `uvm_warning("INVLCMDARGS", $sformatf("Bad severity argument \"%s\" given to command +uvm_set_severity=%s, Usage: +uvm_set_severity=,,,", args[2], values[idx]))
3555
                continue;
3556
        end
3557
        if(!uvm_string_to_severity(args[3], sev)) begin
3558
                `uvm_warning("INVLCMDARGS", $sformatf("Bad severity argument \"%s\" given to command +uvm_set_severity=%s, Usage: +uvm_set_severity=,,,", args[3], values[idx]))
3559
                continue;
3560
        end
3561
 
3562
                t.args=args;
3563
        t.arg=values[idx];
3564
                m_uvm_applied_cl_sev.push_back(t);
3565
        end
3566
        initialized=1;
3567
  end
3568
 
3569
  foreach(m_uvm_applied_cl_sev[i]) begin
3570
        string args[$]=m_uvm_applied_cl_sev[i].args;
3571
 
3572
    if (!uvm_is_match(args[0], get_full_name()) ) continue;
3573
 
3574
        void'(uvm_string_to_severity(args[2], orig_sev));
3575
        void'(uvm_string_to_severity(args[3], sev));
3576
    m_uvm_applied_cl_sev[i].used++;
3577
    if(args[1] == "_ALL_" && args[2] == "_ALL_") begin
3578
      set_report_severity_override(UVM_INFO,sev);
3579
      set_report_severity_override(UVM_WARNING,sev);
3580
      set_report_severity_override(UVM_ERROR,sev);
3581
      set_report_severity_override(UVM_FATAL,sev);
3582
    end
3583
    else if(args[1] == "_ALL_") begin
3584
      set_report_severity_override(orig_sev,sev);
3585
    end
3586
    else if(args[2] == "_ALL_") begin
3587
      set_report_severity_id_override(UVM_INFO,args[1],sev);
3588
      set_report_severity_id_override(UVM_WARNING,args[1],sev);
3589
      set_report_severity_id_override(UVM_ERROR,args[1],sev);
3590
      set_report_severity_id_override(UVM_FATAL,args[1],sev);
3591
    end
3592
    else begin
3593
      set_report_severity_id_override(orig_sev,args[1],sev);
3594
    end
3595
  end
3596
endfunction
3597
 
3598
 
3599
// m_apply_verbosity_settings
3600
// --------------------------
3601
 
3602
function void uvm_component::m_apply_verbosity_settings(uvm_phase phase);
3603
  foreach(m_verbosity_settings[i]) begin
3604
    if(phase.get_name() == m_verbosity_settings[i].phase) begin
3605
      if( m_verbosity_settings[i].offset == 0 ) begin
3606
          if(m_verbosity_settings[i].id == "_ALL_")
3607
            set_report_verbosity_level(m_verbosity_settings[i].verbosity);
3608
          else
3609
            set_report_id_verbosity(m_verbosity_settings[i].id, m_verbosity_settings[i].verbosity);
3610
      end
3611
      else begin
3612
        process p = process::self();
3613
        string p_rand = p.get_randstate();
3614
        fork begin
3615
          m_verbosity_setting setting = m_verbosity_settings[i];
3616
          #setting.offset;
3617
          if(setting.id == "_ALL_")
3618
            set_report_verbosity_level(setting.verbosity);
3619
          else
3620
            set_report_id_verbosity(setting.id, setting.verbosity);
3621
        end join_none;
3622
        p.set_randstate(p_rand);
3623
      end
3624
      // Remove after use
3625
      m_verbosity_settings.delete(i);
3626
    end
3627
  end
3628
endfunction
3629
 
3630
 
3631
// m_do_pre_abort
3632
// --------------
3633
 
3634
function void uvm_component::m_do_pre_abort;
3635
  foreach(m_children[i])
3636
    m_children[i].m_do_pre_abort();
3637
  pre_abort();
3638
endfunction

powered by: WebSVN 2.1.0

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