ovm_config.svh

Go to the documentation of this file.
00001 // $Id: ovm__config_8svh-source.html,v 1.1 2008/10/07 21:54:21 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     `ifdef INCA
00137     $sformat(value_string, "%0d", value);
00138     `else
00139     return "";
00140     `endif
00141   endfunction
00142   virtual function string type_string();
00143     return {(value == null) ? "object" : value.get_type_name()};
00144   endfunction
00145 endclass
00146 
00147 //----------------------------------------------------------------------
00148 //
00149 // Global configuration
00150 //
00151 //----------------------------------------------------------------------
00152 
00153 ovm_config_setting global_configuration_table [$];
00154 
00155 // set_config_int
00156 // --------------
00157 
00158 function void  set_config_int    (string      inst_name,
00159                                                    string      field_name,
00160                                                    ovm_bitstream_t value);
00161   ovm_int_config_setting cfg;
00162   cfg = new(inst_name, field_name, value, "GLOBAL");
00163   global_configuration_table.push_front(cfg);
00164 endfunction
00165 
00166 
00167 // set_config_object
00168 // -----------------
00169 
00170 function void set_config_object  (string      inst_name,
00171                                                    string      field_name,
00172                                                    ovm_object  value,
00173                                                    bit         clone=1);
00174   ovm_object_config_setting cfg;
00175   if(clone && (value != null)) begin
00176     ovm_object tmp;
00177     tmp = value.clone();
00178 
00179     //If the user doesn't implement create, or attempts to clone an object that
00180     //doesn't allow cloning (such as a component reference) the clone will return null.
00181     if(tmp == null) begin
00182       ovm_report_warning("INVCLN", "Clone failed during set_config_object, the original reference will be used for configuration. Check that the create method for the object type is defined properly.");
00183     end
00184     else
00185       value = tmp;
00186   end
00187 
00188   cfg = new(inst_name, field_name, value, "GLOBAL", clone);
00189   global_configuration_table.push_front(cfg);
00190 endfunction
00191 
00192 
00193 // set_config_string
00194 // -----------------
00195 
00196 function void set_config_string  (string      inst_name,  
00197                                                    string      field_name,
00198                                                    string      value);
00199   ovm_string_config_setting cfg;
00200   cfg = new(inst_name, field_name, value, "GLOBAL");
00201   global_configuration_table.push_front(cfg);
00202 endfunction
00203 
00204 
00205 `endif // OVM_CONFIG_SVH

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