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:39 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 
00102 function bit ovm_is_match (string expr, string str);
00103 
00104   int e, es, s, ss;
00105   string tmp;
00106   e  = 0; s  = 0;
00107   es = 0; ss = 0;
00108 
00109   // The ^ used to be used to remove the implicit wildcard, but now we don't
00110   // use implicit wildcard so this character is just stripped.
00111   if(expr[0] == "^")
00112     expr = expr.substr(1, expr.len()-1);
00113 
00114   //This loop is only needed when the first character of the expr may not
00115   //be a *. 
00116   while (s != str.len() && expr.getc(e) != "*") begin
00117     if ((expr.getc(e) != str.getc(s)) && (expr.getc(e) != "?"))
00118       return 0;
00119     e++; s++;
00120   end
00121 
00122   while (s != str.len()) begin
00123     if (expr.getc(e) == "*") begin
00124       e++;
00125       if (e == expr.len()) begin
00126         return 1;
00127       end
00128       es = e;
00129       ss = s+1;
00130     end
00131     else if (expr.getc(e) == str.getc(s) || expr.getc(e) == "?") begin
00132       e++;
00133       s++;
00134     end
00135     else begin
00136       e = es;
00137       s = ss++;
00138     end
00139   end
00140   while (expr.getc(e) == "*")
00141     e++;
00142   if(e == expr.len()) begin
00143     return 1;
00144   end
00145   else begin
00146     return 0;
00147   end
00148 endfunction
00149 
00150 
00151 
00152 //----------------------------------------------------------------------------
00153 //
00154 // FUNCTION: ovm_string_to_bits
00155 //
00156 //----------------------------------------------------------------------------
00157 
00158 `ifndef OVM_LINE_WIDTH
00159   `define OVM_LINE_WIDTH 120
00160 `endif 
00161 parameter OVM_LINE_WIDTH = `OVM_LINE_WIDTH;
00162 
00163 `ifndef OVM_NUM_LINES
00164   `define OVM_NUM_LINES 120
00165 `endif
00166 parameter OVM_NUM_LINES = `OVM_NUM_LINES;
00167 
00168 parameter OVM_SMALL_STRING = OVM_LINE_WIDTH*8-1;
00169 parameter OVM_LARGE_STRING = OVM_LINE_WIDTH*OVM_NUM_LINES*8-1;
00170 
00171 function logic[OVM_LARGE_STRING:0] ovm_string_to_bits(string str);
00172   $swrite(ovm_string_to_bits, "%0s", str);
00173 endfunction
00174 
00175 //----------------------------------------------------------------------------
00176 //
00177 // FUNCTION: ovm_bits_to_string
00178 //
00179 //----------------------------------------------------------------------------
00180 
00181 function string ovm_bits_to_string(logic [OVM_LARGE_STRING:0] str);
00182   $swrite(ovm_bits_to_string, "%0s", str);
00183 endfunction
00184 
00185 
00186 //----------------------------------------------------------------------------
00187 //
00188 // TASK: ovm_wait_for_nba_region
00189 //
00190 // Call this task to wait for a delta cycle. Program blocks don't have an nba
00191 // so just delay for a #0 in a program block.
00192 //----------------------------------------------------------------------------
00193 
00194 task ovm_wait_for_nba_region;
00195 
00196   string s;
00197 
00198   bit nba;
00199   bit nba_scheduled;
00200 
00201   //If `included directly in a program block, can't use a non-blocking assign,
00202   //but it isn't needed since program blocks are in a seperate region.
00203 `ifndef OVM_PROGRAM_BLOCK
00204   if (nba_scheduled == 0) begin
00205     nba_scheduled = 1;
00206     nba = 0;
00207     nba <= 1;
00208     @(posedge nba) nba_scheduled = 0;
00209   end
00210   else begin
00211     @(posedge nba);
00212   end
00213 `else
00214   #0;
00215 `endif
00216 
00217 endtask
00218 
00219 
00220 `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:20:12 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV