00001 // $Id: a00242.html,v 1.1 2009/01/07 19:29:55 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 // FUNCTION: ovm_is_match 00075 // 00076 //---------------------------------------------------------------------------- 00077 // 00078 // Purpose: 00079 // 00080 // Match an string, str, with glob string, expr. 00081 // 00082 // Precondition: 00083 // 00084 // expr is a string which may contain '*' and '?' characters. A '*' 00085 // indicates matching zero or more characters (using a greedy compare), 00086 // '?' indicates matching any single character. 00087 // 00088 // Postcondition: 00089 // 00090 // Returns a 1 if str matches the expression string and returns 00091 // 0 if it does not match. 00092 // 00093 //---------------------------------------------------------------------------- 00094 `ifdef OVM_DPI 00095 import "DPI" function bit ovm_is_match (string expr, string str); 00096 `else 00097 function bit ovm_is_match (string expr, string str); 00098 00099 int e, es, s, ss; 00100 string tmp; 00101 e = 0; s = 0; 00102 es = 0; ss = 0; 00103 00104 // The ^ used to be used to remove the implicit wildcard, but now we don't 00105 // use implicit wildcard so this character is just stripped. 00106 if(expr[0] == "^") 00107 expr = expr.substr(1, expr.len()-1); 00108 00109 //This loop is only needed when the first character of the expr may not 00110 //be a *. 00111 while (s != str.len() && expr.getc(e) != "*") begin 00112 if ((expr.getc(e) != str.getc(s)) && (expr.getc(e) != "?")) 00113 return 0; 00114 e++; s++; 00115 end 00116 00117 while (s != str.len()) begin 00118 if (expr.getc(e) == "*") begin 00119 e++; 00120 if (e == expr.len()) begin 00121 return 1; 00122 end 00123 es = e; 00124 ss = s+1; 00125 end 00126 else if (expr.getc(e) == str.getc(s) || expr.getc(e) == "?") begin 00127 e++; 00128 s++; 00129 end 00130 else begin 00131 e = es; 00132 s = ss++; 00133 end 00134 end 00135 while (expr.getc(e) == "*") 00136 e++; 00137 if(e == expr.len()) begin 00138 return 1; 00139 end 00140 else begin 00141 return 0; 00142 end 00143 endfunction 00144 `endif 00145 00146 00147 //---------------------------------------------------------------------------- 00148 // 00149 // FUNCTION: ovm_string_to_bits 00150 // 00151 //---------------------------------------------------------------------------- 00152 00153 `ifndef OVM_LINE_WIDTH 00154 `define OVM_LINE_WIDTH 120 00155 `endif 00156 parameter OVM_LINE_WIDTH = `OVM_LINE_WIDTH; 00157 00158 `ifndef OVM_NUM_LINES 00159 `define OVM_NUM_LINES 120 00160 `endif 00161 parameter OVM_NUM_LINES = `OVM_NUM_LINES; 00162 00163 parameter OVM_SMALL_STRING = OVM_LINE_WIDTH*8-1; 00164 parameter OVM_LARGE_STRING = OVM_LINE_WIDTH*OVM_NUM_LINES*8-1; 00165 00166 function logic[OVM_LARGE_STRING:0] ovm_string_to_bits(string str); 00167 $swrite(ovm_string_to_bits, "%0s", str); 00168 endfunction 00169 00170 //---------------------------------------------------------------------------- 00171 // 00172 // FUNCTION: ovm_bits_to_string 00173 // 00174 //---------------------------------------------------------------------------- 00175 00176 function string ovm_bits_to_string(logic [OVM_LARGE_STRING:0] str); 00177 $swrite(ovm_bits_to_string, "%0s", str); 00178 endfunction 00179 00180 00181 //---------------------------------------------------------------------------- 00182 // 00183 // TASK: ovm_wait_for_nba_region 00184 // 00185 // Call this task to wait for a delta cycle. Program blocks don't have an nba 00186 // so just delay for a #0 in a program block. 00187 //---------------------------------------------------------------------------- 00188 00189 task ovm_wait_for_nba_region; 00190 00191 string s; 00192 00193 bit nba; 00194 bit nba_scheduled; 00195 00196 //If `included directly in a program block, can't use a non-blocking assign, 00197 //but it isn't needed since program blocks are in a seperate region. 00198 `ifndef OVM_PROGRAM_BLOCK 00199 if (nba_scheduled == 0) begin 00200 nba_scheduled = 1; 00201 nba = 0; 00202 nba <= 1; 00203 @(posedge nba) nba_scheduled = 0; 00204 end 00205 else begin 00206 @(posedge nba); 00207 end 00208 `else 00209 #0; 00210 `endif 00211 00212 endtask 00213 00214 00215 `endif // OVM_MISC_SVH
![]() 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 Version: 1.5.5 Wed Jan 7 19:27:18 2009 |