00001 // $Id: ovm__report__handler_8svh-source.html,v 1.1 2008/10/07 21:54:21 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_HANDLER_SVH 00023 `define OVM_REPORT_HANDLER_SVH 00024 00025 typedef class ovm_report_object; 00026 typedef class ovm_report_server; 00027 typedef class ovm_report_global_server; 00028 00029 `ifdef INCA 00030 00031 class ovm_hash #(type T=int, I1=int, I2=int); 00032 local T d[string]; 00033 function void set(I1 i1, I2 i2, T t); 00034 string s; 00035 $swrite(s,i1,":",i2); 00036 d[s] = t; 00037 endfunction 00038 function T get(I1 i1,I2 i2); 00039 string s; 00040 $swrite(s,i1,":",i2); 00041 return d[s]; 00042 endfunction 00043 function int exists(I1 i1, I2 i2); 00044 string s; 00045 $swrite(s,i1,":",i2); 00046 return d.exists(s); 00047 endfunction 00048 function int first(string index); 00049 return d.first(index); 00050 endfunction 00051 function int next(string index); 00052 return d.next(index); 00053 endfunction 00054 function T fetch(string index); 00055 return d[index]; 00056 endfunction 00057 endclass : ovm_hash 00058 `endif 00059 00060 //---------------------------------------------------------------------- 00061 // CLASS ovm_report_handler 00062 //---------------------------------------------------------------------- 00063 class ovm_report_handler; 00064 00065 ovm_report_global_server m_glob; 00066 00067 // This is the maximum verbosity level for this report 00068 // handler. If any report has a higher verbosity level, 00069 // it is simply ignored 00070 00071 int m_max_verbosity_level; 00072 00073 // actions : severity, id, (severity,id) 00074 ovm_action severity_actions[ovm_severity]; 00075 `ifndef INCA 00076 id_actions_array id_actions; 00077 id_actions_array severity_id_actions[ovm_severity]; 00078 00079 // file handles : default, severity, action, (severity,id) 00080 OVM_FILE default_file_handle; 00081 OVM_FILE severity_file_handles[ovm_severity]; 00082 id_file_array id_file_handles; 00083 id_file_array severity_id_file_handles[ovm_severity]; 00084 `endif 00085 `ifdef INCA 00086 ovm_action id_actions[string]; 00087 ovm_hash #(ovm_action,ovm_severity,string) severity_id_actions = new; 00088 00089 OVM_FILE default_file_handle; 00090 OVM_FILE severity_file_handles[ovm_severity]; 00091 OVM_FILE id_file_handles[string]; 00092 ovm_hash #(OVM_FILE,ovm_severity,string) severity_id_file_handles = new; 00093 `endif 00094 00095 function new(); 00096 m_glob = new(); 00097 initialize; 00098 endfunction 00099 00100 function ovm_report_server get_server(); 00101 return m_glob.get_server(); 00102 endfunction 00103 00104 // forward the call to the server 00105 function void set_max_quit_count(int max_count); 00106 ovm_report_server srvr; 00107 srvr = m_glob.get_server(); 00108 srvr.set_max_quit_count(max_count); 00109 endfunction 00110 00111 function void summarize(OVM_FILE file = 0); 00112 ovm_report_server srvr; 00113 srvr = m_glob.get_server(); 00114 srvr.summarize(file); 00115 endfunction 00116 00117 function void report_header(OVM_FILE file = 0); 00118 00119 ovm_report_server srvr; 00120 00121 srvr = m_glob.get_server(); 00122 srvr.f_display(file, "----------------------------------------------------------------"); 00123 srvr.f_display(file, ovm_revision_string()); 00124 srvr.f_display(file, ovm_mgc_copyright); 00125 srvr.f_display(file, ovm_cdn_copyright); 00126 srvr.f_display(file, "----------------------------------------------------------------"); 00127 endfunction 00128 00129 //-------------------------------------------------------------------- 00130 // initialize 00131 // UPDATE COMMENTS 00132 // all severities both DISPLAY and LOG each report. In 00133 // addition, ERRORs are also COUNTED (so the simulation 00134 // will terminate when max_quit_count is reached) FATALs 00135 // also EXIT (ie, the simulation is immediately 00136 // terminated) 00137 // 00138 // All files (default, severity, id and (severity,id)) 00139 // are initially set to zero. This means that they will be 00140 // ignored. 00141 //-------------------------------------------------------------------- 00142 00143 function void initialize(); 00144 set_default_file(0); 00145 m_max_verbosity_level = OVM_MEDIUM; 00146 set_defaults(); 00147 endfunction 00148 00149 //-------------------------------------------------------------------- 00150 // run_hooks 00151 // 00152 // run the report hooks 00153 //-------------------------------------------------------------------- 00154 virtual function bit run_hooks(ovm_report_object client, 00155 ovm_severity severity, 00156 string id, 00157 string message, 00158 int verbosity, 00159 string filename, 00160 int line); 00161 00162 bit ok; 00163 00164 ok = client.report_hook(id, message, verbosity, filename, line); 00165 00166 case(severity) 00167 OVM_INFO: ok &= client.report_info_hook (id, message, verbosity, filename, line); 00168 OVM_WARNING: ok &= client.report_warning_hook(id, message, verbosity, filename, line); 00169 OVM_ERROR: ok &= client.report_error_hook (id, message, verbosity, filename, line); 00170 OVM_FATAL: ok &= client.report_fatal_hook (id, message, verbosity, filename, line); 00171 endcase 00172 00173 return ok; 00174 00175 endfunction 00176 00177 //-------------------------------------------------------------------- 00178 // get_severity_id_file 00179 // 00180 // Return the file id based on the severity and the id 00181 //-------------------------------------------------------------------- 00182 local function OVM_FILE get_severity_id_file(ovm_severity severity, string id); 00183 00184 `ifndef INCA 00185 id_file_array array; 00186 00187 if(severity_id_file_handles.exists(severity)) begin 00188 array = severity_id_file_handles[severity]; 00189 if(array.exists(id)) 00190 return array[id]; 00191 end 00192 `else 00193 if (severity_id_file_handles.exists(severity,id)) 00194 return severity_id_file_handles.get(severity,id); 00195 `endif 00196 00197 00198 if(id_file_handles.exists(id)) 00199 return id_file_handles[id]; 00200 00201 if(severity_file_handles.exists(severity)) 00202 return severity_file_handles[severity]; 00203 00204 return default_file_handle; 00205 00206 endfunction 00207 00208 //-------------------------------------------------------------------- 00209 // set_verbosity_level 00210 // 00211 // sets the maximum verbosity level 00212 // for this report handler. All reports of higher 00213 // verbosity will be ignored 00214 //-------------------------------------------------------------------- 00215 function void set_verbosity_level(int verbosity_level); 00216 m_max_verbosity_level = verbosity_level; 00217 endfunction 00218 00219 //-------------------------------------------------------------------- 00220 // get_verbosity_level 00221 //-------------------------------------------------------------------- 00222 function int get_verbosity_level(); 00223 return m_max_verbosity_level; 00224 endfunction 00225 00226 //-------------------------------------------------------------------- 00227 // get_action 00228 // 00229 // Retrieve the action based on severity and id. First, 00230 // look to see if there is an action associated with the 00231 // (severity,id) pair. Second, look to see if there is an 00232 // action associated with the id. If neither of those has 00233 // an action then return the action associated with the 00234 // severity. 00235 //-------------------------------------------------------------------- 00236 function ovm_action get_action(ovm_severity severity, string id); 00237 00238 `ifndef INCA 00239 id_actions_array array; 00240 00241 if(severity_id_actions.exists(severity)) begin 00242 array = severity_id_actions[severity]; 00243 if(array.exists(id)) 00244 return array[id]; 00245 end 00246 `else 00247 if (severity_id_actions.exists(severity,id)) 00248 return severity_id_actions.get(severity,id); 00249 `endif 00250 00251 if(id_actions.exists(id)) 00252 return id_actions[id]; 00253 00254 return severity_actions[severity]; 00255 00256 endfunction 00257 00258 //-------------------------------------------------------------------- 00259 // get_file_handle 00260 // 00261 // Retrieve the file handle associated with the severity 00262 // and id. First, look to see if there is a file handle 00263 // associated with the (severity,id) pair. Second, look 00264 // to see if there is a file handle associated with the 00265 // id. If neither the (severity,id) pair nor the id has 00266 // an associated action then return the action associated 00267 // with the severity. 00268 //-------------------------------------------------------------------- 00269 function OVM_FILE get_file_handle(ovm_severity severity, string id); 00270 OVM_FILE file; 00271 00272 file = get_severity_id_file(severity, id); 00273 if (file != 0) 00274 return file; 00275 00276 if (id_file_handles.exists(id)) begin 00277 file = id_file_handles[id]; 00278 if (file != 0) 00279 return file; 00280 end 00281 00282 if (severity_file_handles.exists(severity)) begin 00283 file = severity_file_handles[severity]; 00284 if(file != 0) 00285 return file; 00286 end 00287 00288 return default_file_handle; 00289 endfunction 00290 00291 //-------------------------------------------------------------------- 00292 // report 00293 // 00294 // add line and file info later ... 00295 // 00296 // this is the public access report function. It is not 00297 // visible to the user but is accessed via 00298 // ovm_report_info, ovm_report_warning, 00299 // ovm_report_error and ovm_report_fatal. 00300 //-------------------------------------------------------------------- 00301 function void report( 00302 ovm_severity severity, 00303 string name, 00304 string id, 00305 string message, 00306 int verbosity_level, 00307 string filename, 00308 int line, 00309 ovm_report_object client 00310 ); 00311 00312 ovm_report_server srvr; 00313 srvr = m_glob.get_server(); 00314 srvr.report(severity,name,id,message,verbosity_level,filename,line,client); 00315 00316 endfunction 00317 00318 //-------------------------------------------------------------------- 00319 // format_action 00320 //-------------------------------------------------------------------- 00321 function string format_action(ovm_action action); 00322 string s; 00323 00324 if(action == OVM_NO_ACTION) begin 00325 s = "NO ACTION"; 00326 end 00327 else begin 00328 s = ""; 00329 if(action & OVM_DISPLAY) s = {s, "DISPLAY "}; 00330 if(action & OVM_LOG) s = {s, "LOG "}; 00331 if(action & OVM_COUNT) s = {s, "COUNT "}; 00332 if(action & OVM_EXIT) s = {s, "EXIT "}; 00333 if(action & OVM_CALL_HOOK) s = {s, "CALL_HOOK "}; 00334 if(action & OVM_STOP) s = {s, "STOP "}; 00335 end 00336 00337 return s; 00338 endfunction 00339 00340 function void set_severity_action(input ovm_severity severity, 00341 input ovm_action action); 00342 severity_actions[severity] = action; 00343 endfunction 00344 00345 function void set_defaults(); 00346 set_severity_action(OVM_INFO, OVM_DISPLAY); 00347 set_severity_action(OVM_WARNING, OVM_DISPLAY); 00348 set_severity_action(OVM_ERROR, OVM_DISPLAY | OVM_COUNT); 00349 set_severity_action(OVM_FATAL, OVM_DISPLAY | OVM_EXIT); 00350 00351 set_severity_file(OVM_INFO, default_file_handle); 00352 set_severity_file(OVM_WARNING, default_file_handle); 00353 set_severity_file(OVM_ERROR, default_file_handle); 00354 set_severity_file(OVM_FATAL, default_file_handle); 00355 endfunction 00356 00357 function void set_id_action(input string id, input ovm_action action); 00358 id_actions[id] = action; 00359 endfunction 00360 00361 function void set_severity_id_action(ovm_severity severity, 00362 string id, 00363 ovm_action action); 00364 `ifndef INCA 00365 severity_id_actions[severity][id] = action; 00366 `else 00367 severity_id_actions.set(severity,id,action); 00368 `endif 00369 endfunction 00370 00371 // set_default_file, set_severity_file, set_id_file and 00372 // set_severity_id_file associate verilog file descriptors 00373 // with different kinds of reports in this report 00374 // handler. It is the users responsbility to open and 00375 // close these file descriptors correctly. Users may take 00376 // advantage of the fact that up to 32 files can be 00377 // described by the same file descriptor to send one 00378 // report to many files. 00379 // 00380 // set_default_file sets the default file associated with 00381 // any severity or id in this report handler. 00382 00383 function void set_default_file(input OVM_FILE file); 00384 default_file_handle = file; 00385 endfunction 00386 00387 // set_severity_file sets the file associated with a 00388 // severity in this report handler. It is not visible to 00389 // the user but is accessed via ovm_set_severity_file. A 00390 // file associated with a severity overrides the default 00391 // file for this report handler. 00392 00393 function void set_severity_file(input ovm_severity severity, input OVM_FILE file); 00394 severity_file_handles[severity] = file; 00395 endfunction 00396 00397 // set_id_file sets the file associated with an id in this 00398 // report handler. It is not visible to the user but is 00399 // accessed via ovm_set_id_file. A file associated with an 00400 // id overrides the default file and any files associated 00401 // with a severity. 00402 00403 function void set_id_file(input string id, input OVM_FILE file); 00404 id_file_handles[id] = file; 00405 endfunction 00406 00407 // set_severity_id_file sets the file associated with a 00408 // (severity,id) pair. It is not visible to the user but 00409 // is accessed via ovm_set_severity_id_file. A file 00410 // associated with a (severity,id) pair overrides any 00411 // other file settings in this report handler 00412 00413 function void set_severity_id_file(input ovm_severity severity, 00414 input string id, 00415 input OVM_FILE file); 00416 00417 `ifndef INCA 00418 severity_id_file_handles[severity][id] = file; 00419 `else 00420 severity_id_file_handles.set(severity,id,file); 00421 `endif 00422 endfunction 00423 00424 //-------------------------------------------------------------------- 00425 // dump_state 00426 //-------------------------------------------------------------------- 00427 function void dump_state(); 00428 00429 string s; 00430 ovm_severity_type severity; 00431 ovm_action a; 00432 string idx; 00433 OVM_FILE file; 00434 ovm_report_server srvr; 00435 00436 `ifndef INCA 00437 id_actions_array id_a_ary; 00438 id_file_array id_f_ary; 00439 `else 00440 OVM_FILE id_f_ary[string]; 00441 `endif 00442 00443 srvr = m_glob.get_server(); 00444 00445 srvr.f_display(0, "----------------------------------------------------------------------"); 00446 srvr.f_display(0, "report handler state dump"); 00447 srvr.f_display(0, ""); 00448 00449 $sformat(s, "max verbosity level = %d", m_max_verbosity_level); 00450 srvr.f_display(0, s); 00451 00452 //------------------------------------------------------------------ 00453 // actions 00454 //------------------------------------------------------------------ 00455 00456 srvr.f_display(0, ""); 00457 srvr.f_display(0, "+-------------+"); 00458 srvr.f_display(0, "| actions |"); 00459 srvr.f_display(0, "+-------------+"); 00460 srvr.f_display(0, ""); 00461 00462 srvr.f_display(0, "*** actions by severity"); 00463 foreach( severity_actions[severity] ) begin 00464 $sformat(s, "%s = %s", ovm_severity_type'(severity), format_action(severity_actions[severity])); 00465 srvr.f_display(0, s); 00466 end 00467 00468 srvr.f_display(0, ""); 00469 srvr.f_display(0, "*** actions by id"); 00470 00471 foreach( id_actions[idx] ) begin 00472 $sformat(s, "[%-20s] --> %s", idx, format_action(id_actions[idx])); 00473 srvr.f_display(0, s); 00474 end 00475 00476 // actions by id 00477 00478 srvr.f_display(0, ""); 00479 srvr.f_display(0, "*** actions by id and severity"); 00480 00481 `ifndef INCA 00482 foreach( severity_id_actions[severity] ) begin 00483 // ADAM: is id_a_ary __copied__? 00484 id_a_ary = severity_id_actions[severity]; 00485 foreach( id_a_ary[idx] ) begin 00486 $sformat(s, "%s:%s --> %s", ovm_severity_type'(severity), idx, format_action(id_a_ary[idx])); 00487 srvr.f_display(0, s); 00488 end 00489 end 00490 `else 00491 begin 00492 string idx; 00493 if ( severity_id_actions.first( idx ) ) 00494 do begin 00495 $sformat(s, "%s --> %s", idx, 00496 format_action(severity_id_actions.fetch(idx))); 00497 srvr.f_display(0, s); 00498 end 00499 while ( severity_id_actions.next( idx ) ); 00500 end 00501 `endif 00502 00503 //------------------------------------------------------------------ 00504 // Files 00505 //------------------------------------------------------------------ 00506 00507 srvr.f_display(0, ""); 00508 srvr.f_display(0, "+-------------+"); 00509 srvr.f_display(0, "| files |"); 00510 srvr.f_display(0, "+-------------+"); 00511 srvr.f_display(0, ""); 00512 00513 $sformat(s, "default file handle = %d", default_file_handle); 00514 srvr.f_display(0, s); 00515 00516 srvr.f_display(0, ""); 00517 srvr.f_display(0, "*** files by severity"); 00518 foreach( severity_file_handles[severity] ) begin 00519 file = severity_file_handles[severity]; 00520 $sformat(s, "%s = %d", ovm_severity_type'(severity), file); 00521 srvr.f_display(0, s); 00522 end 00523 00524 srvr.f_display(0, ""); 00525 srvr.f_display(0, "*** files by id"); 00526 00527 foreach ( id_file_handles[idx] ) begin 00528 file = id_file_handles[idx]; 00529 $sformat(s, "id %s --> %d", idx, file); 00530 srvr.f_display(0, s); 00531 end 00532 00533 srvr.f_display(0, ""); 00534 srvr.f_display(0, "*** files by id and severity"); 00535 00536 `ifndef INCA 00537 foreach( severity_id_file_handles[severity] ) begin 00538 id_f_ary = severity_id_file_handles[severity]; 00539 foreach ( id_f_ary[idx] ) begin 00540 $sformat(s, "%s:%s --> %d", ovm_severity_type'(severity), idx, id_f_ary[idx]); 00541 srvr.f_display(0, s); 00542 end 00543 end 00544 `else 00545 begin 00546 string idx; 00547 if ( severity_id_file_handles.first( idx ) ) 00548 do begin 00549 $sformat(s, "%s --> %s", idx, 00550 format_action(severity_id_file_handles.fetch(idx))); 00551 srvr.f_display(0, s); 00552 end 00553 while ( severity_id_file_handles.next( idx ) ); 00554 end 00555 `endif 00556 00557 srvr.dump_server_state(); 00558 00559 srvr.f_display(0, "----------------------------------------------------------------------"); 00560 endfunction 00561 00562 static bit m_deprecated_fncs[string]; 00563 static function void ovm_report_deprecated(string fnc); 00564 if(!m_deprecated_fncs.exists(fnc)) begin 00565 ovm_report_warning("deprecated", {"The function ", fnc, " has been deprecated, refer ", 00566 "to the OVM reference manual for a replacement"}); 00567 m_deprecated_fncs[fnc] = 1; 00568 end 00569 endfunction 00570 00571 endclass : ovm_report_handler 00572 00573 //---------------------------------------------------------------------- 00574 // CLASS default_report_server 00575 // 00576 // wrapper around ovm_report_global_server 00577 //---------------------------------------------------------------------- 00578 class default_report_server; 00579 00580 ovm_report_global_server glob; 00581 00582 function new(); 00583 glob = new; 00584 endfunction 00585 00586 function ovm_report_server get_server(); 00587 return glob.get_server(); 00588 endfunction 00589 00590 endclass 00591 00592 `endif // OVM_REPORT_HANDLER_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 |