ovm_factory.svh

Go to the documentation of this file.
00001 // $Id: ovm__factory_8svh-source.html,v 1.1 2008/10/07 21:54:46 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_FACTORY_SVH
00023 `define OVM_FACTORY_SVH
00024 
00025 typedef class ovm_object;
00026 typedef class ovm_component;
00027 
00028 // To register with a factory, a class must create a wrapper which implements
00029 // Either the create_object (for generic data object) or create_component (for
00030 // hierarchical elements).
00031 
00032 virtual class ovm_object_wrapper;
00033   virtual function ovm_object create_object (string name="");
00034     return null;
00035   endfunction
00036   virtual function ovm_component create_component (string name, 
00037        ovm_component parent); 
00038     return null;
00039   endfunction
00040   // The wrapper must specify the type that it can create
00041   pure virtual function string get_type_name();
00042 
00043 endclass
00044 
00045 class ovm_factory_override;
00046   string inst_path;
00047   string req_type_name;
00048   string type_name;
00049 
00050   function new (string inst_path="", string req_type_name="", 
00051                 string type_name="");
00052     this.inst_path = inst_path;
00053     this.req_type_name = req_type_name;
00054     this.type_name = type_name;
00055   endfunction
00056 endclass
00057 
00058 
00059 
00060 class ovm_factory extends ovm_object;
00061 
00062   extern function ovm_object create (string name="");
00063   extern function new (string name="");
00064 
00065   static ovm_factory inst;
00066 
00067   protected ovm_object_wrapper types[string];
00068   protected ovm_factory_override type_overrides[string];
00069   protected ovm_factory_override inst_overrides[$];
00070 
00071   // Method for registering an object creator. This is called automatically
00072   // by the `ovm_*_utils macros
00073   extern static function void auto_register  (ovm_object_wrapper obj);
00074 
00075   // Methods for creating objects
00076   extern static function ovm_object    create_object    (string lookup_str,  
00077                                                          string inst_path="",
00078                                                          string name="");
00079 
00080   extern static function ovm_component create_component (string lookup_str,
00081                                                          string inst_path="",
00082                                                          string name, 
00083                                                          ovm_component parent);
00084 
00085   // Methods for overriding how objects are created
00086   extern static function void         set_type_override (string lookup_str,
00087                                                          string type_name,
00088                                                          bit    replace=1);
00089 
00090   extern static function void         set_inst_override (string inst_path,
00091                                                          string lookup_str,
00092                                                          string type_name);
00093 
00094   // Debug methods
00095   extern static function void  print_all_overrides (bit all_types=0);
00096 
00097   extern protected function void  m_print_all_overrides (bit all_types=0);
00098 
00099   extern static function void     print_override_info   (string lookup_str,
00100                                                          string inst_path="",
00101                                                          string inst_name="");
00102 
00103   extern protected function void  m_print_override_info (string lookup_str,
00104                                                          string inst_path,
00105                                                          string inst_name);
00106 
00107   // Internal methods used for setting and using overrides.
00108   extern  function void          auto_register_type     (ovm_object_wrapper obj);
00109 
00110   extern  function void          override_type          (string lookup_str,
00111                                                          string type_name,
00112                                                          string inst_path,
00113                                                          bit replace=1);
00114 
00115   extern  function ovm_object   create_type             (string lookup_str,  
00116                                                          string inst_path="",
00117                                                          string name=""); 
00118 
00119   extern  function ovm_component create_component_type  (string lookup_str,  
00120                                                          string inst_path="",
00121                                                          string name, 
00122                                                          ovm_component parent);
00123 
00124   extern function ovm_object_wrapper find_override      (string lookup_str,
00125                                                          string inst_path,
00126                                                          string inst_name);
00127 
00128 endclass
00129 
00130 
00131 `endif // OVM_FACTORY_SVH
00132 

Intelligent Design Verification
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
Doxygen Version: 1.4.6
Mon Sep 29 14:20:12 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV