00001 // $Id: urm__message_8sv-source.html,v 1.1 2008/10/07 21:54:19 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 00023 `include "compatibility/urm_message.svh" 00024 00025 00026 // Utility Functions 00027 00028 00029 function string m_urm_mask_worker(int multi_i, string multi_s, int mask, string text); 00030 if ( multi_i & mask ) begin 00031 if ( multi_s == "" ) begin m_urm_mask_worker = text; end 00032 else begin m_urm_mask_worker = { multi_s, "|", text }; end 00033 end 00034 else begin m_urm_mask_worker = multi_s; end 00035 endfunction 00036 00037 function string m_urm_msg_style_string(int style_i); 00038 string style_s; 00039 case (style_i) 00040 OVM_URM_STYLE_NONE: begin style_s = "NO_STYLE"; end 00041 OVM_URM_LONG: begin style_s = "LONG"; end 00042 OVM_URM_RAW: begin style_s = "RAW"; end 00043 OVM_URM_SHORT: begin style_s = "SHORT"; end 00044 default: begin 00045 style_s = ""; 00046 style_s = m_urm_mask_worker(style_i,style_s,OVM_URM_STYLE_FILE,"FILE"); 00047 style_s = m_urm_mask_worker(style_i,style_s,OVM_URM_STYLE_HIERARCHY,"HIERARCHY"); 00048 style_s = m_urm_mask_worker(style_i,style_s,OVM_URM_STYLE_LINE,"LINE"); 00049 style_s = m_urm_mask_worker(style_i,style_s,OVM_URM_STYLE_MESSAGE_TEXT,"MESSAGE_TEXT"); 00050 style_s = m_urm_mask_worker(style_i,style_s,OVM_URM_STYLE_SCOPE,"SCOPE"); 00051 style_s = m_urm_mask_worker(style_i,style_s,OVM_URM_STYLE_SEVERITY,"SEVERITY"); 00052 style_s = m_urm_mask_worker(style_i,style_s,OVM_URM_STYLE_TAG,"TAG"); 00053 style_s = m_urm_mask_worker(style_i,style_s,OVM_URM_STYLE_TIME,"TIME"); 00054 style_s = m_urm_mask_worker(style_i,style_s,OVM_URM_STYLE_UNIT,"UNIT"); 00055 style_s = m_urm_mask_worker(style_i,style_s,OVM_URM_STYLE_VERBOSITY,"VERBOSITY"); 00056 end 00057 endcase 00058 return style_s; 00059 endfunction 00060 00061 function string m_urm_destination_string(int destination_i); 00062 string destination_s; 00063 $swrite(destination_s,"%0h",destination_i); 00064 return destination_s; 00065 endfunction 00066 00067 function string m_urm_severity_string(int severity_i); 00068 string severity_s; 00069 case (severity_i) 00070 OVM_INFO: begin severity_s = ovm_urm_message_format::info_text; end 00071 OVM_WARNING: begin severity_s = ovm_urm_message_format::warning_text; end 00072 OVM_ERROR: begin severity_s = ovm_urm_message_format::error_text; end 00073 OVM_FATAL: begin severity_s = ovm_urm_message_format::fatal_text; end 00074 default: begin 00075 $swrite(severity_s,"%s%0d",ovm_urm_message_format::info_text,severity_i); 00076 end 00077 endcase 00078 return severity_s; 00079 endfunction 00080 00081 // I, W, E, F -- used by URM formatter 00082 function string m_urm_severity_S(int severity_i); 00083 case (severity_i) 00084 OVM_WARNING: begin m_urm_severity_S = "W"; end 00085 OVM_ERROR: begin m_urm_severity_S = "E"; end 00086 OVM_FATAL: begin m_urm_severity_S = "F"; end 00087 default: begin m_urm_severity_S = "I"; end 00088 endcase 00089 endfunction 00090 00091 // Info, Warning, Error, Fatal, used for DUT messages 00092 function string m_urm_severity_Severity(int severity_i); 00093 string severity_s; 00094 case (severity_i) 00095 OVM_WARNING: begin severity_s = "Warning"; end 00096 OVM_ERROR: begin severity_s = "Error"; end 00097 OVM_FATAL: begin severity_s = "Fatal"; end 00098 default: begin severity_s = "Info"; end 00099 endcase 00100 return severity_s; 00101 endfunction 00102 00103 // info, warning, error, fatal, used for DUT messages 00104 function string m_urm_severity_severity(int severity_i); 00105 string severity_s; 00106 case (severity_i) 00107 OVM_WARNING: begin severity_s = "warning"; end 00108 OVM_ERROR: begin severity_s = "error"; end 00109 OVM_FATAL: begin severity_s = "fatal"; end 00110 default: begin severity_s = "info"; end 00111 endcase 00112 return severity_s; 00113 endfunction 00114 00115 // use when accessing verbosity via get_*verbosity 00116 function string m_urm_verbosity_string(int verbosity_i); 00117 string verbosity_s; 00118 case (verbosity_i) 00119 OVM_NONE: begin verbosity_s = ovm_urm_message_format::none_text; end 00120 OVM_LOW: begin verbosity_s = ovm_urm_message_format::low_text; end 00121 OVM_MEDIUM: begin verbosity_s = ovm_urm_message_format::medium_text; end 00122 OVM_HIGH: begin verbosity_s = ovm_urm_message_format::high_text; end 00123 OVM_FULL: begin verbosity_s = ovm_urm_message_format::full_text; end 00124 default: begin 00125 $swrite(verbosity_s,"%s%0d",ovm_urm_message_format::info_text,verbosity_i); 00126 end 00127 endcase 00128 return verbosity_s; 00129 endfunction 00130 00131 function string m_urm_action_string(int action_i); 00132 string action_s; 00133 action_s = ""; 00134 // special handling for OVM_NO_ACTION 00135 if (action_i == OVM_NO_ACTION) action_s = "NO_ACTION"; 00136 else begin 00137 action_s = m_urm_mask_worker(action_i,action_s,OVM_CALL_HOOK,"CALL_HOOK"); 00138 action_s = m_urm_mask_worker(action_i,action_s,OVM_COUNT,"COUNT"); 00139 action_s = m_urm_mask_worker(action_i,action_s,OVM_DISPLAY,"DISPLAY"); 00140 action_s = m_urm_mask_worker(action_i,action_s,OVM_EXIT,"EXIT"); 00141 action_s = m_urm_mask_worker(action_i,action_s,OVM_LOG,"LOG"); 00142 action_s = m_urm_mask_worker(action_i,action_s,OVM_STOP,"STOP"); 00143 end 00144 return action_s; 00145 endfunction 00146 00147 function string m_urm_actions_string_worker(ovm_report_object h, ovm_severity severity_val); 00148 ovm_report_handler m_rh; m_rh = h.get_report_handler(); 00149 return { 00150 " actions[", m_urm_severity_string(severity_val), "]: ", 00151 m_urm_action_string(m_rh.severity_actions[severity_val]) 00152 }; 00153 endfunction 00154 00155 function string m_urm_actions_string(ovm_report_object h); 00156 string image; 00157 image = { m_urm_actions_string_worker(h,OVM_INFO), "\n" }; 00158 image = { image, m_urm_actions_string_worker(h,OVM_WARNING), "\n" }; 00159 image = { image, m_urm_actions_string_worker(h,OVM_ERROR), "\n" }; 00160 image = { image, m_urm_actions_string_worker(h,OVM_FATAL) }; 00161 return image; 00162 endfunction 00163 00164 00165 //---------------------------------------------------------------------------- 00166 // 00167 // CLASS: ovm_urm_message 00168 // 00169 //---------------------------------------------------------------------------- 00170 00171 00172 function ovm_urm_message::new( 00173 string id, string text, int typ, ovm_severity sev, int verbosity, string hier, 00174 ovm_report_object client, string file, int line, string scope 00175 ); 00176 00177 ovm_component ch; 00178 ovm_report_handler m_rh; 00179 00180 ovm_urm_report_server::init_urm_report_server(); 00181 00182 if ( client == null ) client = _global_reporter; 00183 m_rh = client.get_report_handler(); 00184 00185 if ( typ == OVM_URM_MSG_DUT ) begin 00186 sev = ovm_global_urm_report_server.m_global_severity; 00187 end 00188 00189 if ( typ == OVM_URM_MSG_DEBUG && sev != OVM_INFO ) begin 00190 typ = OVM_URM_MSG_DUT; 00191 end 00192 00193 if ( typ == OVM_URM_MSG_DUT ) begin 00194 verbosity = OVM_NONE; 00195 end 00196 00197 if ( file == "" && line == 0 ) file = "<unknown>"; 00198 00199 if ( scope == "" ) begin 00200 if ( client == _global_reporter ) scope = "__global__"; 00201 else scope = client.get_full_name(); 00202 end 00203 00204 if ( hier == "" ) begin 00205 if ( client == _global_reporter ) hier = scope; 00206 else hier = client.get_full_name(); 00207 end 00208 00209 m_id = id; 00210 m_text = text; 00211 m_type = typ; 00212 m_severity = sev; 00213 m_verbosity = verbosity; 00214 m_max_verbosity = m_rh.m_max_verbosity_level; 00215 m_style = ovm_urm_report_server::get_global_debug_style(); 00216 m_client = client; 00217 m_file = file; 00218 m_line = line; 00219 m_action = m_rh.get_action(sev,id); 00220 m_destination = m_rh.get_file_handle(sev,id); 00221 m_scope = scope; 00222 m_hierarchy = hier; 00223 m_name = client.get_full_name(); 00224 00225 endfunction 00226 00227 00228 //---------------------------------------------------------------------------- 00229 // 00230 // CLASS: ovm_urm_override_request 00231 // 00232 //---------------------------------------------------------------------------- 00233 00234 00235 function ovm_urm_override_request::new(string hierarchy="", 00236 string scope="", 00237 string name="", 00238 string file="", 00239 int line=-1, 00240 string text="", 00241 string tag="", 00242 ovm_urm_override_operator op=null); 00243 match_hierarchy = hierarchy; 00244 match_scope = scope; 00245 match_name = name; 00246 match_file = file; 00247 match_line = line; 00248 match_text = text; 00249 match_tag = tag; 00250 operator = op; 00251 endfunction 00252 00253 00254 function bit ovm_urm_override_request::is_applicable_to_message(ovm_urm_message msg); 00255 // breaking into multiple if-statements instead of one large || 00256 // to stop matching as soon as the first one fails... 00257 if ( !ovm_is_match(match_hierarchy, msg.m_hierarchy) ) 00258 return(0); 00259 else if ( !ovm_is_match(match_scope, msg.m_scope) ) 00260 return(0); 00261 else if ( !ovm_is_match(match_name, msg.m_name) ) 00262 return(0); 00263 else if ( !ovm_is_match(match_text, msg.m_text) ) 00264 return(0); 00265 else if ( !ovm_is_match(match_tag, msg.m_id) ) 00266 return(0); 00267 else if ( !ovm_is_match(match_file, msg.m_file) ) 00268 return(0); 00269 else if ( (match_line != -1) && (match_line != msg.m_line) ) 00270 return(0); 00271 else 00272 return(1); 00273 endfunction 00274 00275 00276 function void ovm_urm_override_request::apply_override(ovm_urm_message msg); 00277 if (operator != null) operator.apply_overrides(msg); 00278 endfunction 00279 00280 00281 function string ovm_urm_override_request::dump_request_details(); 00282 string result; 00283 00284 if (operator == null) return("Invalid request - null operator"); 00285 result = "ovm_message "; 00286 if (match_hierarchy != "*") 00287 result = { result, "-hierarchy \"", match_hierarchy, "\" "}; 00288 00289 if (match_scope != "*") 00290 result = { result, "-scope \"", match_scope, "\" " }; 00291 00292 if (match_name != "*") 00293 result = { result, "-name \"", match_name, "\" " }; 00294 00295 if (match_file != "*") 00296 result = { result, "-file \"", match_file, "\" " }; 00297 00298 if (match_line != -1) 00299 result = { result, "-line ", $psprintf("%0d ", match_line) }; 00300 00301 if (match_text != "*") 00302 result = { result, "-text \"", match_text, "\" "}; 00303 00304 if (match_tag != "*") 00305 result = { result, "-tag \"", match_tag, "\" "}; 00306 00307 result = { result, operator.dump_override_details()}; 00308 return(result); 00309 endfunction 00310 00311 00312 //---------------------------------------------------------------------------- 00313 // 00314 // CLASS: ovm_urm_override_operator 00315 // 00316 //---------------------------------------------------------------------------- 00317 00318 00319 function void ovm_urm_override_operator::apply_overrides(ovm_urm_message msg); 00320 if (m_enable_style) msg.m_style = m_style; 00321 if (m_enable_verbosity) msg.m_max_verbosity = m_verbosity; 00322 if (m_enable_destination) msg.m_destination = m_destination; 00323 00324 if (m_enable_severity) begin 00325 ovm_report_handler m_rh; 00326 ovm_severity adjusted_severity; 00327 m_rh = msg.m_client.get_report_handler(); 00328 msg.m_severity = m_severity; 00329 if ((m_severity >= OVM_INFO) && (m_severity <= OVM_FATAL)) 00330 adjusted_severity = m_severity; 00331 else 00332 adjusted_severity = OVM_INFO; 00333 msg.m_action = m_rh.get_action(adjusted_severity,msg.m_id); 00334 end 00335 00336 if (m_enable_action && (msg.m_severity == m_severity_for_action)) 00337 msg.m_action = m_action; 00338 endfunction 00339 00340 00341 function string ovm_urm_override_operator::dump_override_details(); 00342 string result; 00343 result = ""; 00344 00345 if (m_enable_style) 00346 result = { result, "-set_style ", m_urm_msg_style_string(m_style), " "}; 00347 00348 if (m_enable_verbosity) 00349 result = { result, "-set_verbosity ", m_urm_verbosity_string(m_verbosity), " "}; 00350 00351 if (m_enable_destination) 00352 result = { result, "-set_destination ", $psprintf("%0d", m_destination), " "}; 00353 00354 if (m_enable_severity) 00355 result = { result, "-set_severity ", m_urm_severity_string(m_severity), " "}; 00356 00357 if (m_enable_action) 00358 result = { result, "-severity ", m_urm_severity_string(m_severity_for_action), 00359 " -set_actions ", m_urm_action_string(m_action) }; 00360 00361 return(result); 00362 00363 endfunction 00364 00365 00366 //---------------------------------------------------------------------------- 00367 // 00368 // CLASS: ovm_urm_report_server 00369 // 00370 //---------------------------------------------------------------------------- 00371 00372 00373 function ovm_urm_report_server::new(); 00374 super.new(); 00375 if ( m_initialized != 1 ) begin 00376 m_initialized = 1; 00377 m_global_debug_style = OVM_URM_SHORT; 00378 m_global_hier = ""; 00379 m_global_scope = ""; 00380 m_global_severity = OVM_ERROR; 00381 m_global_default_type = OVM_URM_MSG_DEBUG; 00382 m_global_type = OVM_URM_MSG_DEBUG; 00383 end 00384 endfunction 00385 00386 function void ovm_urm_report_server::report( 00387 ovm_severity severity, 00388 string name, 00389 string id, 00390 string message, 00391 int verbosity_level, 00392 string filename, 00393 int line, 00394 ovm_report_object client 00395 ); 00396 static bit m_action_change_warn_once=1; 00397 ovm_urm_message msg; 00398 00399 msg = new( 00400 id, message, m_global_type, severity, verbosity_level, m_global_hier, 00401 client, filename, line, m_global_scope 00402 ); 00403 m_apply_override_requests(msg); 00404 00405 // consolidate destination information 00406 if ( ! ( msg.m_action & OVM_LOG ) ) msg.m_destination = 0; 00407 if ( msg.m_action & OVM_DISPLAY ) msg.m_destination |= 1; 00408 00409 // enforce limitations on `message actions 00410 if ( msg.m_type == OVM_URM_MSG_DEBUG ) begin 00411 if ((msg.m_action & ~(OVM_DISPLAY|OVM_LOG))&&(m_action_change_warn_once)) begin 00412 $display("OVM messaging ignores OVM_CALL_HOOK, OVM_COUNT, OVM_EXIT and OVM_STOP actions on messages created via `message. "); 00413 m_action_change_warn_once = 0; 00414 end 00415 msg.m_action &= (OVM_DISPLAY|OVM_LOG); 00416 end 00417 00418 // if ( ! msg.handler.filter(msg) ) return; 00419 if ( msg.m_verbosity > msg.m_max_verbosity ) return; 00420 00421 // update counts 00422 ovm_global_urm_report_server.incr_severity_count(msg.m_severity); 00423 ovm_global_urm_report_server.incr_id_count(msg.m_id); 00424 00425 if ( msg.m_destination != 0 ) begin 00426 00427 case (msg.m_type) 00428 00429 OVM_URM_MSG_DEBUG : begin 00430 bit first; 00431 first = 1; 00432 if ( msg.m_style & OVM_URM_STYLE_TIME ) begin 00433 first = 0; 00434 $fwrite(msg.m_destination,"[%0t]",$time); 00435 end 00436 if ( msg.m_style & OVM_URM_STYLE_VERBOSITY ) begin 00437 if ( first ) first = 0; else $write(" "); 00438 $fwrite(msg.m_destination,"(%0s)",m_urm_verbosity_string(msg.m_verbosity)); 00439 end 00440 if ( msg.m_style & OVM_URM_STYLE_SEVERITY ) begin 00441 if ( first ) first = 0; else $write(" "); 00442 $fwrite(msg.m_destination,"severity=%0s",m_urm_severity_string(msg.m_severity)); 00443 end 00444 if ( msg.m_style & OVM_URM_STYLE_TAG ) begin 00445 if ( first ) first = 0; else $write(" "); 00446 $fwrite(msg.m_destination,"tag=%0s",msg.m_id); 00447 end 00448 if ( msg.m_style & OVM_URM_STYLE_SCOPE ) begin 00449 if ( first ) first = 0; else $write(" "); 00450 $fwrite(msg.m_destination,"scope=%0s",msg.m_scope); 00451 end 00452 if ( msg.m_style & OVM_URM_STYLE_HIERARCHY ) begin 00453 if ( first ) first = 0; else $write(" "); 00454 $fwrite(msg.m_destination,"hier=%0s",msg.m_hierarchy); 00455 end 00456 if ( msg.m_style & OVM_URM_STYLE_MESSAGE_TEXT ) begin 00457 if ( ! first ) $fwrite(msg.m_destination,": "); 00458 $fdisplay(msg.m_destination,"%s",msg.m_text); 00459 end 00460 else begin 00461 if ( ! first ) $fdisplay(msg.m_destination); 00462 end 00463 first = 1; 00464 if ( ( msg.m_style & OVM_URM_STYLE_FILE ) && ( msg.m_style & OVM_URM_STYLE_LINE ) ) begin 00465 first = 0; 00466 $fwrite(msg.m_destination,"%0s, %0d",msg.m_file,msg.m_line); 00467 end 00468 else if ( msg.m_style & OVM_URM_STYLE_FILE ) begin 00469 first = 0; 00470 $fwrite(msg.m_destination,"%0s",msg.m_file); 00471 end 00472 else if ( msg.m_style & OVM_URM_STYLE_LINE ) begin 00473 first = 0; 00474 $fwrite(msg.m_destination,"%0d",msg.m_line); 00475 end 00476 if ( ( msg.m_style & OVM_URM_STYLE_UNIT ) ) begin 00477 ovm_component ch; 00478 if ( $cast(ch,msg.m_client) ) begin 00479 if ( first ) first = 0; else $fwrite(msg.m_destination," "); 00480 $fwrite(msg.m_destination,"%0s",ch.get_full_name()); 00481 end 00482 end 00483 if ( ! first ) $fdisplay(msg.m_destination); 00484 end 00485 00486 OVM_URM_MSG_DUT : begin 00487 $fdisplay( 00488 msg.m_destination, 00489 "*** OVM: DUT %s at time %0t\nChecked at line %0d in %s\nIn %s", 00490 m_urm_severity_severity(msg.m_severity), 00491 $time, msg.m_line, msg.m_file, 00492 msg.m_hierarchy 00493 ); 00494 $fdisplay(msg.m_destination,"%s",msg.m_text); 00495 if ( msg.m_action & (OVM_EXIT|OVM_STOP) ) begin 00496 ovm_report_handler m_rh; 00497 m_rh = msg.m_client.get_report_handler(); 00498 $fdisplay( 00499 msg.m_destination, 00500 "Will stop execution immediately (check effect is %0s)", 00501 m_rh.format_action(msg.m_action) 00502 ); 00503 end 00504 $fdisplay( 00505 msg.m_destination, 00506 "*** %0s: A DUT %0s has occurred\n", 00507 m_urm_severity_Severity(msg.m_severity), 00508 m_urm_severity_severity(msg.m_severity) 00509 ); 00510 end 00511 00512 OVM_URM_MSG_TOOL : begin 00513 $fwrite( 00514 msg.m_destination, 00515 "ovm: *%s,%s (%s,%0d): ", 00516 m_urm_severity_S(msg.m_severity), msg.m_id, 00517 msg.m_file, msg.m_line 00518 ); 00519 $fdisplay(msg.m_destination,"%s",msg.m_text); 00520 end 00521 00522 OVM_URM_MSG_OVM : begin 00523 string image; 00524 image = ovm_global_urm_report_server.compose_message( 00525 msg.m_severity, msg.m_name, msg.m_id, 00526 msg.m_text, msg.m_file, msg.m_line 00527 ); 00528 $fdisplay(msg.m_destination,"%s",image); 00529 end 00530 00531 endcase 00532 00533 end 00534 00535 if ( msg.m_action & OVM_COUNT ) begin 00536 if ( ovm_global_urm_report_server.get_max_quit_count() != 0 ) begin 00537 ovm_global_urm_report_server.incr_quit_count(); 00538 if ( ovm_global_urm_report_server.is_quit_count_reached() ) begin 00539 $display("** ERROR LIMIT REACHED **"); 00540 msg.m_action |= OVM_EXIT; 00541 end 00542 end 00543 end 00544 00545 if ( msg.m_action & OVM_EXIT ) msg.m_client.die(); 00546 00547 if ( msg.m_action & OVM_STOP ) $stop; 00548 00549 endfunction 00550 00551 function int ovm_urm_report_server::get_global_max_quit_count(); 00552 ovm_urm_report_server::init_urm_report_server(); 00553 return ovm_global_urm_report_server.get_max_quit_count(); 00554 endfunction 00555 00556 function void ovm_urm_report_server::set_global_max_quit_count(int value); 00557 ovm_urm_report_server::init_urm_report_server(); 00558 ovm_global_urm_report_server.set_max_quit_count(value); 00559 endfunction 00560 00561 function int ovm_urm_report_server::get_global_debug_style(); 00562 ovm_urm_report_server::init_urm_report_server(); 00563 return ovm_global_urm_report_server.m_global_debug_style; 00564 endfunction 00565 00566 function void ovm_urm_report_server::set_global_debug_style(int value); 00567 ovm_urm_report_server::init_urm_report_server(); 00568 ovm_global_urm_report_server.m_global_debug_style = value; 00569 endfunction 00570 00571 function void ovm_urm_report_server::set_message_debug_style( 00572 string hierarchy, // wildcard for message hierarchy, default "*" 00573 string scope, // wildcard for message scope, default "*" 00574 string name, // wildcard for message name, default "*" 00575 string file, // wildcard for file name, default "*" 00576 int line, // wildcard for line number, default -1 (matches all) 00577 string text, // wildcard for message text, default "*" 00578 string tag, // wildcard for message tag, default "*" 00579 bit remove, // FALSE --> add rule, TRUE --> remove it 00580 int value 00581 ); 00582 ovm_urm_override_operator op; 00583 ovm_urm_override_request new_req; 00584 op = new; 00585 if (! op.set_style(value)) return; 00586 new_req = new(hierarchy, scope, name, file, line, text, tag, op); 00587 m_handle_new_request(new_req, remove); 00588 endfunction 00589 00590 function int ovm_urm_report_server::get_global_verbosity(); 00591 ovm_report_handler m_rh; 00592 ovm_urm_report_server::init_urm_report_server(); 00593 m_rh = _global_reporter.get_report_handler(); 00594 return m_rh.m_max_verbosity_level; 00595 endfunction 00596 00597 function void ovm_urm_report_server::set_global_verbosity(int value); 00598 ovm_report_handler m_rh; 00599 ovm_urm_report_server::init_urm_report_server(); 00600 m_rh = _global_reporter.get_report_handler(); 00601 m_rh.m_max_verbosity_level = value; 00602 endfunction 00603 00604 function void ovm_urm_report_server::set_message_verbosity( 00605 string hierarchy, // wildcard for message hierarchy, default "*" 00606 string scope, // wildcard for message scope, default "*" 00607 string name, // wildcard for message name, default "*" 00608 string file, // wildcard for file name, default "*" 00609 int line, // wildcard for line number, default -1 (matches all) 00610 string text, // wildcard for message text, default "*" 00611 string tag, // wildcard for message tag, default "*" 00612 bit remove, // FALSE --> add rule, TRUE --> remove it 00613 int value 00614 ); 00615 ovm_urm_override_operator op; 00616 ovm_urm_override_request new_req; 00617 op = new; 00618 if (! op.set_verbosity(value)) return; 00619 // verbosity is applied by default to messages with a "DEBUG" tag 00620 if (tag == "*") tag = "DEBUG"; 00621 new_req = new(hierarchy, scope, name, file, line, text, tag, op); 00622 m_handle_new_request(new_req, remove); 00623 endfunction 00624 00625 function int ovm_urm_report_server::get_global_destination(); 00626 ovm_report_handler m_rh; 00627 ovm_urm_report_server::init_urm_report_server(); 00628 m_rh = _global_reporter.get_report_handler(); 00629 return m_rh.default_file_handle; 00630 endfunction 00631 00632 function void ovm_urm_report_server::set_global_destination(int value); 00633 ovm_report_handler m_rh; 00634 ovm_urm_report_server::init_urm_report_server(); 00635 m_rh = _global_reporter.get_report_handler(); 00636 `ifdef OVM_AVOID_SFORMATF 00637 `urm_static_warning(("Changing destination on messages is not supported in this version of URM")) 00638 `else 00639 m_rh.default_file_handle = value; 00640 `endif 00641 endfunction 00642 00643 function void ovm_urm_report_server::set_message_destination( 00644 string hierarchy, // wildcard for message hierarchy, default "*" 00645 string scope, // wildcard for message scope, default "*" 00646 string name, // wildcard for message name, default "*" 00647 string file, // wildcard for file name, default "*" 00648 int line, // wildcard for line number, default -1 (matches all) 00649 string text, // wildcard for message text, default "*" 00650 string tag, // wildcard for message tag, default "*" 00651 bit remove, // FALSE --> add rule, TRUE --> remove it 00652 int value 00653 ); 00654 ovm_urm_override_operator op; 00655 ovm_urm_override_request new_req; 00656 `ifdef OVM_AVOID_SFORMATF 00657 if ( remove ) 00658 `urm_warning(("Cannot find a matching rule to remove. Ignoring.")) 00659 else 00660 `urm_warning(("Changing destination on messages is not supported in this version of URM")) 00661 `else 00662 op = new; 00663 if (! op.set_destination(value)) return; 00664 new_req = new(hierarchy, scope, name, file, line, text, tag, op); 00665 m_handle_new_request(new_req, remove); 00666 `endif 00667 endfunction 00668 00669 function ovm_severity ovm_urm_report_server::get_global_severity(); 00670 ovm_urm_report_server::init_urm_report_server(); 00671 return ovm_global_urm_report_server.m_global_severity; 00672 endfunction 00673 00674 function void ovm_urm_report_server::set_global_severity(ovm_severity value); 00675 ovm_urm_report_server::init_urm_report_server(); 00676 ovm_global_urm_report_server.m_global_severity = value; 00677 endfunction 00678 00679 function void ovm_urm_report_server::set_message_severity( 00680 string hierarchy, // wildcard for message hierarchy, default "*" 00681 string scope, // wildcard for message scope, default "*" 00682 string name, // wildcard for message name, default "*" 00683 string file, // wildcard for file name, default "*" 00684 int line, // wildcard for line number, default -1 (matches all) 00685 string text, // wildcard for message text, default "*" 00686 string tag, // wildcard for message tag, default "*" 00687 bit remove, // FALSE --> add rule, TRUE --> remove it 00688 ovm_severity value 00689 ); 00690 ovm_urm_override_operator op; 00691 ovm_urm_override_request new_req; 00692 op = new; 00693 if (! op.set_severity(value)) return; 00694 // severity is applied by default to messages with a "DUT" tag 00695 if (tag == "*") tag = "DUT"; 00696 new_req = new(hierarchy, scope, name, file, line, text, tag, op); 00697 m_handle_new_request(new_req, remove); 00698 endfunction 00699 00700 function int ovm_urm_report_server::get_global_actions(ovm_severity sev); 00701 ovm_report_handler m_rh; 00702 ovm_urm_report_server::init_urm_report_server(); 00703 m_rh = _global_reporter.get_report_handler(); 00704 return m_rh.severity_actions[sev]; 00705 endfunction 00706 00707 function void ovm_urm_report_server::set_global_actions(ovm_severity sev, int value); 00708 ovm_report_handler m_rh; 00709 ovm_urm_report_server::init_urm_report_server(); 00710 m_rh = _global_reporter.get_report_handler(); 00711 m_rh.severity_actions[sev] = value; 00712 endfunction 00713 00714 function void ovm_urm_report_server::set_message_actions( 00715 string hierarchy, // wildcard for message hierarchy, default "*" 00716 string scope, // wildcard for message scope, default "*" 00717 string name, // wildcard for message name, default "*" 00718 string file, // wildcard for file name, default "*" 00719 int line, // wildcard for line number, default -1 (matches all) 00720 string text, // wildcard for message text, default "*" 00721 string tag, // wildcard for message tag, default "*" 00722 bit remove, // FALSE --> add rule, TRUE --> remove it 00723 ovm_severity severity_val, 00724 int value 00725 ); 00726 ovm_urm_override_operator op; 00727 ovm_urm_override_request new_req; 00728 op = new; 00729 if (! op.set_action(severity_val, value)) return; 00730 new_req = new(hierarchy, scope, name, file, line, text, tag, op); 00731 m_handle_new_request(new_req, remove); 00732 endfunction 00733 00734 function void ovm_urm_report_server::init_urm_report_server(); 00735 if ( ovm_global_urm_report_server == null ) begin 00736 ovm_report_handler m_rh; 00737 ovm_report_global_server glob; 00738 ovm_global_urm_report_server = new; 00739 glob = new; 00740 glob.set_server(ovm_global_urm_report_server); 00741 m_rh = _global_reporter.get_report_handler(); 00742 m_rh.m_max_verbosity_level = OVM_LOW; 00743 m_rh.set_severity_action(OVM_INFO,OVM_DISPLAY); 00744 m_rh.set_severity_action(OVM_WARNING,OVM_DISPLAY); 00745 m_rh.set_severity_action(OVM_ERROR,OVM_COUNT|OVM_DISPLAY|OVM_EXIT); 00746 m_rh.set_severity_action(OVM_FATAL,OVM_COUNT|OVM_DISPLAY|OVM_EXIT); 00747 end 00748 endfunction 00749 00750 function void ovm_urm_report_server::set_default_report_type(int value); 00751 ovm_urm_report_server::init_urm_report_server(); 00752 ovm_global_urm_report_server.m_global_default_type = value; 00753 ovm_global_urm_report_server.m_global_type = value; 00754 endfunction 00755 00756 function bit ovm_urm_report_server::m_message_header(ovm_urm_message message); 00757 static bit m_action_change_warn_once =1; 00758 00759 m_apply_override_requests(message); 00760 // consolidate destination information 00761 if ( ! ( message.m_action & OVM_LOG ) ) message.m_destination = 0; 00762 if ( message.m_action & OVM_DISPLAY ) message.m_destination |= 1; 00763 00764 // enforce limitations on `message actions 00765 if ( message.m_type == OVM_URM_MSG_DEBUG ) begin 00766 if ((message.m_action & ~(OVM_DISPLAY|OVM_LOG))&&(m_action_change_warn_once)) begin 00767 $display("OVM messaging ignores OVM_CALL_HOOK, OVM_COUNT, OVM_EXIT and OVM_STOP actions on messages created via `message. "); 00768 m_action_change_warn_once = 0; 00769 end 00770 message.m_action &= (OVM_DISPLAY|OVM_LOG); 00771 end 00772 00773 // return message.handler.filter(message); 00774 return message.m_verbosity <= message.m_max_verbosity; 00775 endfunction 00776 00777 function bit ovm_urm_report_server::m_message_subheader(ovm_urm_message message); 00778 00779 // update counts 00780 ovm_global_urm_report_server.incr_severity_count(message.m_severity); 00781 ovm_global_urm_report_server.incr_id_count(message.m_id); 00782 00783 if ( message.m_destination == 0 ) return 0; 00784 00785 case (message.m_type) 00786 00787 OVM_URM_MSG_DEBUG : begin 00788 bit first; 00789 first = 1; 00790 if ( message.m_style & OVM_URM_STYLE_TIME ) begin 00791 first = 0; 00792 $write("[%0t]",$time); 00793 end 00794 if ( message.m_style & OVM_URM_STYLE_VERBOSITY ) begin 00795 if ( first ) first = 0; else $write(" "); 00796 $write("(%0s)",m_urm_verbosity_string(message.m_verbosity)); 00797 end 00798 if ( message.m_style & OVM_URM_STYLE_SEVERITY ) begin 00799 if ( first ) first = 0; else $write(" "); 00800 $write("severity=%0s",m_urm_severity_string(message.m_severity)); 00801 end 00802 if ( message.m_style & OVM_URM_STYLE_TAG ) begin 00803 if ( first ) first = 0; else $write(" "); 00804 $write("tag=%0s",message.m_id); 00805 end 00806 if ( message.m_style & OVM_URM_STYLE_SCOPE ) begin 00807 if ( first ) first = 0; else $write(" "); 00808 $write("scope=%0s",message.m_scope); 00809 end 00810 if ( message.m_style & OVM_URM_STYLE_HIERARCHY ) begin 00811 if ( first ) first = 0; else $write(" "); 00812 $write("hier=%0s",message.m_hierarchy); 00813 end 00814 if ( message.m_style & OVM_URM_STYLE_MESSAGE_TEXT ) begin 00815 if ( ! first ) $write(": "); 00816 return 1; 00817 end 00818 else begin 00819 if ( ! first ) $display; 00820 return 0; 00821 end 00822 end 00823 00824 OVM_URM_MSG_DUT : begin 00825 $display( 00826 "\n*** OVM: DUT %s at time %0t\n Checked at line %0d in %s\n In %s\n", 00827 m_urm_severity_severity(message.m_severity), 00828 $time, message.m_line, message.m_file, 00829 message.m_hierarchy 00830 ); 00831 end 00832 00833 OVM_URM_MSG_TOOL : begin 00834 $write( 00835 "ovm: *%s,%s (%s,%0d): ", 00836 m_urm_severity_S(message.m_severity), message.m_id, 00837 message.m_file, message.m_line 00838 ); 00839 end 00840 00841 OVM_URM_MSG_OVM : begin 00842 string image; 00843 image = ovm_global_urm_report_server.compose_message( 00844 message.m_severity, message.m_name, message.m_id, 00845 "", message.m_file, message.m_line 00846 ); 00847 $write("%s",image); 00848 end 00849 00850 endcase 00851 00852 return 1; 00853 00854 endfunction 00855 00856 function void ovm_urm_report_server::m_message_footer(ovm_urm_message message); 00857 00858 if ( message.m_destination != 0 ) begin 00859 00860 case (message.m_type) 00861 00862 OVM_URM_MSG_DEBUG : begin 00863 bit first; 00864 first = 1; 00865 if ( ( message.m_style & OVM_URM_STYLE_FILE ) && ( message.m_style & OVM_URM_STYLE_LINE ) ) begin 00866 first = 0; 00867 $write("%0s, %0d",message.m_file,message.m_line); 00868 end 00869 else if ( message.m_style & OVM_URM_STYLE_FILE ) begin 00870 first = 0; 00871 $write("%0s",message.m_file); 00872 end 00873 else if ( message.m_style & OVM_URM_STYLE_LINE ) begin 00874 first = 0; 00875 $write("%0d",message.m_line); 00876 end 00877 if ( ( message.m_style & OVM_URM_STYLE_UNIT ) ) begin 00878 ovm_component ch; 00879 if ( $cast(ch,message.m_client) ) begin 00880 if ( first ) first = 0; else $write(" "); 00881 $write("%0s",ch.get_full_name()); 00882 end 00883 end 00884 if ( ! first ) $display; 00885 end 00886 00887 OVM_URM_MSG_DUT : begin 00888 if ( message.m_action & (OVM_EXIT|OVM_STOP) ) begin 00889 ovm_report_handler m_rh; 00890 m_rh = message.m_client.get_report_handler(); 00891 $display( 00892 "Will stop execution immediately (check effect is %0s)", 00893 m_rh.format_action(message.m_action) 00894 ); 00895 end 00896 $display( 00897 "*** %0s: A DUT %0s has occurred\n", 00898 m_urm_severity_Severity(message.m_severity), 00899 m_urm_severity_severity(message.m_severity) 00900 ); 00901 end 00902 00903 endcase 00904 00905 end 00906 00907 if ( message.m_action & OVM_COUNT ) begin 00908 if ( ovm_global_urm_report_server.get_max_quit_count() != 0 ) begin 00909 ovm_global_urm_report_server.incr_quit_count(); 00910 if ( ovm_global_urm_report_server.is_quit_count_reached() ) begin 00911 $display("** ERROR LIMIT REACHED **"); 00912 message.m_action |= OVM_EXIT; 00913 end 00914 end 00915 end 00916 00917 if ( message.m_action & OVM_EXIT ) message.m_client.die(); 00918 00919 if ( message.m_action & OVM_STOP ) $stop; 00920 00921 endfunction 00922 00923 function void ovm_urm_report_server::m_set_report_hier(string hier); 00924 ovm_urm_report_server::init_urm_report_server(); 00925 ovm_global_urm_report_server.m_global_hier = hier; 00926 endfunction 00927 00928 function void ovm_urm_report_server::m_set_report_scope(string scope); 00929 ovm_urm_report_server::init_urm_report_server(); 00930 ovm_global_urm_report_server.m_global_scope = scope; 00931 endfunction 00932 00933 function void ovm_urm_report_server::m_set_report_type(int typ); 00934 ovm_urm_report_server::init_urm_report_server(); 00935 ovm_global_urm_report_server.m_global_type = typ; 00936 endfunction 00937 00938 function void ovm_urm_report_server::m_reset_report_flags(); 00939 ovm_urm_report_server::init_urm_report_server(); 00940 ovm_global_urm_report_server.m_global_hier = ""; 00941 ovm_global_urm_report_server.m_global_scope = ""; 00942 ovm_global_urm_report_server.m_global_type = ovm_global_urm_report_server.m_global_default_type; 00943 endfunction 00944 00945 function string ovm_urm_report_server::m_dump_global_debug_style(); 00946 int style_e; 00947 style_e = get_global_debug_style(); 00948 return m_urm_msg_style_string(style_e); 00949 endfunction 00950 00951 function string ovm_urm_report_server::m_dump_rules_debug_style(); 00952 string result; 00953 result = ""; 00954 for (int i=0 ; i<m_override_requests.size(); i++) 00955 if (m_override_requests[i].is_style_override()) 00956 result = { result, m_override_requests[i].dump_request_details(), "\n"}; 00957 return (result); 00958 endfunction 00959 00960 function string ovm_urm_report_server::m_dump_global_verbosity(); 00961 int verbosity_i; 00962 verbosity_i = get_global_verbosity(); 00963 return m_urm_verbosity_string(verbosity_i); 00964 endfunction 00965 00966 function string ovm_urm_report_server::m_dump_rules_verbosity(); 00967 string result; 00968 result = ""; 00969 for (int i=0 ; i<m_override_requests.size(); i++) 00970 if (m_override_requests[i].is_verbosity_override()) 00971 result = { result, m_override_requests[i].dump_request_details(), "\n"}; 00972 return (result); 00973 endfunction 00974 00975 function string ovm_urm_report_server::m_dump_global_destination(); 00976 int destination_i; 00977 destination_i = get_global_destination(); 00978 return m_urm_destination_string(destination_i); 00979 endfunction 00980 00981 function string ovm_urm_report_server::m_dump_rules_destination(); 00982 string result; 00983 result = ""; 00984 for (int i=0 ; i<m_override_requests.size(); i++) 00985 if (m_override_requests[i].is_destination_override()) 00986 result = { result, m_override_requests[i].dump_request_details(), "\n"}; 00987 return (result); 00988 endfunction 00989 00990 function string ovm_urm_report_server::m_dump_global_severity(); 00991 int severity_i; 00992 severity_i = get_global_severity(); 00993 return m_urm_severity_string(severity_i); 00994 endfunction 00995 00996 function string ovm_urm_report_server::m_dump_rules_severity(); 00997 string result; 00998 result = ""; 00999 for (int i=0 ; i<m_override_requests.size(); i++) 01000 if (m_override_requests[i].is_severity_override()) 01001 result = { result, m_override_requests[i].dump_request_details(), "\n"}; 01002 return (result); 01003 endfunction 01004 01005 function string ovm_urm_report_server::m_dump_global_actions(); 01006 ovm_urm_report_server::init_urm_report_server(); 01007 return m_urm_actions_string(_global_reporter); 01008 endfunction 01009 01010 function string ovm_urm_report_server::m_dump_rules_actions(); 01011 string result; 01012 result = ""; 01013 for (int i=0 ; i<m_override_requests.size(); i++) 01014 if (m_override_requests[i].is_action_override()) 01015 result = { result, m_override_requests[i].dump_request_details(), "\n"}; 01016 return (result); 01017 endfunction 01018 01019 function void ovm_urm_report_server::m_handle_new_request( 01020 ovm_urm_override_request new_req, bit remove 01021 ); 01022 int existing_req_loc; 01023 `ifdef OVM_AVOID_SFORMATF 01024 if ( new_req.match_text != "*" && ! remove ) begin 01025 `urm_warning(("%s%s", 01026 "Filtering message overrides by message text is not supported ", 01027 "in this version of OVM; this override will be ignored" 01028 )) 01029 return; 01030 end 01031 `endif 01032 existing_req_loc = m_find_last_matching_request_loc(new_req); 01033 if (remove) begin 01034 if (existing_req_loc != -1) 01035 m_override_requests.delete(existing_req_loc); 01036 else 01037 `urm_warning(("Cannot find a matching rule to remove. Ignoring.")) 01038 end 01039 else begin // !remove 01040 if ( (m_override_requests.size() == 0) 01041 || 01042 (existing_req_loc != m_override_requests.size()-1)) 01043 m_override_requests.push_back(new_req); 01044 else 01045 `urm_warning(("Repeating the same command as the last one. Ignoring.")) 01046 end 01047 endfunction 01048 01049 function int ovm_urm_report_server::m_find_last_matching_request_loc( 01050 ovm_urm_override_request req 01051 ); 01052 for (int i=m_override_requests.size()-1; i >= 0 ; i--) 01053 if (m_override_requests[i].compare(req)) return(i); 01054 return(-1); 01055 endfunction 01056 01057 function void ovm_urm_report_server::m_apply_override_requests(ovm_urm_message msg); 01058 for (int i=0; i < m_override_requests.size(); i++) 01059 if (m_override_requests[i].is_applicable_to_message(msg)) 01060 m_override_requests[i].apply_override(msg); 01061 endfunction 01062 01063
![]() 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 |