00001 // $Id: ovm__registry_8svh-source.html,v 1.1 2008/10/07 21:54:27 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 `ifndef OVM_REGISTRY_SVH 00022 `define OVM_REGISTRY_SVH 00023 00024 class ovm_component_registry #(type T=ovm_component, string Tname="<unknown>") 00025 extends ovm_object_wrapper; 00026 typedef ovm_component_registry #(T,Tname) this_type; 00027 00028 function ovm_component create_component(string name, ovm_component parent); 00029 T obj; 00030 obj = new(name, parent); 00031 return obj; 00032 endfunction 00033 00034 const static string type_name = Tname; 00035 00036 function string get_type_name(); 00037 return type_name; 00038 endfunction 00039 00040 local static this_type me = get(); 00041 00042 static function this_type get(); 00043 if (me == null) begin 00044 ovm_factory f = ovm_factory::get(); 00045 me = new; 00046 f.register(me); 00047 end 00048 return me; 00049 endfunction 00050 00051 static function T create(string name, ovm_component parent, string contxt=""); 00052 ovm_object obj; 00053 ovm_factory f = ovm_factory::get(); 00054 if (contxt == "" && parent != null) 00055 contxt = parent.get_full_name(); 00056 obj = f.create_component_by_type(get(),contxt,name,parent); 00057 assert ($cast(create,obj)) 00058 else $fatal(0,"Factory did not return a component of type '",type_name,"'. A component of type '",obj == null ? "null" : obj.get_type_name(),"' was returned instead. Name=",name," Parent=",parent==null?"null":parent.get_type_name()," contxt=",contxt); 00059 endfunction 00060 00061 static function void set_type_override(ovm_object_wrapper override_type, bit replace=1); 00062 factory.set_type_override_by_type(get(),override_type,replace); 00063 endfunction 00064 00065 static function void set_inst_override(ovm_object_wrapper override_type, 00066 string inst_path, 00067 ovm_component parent=null); 00068 string full_inst_path; 00069 if (parent != null) begin 00070 if (inst_path == "") 00071 inst_path = parent.get_full_name(); 00072 else 00073 inst_path = {parent.get_full_name(),".",inst_path}; 00074 end 00075 factory.set_inst_override_by_type(get(),override_type,inst_path); 00076 endfunction 00077 00078 endclass 00079 00080 00081 class ovm_object_registry #(type T=ovm_object, string Tname="<unknown>") 00082 extends ovm_object_wrapper; 00083 typedef ovm_object_registry #(T,Tname) this_type; 00084 00085 function ovm_object create_object(string name); 00086 T obj; 00087 obj = new(); 00088 obj.set_name(name); 00089 return obj; 00090 endfunction 00091 00092 const static string type_name = Tname; 00093 00094 function string get_type_name(); 00095 return type_name; 00096 endfunction 00097 00098 local static this_type me = get(); 00099 00100 static function this_type get(); 00101 if (me == null) begin 00102 ovm_factory f = ovm_factory::get(); 00103 me = new; 00104 f.register(me); 00105 end 00106 return me; 00107 endfunction 00108 00109 static function T create(string name="", ovm_component parent=null, string contxt=""); 00110 ovm_object obj; 00111 ovm_factory f = ovm_factory::get(); 00112 if (contxt == "" && parent != null) 00113 contxt = parent.get_full_name(); 00114 obj = f.create_object_by_type(get(),contxt,name); 00115 assert ($cast(create,obj)) 00116 else $fatal(0,"Factory did not return an object of type '",type_name,"'. An object of type '",obj == null ? "null" : obj.get_type_name(),"' was returned instead. Name=",name," Parent=",parent==null?"null":parent.get_type_name()," contxt=",contxt); 00117 endfunction 00118 00119 static function void set_type_override(ovm_object_wrapper override_type, bit replace=1); 00120 factory.set_type_override_by_type(get(),override_type,replace); 00121 endfunction 00122 00123 static function void set_inst_override(ovm_object_wrapper override_type, 00124 string inst_path, 00125 ovm_component parent=null); 00126 string full_inst_path; 00127 if (parent != null) begin 00128 if (inst_path == "") 00129 inst_path = parent.get_full_name(); 00130 else 00131 inst_path = {parent.get_full_name(),".",inst_path}; 00132 end 00133 factory.set_inst_override_by_type(get(),override_type,inst_path); 00134 endfunction 00135 00136 endclass 00137 00138 `endif
![]() 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 |