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