00001 // $Id: ovm__factory_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 `include "base/ovm_factory.svh" 00023 `include "base/ovm_object.svh" 00024 00025 //------------------------------------------------------------------------------ 00026 // 00027 // CLASS: ovm_factory 00028 // 00029 //------------------------------------------------------------------------------ 00030 00031 // get 00032 // --- 00033 00034 function ovm_factory ovm_factory::get(); 00035 if (m_inst == null) begin 00036 m_inst = new(); 00037 end 00038 return m_inst; 00039 endfunction 00040 00041 // new 00042 // --- 00043 00044 function ovm_factory::new (); 00045 endfunction 00046 00047 00048 // auto_register (static) 00049 // ------------- 00050 00051 function void ovm_factory::auto_register (ovm_object_wrapper obj); 00052 m_inst = ovm_factory::get(); 00053 m_inst.register(obj); 00054 endfunction 00055 00056 00057 // register 00058 // -------- 00059 00060 function void ovm_factory::register (ovm_object_wrapper obj); 00061 00062 assert(obj!=null); 00063 if (obj.get_type_name() == "" || obj.get_type_name() == "<unknown>") begin 00064 //ovm_report_warning("EMPTNM", {"Factory registration with ", 00065 // "unknown type name prevents name-based operations. "}); 00066 end 00067 else begin 00068 if (m_type_names.exists(obj.get_type_name())) 00069 ovm_report_warning("TPRGED", {"Type name '",obj.get_type_name(), 00070 "' already registered with factory. No string-based lookup ", 00071 "support for multiple types with the same type name."}); 00072 else 00073 m_type_names[obj.get_type_name()] = obj; 00074 end 00075 00076 if (m_types.exists(obj)) begin 00077 if (obj.get_type_name() != "" && obj.get_type_name() != "<unknown>") 00078 ovm_report_warning("TPRGED", {"Object type '",obj.get_type_name(), 00079 "' already registered with factory. "}); 00080 end 00081 else 00082 m_types[obj] = 1; 00083 00084 endfunction 00085 00086 00087 00088 // set_type_override (static) 00089 // ----------------- 00090 00091 function void ovm_factory::set_type_override (string original_type_name, 00092 string override_type_name, 00093 bit replace=1); 00094 m_inst = ovm_factory::get(); 00095 m_inst.set_type_override_by_name (original_type_name, override_type_name, replace); 00096 endfunction 00097 00098 00099 // set_type_override_by_type 00100 // ------------------------- 00101 00102 function void ovm_factory::set_type_override_by_type (ovm_object_wrapper original_type, 00103 ovm_object_wrapper override_type, 00104 bit replace=1); 00105 bit replaced; 00106 00107 // check that old and new are not the same 00108 if (original_type == override_type) begin 00109 if (original_type.get_type_name() == "" || original_type.get_type_name() == "<unknown>") 00110 ovm_report_warning("TYPDUP", {"Original and override type ", 00111 "arguments are identical"}); 00112 else 00113 ovm_report_warning("TYPDUP", {"Original and override type ", 00114 "arguments are identical: ", 00115 original_type.get_type_name()}); 00116 return; 00117 end 00118 00119 // register the types if not already done so, for the benefit of string-based lookup 00120 if (!m_types.exists(original_type)) 00121 register(original_type); 00122 00123 if (!m_types.exists(override_type)) 00124 register(override_type); 00125 00126 00127 // check for existing type override 00128 foreach (m_type_overrides[index]) begin 00129 if (m_type_overrides[index].orig_type == original_type || 00130 (m_type_overrides[index].orig_type_name != "<unknown>" && 00131 m_type_overrides[index].orig_type_name != "" && 00132 m_type_overrides[index].orig_type_name == original_type.get_type_name())) begin 00133 string msg; 00134 msg = {"Original object type '",original_type.get_type_name(), 00135 "' already registered to produce '", 00136 m_type_overrides[index].ovrd_type_name,"'"}; 00137 if (!replace) begin 00138 msg = {msg, ". Set 'replace' argument to replace the existing entry."}; 00139 ovm_report_warning("TPREGD", msg); 00140 return; 00141 end 00142 msg = {msg, ". Replacing with override to produce type '", 00143 override_type.get_type_name(),"'."}; 00144 ovm_report_warning("TPREGD", msg); 00145 replaced = 1; 00146 m_type_overrides[index].orig_type = original_type; 00147 m_type_overrides[index].orig_type_name = original_type.get_type_name(); 00148 m_type_overrides[index].ovrd_type = override_type; 00149 m_type_overrides[index].ovrd_type_name = override_type.get_type_name(); 00150 end 00151 end 00152 00153 // make a new entry 00154 if (!replaced) begin 00155 ovm_factory_override override; 00156 override = new(.orig_type(original_type), 00157 .orig_type_name(original_type.get_type_name()), 00158 .full_inst_path("*"), 00159 .ovrd_type(override_type)); 00160 00161 m_type_overrides.push_back(override); 00162 end 00163 00164 endfunction 00165 00166 00167 // set_type_override_by_name 00168 // ------------------------- 00169 00170 function void ovm_factory::set_type_override_by_name (string original_type_name, 00171 string override_type_name, 00172 bit replace=1); 00173 bit replaced; 00174 00175 // check that type is registered with the factory 00176 if (!m_type_names.exists(override_type_name)) begin 00177 ovm_report_error("TYPNTF", {"Cannot register override for original type '", 00178 original_type_name,"' because the override type '", 00179 override_type_name, "' is not registered with the factory."}); 00180 return; 00181 end 00182 00183 // check that old and new are not the same 00184 if (original_type_name == override_type_name) begin 00185 ovm_report_warning("TYPDUP", {"Requested and actual type name ", 00186 " arguments are identical: ",original_type_name,". Ignoring this override."}); 00187 return; 00188 end 00189 00190 foreach (m_type_overrides[index]) begin 00191 if (m_type_overrides[index].orig_type_name == original_type_name) begin 00192 if (!replace) begin 00193 ovm_report_warning("TPREGD", {"Original type '",original_type_name, 00194 "' already registered to produce '",m_type_overrides[index].ovrd_type_name, 00195 "'. Set 'replace' argument to replace the existing entry."}); 00196 return; 00197 end 00198 ovm_report_warning("TPREGR", {"Original object type '",original_type_name, 00199 "' already registered to produce '",m_type_overrides[index].ovrd_type_name, 00200 "'. Replacing with override to produce type '",override_type_name,"'."}); 00201 replaced = 1; 00202 m_type_overrides[index].ovrd_type = m_type_names[override_type_name]; 00203 m_type_overrides[index].ovrd_type_name = override_type_name; 00204 end 00205 end 00206 00207 if (!m_type_names.exists(original_type_name)) 00208 m_lookup_strs[original_type_name] = 1; 00209 00210 if (!replaced) begin 00211 ovm_factory_override override; 00212 override = new(.orig_type(m_type_names[original_type_name]), 00213 .orig_type_name(original_type_name), 00214 .full_inst_path("*"), 00215 .ovrd_type(m_type_names[override_type_name])); 00216 00217 m_type_overrides.push_back(override); 00218 //m_type_names[original_type_name] = override.ovrd_type; 00219 end 00220 00221 endfunction 00222 00223 00224 // set_inst_override (static) 00225 // ----------------- 00226 00227 function void ovm_factory::set_inst_override (string full_inst_path, 00228 string original_type_name, 00229 string override_type_name); 00230 m_inst = ovm_factory::get(); 00231 m_inst.set_inst_override_by_name (original_type_name, override_type_name, full_inst_path); 00232 endfunction 00233 00234 00235 // set_inst_override_by_type 00236 // ------------------------- 00237 00238 function void ovm_factory::set_inst_override_by_type (ovm_object_wrapper original_type, 00239 ovm_object_wrapper override_type, 00240 string full_inst_path); 00241 00242 ovm_factory_override override; 00243 00244 // register the types if not already done so 00245 if (!m_types.exists(original_type)) 00246 register(original_type); 00247 00248 if (!m_types.exists(override_type)) 00249 register(override_type); 00250 00251 override = new(.full_inst_path(full_inst_path), 00252 .orig_type(original_type), 00253 .orig_type_name(original_type.get_type_name()), 00254 .ovrd_type(override_type)); 00255 00256 m_inst_overrides.push_back(override); 00257 00258 endfunction 00259 00260 00261 // set_inst_override_by_name 00262 // ------------------------- 00263 00264 function void ovm_factory::set_inst_override_by_name (string original_type_name, 00265 string override_type_name, 00266 string full_inst_path); 00267 00268 ovm_factory_override override; 00269 00270 // check that type is registered with the factory 00271 if (!m_type_names.exists(override_type_name)) begin 00272 ovm_report_error("TYPNTF", {"Cannot register instance override with type name '", 00273 original_type_name,"' and instance path '",full_inst_path,"' because the type it's supposed ", 00274 "to produce, '",override_type_name,"', is not registered with the factory."}); 00275 return; 00276 end 00277 00278 if (!m_type_names.exists(original_type_name)) 00279 m_lookup_strs[original_type_name] = 1; 00280 00281 override = new(.full_inst_path(full_inst_path), 00282 .orig_type(m_type_names[original_type_name]), 00283 .orig_type_name(original_type_name), 00284 .ovrd_type(m_type_names[override_type_name])); 00285 00286 m_inst_overrides.push_back(override); 00287 00288 endfunction 00289 00290 00291 // create_object (static) 00292 // ------------- 00293 00294 function ovm_object ovm_factory::create_object (string requested_type_name, 00295 string parent_inst_path="", 00296 string name=""); 00297 m_inst = ovm_factory::get(); 00298 return m_inst.create_object_by_name(requested_type_name, parent_inst_path, name); 00299 endfunction 00300 00301 00302 // create_object_by_name 00303 // --------------------- 00304 00305 function ovm_object ovm_factory::create_object_by_name (string requested_type_name, 00306 string parent_inst_path="", 00307 string name=""); 00308 00309 ovm_object_wrapper wrapper; 00310 string inst_path; 00311 00312 if (parent_inst_path == "") 00313 inst_path = name; 00314 else if (name != "") 00315 inst_path = {parent_inst_path,".",name}; 00316 else 00317 inst_path = parent_inst_path; 00318 00319 `ovm_clear_queue(m_override_info) 00320 00321 wrapper = find_override_by_name(requested_type_name, inst_path); 00322 00323 // if no override exists, try to use requested_type_name directly 00324 if (wrapper==null) begin 00325 if(!m_type_names.exists(requested_type_name)) begin 00326 ovm_report_warning("BDTYP",{"Cannot create an object of type '", 00327 requested_type_name,"' because it is not registered with the factory."}); 00328 return null; 00329 end 00330 wrapper = m_type_names[requested_type_name]; 00331 end 00332 00333 return wrapper.create_object(name); 00334 00335 endfunction 00336 00337 00338 // create_object_by_type 00339 // --------------------- 00340 00341 function ovm_object ovm_factory::create_object_by_type (ovm_object_wrapper requested_type, 00342 string parent_inst_path="", 00343 string name=""); 00344 00345 string full_inst_path; 00346 00347 if (parent_inst_path == "") 00348 full_inst_path = name; 00349 else if (name != "") 00350 full_inst_path = {parent_inst_path,".",name}; 00351 else 00352 full_inst_path = parent_inst_path; 00353 00354 `ovm_clear_queue(m_override_info) 00355 00356 requested_type = find_override_by_type(requested_type, full_inst_path); 00357 00358 return requested_type.create_object(name); 00359 00360 endfunction 00361 00362 00363 // create_component (static) 00364 // ---------------- 00365 00366 function ovm_component ovm_factory::create_component (string requested_type_name, 00367 string parent_inst_path="", 00368 string name, 00369 ovm_component parent); 00370 m_inst = ovm_factory::get(); 00371 return m_inst.create_component_by_name(requested_type_name, parent_inst_path, name, parent); 00372 endfunction 00373 00374 00375 // create_component_by_name 00376 // ------------------------ 00377 00378 function ovm_component ovm_factory::create_component_by_name (string requested_type_name, 00379 string parent_inst_path="", 00380 string name, 00381 ovm_component parent); 00382 ovm_object_wrapper wrapper; 00383 string inst_path; 00384 00385 if (parent_inst_path == "") 00386 inst_path = name; 00387 else if (name != "") 00388 inst_path = {parent_inst_path,".",name}; 00389 else 00390 inst_path = parent_inst_path; 00391 00392 `ovm_clear_queue(m_override_info) 00393 00394 wrapper = find_override_by_name(requested_type_name, inst_path); 00395 00396 // if no override exists, try to use requested_type_name directly 00397 if (wrapper == null) begin 00398 if(!m_type_names.exists(requested_type_name)) begin 00399 ovm_report_warning("BDTYP",{"Cannot create a component of type '", 00400 requested_type_name,"' because it is not registered with the factory."}); 00401 return null; 00402 end 00403 wrapper = m_type_names[requested_type_name]; 00404 end 00405 00406 return wrapper.create_component(name, parent); 00407 00408 endfunction 00409 00410 00411 // create_component_by_type 00412 // ------------------------ 00413 00414 function ovm_component ovm_factory::create_component_by_type (ovm_object_wrapper requested_type, 00415 string parent_inst_path="", 00416 string name, 00417 ovm_component parent); 00418 string full_inst_path; 00419 00420 if (parent_inst_path == "") 00421 full_inst_path = name; 00422 else if (name != "") 00423 full_inst_path = {parent_inst_path,".",name}; 00424 else 00425 full_inst_path = parent_inst_path; 00426 00427 `ovm_clear_queue(m_override_info) 00428 00429 requested_type = find_override_by_type(requested_type, full_inst_path); 00430 00431 return requested_type.create_component(name, parent); 00432 00433 endfunction 00434 00435 00436 00437 // find_override_by_name 00438 // --------------------- 00439 00440 function ovm_object_wrapper ovm_factory::find_override_by_name (string requested_type_name, 00441 string full_inst_path); 00442 00443 // inst override; return first match; takes precedence over type overrides 00444 if (full_inst_path != "") 00445 foreach (m_inst_overrides[index]) 00446 if (ovm_is_match(m_inst_overrides[index].orig_type_name, requested_type_name) && 00447 ovm_is_match(m_inst_overrides[index].full_inst_path, full_inst_path)) begin 00448 m_override_info.push_back(m_inst_overrides[index]); 00449 if (m_inst_overrides[index].ovrd_type.get_type_name() == requested_type_name) 00450 return m_inst_overrides[index].ovrd_type; 00451 else 00452 return find_override_by_type(m_inst_overrides[index].ovrd_type,full_inst_path); 00453 end 00454 00455 // type override - exact match 00456 foreach (m_type_overrides[index]) 00457 if (m_type_overrides[index].orig_type_name == requested_type_name) begin 00458 m_override_info.push_back(m_type_overrides[index]); 00459 return find_override_by_type(m_type_overrides[index].ovrd_type,full_inst_path); 00460 end 00461 00462 // type override with wildcard match 00463 //foreach (m_type_overrides[index]) 00464 // if (ovm_is_match(index,requested_type_name)) begin 00465 // m_override_info.push_back(m_inst_overrides[index]); 00466 // return find_override_by_type(m_type_overrides[index].ovrd_type,full_inst_path); 00467 // end 00468 00469 // No override found 00470 return null; 00471 00472 endfunction 00473 00474 00475 // find_override_by_type 00476 // --------------------- 00477 00478 function ovm_object_wrapper ovm_factory::find_override_by_type(ovm_object_wrapper requested_type, 00479 string full_inst_path); 00480 00481 00482 foreach (m_override_info[index]) begin 00483 if ( //index != m_override_info.size()-1 && 00484 m_override_info[index].orig_type == requested_type) begin 00485 ovm_report_error("OVRDLOOP", "Recursive loop detected while finding override."); 00486 if (!m_debug_pass) 00487 m_debug_display(requested_type.get_type_name(),requested_type,full_inst_path); 00488 return requested_type; 00489 end 00490 end 00491 00492 // inst override; return first match; takes precedence over type overrides 00493 if (full_inst_path != "") 00494 foreach (m_inst_overrides[index]) begin 00495 if ((m_inst_overrides[index].orig_type == requested_type || 00496 (m_inst_overrides[index].orig_type_name != "<unknown>" && 00497 m_inst_overrides[index].orig_type_name != "" && 00498 m_inst_overrides[index].orig_type_name == requested_type.get_type_name())) && 00499 ovm_is_match(m_inst_overrides[index].full_inst_path, full_inst_path)) begin 00500 m_override_info.push_back(m_inst_overrides[index]); 00501 if (m_inst_overrides[index].ovrd_type == requested_type) 00502 return requested_type; 00503 else 00504 return find_override_by_type(m_inst_overrides[index].ovrd_type,full_inst_path); 00505 end 00506 end 00507 00508 // type override - exact match 00509 foreach (m_type_overrides[index]) begin 00510 if (m_type_overrides[index].orig_type == requested_type || 00511 (m_type_overrides[index].orig_type_name != "<unknown>" && 00512 m_type_overrides[index].orig_type_name != "" && 00513 m_type_overrides[index].orig_type_name == requested_type.get_type_name())) begin 00514 m_override_info.push_back(m_type_overrides[index]); 00515 if (m_type_overrides[index].ovrd_type == requested_type) 00516 return requested_type; 00517 else 00518 return find_override_by_type(m_type_overrides[index].ovrd_type,full_inst_path); 00519 end 00520 end 00521 00522 // type override with wildcard match 00523 //foreach (m_type_overrides[index]) 00524 // if (ovm_is_match(index,requested_type.get_type_name())) begin 00525 // m_override_info.push_back(m_inst_overrides[index]); 00526 // return find_override_by_type(m_type_overrides[index],full_inst_path); 00527 // end 00528 return requested_type; 00529 00530 endfunction 00531 00532 00533 // print_all_overrides (static) 00534 // ------------------- 00535 00536 function void ovm_factory::print_all_overrides (int all_types=0); 00537 m_inst = ovm_factory::get(); 00538 m_inst.print(all_types); 00539 endfunction 00540 00541 00542 // print 00543 // ----- 00544 00545 function void ovm_factory::print (int all_types=1); 00546 00547 string key; 00548 00549 $display("\n#### Factory Configuration (*)\n"); 00550 00551 // print instance overrides 00552 if(!m_type_overrides.size() && !m_inst_overrides.size()) 00553 $display(" No instance or type overrides are registered with this factory"); 00554 else begin 00555 int max1,max2,max3; 00556 string dash = "---------------------------------------------------------------------------------------------------"; 00557 string space= " "; 00558 00559 // print instance overrides 00560 if(!m_inst_overrides.size()) 00561 $display("No instance overrides are registered with this factory"); 00562 else begin 00563 foreach (m_inst_overrides[i]) begin 00564 if (m_inst_overrides[i].orig_type_name.len() > max1) 00565 max1=m_inst_overrides[i].orig_type_name.len(); 00566 if (m_inst_overrides[i].full_inst_path.len() > max2) 00567 max2=m_inst_overrides[i].full_inst_path.len(); 00568 if (m_inst_overrides[i].ovrd_type_name.len() > max3) 00569 max3=m_inst_overrides[i].ovrd_type_name.len(); 00570 end 00571 if (max1 < 14) max1 = 14; 00572 if (max2 < 13) max2 = 13; 00573 if (max3 < 13) max3 = 13; 00574 00575 $display("Instance Overrides:\n"); 00576 $display(" %0s%0s %0s%0s %0s%0s","Requested Type",space.substr(1,max1-14), 00577 "Override Path", space.substr(1,max2-13), 00578 "Override Type", space.substr(1,max3-13)); 00579 $display(" %0s %0s %0s",dash.substr(1,max1), 00580 dash.substr(1,max2), 00581 dash.substr(1,max3)); 00582 00583 foreach (m_inst_overrides[i]) begin 00584 $write(" %0s%0s",m_inst_overrides[i].orig_type_name, 00585 space.substr(1,max1-m_inst_overrides[i].orig_type_name.len())); 00586 $write(" %0s%0s", m_inst_overrides[i].full_inst_path, 00587 space.substr(1,max2-m_inst_overrides[i].full_inst_path.len())); 00588 $display(" %0s", m_inst_overrides[i].ovrd_type_name); 00589 end 00590 end 00591 00592 // print type overrides 00593 if (!m_type_overrides.size()) 00594 $display("\nNo type overrides are registered with this factory"); 00595 else begin 00596 foreach (m_type_overrides[i]) begin 00597 if (m_type_overrides[i].orig_type_name.len() > max1) 00598 max1=m_type_overrides[i].orig_type_name.len(); 00599 if (m_type_overrides[i].ovrd_type_name.len() > max3) 00600 max2=m_type_overrides[i].ovrd_type_name.len(); 00601 end 00602 if (max1 < 14) max1 = 14; 00603 if (max2 < 13) max2 = 13; 00604 $display("\nType Overrides:\n"); 00605 $display(" %0s%0s %0s%0s","Requested Type",space.substr(1,max1-14), 00606 "Override Type", space.substr(1,max2-13)); 00607 $display(" %0s %0s",dash.substr(1,max1), 00608 dash.substr(1,max2)); 00609 foreach (m_type_overrides[index]) 00610 $display(" %0s%0s %0s", 00611 m_type_overrides[index].orig_type_name, 00612 space.substr(1,max1-m_type_overrides[index].orig_type_name.len()), 00613 m_type_overrides[index].ovrd_type_name); 00614 end 00615 end 00616 00617 // print all registered types, if all_types >= 1 00618 if (all_types >= 1 && m_type_names.first(key)) begin 00619 bit banner; 00620 $display("\nAll types registered with the factory: %0d total",m_types.num()); 00621 $display("(types without type names will not be printed)\n"); 00622 do begin 00623 // filter out ovm_ classes (if all_types<2) and non-types (lookup strings) 00624 if (!(all_types < 2 && ovm_is_match("ovm_*", 00625 m_type_names[key].get_type_name())) && 00626 key == m_type_names[key].get_type_name()) begin 00627 if (!banner) begin 00628 $display(" Type Name"); 00629 $display(" ---------"); 00630 banner=1; 00631 end 00632 $display(" ", m_type_names[key].get_type_name()); 00633 end 00634 end while(m_type_names.next(key)); 00635 end 00636 00637 $display("(*) Types with no associated type name will be printed as <unknown>"); 00638 00639 $display("\n####\n"); 00640 00641 endfunction 00642 00643 00644 // print_override_info (static) 00645 // ------------------- 00646 00647 function void ovm_factory::print_override_info (string requested_type_name, 00648 string parent_inst_path="", 00649 string name=""); 00650 m_inst = ovm_factory::get(); 00651 m_inst.m_debug_create(requested_type_name, null, parent_inst_path, name); 00652 endfunction 00653 00654 00655 // debug_create_by_name 00656 // -------------------- 00657 00658 function void ovm_factory::debug_create_by_name (string requested_type_name, 00659 string parent_inst_path="", 00660 string name=""); 00661 m_debug_create(requested_type_name, null, parent_inst_path, name); 00662 endfunction 00663 00664 00665 // debug_create_by_type 00666 // -------------------- 00667 00668 function void ovm_factory::debug_create_by_type (ovm_object_wrapper requested_type, 00669 string parent_inst_path="", 00670 string name=""); 00671 m_debug_create("", requested_type, parent_inst_path, name); 00672 endfunction 00673 00674 00675 // m_debug_create 00676 // -------------- 00677 00678 function void ovm_factory::m_debug_create (string requested_type_name, 00679 ovm_object_wrapper requested_type, 00680 string parent_inst_path, 00681 string name); 00682 00683 string full_inst_path; 00684 ovm_object_wrapper result; 00685 00686 if (parent_inst_path == "") 00687 full_inst_path = name; 00688 else if (name != "") 00689 full_inst_path = {parent_inst_path,".",name}; 00690 else 00691 full_inst_path = parent_inst_path; 00692 00693 `ovm_clear_queue(m_override_info) 00694 00695 if (requested_type == null) begin 00696 if (!m_type_names.exists(requested_type_name) && 00697 !m_lookup_strs.exists(requested_type_name)) begin 00698 ovm_report_warning("Factory Warning", {"The factory does not recognize '", 00699 requested_type_name,"' as a registered type."}); 00700 return; 00701 end 00702 m_debug_pass = 1; 00703 result = find_override_by_name(requested_type_name,full_inst_path); 00704 end 00705 else begin 00706 m_debug_pass = 1; 00707 if (!m_types.exists(requested_type)) 00708 register(requested_type); 00709 result = find_override_by_type(requested_type,full_inst_path); 00710 if (requested_type_name == "") 00711 requested_type_name = requested_type.get_type_name(); 00712 end 00713 00714 m_debug_display(requested_type_name, result, full_inst_path); 00715 m_debug_pass = 0; 00716 00717 endfunction 00718 00719 00720 // m_debug_display 00721 // --------------- 00722 00723 function void ovm_factory::m_debug_display (string requested_type_name, 00724 ovm_object_wrapper result, 00725 string full_inst_path); 00726 00727 int max1,max2,max3; 00728 string dash = "---------------------------------------------------------------------------------------------------"; 00729 string space= " "; 00730 00731 $display("\n#### Factory Override Information (*)\n"); 00732 $write("Given a request for an object of type '",requested_type_name, 00733 "' with an instance\npath of '",full_inst_path, 00734 "', the factory encountered\n"); 00735 00736 if (m_override_info.size() == 0) 00737 $display("no relevant overrides.\n"); 00738 else begin 00739 00740 $display("the following relevant overrides:\n"); 00741 00742 foreach (m_override_info[i]) begin 00743 if (m_override_info[i].orig_type_name.len() > max1) 00744 max1=m_override_info[i].orig_type_name.len(); 00745 if (m_override_info[i].full_inst_path.len() > max2) 00746 max2=m_override_info[i].full_inst_path.len(); 00747 if (m_override_info[i].ovrd_type_name.len() > max3) 00748 max3=m_override_info[i].ovrd_type_name.len(); 00749 end 00750 00751 if (max1 < 13) max1 = 13; 00752 if (max2 < 13) max2 = 13; 00753 if (max3 < 13) max3 = 13; 00754 00755 $display(" %0s%0s", "Original Type", space.substr(1,max1-13), 00756 " %0s%0s", "Instance Path", space.substr(1,max2-13), 00757 " %0s%0s", "Override Type", space.substr(1,max3-13)); 00758 00759 $display(" %0s %0s %0s",dash.substr(1,max1), 00760 dash.substr(1,max2), 00761 dash.substr(1,max3)); 00762 00763 foreach (m_override_info[i]) begin 00764 $write(" %0s%0s", m_override_info[i].orig_type_name, 00765 space.substr(1,max1-m_override_info[i].orig_type_name.len())); 00766 $write(" %0s%0s", m_override_info[i].full_inst_path, 00767 space.substr(1,max2-m_override_info[i].full_inst_path.len())); 00768 $write(" %0s%0s", m_override_info[i].ovrd_type_name, 00769 space.substr(1,max3-m_override_info[i].ovrd_type_name.len())); 00770 if (m_override_info[i].full_inst_path == "*") 00771 $display(" <type override>"); 00772 else 00773 $display(); 00774 end 00775 $display(); 00776 end 00777 00778 00779 $display("Result:\n"); 00780 $display(" The factory will produce an object of type '%0s'", 00781 result == null ? requested_type_name : result.get_type_name()); 00782 00783 $display("\n(*) Types with no associated type name will be printed as <unknown>"); 00784 00785 $display("\n####\n"); 00786 00787 endfunction 00788 00789
![]() 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:29 2008 |