ovm_config.svh

Go to the documentation of this file.
00001 // $Id: a00225.html,v 1.1 2009/01/07 19:30:01 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_CONFIG_SVH
00023 `define OVM_CONFIG_SVH
00024 
00025 typedef class ovm_component;
00026 
00027 
00028 class ovm_config_setting;
00029   string inst;
00030   string field;
00031   string from;
00032   function new (string inst, string field, string from);
00033     this.inst = inst;
00034     this.field = field;
00035     this.from = from;
00036   endfunction
00037   virtual function string matches_string(ovm_component to, ovm_component from);
00038     string v;
00039     if(component_match(to)) begin
00040       if(from==null) begin
00041         v = " GLOBAL"; while(v.len() < 17) v = {v, " "};
00042       end
00043       else begin
00044         $swrite(v, " %0s(%0s)",from.get_full_name(), from.get_type_name()); while(v.len() < 17) v = {v, " "};
00045       end
00046       v = {v, " ", inst}; while(v.len() < 35) v = {v," "};
00047       v = {v, " ", field}; while(v.len() < 48) v = {v," "};
00048       return v;
00049     end
00050   endfunction
00051   virtual function string value_string();
00052     return "";
00053   endfunction
00054   virtual function string type_string();
00055     return "";
00056   endfunction
00057   function bit component_match (ovm_component to);
00058     if(to==null) return 0;
00059     return ovm_is_match(inst, to.get_full_name());
00060   endfunction
00061   function bit field_match (string to);
00062     if(to == "") return 0;
00063     return ovm_is_match(field, to);
00064   endfunction
00065   virtual function void print_match (ovm_component to, ovm_component from, string field);
00066 
00067     if((to!=null) && (from!=null))
00068       $display("Configuration match for %s.%s from %s: instance match = \"%s\"  field match = \"%s\"",
00069         to.get_full_name(), field, from.get_full_name(), inst, field);
00070     else if(to!=null)
00071       $display("Configuration match for %s.%s from %s: instance match = \"%s\"  field match = \"%s\"",
00072         to.get_full_name(), field, "GLOBAL", inst, field);
00073     else 
00074       $display("Configuration match for %s from %s: instance match = \"%s\"  field match = \"%s\"",
00075         field, "GLOBAL", inst, field);
00076   endfunction
00077 endclass
00078 
00079 class ovm_int_config_setting extends ovm_config_setting;
00080   ovm_bitstream_t value;
00081   function new (string inst, string field, ovm_bitstream_t value, string from);
00082     super.new(inst, field, from);
00083     this.value = value;
00084   endfunction
00085   virtual function string matches_string(ovm_component to, ovm_component from);
00086     if(component_match(to)) begin
00087       matches_string = super.matches_string(to, from);
00088       $swrite(matches_string, "%s int     %0d", matches_string, value);
00089     end
00090   endfunction
00091   virtual function string value_string();
00092     $sformat(value_string, "%0d", value);
00093   endfunction
00094   virtual function string type_string();
00095     return "int";
00096   endfunction
00097 endclass
00098 
00099 class ovm_string_config_setting extends ovm_config_setting;
00100   string value;
00101   function new (string inst, string field, string value, string from);
00102     super.new(inst, field, from);
00103     this.value = value;
00104   endfunction
00105   virtual function string matches_string(ovm_component to, ovm_component from);
00106     if(component_match(to)) begin
00107       matches_string = super.matches_string(to, from);
00108       $swrite(matches_string, "%s string  %0s", matches_string, value);
00109     end
00110   endfunction
00111   virtual function string value_string();
00112     value_string = value;
00113   endfunction
00114   virtual function string type_string();
00115     return "string";
00116   endfunction
00117 endclass
00118 
00119 class ovm_object_config_setting extends ovm_config_setting;
00120   ovm_object value;
00121   bit clone;
00122   function new (string inst, string field, ovm_object value, string from, bit clone);
00123     super.new(inst, field, from);
00124     this.value = value;
00125     this.clone = clone;
00126   endfunction
00127   virtual function string matches_string(ovm_component to, ovm_component from);
00128     string s2;
00129     if(component_match(to)) begin
00130       s2 = ovm_object_value_str(value);
00131       matches_string = super.matches_string(to, from);
00132       $swrite(matches_string, "%s %0s  %0s", matches_string, type_string(), s2);
00133     end
00134   endfunction
00135   virtual function string value_string();
00136     return ovm_object_value_str(value);
00137   endfunction
00138   virtual function string type_string();
00139     return {(value == null) ? "object" : value.get_type_name()};
00140   endfunction
00141 endclass
00142 
00143 //----------------------------------------------------------------------
00144 //
00145 // Global configuration
00146 //
00147 //----------------------------------------------------------------------
00148 
00149 ovm_config_setting global_configuration_table [$];
00150 
00151 // set_config_int
00152 // --------------
00153 
00154 function void  set_config_int    (string      inst_name,
00155                                                    string      field_name,
00156                                                    ovm_bitstream_t value);
00157   ovm_int_config_setting cfg;
00158   cfg = new(inst_name, field_name, value, "GLOBAL");
00159   global_configuration_table.push_front(cfg);
00160 endfunction
00161 
00162 
00163 // set_config_object
00164 // -----------------
00165 
00166 function void set_config_object  (string      inst_name,
00167                                                    string      field_name,
00168                                                    ovm_object  value,
00169                                                    bit         clone=1);
00170   ovm_object_config_setting cfg;
00171   if(clone && (value != null)) begin
00172     ovm_object tmp;
00173     tmp = value.clone();
00174 
00175     //If the user doesn't implement create, or attempts to clone an object that
00176     //doesn't allow cloning (such as a component reference) the clone will return null.
00177     if(tmp == null) begin
00178       ovm_component comp;
00179       if ($cast(comp,value)) begin
00180         ovm_report_error("INVCLNC", {"Clone failed during set_config_object ",
00181           "with an object that is an ovm_component. Components cannot be cloned."});
00182         return;
00183       end
00184       else begin
00185         ovm_report_warning("INVCLN", {"Clone failed during set_config_object, ",
00186           "the original reference will be used for configuration. Check that ",
00187           "the create method for the object type is defined properly."});
00188       end
00189     end
00190     else
00191       value = tmp;
00192   end
00193 
00194   cfg = new(inst_name, field_name, value, "GLOBAL", clone);
00195   global_configuration_table.push_front(cfg);
00196 endfunction
00197 
00198 
00199 // set_config_string
00200 // -----------------
00201 
00202 function void set_config_string  (string      inst_name,  
00203                                                    string      field_name,
00204                                                    string      value);
00205   ovm_string_config_setting cfg;
00206   cfg = new(inst_name, field_name, value, "GLOBAL");
00207   global_configuration_table.push_front(cfg);
00208 endfunction
00209 
00210 
00211 `endif // OVM_CONFIG_SVH

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:17 2009
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV