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

Subversion Repositories uart2bus_testbench

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 HanySalah
//
2
//------------------------------------------------------------------------------
3
//   Copyright 2007-2010 Mentor Graphics Corporation
4
//   Copyright 2007-2011 Cadence Design Systems, Inc.
5
//   Copyright 2010 Synopsys, Inc.
6
//   All Rights Reserved Worldwide
7
//
8
//   Licensed under the Apache License, Version 2.0 (the
9
//   "License"); you may not use this file except in
10
//   compliance with the License.  You may obtain a copy of
11
//   the License at
12
//
13
//       http://www.apache.org/licenses/LICENSE-2.0
14
//
15
//   Unless required by applicable law or agreed to in
16
//   writing, software distributed under the License is
17
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
18
//   CONDITIONS OF ANY KIND, either express or implied.  See
19
//   the License for the specific language governing
20
//   permissions and limitations under the License.
21
//------------------------------------------------------------------------------
22
 
23
`ifndef UVM_REPORT_CLIENT_SVH
24
`define UVM_REPORT_CLIENT_SVH
25
 
26
typedef class uvm_component;
27
typedef class uvm_env;
28
typedef class uvm_root;
29
 
30
//------------------------------------------------------------------------------
31
//
32
// CLASS: uvm_report_object
33
//
34
//------------------------------------------------------------------------------
35
//
36
// The uvm_report_object provides an interface to the UVM reporting facility.
37
// Through this interface, components issue the various messages that occur
38
// during simulation. Users can configure what actions are taken and what
39
// file(s) are output for individual messages from a particular component
40
// or for all messages from all components in the environment. Defaults are
41
// applied where there is no explicit configuration.
42
//
43
// Most methods in uvm_report_object are delegated to an internal instance of a
44
// , which stores the reporting configuration and determines
45
// whether an issued message should be displayed based on that configuration.
46
// Then, to display a message, the report handler delegates the actual
47
// formatting and production of messages to a central .
48
//
49
// A report consists of an id string, severity, verbosity level, and the textual
50
// message itself. They may optionally include the filename and line number from
51
// which the message came. If the verbosity level of a report is greater than the
52
// configured maximum verbosity level of its report object, it is ignored.
53
// If a report passes the verbosity filter in effect, the report's action is
54
// determined. If the action includes output to a file, the configured file
55
// descriptor(s) are determined.
56
//
57
// Actions - can be set for (in increasing priority) severity, id, and
58
// (severity,id) pair. They include output to the screen ,
59
// whether the message counters should be incremented , and
60
// whether a $finish should occur .
61
//
62
// Default Actions - The following provides the default actions assigned to
63
// each severity. These can be overridden by any of the ~set_*_action~ methods.
64
//|    UVM_INFO -       UVM_DISPLAY
65
//|    UVM_WARNING -    UVM_DISPLAY
66
//|    UVM_ERROR -      UVM_DISPLAY | UVM_COUNT
67
//|    UVM_FATAL -      UVM_DISPLAY | UVM_EXIT
68
//
69
// File descriptors - These can be set by (in increasing priority) default,
70
// severity level, an id, or (severity,id) pair.  File descriptors are
71
// standard SystemVerilog file descriptors; they may refer to more than one file.
72
// It is the user's responsibility to open and close them.
73
//
74
// Default file handle - The default file handle is 0, which means that reports
75
// are not sent to a file even if a UVM_LOG attribute is set in the action
76
// associated with the report. This can be overridden by any of the ~set_*_file~
77
// methods.
78
//
79
//------------------------------------------------------------------------------
80
 
81
class uvm_report_object extends uvm_object;
82
 
83
  uvm_report_handler m_rh;
84
 
85
 
86
  // Function: new
87
  //
88
  // Creates a new report object with the given name. This method also creates
89
  // a new  object to which most tasks are delegated.
90
 
91
  function new(string name = "");
92
    super.new(name);
93
    m_rh = uvm_report_handler::type_id::create(name);
94
  endfunction
95
 
96
 
97
  //----------------------------------------------------------------------------
98
  // Group: Reporting
99
  //----------------------------------------------------------------------------
100
 
101
  // Function: uvm_get_report_object
102
  //
103
  // Returns the nearest uvm_report_object when called.  From inside a
104
  // uvm_component, the method simply returns ~this~.
105
  //
106
  // See also the global version of .
107
 
108
  function uvm_report_object uvm_get_report_object();
109
    return this;
110
  endfunction
111
 
112
  // Function: uvm_report_enabled
113
  //
114
  // Returns 1 if the configured verbosity for this severity/id is greater than
115
  // or equal to ~verbosity~ else returns 0.
116
  //
117
  // See also  and the global version of
118
  // .
119
 
120
  function int uvm_report_enabled(int verbosity,
121
                                  uvm_severity severity = UVM_INFO, string id = "");
122
    if (get_report_verbosity_level(severity, id) < verbosity)
123
      return 0;
124
    return 1;
125
  endfunction
126
 
127
  // Function: uvm_report
128
 
129
  virtual function void uvm_report( uvm_severity severity,
130
                                    string id,
131
                                    string message,
132
                                    int verbosity = (severity == uvm_severity'(UVM_ERROR)) ? UVM_LOW :
133
                                                    (severity == uvm_severity'(UVM_FATAL)) ? UVM_NONE : UVM_MEDIUM,
134
                                    string filename = "",
135
                                    int line = 0,
136
                                    string context_name = "",
137
                                    bit report_enabled_checked =0);
138
    uvm_report_message l_report_message;
139
    if (report_enabled_checked == 0) begin
140
      if (!uvm_report_enabled(verbosity, severity, id))
141
        return;
142
    end
143
    l_report_message = uvm_report_message::new_report_message();
144
    l_report_message.set_report_message(severity, id, message,
145
                                        verbosity, filename, line, context_name);
146
    uvm_process_report_message(l_report_message);
147
  endfunction
148
 
149
 
150
  // Function: uvm_report_info
151
 
152
  virtual function void uvm_report_info( string id,
153
                                         string message,
154
                                         int verbosity = UVM_MEDIUM,
155
                                         string filename = "",
156
                                         int line = 0,
157
                                         string context_name = "",
158
                                         bit report_enabled_checked = 0);
159
 
160
    uvm_report (UVM_INFO, id, message, verbosity,
161
                filename, line, context_name, report_enabled_checked);
162
  endfunction
163
 
164
  // Function: uvm_report_warning
165
 
166
  virtual function void uvm_report_warning( string id,
167
                                            string message,
168
                                            int verbosity = UVM_MEDIUM,
169
                                            string filename = "",
170
                                            int line = 0,
171
                                            string context_name = "",
172
                                            bit report_enabled_checked = 0);
173
 
174
    uvm_report (UVM_WARNING, id, message, verbosity,
175
                filename, line, context_name, report_enabled_checked);
176
  endfunction
177
 
178
  // Function: uvm_report_error
179
 
180
  virtual function void uvm_report_error( string id,
181
                                          string message,
182
                                          int verbosity = UVM_LOW,
183
                                          string filename = "",
184
                                          int line = 0,
185
                                          string context_name = "",
186
                                          bit report_enabled_checked = 0);
187
 
188
    uvm_report (UVM_ERROR, id, message, verbosity,
189
                filename, line, context_name, report_enabled_checked);
190
  endfunction
191
 
192
  // Function: uvm_report_fatal
193
  //
194
  // These are the primary reporting methods in the UVM. Using these instead
195
  // of ~$display~ and other ad hoc approaches ensures consistent output and
196
  // central control over where output is directed and any actions that
197
  // result. All reporting methods have the same arguments, although each has
198
  // a different default verbosity:
199
  //
200
  //   id        - a unique id for the report or report group that can be used
201
  //               for identification and therefore targeted filtering. You can
202
  //               configure an individual report's actions and output file(s)
203
  //               using this id string.
204
  //
205
  //   message   - the message body, preformatted if necessary to a single
206
  //               string.
207
  //
208
  //   verbosity - the verbosity of the message, indicating its relative
209
  //               importance. If this number is less than or equal to the
210
  //               effective verbosity level, see ,
211
  //               then the report is issued, subject to the configured action
212
  //               and file descriptor settings.  Verbosity is ignored for
213
  //               warnings, errors, and fatals. However, if a warning, error
214
  //               or fatal is demoted to an info message using the
215
  //               , then the verbosity is taken into
216
  //               account.
217
  //
218
  //   filename/line - (Optional) The location from which the report was issued.
219
  //               Use the predefined macros, `__FILE__ and `__LINE__.
220
  //               If specified, it is displayed in the output.
221
  //
222
  //   context_name - (Optional) The string context from where the message is
223
  //               originating.  This can be the %m of a module, a specific
224
  //               method, etc.
225
  //
226
  //   report_enabled_checked - (Optional) This bit indicates whether the
227
  //               currently provided message has been checked as to whether
228
  //               the message should be processed. If it hasn't been checked,
229
  //               it will be checked inside the uvm_report function.
230
 
231
  virtual function void uvm_report_fatal( string id,
232
                                          string message,
233
                                          int verbosity = UVM_NONE,
234
                                          string filename = "",
235
                                          int line = 0,
236
                                          string context_name = "",
237
                                          bit report_enabled_checked = 0);
238
 
239
    uvm_report (UVM_FATAL, id, message, verbosity,
240
                filename, line, context_name, report_enabled_checked);
241
  endfunction
242
 
243
  // Function: uvm_process_report_message
244
  //
245
  // This method takes a preformed uvm_report_message, populates it with
246
  // the report object and passes it to the report handler for processing.
247
  // It is expected to be checked for verbosity and populated.
248
 
249
  virtual function void uvm_process_report_message(uvm_report_message report_message);
250
    report_message.set_report_object(this);
251
    m_rh.process_report_message(report_message);
252
  endfunction
253
 
254
 
255
  //----------------------------------------------------------------------------
256
  // Group: Verbosity Configuration
257
  //----------------------------------------------------------------------------
258
 
259
 
260
  // Function: get_report_verbosity_level
261
  //
262
  // Gets the verbosity level in effect for this object. Reports issued
263
  // with verbosity greater than this will be filtered out. The severity
264
  // and tag arguments check if the verbosity level has been modified for
265
  // specific severity/tag combinations.
266
 
267
  function int get_report_verbosity_level(uvm_severity severity=UVM_INFO, string id="");
268
    return m_rh.get_verbosity_level(severity, id);
269
  endfunction
270
 
271
 
272
  // Function: get_report_max_verbosity_level
273
  //
274
  // Gets the maximum verbosity level in effect for this report object.
275
  // Any report from this component whose verbosity exceeds this maximum will
276
  // be ignored.
277
 
278
  function int get_report_max_verbosity_level();
279
    return m_rh.m_max_verbosity_level;
280
  endfunction
281
 
282
 
283
  // Function: set_report_verbosity_level
284
  //
285
  // This method sets the maximum verbosity level for reports for this component.
286
  // Any report from this component whose verbosity exceeds this maximum will
287
  // be ignored.
288
 
289
  function void set_report_verbosity_level (int verbosity_level);
290
    m_rh.set_verbosity_level(verbosity_level);
291
  endfunction
292
 
293
  // Function: set_report_id_verbosity
294
  //
295
  function void set_report_id_verbosity (string id, int verbosity);
296
    m_rh.set_id_verbosity(id, verbosity);
297
  endfunction
298
 
299
  // Function: set_report_severity_id_verbosity
300
  //
301
  // These methods associate the specified verbosity threshold with reports of the
302
  // given ~severity~, ~id~, or ~severity-id~ pair. This threshold is compared with
303
  // the verbosity originally assigned to the report to decide whether it gets
304
  // processed.  A verbosity threshold associated with a particular ~severity-id~
305
  // pair takes precedence over a verbosity threshold associated with ~id~, which
306
  // takes precedence over a verbosity threshold associated with a ~severity~.
307
  //
308
  // The ~verbosity~ argument can be any integer, but is most commonly a
309
  // predefined  value, , , ,
310
  // , .
311
 
312
  function void set_report_severity_id_verbosity (uvm_severity severity,
313
                                               string id, int verbosity);
314
    m_rh.set_severity_id_verbosity(severity, id, verbosity);
315
  endfunction
316
 
317
 
318
  //----------------------------------------------------------------------------
319
  // Group: Action Configuration
320
  //----------------------------------------------------------------------------
321
 
322
 
323
  // Function: get_report_action
324
  //
325
  // Gets the action associated with reports having the given ~severity~
326
  // and ~id~.
327
 
328
  function int get_report_action(uvm_severity severity, string id);
329
    return m_rh.get_action(severity,id);
330
  endfunction
331
 
332
 
333
  // Function: set_report_severity_action
334
  //
335
  function void set_report_severity_action (uvm_severity severity,
336
                                            uvm_action action);
337
    m_rh.set_severity_action(severity, action);
338
  endfunction
339
 
340
  // Function: set_report_id_action
341
  //
342
  function void set_report_id_action (string id, uvm_action action);
343
    m_rh.set_id_action(id, action);
344
  endfunction
345
 
346
  // Function: set_report_severity_id_action
347
  //
348
  // These methods associate the specified action or actions with reports of the
349
  // given ~severity~, ~id~, or ~severity-id~ pair. An action associated with a
350
  // particular ~severity-id~ pair takes precedence over an action associated with
351
  // ~id~, which takes precedence over an action associated with a ~severity~.
352
  //
353
  // The ~action~ argument can take the value , or it can be a
354
  // bitwise OR of any combination of , , ,
355
  // , , and .
356
 
357
  function void set_report_severity_id_action (uvm_severity severity,
358
                                               string id, uvm_action action);
359
    m_rh.set_severity_id_action(severity, id, action);
360
  endfunction
361
 
362
 
363
  //----------------------------------------------------------------------------
364
  // Group: File Configuration
365
  //----------------------------------------------------------------------------
366
 
367
 
368
  // Function: get_report_file_handle
369
  //
370
  // Gets the file descriptor associated with reports having the given
371
  // ~severity~ and ~id~.
372
 
373
  function int get_report_file_handle(uvm_severity severity, string id);
374
    return m_rh.get_file_handle(severity,id);
375
  endfunction
376
 
377
 
378
  // Function: set_report_default_file
379
 
380
  function void set_report_default_file (UVM_FILE file);
381
    m_rh.set_default_file(file);
382
  endfunction
383
 
384
  // Function: set_report_id_file
385
 
386
  function void set_report_id_file (string id, UVM_FILE file);
387
    m_rh.set_id_file(id, file);
388
  endfunction
389
 
390
  // Function: set_report_severity_file
391
  //
392
  function void set_report_severity_file (uvm_severity severity, UVM_FILE file);
393
    m_rh.set_severity_file(severity, file);
394
  endfunction
395
 
396
  // Function: set_report_severity_id_file
397
  //
398
  // These methods configure the report handler to direct some or all of its
399
  // output to the given file descriptor. The ~file~ argument must be a
400
  // multi-channel descriptor (mcd) or file id compatible with $fdisplay.
401
  //
402
  // A FILE descriptor can be associated with reports of
403
  // the given ~severity~, ~id~, or ~severity-id~ pair.  A FILE associated with
404
  // a particular ~severity-id~ pair takes precedence over a FILE associated
405
  // with ~id~, which take precedence over an a FILE associated with a
406
  // ~severity~, which takes precedence over the default FILE descriptor.
407
  //
408
  // When a report is issued and its associated action has the UVM_LOG bit
409
  // set, the report will be sent to its associated FILE descriptor.
410
  // The user is responsible for opening and closing these files.
411
 
412
  function void set_report_severity_id_file (uvm_severity severity, string id,
413
                                             UVM_FILE file);
414
    m_rh.set_severity_id_file(severity, id, file);
415
  endfunction
416
 
417
 
418
  //----------------------------------------------------------------------------
419
  // Group: Override Configuration
420
  //----------------------------------------------------------------------------
421
 
422
 
423
  // Function: set_report_severity_override
424
  //
425
  function void set_report_severity_override(uvm_severity cur_severity,
426
                                             uvm_severity new_severity);
427
    m_rh.set_severity_override(cur_severity, new_severity);
428
  endfunction
429
 
430
  // Function: set_report_severity_id_override
431
  //
432
  // These methods provide the ability to upgrade or downgrade a message in
433
  // terms of severity given ~severity~ and ~id~.  An upgrade or downgrade for
434
  // a specific ~id~ takes precedence over an upgrade or downgrade associated
435
  // with a ~severity~.
436
  function void set_report_severity_id_override(uvm_severity cur_severity,
437
                                                string id,
438
                                                uvm_severity new_severity);
439
    m_rh.set_severity_id_override(cur_severity, id, new_severity);
440
  endfunction
441
 
442
 
443
  //----------------------------------------------------------------------------
444
  // Group: Report Handler Configuration
445
  //----------------------------------------------------------------------------
446
 
447
  // Function: set_report_handler
448
  //
449
  // Sets the report handler, overwriting the default instance. This allows
450
  // more than one component to share the same report handler.
451
 
452
  function void set_report_handler(uvm_report_handler handler);
453
    m_rh = handler;
454
  endfunction
455
 
456
 
457
  // Function: get_report_handler
458
  //
459
  // Returns the underlying report handler to which most reporting tasks
460
  // are delegated.
461
 
462
  function uvm_report_handler get_report_handler();
463
    return m_rh;
464
  endfunction
465
 
466
 
467
  // Function: reset_report_handler
468
  //
469
  // Resets the underlying report handler to its default settings. This clears
470
  // any settings made with the ~set_report_*~ methods (see below).
471
 
472
  function void reset_report_handler;
473
    m_rh.initialize();
474
  endfunction
475
 
476
 
477
`ifndef UVM_NO_DEPRECATED
478
 
479
 
480
  //----------------------------------------------------------------------------
481
  // Group- Callbacks
482
  //----------------------------------------------------------------------------
483
 
484
 
485
  // Function- report_info_hook
486
  //
487
  //
488
 
489
  virtual function bit report_info_hook(
490
           string id, string message, int verbosity, string filename, int line);
491
    return 1;
492
  endfunction
493
 
494
  // Function- report_error_hook
495
  //
496
  //
497
 
498
  virtual function bit report_error_hook(
499
           string id, string message, int verbosity, string filename, int line);
500
    return 1;
501
  endfunction
502
 
503
  // Function- report_warning_hook
504
  //
505
  //
506
 
507
  virtual function bit report_warning_hook(
508
           string id, string message, int verbosity, string filename, int line);
509
    return 1;
510
  endfunction
511
 
512
  // Function- report_fatal_hook
513
  //
514
  //
515
 
516
  virtual function bit report_fatal_hook(
517
           string id, string message, int verbosity, string filename, int line);
518
    return 1;
519
  endfunction
520
 
521
  // Function- report_hook
522
  //
523
  // These hook methods can be defined in derived classes to perform additional
524
  // actions when reports are issued. They are called only if the 
525
  // bit is specified in the action associated with the report. The default
526
  // implementations return 1, which allows the report to be processed. If an
527
  // override returns 0, then the report is not processed.
528
  //
529
  // First, the ~report_hook~ method is called, followed by the severity-specific
530
  // hook (, etc.). If either hook method
531
  // returns 0 then the report is not processed further.
532
 
533
  virtual function bit report_hook(
534
           string id, string message, int verbosity, string filename, int line);
535
    return 1;
536
  endfunction
537
 
538
 
539
  // Function- report_header
540
  //
541
  // Prints version and copyright information. This information is sent to the
542
  // command line if ~file~ is 0, or to the file descriptor ~file~ if it is not 0.
543
  // The  task calls this method just before it component
544
  // phasing begins.
545
  //
546
  // Use 
547
 
548
  virtual function void report_header(UVM_FILE file = 0);
549
     uvm_root l_root;
550
     uvm_coreservice_t cs;
551
     cs = uvm_coreservice_t::get();
552
     l_root = cs.get_root();
553
     l_root.report_header(file);
554
  endfunction
555
 
556
 
557
  // Function- report_summarize
558
  //
559
  // Outputs statistical information on the reports issued by the central report
560
  // server. This information will be sent to the command line if ~file~ is 0, or
561
  // to the file descriptor ~file~ if it is not 0.
562
  //
563
  // The  method in uvm_top calls this method.
564
  //
565
  // Use:
566
  // uvm_report_server rs =uvm_report_server::get_server();
567
  // rs.report_summarize();
568
 
569
  virtual function void report_summarize(UVM_FILE file = 0);
570
    uvm_report_server l_rs = uvm_report_server::get_server();
571
    l_rs.report_summarize(file);
572
  endfunction
573
 
574
 
575
  // Function- die
576
  //
577
  // This method is called by the report server if a report reaches the maximum
578
  // quit count or has a UVM_EXIT action associated with it, e.g., as with
579
  // fatal errors.
580
  //
581
  // Calls the  method
582
  // on the entire  hierarchy in a bottom-up fashion.
583
  // It then call calls  and terminates the simulation
584
  // with ~$finish~.
585
  //
586
  // Use:
587
  // uvm_report_server rs =uvm_report_server::get_server();
588
  // rs.die()
589
 
590
  virtual function void die();
591
     uvm_root l_root;
592
     uvm_coreservice_t cs;
593
     cs = uvm_coreservice_t::get();
594
     l_root = cs.get_root();
595
    l_root.die();
596
  endfunction
597
 
598
 
599
  // Function- set_report_max_quit_count
600
  //
601
  // Sets the maximum quit count in the report handler to ~max_count~. When the
602
  // number of UVM_COUNT actions reaches ~max_count~, the  method is called.
603
  //
604
  // The default value of 0 indicates that there is no upper limit to the number
605
  // of UVM_COUNT reports.
606
  //
607
  // Use:
608
  // uvm_report_server rs =uvm_report_server::get_server();
609
  // rs.set_max_quit_count()
610
 
611
  function void set_report_max_quit_count(int max_count);
612
    uvm_report_server l_rs = uvm_report_server::get_server();
613
    l_rs.set_max_quit_count(max_count);
614
  endfunction
615
 
616
 
617
  // Function- get_report_server
618
  //
619
  // Returns the  instance associated with this report object.
620
  //
621
  // Use 
622
 
623
  function uvm_report_server get_report_server();
624
    uvm_report_server l_rs = uvm_report_server::get_server();
625
    return l_rs;
626
  endfunction
627
 
628
 
629
  // Function- dump_report_state
630
  //
631
  // This method dumps the internal state of the report handler. This includes
632
  // information about the maximum quit count, the maximum verbosity, and the
633
  // action and files associated with severities, ids, and (severity, id) pairs.
634
  //
635
  // Use:
636
  // uvm_report_handler rh =get_report_handler();
637
  // rh.print().
638
 
639
  function void dump_report_state();
640
    m_rh.dump_state();
641
  endfunction
642
 
643
 
644
  //----------------------------------------------------------------------------
645
  //                     PRIVATE or PSUEDO-PRIVATE members
646
  //                      *** Do not call directly ***
647
  //         Implementation and even existence are subject to change.
648
  //----------------------------------------------------------------------------
649
 
650
  protected virtual function uvm_report_object m_get_report_object();
651
    return this;
652
  endfunction
653
 
654
`endif
655
 
656
endclass
657
 
658
`endif // UVM_REPORT_CLIENT_SVH

powered by: WebSVN 2.1.0

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