ovm_registry.svh

Go to the documentation of this file.
00001 // $Id: a00264.html,v 1.1 2009/01/07 19:29:48 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(name), .parent(parent));
00031     obj = new(name, parent);
00032     return obj;
00033   endfunction
00034 
00035   const static string type_name = Tname;
00036 
00037   function string get_type_name();
00038     return type_name;
00039   endfunction
00040 
00041   local static this_type me = get();
00042 
00043   static function this_type get();
00044     if (me == null) begin
00045       ovm_factory f = ovm_factory::get();
00046       me = new;
00047       f.register(me);
00048     end
00049     return me;
00050   endfunction
00051 
00052   static function T create(string name, ovm_component parent, string contxt="");
00053     ovm_object obj;
00054     ovm_factory f = ovm_factory::get();
00055     if (contxt == "" && parent != null)
00056       contxt = parent.get_full_name();
00057     obj = f.create_component_by_type(get(),contxt,name,parent);
00058     assert ($cast(create,obj))
00059     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);
00060   endfunction
00061 
00062   static function void set_type_override(ovm_object_wrapper override_type, bit replace=1);
00063     factory.set_type_override_by_type(get(),override_type,replace);
00064   endfunction
00065 
00066   static function void set_inst_override(ovm_object_wrapper override_type,
00067                                          string inst_path,
00068                                          ovm_component parent=null);
00069     string full_inst_path;
00070     if (parent != null) begin
00071       if (inst_path == "")
00072         inst_path = parent.get_full_name();
00073       else
00074         inst_path = {parent.get_full_name(),".",inst_path};
00075     end
00076     factory.set_inst_override_by_type(get(),override_type,inst_path);
00077   endfunction
00078 
00079 endclass
00080 
00081 
00082 class ovm_object_registry #(type T=ovm_object, string Tname="<unknown>")
00083                                            extends ovm_object_wrapper;
00084   typedef ovm_object_registry #(T,Tname) this_type;
00085 
00086   function ovm_object create_object(string name);
00087     T obj;
00088     obj = new();
00089     obj.set_name(name);
00090     return obj;
00091   endfunction
00092 
00093   const static string type_name = Tname;
00094 
00095   function string get_type_name();
00096     return type_name;
00097   endfunction
00098 
00099   local static this_type me = get();
00100 
00101   static function this_type get();
00102     if (me == null) begin
00103       ovm_factory f = ovm_factory::get();
00104       me = new;
00105       f.register(me);
00106     end
00107     return me;
00108   endfunction
00109 
00110   static function T create(string name="", ovm_component parent=null, string contxt="");
00111     ovm_object obj;
00112     ovm_factory f = ovm_factory::get();
00113     if (contxt == "" && parent != null)
00114       contxt = parent.get_full_name();
00115     obj = f.create_object_by_type(get(),contxt,name);
00116     assert ($cast(create,obj))
00117     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);
00118   endfunction
00119 
00120   static function void set_type_override(ovm_object_wrapper override_type, bit replace=1);
00121     factory.set_type_override_by_type(get(),override_type,replace);
00122   endfunction
00123 
00124   static function void set_inst_override(ovm_object_wrapper override_type,
00125                                          string inst_path,
00126                                          ovm_component parent=null);
00127     string full_inst_path;
00128     if (parent != null) begin
00129       if (inst_path == "")
00130         inst_path = parent.get_full_name();
00131       else
00132         inst_path = {parent.get_full_name(),".",inst_path};
00133     end
00134     factory.set_inst_override_by_type(get(),override_type,inst_path);
00135   endfunction
00136 
00137 endclass
00138 
00139 `endif

Intelligent Design Verification
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
Doxygen Version: 1.5.5
Wed Jan 7 19:27:18 2009
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV