ovm_globals.svh

Go to the documentation of this file.
00001 // $Id: ovm_globals.svh 15 2009-06-21 17:30:53Z seanoboyle $
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 
00023 // Title: Globals
00024 
00025 //------------------------------------------------------------------------------
00026 //
00027 // Group: Simulation Control
00028 //
00029 //------------------------------------------------------------------------------
00030 
00031 // Task: run_test
00032 //
00033 // Convenience function for ovm_top.run_test(). See ovm_root for more
00034 // information.
00035 
00036 task run_test (string test_name="");
00037   ovm_root top;
00038   top = ovm_root::get();
00039   top.run_test(test_name);
00040 endtask
00041 
00042 
00043 // Method: global_stop_request 
00044 //
00045 // Convenience function for ovm_top.stop_request(). See ovm_root for more
00046 // information.
00047 
00048 function void global_stop_request();
00049   ovm_root top;
00050   top = ovm_root::get();
00051   top.stop_request();
00052 endfunction
00053 
00054 
00055 // Method: set_global_timeout 
00056 //
00057 // Convenience function for ovm_top.phase_timeout = timeout. See ovm_root
00058 // for more information.
00059 
00060 function void set_global_timeout(time timeout);
00061   ovm_root top;
00062   top = ovm_root::get();
00063   top.phase_timeout = timeout;
00064 endfunction
00065 
00066 
00067 // Function: set_global_stop_timeout
00068 //
00069 // Convenience function for ovm_top.stop_timeout = timeout.
00070 // See ovm_root for more information.
00071 
00072 function void set_global_stop_timeout(time timeout);
00073   ovm_root top;
00074   top = ovm_root::get();
00075   top.stop_timeout = timeout;
00076 endfunction
00077 
00078 
00079 // ovm_find_component (deprecated)
00080 // ------------------
00081 
00082 function ovm_component ovm_find_component (string comp_name);
00083   ovm_root top;
00084   static bit issued=0;
00085   if (!issued) begin
00086     issued=1;
00087     ovm_report_warning("deprecated",
00088       {"ovm_find_component() is deprecated and replaced by ",
00089       "ovm_top.find(comp_name)"});
00090   end
00091   top = ovm_root::get();
00092   return top.find(comp_name);
00093 endfunction
00094 
00095 
00096 // ovm_print_topology (deprecated)
00097 // ------------------
00098 
00099 function void ovm_print_topology(ovm_printer printer=null);
00100   static bit issued=0;
00101   if (!issued) begin
00102     issued=1;
00103     ovm_report_warning("deprecated",
00104       {"ovm_print_topology() is deprecated and replaced by ",
00105       "ovm_top.print_topology()"});
00106   end
00107   ovm_top.print_topology(printer);
00108 endfunction
00109 
00110 
00111 
00112 //----------------------------------------------------------------------------
00113 //
00114 // Group: Reporting
00115 //
00116 //----------------------------------------------------------------------------
00117 
00118 // Function: ovm_report_enabled
00119 //
00120 // Returns 1 if the report will be issued given the report's declared
00121 // verbosity level and the configured verbosity level in ovm_top. The
00122 // ovm_report_object also has an ovm_report_enabled method, which checks
00123 // the report's declared verbosity level with the configured verbosity
00124 // level for that particular instance (i.e., for the component instance.)
00125 //
00126 // Static methods of an extension of ovm_report_object can not call 
00127 // ovm_report_enabled() because the call will resolve to the ovm_report_object
00128 // non-static method. Static methods can not call non-static methods of the
00129 // same class. 
00130 
00131 function bit ovm_report_enabled (int verbosity);
00132   return (ovm_top.get_report_verbosity_level() >= verbosity);
00133 endfunction
00134 
00135 
00136 // Function: ovm_report_info
00137 
00138 function void ovm_report_info(string id,
00139                string message,
00140                               int verbosity = OVM_MEDIUM,
00141                string filename = "",
00142                int line = 0);
00143   ovm_top.ovm_report_info(id, message, verbosity, filename, line);
00144 endfunction
00145 
00146 
00147 // Function: ovm_report_warning
00148 
00149 function void ovm_report_warning(string id,
00150                                  string message,
00151                                  int verbosity = OVM_MEDIUM,
00152              string filename = "",
00153              int line = 0);
00154   ovm_top.ovm_report_warning(id, message, verbosity, filename, line);
00155 endfunction
00156 
00157 
00158 // Function: ovm_report_error
00159 
00160 function void ovm_report_error(string id,
00161                                string message,
00162                                int verbosity = OVM_LOW,
00163                 string filename = "",
00164                 int line = 0);
00165   ovm_top.ovm_report_error(id, message, verbosity, filename, line);
00166 endfunction
00167 
00168 
00169 // Function: ovm_report_fatal
00170 //
00171 // These methods, defined in package scope, are convenience functions that
00172 // delegate to the corresponding component methods in ~ovm_top~. They can be
00173 // used in module-based code to use the same reporting mechanism as class-based
00174 // components. See <ovm_report_object> for details on the reporting mechanism. 
00175 
00176 function void ovm_report_fatal(string id,
00177                           string message,
00178                                int verbosity = OVM_NONE,
00179                 string filename = "",
00180                 int line = 0);
00181   ovm_top.ovm_report_fatal(id, message, verbosity, filename, line);
00182 endfunction
00183 
00184   
00185 //------------------------------------------------------------------------------
00186 //
00187 // Group: Configuration
00188 //
00189 //------------------------------------------------------------------------------
00190 
00191 // Function: set_config_int
00192 //
00193 // This is the global version of set_config_int in <ovm_component>. This
00194 // function places the configuration setting for an integral field in a
00195 // global override table, which has highest precedence over any
00196 // component-level setting.  See <ovm_component::set_config_int> for
00197 // details on setting configuration.
00198 
00199 function void  set_config_int  (string inst_name,
00200                                 string field_name,
00201                                 ovm_bitstream_t value);
00202   ovm_root top;
00203   top = ovm_root::get();
00204   top.set_config_int(inst_name, field_name, value);
00205 endfunction
00206 
00207 
00208 // Function: set_config_object
00209 //
00210 // This is the global version of set_config_object in <ovm_component>. This
00211 // function places the configuration setting for an object field in a
00212 // global override table, which has highest precedence over any
00213 // component-level setting.  See <ovm_component::set_config_object> for
00214 // details on setting configuration.
00215 
00216 function void set_config_object (string inst_name,
00217                                  string field_name,
00218                                  ovm_object value,
00219                                  bit clone=1);
00220   ovm_root top;
00221   top = ovm_root::get();
00222   top.set_config_object(inst_name, field_name, value, clone);
00223 endfunction
00224 
00225 
00226 // Function: set_config_string
00227 //
00228 // This is the global version of set_config_string in <ovm_component>. This
00229 // function places the configuration setting for an string field in a
00230 // global override table, which has highest precedence over any
00231 // component-level setting.  See <ovm_component::set_config_string> for
00232 // details on setting configuration.
00233 
00234 function void set_config_string (string inst_name,  
00235                                  string field_name,
00236                                  string value);
00237   ovm_root top;
00238   top = ovm_root::get();
00239   top.set_config_string(inst_name, field_name, value);
00240 endfunction
00241 
00242 
00243 
00244 //----------------------------------------------------------------------------
00245 //
00246 // Group: Miscellaneous
00247 //
00248 //----------------------------------------------------------------------------
00249 
00250 
00251 // Function: ovm_is_match
00252 //
00253 // Returns 1 if the two strings match, 0 otherwise.
00254 //
00255 // The first string, ~expr~, is a string that may contain '*' and '?'
00256 // characters. A * matches zero or more characters, and ? matches any single
00257 // character. The 2nd argument, ~str~, is the string begin matched against.
00258 // It must not contain any wildcards.
00259 //
00260 //----------------------------------------------------------------------------
00261 
00262 `ifdef OVM_DPI
00263 import "DPI" function bit ovm_is_match (string expr, string str);
00264 `else
00265 function bit ovm_is_match (string expr, string str);
00266 
00267   int e, es, s, ss;
00268   string tmp;
00269   e  = 0; s  = 0;
00270   es = 0; ss = 0;
00271 
00272   if(expr.len() == 0)
00273     return 1;
00274 
00275   // The ^ used to be used to remove the implicit wildcard, but now we don't
00276   // use implicit wildcard so this character is just stripped.
00277   if(expr[0] == "^")
00278     expr = expr.substr(1, expr.len()-1);
00279 
00280   //This loop is only needed when the first character of the expr may not
00281   //be a *. 
00282   while (s != str.len() && expr.getc(e) != "*") begin
00283     if ((expr.getc(e) != str.getc(s)) && (expr.getc(e) != "?"))
00284       return 0;
00285     e++; s++;
00286   end
00287 
00288   while (s != str.len()) begin
00289     if (expr.getc(e) == "*") begin
00290       e++;
00291       if (e == expr.len()) begin
00292         return 1;
00293       end
00294       es = e;
00295       ss = s+1;
00296     end
00297     else if (expr.getc(e) == str.getc(s) || expr.getc(e) == "?") begin
00298       e++;
00299       s++;
00300     end
00301     else begin
00302       e = es;
00303       s = ss++;
00304     end
00305   end
00306   while (expr.getc(e) == "*")
00307     e++;
00308   if(e == expr.len()) begin
00309     return 1;
00310   end
00311   else begin
00312     return 0;
00313   end
00314 endfunction
00315 `endif
00316 
00317 
00318 `ifndef OVM_LINE_WIDTH
00319   `define OVM_LINE_WIDTH 120
00320 `endif 
00321 parameter OVM_LINE_WIDTH = `OVM_LINE_WIDTH;
00322 
00323 `ifndef OVM_NUM_LINES
00324   `define OVM_NUM_LINES 120
00325 `endif
00326 parameter OVM_NUM_LINES = `OVM_NUM_LINES;
00327 
00328 parameter OVM_SMALL_STRING = OVM_LINE_WIDTH*8-1;
00329 parameter OVM_LARGE_STRING = OVM_LINE_WIDTH*OVM_NUM_LINES*8-1;
00330 
00331 
00332 //----------------------------------------------------------------------------
00333 //
00334 // Function: ovm_string_to_bits
00335 //
00336 // Converts an input string to its bit-vector equivalent. Max bit-vector
00337 // length is approximately 14000 characters.
00338 //----------------------------------------------------------------------------
00339 
00340 function logic[OVM_LARGE_STRING:0] ovm_string_to_bits(string str);
00341   $swrite(ovm_string_to_bits, "%0s", str);
00342 endfunction
00343 
00344 
00345 //----------------------------------------------------------------------------
00346 //
00347 // Function: ovm_bits_to_string
00348 //
00349 // Converts an input bit-vector to its string equivalent. Max bit-vector
00350 // length is approximately 14000 characters.
00351 //----------------------------------------------------------------------------
00352 
00353 function string ovm_bits_to_string(logic [OVM_LARGE_STRING:0] str);
00354   $swrite(ovm_bits_to_string, "%0s", str);
00355 endfunction
00356 
00357 
00358 //----------------------------------------------------------------------------
00359 //
00360 // Task: ovm_wait_for_nba_region
00361 //
00362 // Call this task to wait for a delta cycle. Program blocks don't have an nba
00363 // so just delay for a #0 in a program block.
00364 //----------------------------------------------------------------------------
00365 
00366 task ovm_wait_for_nba_region;
00367 
00368   string s;
00369 
00370   bit nba;
00371   bit nba_scheduled;
00372 
00373   //If `included directly in a program block, can't use a non-blocking assign,
00374   //but it isn't needed since program blocks are in a seperate region.
00375 `ifndef OVM_PROGRAM_BLOCK
00376   if (nba_scheduled == 0) begin
00377     nba_scheduled = 1;
00378     nba = 0;
00379     nba <= 1;
00380     @(posedge nba) nba_scheduled = 0;
00381   end
00382   else begin
00383     @(posedge nba);
00384   end
00385 `else
00386   #0;
00387 `endif
00388 
00389 
00390 endtask
00391 
00392 

Intelligent Design Verification
Intelligent Design Verification
Project: OVM, Revision: 2.0.2
Copyright (c) 2008-2010 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.6.3
IDV SV Filter Version: 2.6.3
Sat Jun 19 11:43:33 2010
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV