00001 // $Id: ovm__report__object_8svh-source.html,v 1.1 2008/10/07 21:54:23 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 function int ovm_get_max_verbosity(); 00068 return m_rh.m_max_verbosity_level; 00069 endfunction 00070 00071 //---------------------------------------------------------------------------- 00072 // Construction and management 00073 //---------------------------------------------------------------------------- 00074 // new 00075 // The constructor takes an optional name as argument. The name is used as 00076 // the leaf name of the report object. This object's internal report-handler 00077 // is then created. Most work is delegated to this report handler. 00078 // 00079 // get_report_handler 00080 // Returns a handle to the underlying report handler. 00081 // 00082 // get_report_server 00083 // Returns a handle to the common report server. 00084 // 00085 // set_report_handler 00086 // Replaces this report object's existing report handler. 00087 // 00088 // reset_report_handler 00089 // Resets the underlying report handler to its default settings. This clears 00090 // any settings made with the set_report_* methods (see below). 00091 // 00092 // set_report_max_quit_count 00093 // Sets the threshold at which the server will terminate simulation. When 00094 // a report is issued and its action includes OVM_COUNT, an internal counter 00095 // is incremented. When the max is reached, simulation is terminated via a 00096 // call to 'die'. 00097 // 00098 // die 00099 // This function is used by the report handler to trigger the end of 00100 // simulation, or, if this report object is an ovm_component and we're 00101 // in the run phase, the end of the run phase. 00102 // 00103 //REVIEW: need way to plug-n-play a different server, e.g. set_server 00104 //REVIEW: propose to delete report_name member and methods in favor of 00105 // get_full_name. Couple of source changes, and 2 tests need regold. 00106 //REVIEW: ovm_report_handler::initialize doesn't clear out id and (sev,id) 00107 // arrays. 00108 //REVIEW: any discussion on reports-as-objects? This would reduce overrhead 00109 // when forwarding arguments to various methods in handler, hooks, etc. 00110 // A single container could be reused over and over because reporting 00111 // does not consume time. It also may help to centralize message 00112 // definition and formatting. 00113 //---------------------------------------------------------------------------- 00114 00115 function new(string name = ""); 00116 super.new(name); 00117 m_rh = new(); 00118 endfunction 00119 00120 function ovm_report_handler get_report_handler(); 00121 return m_rh; 00122 endfunction 00123 00124 function ovm_report_server get_report_server(); 00125 return m_rh.get_server(); 00126 endfunction 00127 00128 function void set_report_handler(ovm_report_handler handler); 00129 m_rh = handler; 00130 endfunction 00131 00132 function void reset_report_handler; 00133 m_rh.initialize; 00134 endfunction 00135 00136 function void set_report_max_quit_count(int max_count); 00137 m_rh.set_max_quit_count(max_count); 00138 endfunction 00139 00140 virtual function void die(); 00141 ovm_component comp; 00142 if($cast(comp, this) && run_ph.is_in_progress()) 00143 ovm_top.stop_request(); 00144 else begin 00145 fork 00146 begin 00147 //Fork allows die to complete on all threads before finishing 00148 report_summarize(); 00149 $finish; 00150 end 00151 join_none 00152 end 00153 endfunction 00154 00155 00156 //---------------------------------------------------------------------------- 00157 // Core reporting methods 00158 //---------------------------------------------------------------------------- 00159 // ovm_report_* 00160 // These are the primary reporting methods in the OVM. Using these instead 00161 // of $display and other ad hoc approaches ensures consistent output and 00162 // central control over where output is directed and any actions that 00163 // result. All reporting methods have the same arguments, albeit different 00164 // default verbosities: 00165 // 00166 // id - a unique id for the report or report group that can be used 00167 // for identification and targeted filtering. 00168 // 00169 // message - the message itself, preformatted 00170 // 00171 // verbosity - the verbosity of the message. If this number is less than or 00172 // equal to the effective verbosity level (see 00173 // set_report_verbosity_level), the report is issued. Each 00174 // severity has a default verbosity level. 00175 // 00176 // filename - the filename in which the method was invoked. 00177 // 00178 // line - the line number of the file in which the method was invoked. 00179 // 00180 // These methods delegate to corresponding methods in the ovm_report_handler 00181 // associated with this report object, passing in the report_object's name and 00182 // handle, which defines the context of the report. 00183 //---------------------------------------------------------------------------- 00184 00185 virtual function void ovm_report_info( string id, 00186 string message, 00187 int verbosity = OVM_MEDIUM, 00188 string filename = "", 00189 int line = 0); 00190 m_rh.report(OVM_INFO, get_full_name(), id, message, verbosity, 00191 filename, line, this); 00192 endfunction 00193 00194 virtual function void ovm_report_warning( string id, 00195 string message, 00196 int verbosity = OVM_MEDIUM, 00197 string filename = "", 00198 int line = 0); 00199 m_rh.report(OVM_WARNING, get_full_name(), id, message, verbosity, 00200 filename, line, this); 00201 endfunction 00202 00203 virtual function void ovm_report_error( string id, 00204 string message, 00205 int verbosity = OVM_LOW, 00206 string filename = "", 00207 int line = 0); 00208 m_rh.report(OVM_ERROR, get_full_name(), id, message, verbosity, 00209 filename, line, this); 00210 endfunction 00211 00212 virtual function void ovm_report_fatal( string id, 00213 string message, 00214 int verbosity = OVM_NONE, 00215 string filename = "", 00216 int line = 0); 00217 m_rh.report(OVM_FATAL, get_full_name(), id, message, verbosity, 00218 filename, line, this); 00219 endfunction 00220 00221 virtual function void report_summarize(OVM_FILE file = 0); 00222 m_rh.summarize(file); 00223 endfunction 00224 00225 virtual function void report_header(OVM_FILE file = 0); 00226 m_rh.report_header(file); 00227 endfunction 00228 00229 //---------------------------------------------------------------------------- 00230 // Report action hooks 00231 //---------------------------------------------------------------------------- 00232 // These virtual methods offer subclasses the opportunity to perform 00233 // pre-report processing and filtering. First, the hook method associated with 00234 // the report's severity is called with the same arguments as given the report 00235 // report. If it returns 1, the catch-all method, report_hook, is then called. 00236 // If this method also returns 1, then the report is issued. If either hook 00237 // method returns 0, the report is not issued. If the severity-specific hook 00238 // returns 0, the catch-all hook is not called. The default implementations 00239 // return 1, i.e. do not preempt reports from being issued. 00240 //---------------------------------------------------------------------------- 00241 00242 virtual function bit report_hook( string id, 00243 string message, 00244 int verbosity, 00245 string filename, 00246 int line); 00247 return 1; 00248 endfunction 00249 00250 virtual function bit report_info_hook( string id, 00251 string message, 00252 int verbosity, 00253 string filename, 00254 int line); 00255 return 1; 00256 endfunction 00257 00258 virtual function bit report_warning_hook( string id, 00259 string message, 00260 int verbosity, 00261 string filename, 00262 int line); 00263 return 1; 00264 endfunction 00265 00266 virtual function bit report_error_hook( string id, 00267 string message, 00268 int verbosity, 00269 string filename, 00270 int line); 00271 return 1; 00272 endfunction 00273 00274 virtual function bit report_fatal_hook( string id, 00275 string message, 00276 int verbosity, 00277 string filename, 00278 int line); 00279 return 1; 00280 endfunction 00281 00282 00283 //---------------------------------------------------------------------------- 00284 // File and Action Configuration 00285 //---------------------------------------------------------------------------- 00286 // set_report_*_action 00287 // These methods associate the specified action 00288 // with reports of the given severity, id, or severity-id pair. An action 00289 // associated with a particular severity-id pair takes precedence over an 00290 // action associated with id, which take precedence over an an action 00291 // associated with a severity. 00292 // 00293 // set_report_*_file 00294 // These methods associate the specified FILE descriptor with reports of 00295 // the given severity, id, or severity-id pair. A FILE associated with a 00296 // particular severity-id pair takes precedence over a FILE associated with 00297 // id, which take precedence over an a FILE associated with a severity, 00298 // which takes precedence over the default FILE descriptor. 00299 // 00300 // set_report_verbosity_level 00301 // This method sets the maximum verbosity level for reports for this 00302 // component and all those below it. Any report from this component 00303 // whose verbosity exceeds this maximum will be ignored. 00304 // 00305 // When a report is issued and its associated action has the LOG bit 00306 // set, the report will be sent to its associated FILE descriptor. 00307 // The user is responsible for opening and closing these files. 00308 //---------------------------------------------------------------------------- 00309 00310 function void set_report_verbosity_level (int verbosity_level); 00311 m_rh.set_verbosity_level(verbosity_level); 00312 endfunction 00313 00314 function void set_report_severity_action (ovm_severity severity, ovm_action action); 00315 m_rh.set_severity_action(severity, action); 00316 endfunction 00317 00318 function void set_report_id_action (string id, ovm_action action); 00319 m_rh.set_id_action(id, action); 00320 endfunction 00321 00322 function void set_report_severity_id_action (ovm_severity severity, string id, 00323 ovm_action action); 00324 m_rh.set_severity_id_action(severity, id, action); 00325 endfunction 00326 00327 function void set_report_default_file ( OVM_FILE file); 00328 m_rh.set_default_file(file); 00329 endfunction 00330 00331 function void set_report_severity_file (ovm_severity severity, OVM_FILE file); 00332 m_rh.set_severity_file(severity, file); 00333 endfunction 00334 00335 function void set_report_id_file (string id, OVM_FILE file); 00336 m_rh.set_id_file(id, file); 00337 endfunction 00338 00339 function void set_report_severity_id_file (ovm_severity severity, string id, 00340 OVM_FILE file); 00341 m_rh.set_severity_id_file(severity, id, file); 00342 endfunction 00343 00344 function void dump_report_state(); 00345 m_rh.dump_state(); 00346 endfunction 00347 00348 00349 //---------------------------------------------------------------------------- 00350 // PRIVATE or PSUEDO-PRIVATE members 00351 // *** Do not call directly *** 00352 // Implementation and even existence are subject to change. 00353 //---------------------------------------------------------------------------- 00354 00355 protected virtual function ovm_report_object m_get_report_object(); 00356 return this; 00357 endfunction 00358 00359 00360 //---------------------------------------------------------------------------- 00361 // DEPRECATED MEMBERS 00362 // *** Do not use in new code *** 00363 // Convert existing code when appropriate. 00364 //---------------------------------------------------------------------------- 00365 00366 function void avm_report_message( string id, 00367 string message, 00368 int verbosity = OVM_MEDIUM, 00369 string filename = "", 00370 int line = 0); 00371 m_rh.report(OVM_INFO, get_full_name(), id, message, verbosity, 00372 filename, line, this); 00373 endfunction 00374 00375 function void avm_report_warning( string id, 00376 string message, 00377 int verbosity = OVM_MEDIUM, 00378 string filename = "", 00379 int line = 0); 00380 m_rh.report(OVM_WARNING, get_full_name(), id, message, verbosity, 00381 filename, line, this); 00382 endfunction 00383 00384 function void avm_report_error( string id, 00385 string message, 00386 int verbosity = OVM_LOW, 00387 string filename = "", 00388 int line = 0); 00389 m_rh.report(OVM_ERROR, get_full_name(), id, message, verbosity, 00390 filename, line, this); 00391 endfunction 00392 00393 function void avm_report_fatal( string id, 00394 string message, 00395 int verbosity = OVM_NONE, 00396 string filename = "", 00397 int line = 0); 00398 m_rh.report(OVM_FATAL, get_full_name(), id, message, verbosity, 00399 filename, line, this); 00400 endfunction 00401 00402 00403 endclass 00404 00405 00406 00407 //------------------------------------------------------------------------------ 00408 // 00409 // CLASS: ovm_reporter 00410 // 00411 //------------------------------------------------------------------------------ 00412 // For use by objects that do not inherit the features of ovm_report_object, 00413 // i.e. for use by non-ovm_component-based objects. 00414 //------------------------------------------------------------------------------ 00415 00416 class ovm_reporter extends ovm_report_object; 00417 00418 const static string type_name = "ovm_reporter"; 00419 00420 function new(string name = "reporter"); 00421 super.new(name); 00422 endfunction 00423 00424 virtual function string get_type_name (); 00425 return type_name; 00426 endfunction 00427 00428 virtual function ovm_object create (string name = ""); 00429 ovm_reporter r; 00430 if(name=="") name="reporter"; 00431 r=new(name); 00432 return r; 00433 endfunction 00434 00435 endclass 00436 00437 `endif //OVM_REPORT_CLIENT_SVH
![]() 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 Version: 1.4.6 Mon Sep 29 14:23:30 2008 |