00001 // $Id: a00268.html,v 1.1 2009/01/07 19:29:44 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 handler); 00125 m_rh = handler; 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 max_count); 00133 m_rh.set_max_quit_count(max_count); 00134 endfunction 00135 00136 virtual function void die(); 00137 ovm_component comp; 00138 if($cast(comp, this) && run_ph.is_in_progress()) begin 00139 ovm_top.stop_request(); 00140 end 00141 00142 fork 00143 begin 00144 //Fork allows die to complete on all threads before finishing 00145 report_summarize(); 00146 $finish; 00147 end 00148 join_none 00149 00150 endfunction 00151 00152 00153 //---------------------------------------------------------------------------- 00154 // Core reporting methods 00155 //---------------------------------------------------------------------------- 00156 // ovm_report_* 00157 // These are the primary reporting methods in the OVM. Using these instead 00158 // of $display and other ad hoc approaches ensures consistent output and 00159 // central control over where output is directed and any actions that 00160 // result. All reporting methods have the same arguments, albeit different 00161 // default verbosities: 00162 // 00163 // id - a unique id for the report or report group that can be used 00164 // for identification and targeted filtering. 00165 // 00166 // message - the message itself, preformatted 00167 // 00168 // verbosity - the verbosity of the message. If this number is less than or 00169 // equal to the effective verbosity level (see 00170 // set_report_verbosity_level), the report is issued. Each 00171 // severity has a default verbosity level. 00172 // 00173 // filename - the filename in which the method was invoked. 00174 // 00175 // line - the line number of the file in which the method was invoked. 00176 // 00177 // These methods delegate to corresponding methods in the ovm_report_handler 00178 // associated with this report object, passing in the report_object's name and 00179 // handle, which defines the context of the report. 00180 //---------------------------------------------------------------------------- 00181 00182 virtual function void ovm_report_info( string id, 00183 string message, 00184 int verbosity = OVM_MEDIUM, 00185 string filename = "", 00186 int line = 0); 00187 m_rh.report(OVM_INFO, get_full_name(), id, message, verbosity, 00188 filename, line, this); 00189 endfunction 00190 00191 virtual function void ovm_report_warning( string id, 00192 string message, 00193 int verbosity = OVM_MEDIUM, 00194 string filename = "", 00195 int line = 0); 00196 m_rh.report(OVM_WARNING, get_full_name(), id, message, verbosity, 00197 filename, line, this); 00198 endfunction 00199 00200 virtual function void ovm_report_error( string id, 00201 string message, 00202 int verbosity = OVM_LOW, 00203 string filename = "", 00204 int line = 0); 00205 m_rh.report(OVM_ERROR, get_full_name(), id, message, verbosity, 00206 filename, line, this); 00207 endfunction 00208 00209 virtual function void ovm_report_fatal( string id, 00210 string message, 00211 int verbosity = OVM_NONE, 00212 string filename = "", 00213 int line = 0); 00214 m_rh.report(OVM_FATAL, get_full_name(), id, message, verbosity, 00215 filename, line, this); 00216 endfunction 00217 00218 virtual function void report_summarize(OVM_FILE file = 0); 00219 m_rh.summarize(file); 00220 endfunction 00221 00222 virtual function void report_header(OVM_FILE file = 0); 00223 m_rh.report_header(file); 00224 endfunction 00225 00226 //---------------------------------------------------------------------------- 00227 // Report action hooks 00228 //---------------------------------------------------------------------------- 00229 // These virtual methods offer subclasses the opportunity to perform 00230 // pre-report processing and filtering. First, the hook method associated with 00231 // the report's severity is called with the same arguments as given the report 00232 // report. If it returns 1, the catch-all method, report_hook, is then called. 00233 // If this method also returns 1, then the report is issued. If either hook 00234 // method returns 0, the report is not issued. If the severity-specific hook 00235 // returns 0, the catch-all hook is not called. The default implementations 00236 // return 1, i.e. do not preempt reports from being issued. 00237 //---------------------------------------------------------------------------- 00238 00239 virtual function bit report_hook( string id, 00240 string message, 00241 int verbosity, 00242 string filename, 00243 int line); 00244 return 1; 00245 endfunction 00246 00247 virtual function bit report_info_hook( string id, 00248 string message, 00249 int verbosity, 00250 string filename, 00251 int line); 00252 return 1; 00253 endfunction 00254 00255 virtual function bit report_warning_hook( string id, 00256 string message, 00257 int verbosity, 00258 string filename, 00259 int line); 00260 return 1; 00261 endfunction 00262 00263 virtual function bit report_error_hook( string id, 00264 string message, 00265 int verbosity, 00266 string filename, 00267 int line); 00268 return 1; 00269 endfunction 00270 00271 virtual function bit report_fatal_hook( string id, 00272 string message, 00273 int verbosity, 00274 string filename, 00275 int line); 00276 return 1; 00277 endfunction 00278 00279 00280 //---------------------------------------------------------------------------- 00281 // File and Action Configuration 00282 //---------------------------------------------------------------------------- 00283 // set_report_*_action 00284 // These methods associate the specified action 00285 // with reports of the given severity, id, or severity-id pair. An action 00286 // associated with a particular severity-id pair takes precedence over an 00287 // action associated with id, which take precedence over an an action 00288 // associated with a severity. 00289 // 00290 // set_report_*_file 00291 // These methods associate the specified FILE descriptor with reports of 00292 // the given severity, id, or severity-id pair. A FILE associated with a 00293 // particular severity-id pair takes precedence over a FILE associated with 00294 // id, which take precedence over an a FILE associated with a severity, 00295 // which takes precedence over the default FILE descriptor. 00296 // 00297 // set_report_verbosity_level 00298 // This method sets the maximum verbosity level for reports for this 00299 // component and all those below it. Any report from this component 00300 // whose verbosity exceeds this maximum will be ignored. 00301 // 00302 // When a report is issued and its associated action has the LOG bit 00303 // set, the report will be sent to its associated FILE descriptor. 00304 // The user is responsible for opening and closing these files. 00305 //---------------------------------------------------------------------------- 00306 00307 function void set_report_verbosity_level (int verbosity_level); 00308 m_rh.set_verbosity_level(verbosity_level); 00309 endfunction 00310 00311 function void set_report_severity_action (ovm_severity severity, ovm_action action); 00312 m_rh.set_severity_action(severity, action); 00313 endfunction 00314 00315 function void set_report_id_action (string id, ovm_action action); 00316 m_rh.set_id_action(id, action); 00317 endfunction 00318 00319 function void set_report_severity_id_action (ovm_severity severity, string id, 00320 ovm_action action); 00321 m_rh.set_severity_id_action(severity, id, action); 00322 endfunction 00323 00324 function void set_report_default_file ( OVM_FILE file); 00325 m_rh.set_default_file(file); 00326 endfunction 00327 00328 function void set_report_severity_file (ovm_severity severity, OVM_FILE file); 00329 m_rh.set_severity_file(severity, file); 00330 endfunction 00331 00332 function void set_report_id_file (string id, OVM_FILE file); 00333 m_rh.set_id_file(id, file); 00334 endfunction 00335 00336 function void set_report_severity_id_file (ovm_severity severity, string id, 00337 OVM_FILE file); 00338 m_rh.set_severity_id_file(severity, id, file); 00339 endfunction 00340 00341 function int get_report_verbosity_level(); 00342 return m_rh.get_verbosity_level(); 00343 endfunction 00344 00345 function int get_report_action(ovm_severity severity, string id); 00346 return m_rh.get_action(severity,id); 00347 endfunction 00348 00349 function int get_report_file_handle(ovm_severity severity, string id); 00350 return m_rh.get_file_handle(severity,id); 00351 endfunction 00352 00353 function int ovm_report_enabled(int verbosity); 00354 return (get_report_verbosity_level() >= verbosity); 00355 endfunction 00356 00357 function void dump_report_state(); 00358 m_rh.dump_state(); 00359 endfunction 00360 00361 00362 //---------------------------------------------------------------------------- 00363 // PRIVATE or PSUEDO-PRIVATE members 00364 // *** Do not call directly *** 00365 // Implementation and even existence are subject to change. 00366 //---------------------------------------------------------------------------- 00367 00368 protected virtual function ovm_report_object m_get_report_object(); 00369 return this; 00370 endfunction 00371 00372 00373 //---------------------------------------------------------------------------- 00374 // DEPRECATED MEMBERS 00375 // *** Do not use in new code *** 00376 // Convert existing code when appropriate. 00377 //---------------------------------------------------------------------------- 00378 00379 function void avm_report_message( string id, 00380 string message, 00381 int verbosity = OVM_MEDIUM, 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 = OVM_MEDIUM, 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 = OVM_LOW, 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 = OVM_NONE, 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 endclass 00417 00418 00419 00420 //------------------------------------------------------------------------------ 00421 // 00422 // CLASS: ovm_reporter 00423 // 00424 //------------------------------------------------------------------------------ 00425 // For use by objects that do not inherit the features of ovm_report_object, 00426 // i.e. for use by non-ovm_component-based objects. 00427 //------------------------------------------------------------------------------ 00428 00429 class ovm_reporter extends ovm_report_object; 00430 00431 const static string type_name = "ovm_reporter"; 00432 00433 function new(string name = "reporter"); 00434 super.new(name); 00435 endfunction 00436 00437 virtual function string get_type_name (); 00438 return type_name; 00439 endfunction 00440 00441 virtual function ovm_object create (string name = ""); 00442 ovm_reporter r; 00443 if(name=="") name="reporter"; 00444 r=new(name); 00445 return r; 00446 endfunction 00447 00448 endclass 00449 00450 `endif //OVM_REPORT_CLIENT_SVH
![]() Intelligent Design Verification Project: OVM, Revision: 2.0.1 |
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.5.5 Wed Jan 7 19:27:18 2009 |