ovm_report_object.svh

Go to the documentation of this file.
00001 // $Id: ovm__report__object_8svh-source.html,v 1.1 2008/10/07 21:54:50 alex.marin Exp $
00002 //------------------------------------------------------------------------------
00003 //   Copyright 2007-2008 Mentor Graphics Corporation
00004 //   Copyright 2007-2008 Cadence Design Systems, Inc.
00005 //   All Rights Reserved Worldwide
00006 //
00007 //   Licensed under the Apache License, Version 2.0 (the
00008 //   "License"); you may not use this file except in
00009 //   compliance with the License.  You may obtain a copy of
00010 //   the License at
00011 //
00012 //       http://www.apache.org/licenses/LICENSE-2.0
00013 //
00014 //   Unless required by applicable law or agreed to in
00015 //   writing, software distributed under the License is
00016 //   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00017 //   CONDITIONS OF ANY KIND, either express or implied.  See
00018 //   the License for the specific language governing
00019 //   permissions and limitations under the License.
00020 //------------------------------------------------------------------------------
00021 
00022 `ifndef OVM_REPORT_CLIENT_SVH
00023 `define OVM_REPORT_CLIENT_SVH
00024 
00025 typedef class ovm_component;
00026 typedef class ovm_env;
00027 typedef class ovm_root;
00028 
00029 //------------------------------------------------------------------------------
00030 //
00031 // CLASS: ovm_report_object
00032 //
00033 //------------------------------------------------------------------------------
00034 //
00035 // This class provides the public interface for reporting.  Any ovm_object-based
00036 // object that wants to do reporting inherits from this class thus
00037 // making available all the reporting methods.
00038 //
00039 // The ovm_report_object provides a front-end to a report handler, to which all
00040 // operations are delegated and all state is maintained.  When a report passes
00041 // through all filters, the report handler will forward the report to a central
00042 // report server for final formatting and processing.
00043 //
00044 // Each report consists of an id string, severity, verbosity level, and the
00045 // actual message.  If the verbosity level of a report is greater than the
00046 // configured maximum verbosity level of its report handler, it is ignored.
00047 //
00048 // If a report passes the verbosity filter in effect, the handler will then
00049 // determine the configured action, and, if the action includes output to a
00050 // file, the configured file descriptor. 
00051 //
00052 //   Actions - can be set for (in increasing priority) severity, id, and
00053 //   (severity,id) pair.  
00054 //
00055 //   File descriptors -- can be set for (in increasing priority) default,
00056 //   severity level, an id, or a (severity,id) pair.  File descriptors are just
00057 //   ordinary verilog file descriptors; they may refer to more than one file.
00058 //   It is the user's responsibility to open and close them.
00059 //
00060 // File names and line numbers are not yet implemented.
00061 //------------------------------------------------------------------------------
00062 
00063 virtual class ovm_report_object extends ovm_object;
00064 
00065   ovm_report_handler m_rh;
00066 
00067   //----------------------------------------------------------------------------
00068   // Construction and management
00069   //----------------------------------------------------------------------------
00070   // new
00071   //   The constructor takes an optional name as argument. The name is used as
00072   //   the leaf name of the report object. This object's internal report-handler
00073   //   is then created. Most work is delegated to this report handler.
00074   //
00075   // get_report_handler
00076   //   Returns a handle to the underlying report handler.
00077   //
00078   // get_report_server
00079   //   Returns a handle to the common report server.
00080   //
00081   // set_report_handler
00082   //   Replaces this report object's existing report handler.
00083   //
00084   // reset_report_handler
00085   //   Resets the underlying report handler to its default settings. This clears
00086   //   any settings made with the set_report_* methods (see below).
00087   //
00088   // set_report_max_quit_count
00089   //   Sets the threshold at which the server will terminate simulation. When
00090   //   a report is issued and its action includes OVM_COUNT, an internal counter
00091   //   is incremented. When the max is reached, simulation is terminated via a
00092   //   call to 'die'.
00093   //
00094   // die
00095   //   This function is used by the report handler to trigger the end of
00096   //   simulation, or, if this report object is an ovm_component and we're
00097   //   in the run phase, the end of the run phase. 
00098   //
00099   //REVIEW: need way to plug-n-play a different server, e.g. set_server
00100   //REVIEW: propose to delete report_name member and methods in favor of
00101   //        get_full_name. Couple of source changes, and 2 tests need regold.
00102   //REVIEW: ovm_report_handler::initialize doesn't clear out id and (sev,id)
00103   //        arrays.
00104   //REVIEW: any discussion on reports-as-objects? This would reduce overrhead
00105   //        when forwarding arguments to various methods in handler, hooks, etc.
00106   //        A single container could be reused over and over because reporting
00107   //        does not consume time. It also may help to centralize message
00108   //        definition and formatting.
00109   //----------------------------------------------------------------------------
00110 
00111   function new(string name = "");
00112     super.new(name);
00113     m_rh = new();
00114   endfunction
00115 
00116   function ovm_report_handler get_report_handler();
00117     return m_rh;
00118   endfunction
00119 
00120   function ovm_report_server get_report_server();
00121     return m_rh.get_server();
00122   endfunction
00123 
00124   function void set_report_handler(ovm_report_handler hndlr);
00125     m_rh = hndlr;
00126   endfunction
00127 
00128   function void reset_report_handler;
00129     m_rh.initialize;
00130   endfunction
00131 
00132   function void set_report_max_quit_count(int m);
00133     m_rh.set_max_quit_count(m);
00134   endfunction
00135 
00136   virtual function void die();
00137     ovm_component comp;
00138     if($cast(comp, this) && run_ph.is_in_progress())
00139       ovm_top.stop_request();
00140     else begin
00141       fork 
00142         begin
00143           //Fork allows die to complete on all threads before finishing
00144           report_summarize();
00145           $finish;
00146         end
00147       join_none
00148     end
00149   endfunction
00150 
00151 
00152   //----------------------------------------------------------------------------
00153   // Core reporting methods
00154   //----------------------------------------------------------------------------
00155   // ovm_report_*
00156   //   These are the primary reporting methods in the OVM. Using these instead
00157   //   of $display and other ad hoc approaches ensures consistent output and
00158   //   central control over where output is directed and any actions that
00159   //   result. All reporting methods have the same arguments, albeit different
00160   //   default verbosities:
00161   //
00162   //   id        - a unique id for the report or report group that can be used
00163   //               for identification and targeted filtering.
00164   //
00165   //   message   - the message itself, preformatted
00166   //
00167   //   verbosity - the verbosity of the message. If this number is less than or
00168   //               equal to the effective verbosity level (see 
00169   //               set_report_verbosity_level), the report is issued. Each
00170   //               severity has a default verbosity level.
00171   //
00172   //   filename  - the filename in which the method was invoked.
00173   //
00174   //   line      - the line number of the file in which the method was invoked.
00175   //
00176   // These methods delegate to corresponding methods in the ovm_report_handler
00177   // associated with this report object, passing in the report_object's name and
00178   // handle, which defines the context of the report.
00179   //----------------------------------------------------------------------------
00180 
00181   virtual function void ovm_report_info( string id,
00182                                          string message,
00183                                          int verbosity = 300,
00184                                          string filename = "",
00185                                          int line = 0);
00186     m_rh.report(OVM_INFO, get_full_name(), id, message, verbosity,
00187                 filename, line, this);
00188   endfunction
00189 
00190   virtual function void ovm_report_warning( string id,
00191                                             string message,
00192                                             int verbosity = 200,
00193                                             string filename = "",
00194                                             int line = 0);
00195     m_rh.report(OVM_WARNING, get_full_name(), id, message, verbosity, 
00196                filename, line, this);
00197   endfunction
00198 
00199   virtual function void ovm_report_error( string id,
00200                                           string message,
00201                                           int verbosity = 100,
00202                                           string filename = "",
00203                                           int line = 0);
00204     m_rh.report(OVM_ERROR, get_full_name(), id, message, verbosity, 
00205                filename, line, this);
00206   endfunction
00207 
00208   virtual function void ovm_report_fatal( string id,
00209                                           string message,
00210                                           int verbosity = 0,
00211                                           string filename = "",
00212                                           int line = 0);
00213     m_rh.report(OVM_FATAL, get_full_name(), id, message, verbosity, 
00214                filename, line, this);
00215   endfunction
00216 
00217   virtual function void report_summarize(OVM_FILE f = 0);
00218     m_rh.summarize(f);
00219   endfunction
00220 
00221   virtual function void report_header(OVM_FILE f = 0);
00222     m_rh.report_header(f);
00223   endfunction
00224 
00225   //----------------------------------------------------------------------------
00226   // Report action hooks
00227   //----------------------------------------------------------------------------
00228   // These virtual methods offer subclasses the opportunity to perform
00229   // pre-report processing and filtering. First, the hook method associated with
00230   // the report's severity is called with the same arguments as given the report
00231   // report. If it returns 1, the catch-all method, report_hook, is then called.
00232   // If this method also returns 1, then the report is issued. If either hook
00233   // method returns 0, the report is not issued. If the severity-specific hook
00234   // returns 0, the catch-all hook is not called.  The default implementations
00235   // return 1, i.e. do not preempt reports from being issued.
00236   //----------------------------------------------------------------------------
00237 
00238   virtual function bit report_hook( string id,
00239                                     string message,
00240                                     int verbosity,
00241                                     string filename,
00242                                     int line);
00243     return 1;
00244   endfunction
00245 
00246   virtual function bit report_info_hook( string id,
00247                                          string message,
00248                                          int verbosity,
00249                                          string filename,
00250                                          int line);
00251     return 1;
00252   endfunction
00253 
00254   virtual function bit report_warning_hook( string id,
00255                                             string message,
00256                                             int verbosity,
00257                                             string filename,
00258                                             int line);
00259     return 1;
00260   endfunction
00261 
00262   virtual function bit report_error_hook( string id,
00263                                           string message,
00264                                           int verbosity,
00265                                           string filename,
00266                                           int line);
00267     return 1;
00268   endfunction
00269 
00270   virtual function bit report_fatal_hook( string id,
00271                                           string message,
00272                                           int verbosity,
00273                                           string filename,
00274                                           int line);
00275     return 1;
00276   endfunction
00277 
00278 
00279   //----------------------------------------------------------------------------
00280   // File and Action Configuration
00281   //----------------------------------------------------------------------------
00282   // set_report_*_action
00283   //   These methods associate the specified action
00284   //   with reports of the given severity, id, or severity-id pair. An action
00285   //   associated with a particular severity-id pair takes precedence over an
00286   //   action associated with id, which take precedence over an an action
00287   //   associated with a severity.
00288   // 
00289   // set_report_*_file
00290   //   These methods associate the specified FILE descriptor with reports of
00291   //   the given severity, id, or severity-id pair.  A FILE associated with a
00292   //   particular severity-id pair takes precedence over a FILE associated with
00293   //   id, which take precedence over an a FILE associated with a severity,
00294   //   which takes precedence over the default FILE descriptor.
00295   //
00296   // set_report_verbosity_level
00297   //   This method sets the maximum verbosity level for reports for this
00298   //   component and all those below it.  Any report from this component
00299   //   whose verbosity exceeds this maximum will be ignored.
00300   // 
00301   // When a report is issued and its associated action has the LOG bit
00302   // set, the report will be sent to its associated FILE descriptor.
00303   // The user is responsible for opening and closing these files.
00304   //----------------------------------------------------------------------------
00305 
00306   function void set_report_verbosity_level (int verbosity_level);
00307     m_rh.set_verbosity_level(verbosity_level);
00308   endfunction
00309 
00310   function void set_report_severity_action (ovm_severity s, ovm_action a);
00311     m_rh.set_severity_action(s, a);
00312   endfunction
00313 
00314   function void set_report_id_action (string id, ovm_action a);
00315     m_rh.set_id_action(id, a);
00316   endfunction
00317 
00318   function void set_report_severity_id_action (ovm_severity s, string id,
00319                                                ovm_action a);
00320     m_rh.set_severity_id_action(s, id, a);
00321   endfunction
00322 
00323   function void set_report_default_file ( OVM_FILE f);
00324     m_rh.set_default_file(f);
00325   endfunction
00326 
00327   function void set_report_severity_file (ovm_severity s, OVM_FILE f);
00328     m_rh.set_severity_file(s, f);
00329   endfunction
00330 
00331   function void set_report_id_file (string id, OVM_FILE f);
00332     m_rh.set_id_file(id, f);
00333   endfunction
00334 
00335   function void set_report_severity_id_file (ovm_severity s, string id,
00336                                              OVM_FILE f);
00337     m_rh.set_severity_id_file(s, id, f);
00338   endfunction
00339 
00340   function void dump_report_state();
00341     m_rh.dump_state();
00342   endfunction
00343 
00344 
00345   //----------------------------------------------------------------------------
00346   //                     PRIVATE or PSUEDO-PRIVATE members
00347   //                      *** Do not call directly ***
00348   //         Implementation and even existence are subject to change. 
00349   //----------------------------------------------------------------------------
00350 
00351   protected virtual function ovm_report_object m_get_report_object();
00352     return this;
00353   endfunction
00354 
00355 
00356   //----------------------------------------------------------------------------
00357   //                          DEPRECATED MEMBERS
00358   //                      *** Do not use in new code ***
00359   //                  Convert existing code when appropriate.
00360   //----------------------------------------------------------------------------
00361 
00362   virtual function void ovm_report_message( string id,
00363                                             string message,
00364                                             int verbosity = 300,
00365                                             string filename = "",
00366                                             int line = 0);
00367     m_rh.report(OVM_INFO, get_full_name(), id, message, verbosity, 
00368                filename, line, this);
00369   endfunction
00370 
00371   virtual function bit report_message_hook( string id,
00372                                             string message,
00373                                             int verbosity,
00374                                             string filename,
00375                                             int line);
00376     return 1;
00377   endfunction
00378 
00379   function void avm_report_message( string id,
00380                                     string message,
00381                                     int verbosity = 300,
00382                                     string filename = "",
00383                                     int line = 0);
00384     m_rh.report(OVM_INFO, get_full_name(), id, message, verbosity,
00385                 filename, line, this);
00386   endfunction
00387 
00388   function void avm_report_warning( string id,
00389                                     string message,
00390                                     int verbosity = 200,
00391                                     string filename = "",
00392                                     int line = 0);
00393     m_rh.report(OVM_WARNING, get_full_name(), id, message, verbosity,
00394                 filename, line, this);
00395   endfunction
00396 
00397   function void avm_report_error( string id,
00398                                   string message,
00399                                   int verbosity = 100,
00400                                   string filename = "",
00401                                   int line = 0);
00402     m_rh.report(OVM_ERROR, get_full_name(), id, message, verbosity,
00403                 filename, line, this);
00404   endfunction
00405 
00406   function void avm_report_fatal( string id,
00407                                   string message,
00408                                   int verbosity = 0,
00409                                   string filename = "",
00410                                   int line = 0);
00411     m_rh.report(OVM_FATAL, get_full_name(), id, message, verbosity,
00412                 filename, line, this);
00413   endfunction
00414 
00415   /*
00416   local string m_report_name;
00417 
00418   function string get_report_name();
00419     return m_report_name;
00420   endfunction
00421 
00422   function void set_report_name(string s);
00423     m_report_name = s;
00424   endfunction
00425   */
00426 
00427 endclass
00428 
00429 
00430 
00431 //------------------------------------------------------------------------------
00432 //
00433 // CLASS: ovm_reporter
00434 //
00435 //------------------------------------------------------------------------------
00436 // For use by objects that do not inherit the features of ovm_report_object,
00437 // i.e. for use by non-ovm_component-based objects.
00438 //------------------------------------------------------------------------------
00439 
00440 class ovm_reporter extends ovm_report_object;
00441 
00442   function new(string name = "reporter");
00443     super.new(name);
00444   endfunction
00445 
00446   function ovm_object create (string name = "");
00447     ovm_reporter r; 
00448     if(name=="") name="reporter"; 
00449     r=new(name);
00450     return r;
00451   endfunction
00452 
00453 endclass
00454 
00455 `endif //OVM_REPORT_CLIENT_SVH

Intelligent Design Verification
Intelligent Design Verification
Project: OVM, Revision: 1.1.0
Copyright (c) 2008 Intelligent Design Verification.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included here:
http://www.intelligentdv.com/licenses/fdl.txt
doxygen
Doxygen Version: 1.4.6
Mon Sep 29 14:20:12 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV