ovm_misc.svh

Go to the documentation of this file.
00001 // $Id: ovm__misc_8svh-source.html,v 1.1 2008/10/07 21:54:25 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_MISC_SVH
00023 `define OVM_MISC_SVH
00024 
00025 // Used to indicate "no valid default value" in a parameter
00026 virtual class avm_virtual_class; endclass
00027 
00028 //------------------------------------------------------------------------------
00029 //
00030 // CLASS: ovm_void
00031 //
00032 // Empty root class. Acts as a void pointer.
00033 //
00034 //------------------------------------------------------------------------------
00035 
00036 virtual class ovm_void;
00037 endclass
00038 
00039 // Forward declaration since scope stack uses ovm_objects now
00040 typedef class ovm_object;
00041 
00042 //----------------------------------------------------------------------------
00043 //
00044 // CLASS: ovm_scope_stack
00045 //
00046 //----------------------------------------------------------------------------
00047 
00048 class ovm_scope_stack;
00049   local string   m_scope="";
00050   local string   m_scope_arg="";
00051   local int      m_depth=0;
00052   local bit      m_object_map[ovm_void];
00053   local ovm_void m_stack[$];
00054 
00055   extern function void   set          (string s, ovm_object obj);
00056   extern function void   down         (string s, ovm_object obj);
00057   extern function void   down_element (int element, ovm_object obj);
00058   extern function void   up           (ovm_object obj, byte separator=".");
00059   extern function void   up_element   (ovm_object obj);
00060   extern function void   set_arg      (string arg);
00061   extern function void   unset_arg    (string arg);
00062   extern function void   set_arg_element  (string arg, int ele);
00063   extern function int    depth        ();
00064   extern function string get          ();
00065   extern function string get_arg      ();
00066   extern function ovm_object current    ();
00067 
00068   extern function bit    in_hierarchy  (ovm_object obj);
00069 endclass
00070 
00071 
00072 //----------------------------------------------------------------------------
00073 //
00074 // GLOBALS (in OVM package)
00075 //
00076 //----------------------------------------------------------------------------
00077 
00078 
00079 //----------------------------------------------------------------------------
00080 //
00081 // FUNCTION: ovm_is_match
00082 //
00083 //----------------------------------------------------------------------------
00084 //
00085 // Purpose:
00086 //
00087 //   Match an string, str, with glob string, expr. 
00088 //
00089 // Precondition:
00090 //
00091 //  expr is a string which may contain '*' and '?' characters. A '*'
00092 //  indicates matching zero or more characters (using a greedy compare),
00093 //  '?' indicates matching any single character.
00094 //
00095 // Postcondition:
00096 //
00097 //  Returns a 1 if str matches the expression string and returns
00098 //  0 if it does not match.
00099 //
00100 //----------------------------------------------------------------------------
00101 `ifdef OVM_DPI
00102 import "DPI" function bit ovm_is_match (string expr, string str);
00103 `else
00104 function bit ovm_is_match (string expr, string str);
00105 
00106   int e, es, s, ss;
00107   string tmp;
00108   e  = 0; s  = 0;
00109   es = 0; ss = 0;
00110 
00111   // The ^ used to be used to remove the implicit wildcard, but now we don't
00112   // use implicit wildcard so this character is just stripped.
00113   if(expr[0] == "^")
00114     expr = expr.substr(1, expr.len()-1);
00115 
00116   //This loop is only needed when the first character of the expr may not
00117   //be a *. 
00118   while (s != str.len() && expr.getc(e) != "*") begin
00119     if ((expr.getc(e) != str.getc(s)) && (expr.getc(e) != "?"))
00120       return 0;
00121     e++; s++;
00122   end
00123 
00124   while (s != str.len()) begin
00125     if (expr.getc(e) == "*") begin
00126       e++;
00127       if (e == expr.len()) begin
00128         return 1;
00129       end
00130       es = e;
00131       ss = s+1;
00132     end
00133     else if (expr.getc(e) == str.getc(s) || expr.getc(e) == "?") begin
00134       e++;
00135       s++;
00136     end
00137     else begin
00138       e = es;
00139       s = ss++;
00140     end
00141   end
00142   while (expr.getc(e) == "*")
00143     e++;
00144   if(e == expr.len()) begin
00145     return 1;
00146   end
00147   else begin
00148     return 0;
00149   end
00150 endfunction
00151 `endif
00152 
00153 
00154 //----------------------------------------------------------------------------
00155 //
00156 // FUNCTION: ovm_string_to_bits
00157 //
00158 //----------------------------------------------------------------------------
00159 
00160 `ifndef OVM_LINE_WIDTH
00161   `define OVM_LINE_WIDTH 120
00162 `endif 
00163 parameter OVM_LINE_WIDTH = `OVM_LINE_WIDTH;
00164 
00165 `ifndef OVM_NUM_LINES
00166   `define OVM_NUM_LINES 120
00167 `endif
00168 parameter OVM_NUM_LINES = `OVM_NUM_LINES;
00169 
00170 parameter OVM_SMALL_STRING = OVM_LINE_WIDTH*8-1;
00171 parameter OVM_LARGE_STRING = OVM_LINE_WIDTH*OVM_NUM_LINES*8-1;
00172 
00173 function logic[OVM_LARGE_STRING:0] ovm_string_to_bits(string str);
00174   $swrite(ovm_string_to_bits, "%0s", str);
00175 endfunction
00176 
00177 //----------------------------------------------------------------------------
00178 //
00179 // FUNCTION: ovm_bits_to_string
00180 //
00181 //----------------------------------------------------------------------------
00182 
00183 function string ovm_bits_to_string(logic [OVM_LARGE_STRING:0] str);
00184   $swrite(ovm_bits_to_string, "%0s", str);
00185 endfunction
00186 
00187 
00188 //----------------------------------------------------------------------------
00189 //
00190 // TASK: ovm_wait_for_nba_region
00191 //
00192 // Call this task to wait for a delta cycle. Program blocks don't have an nba
00193 // so just delay for a #0 in a program block.
00194 //----------------------------------------------------------------------------
00195 
00196 task ovm_wait_for_nba_region;
00197 
00198   string s;
00199 
00200   bit nba;
00201   bit nba_scheduled;
00202 
00203   //If `included directly in a program block, can't use a non-blocking assign,
00204   //but it isn't needed since program blocks are in a seperate region.
00205 `ifndef OVM_PROGRAM_BLOCK
00206   if (nba_scheduled == 0) begin
00207     nba_scheduled = 1;
00208     nba = 0;
00209     nba <= 1;
00210     @(posedge nba) nba_scheduled = 0;
00211   end
00212   else begin
00213     @(posedge nba);
00214   end
00215 `else
00216   #0;
00217 `endif
00218 
00219 endtask
00220 
00221 
00222 `endif // OVM_MISC_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:30 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV