00001 //---------------------------------------------------------------------- 00002 // Copyright 2007-2008 Mentor Graphics Corporation 00003 // Copyright 2007-2008 Cadence Design Systems, Inc. 00004 // All Rights Reserved Worldwide 00005 // 00006 // Licensed under the Apache License, Version 2.0 (the 00007 // "License"); you may not use this file except in 00008 // compliance with the License. You may obtain a copy of 00009 // the License at 00010 // 00011 // http://www.apache.org/licenses/LICENSE-2.0 00012 // 00013 // Unless required by applicable law or agreed to in 00014 // writing, software distributed under the License is 00015 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 00016 // CONDITIONS OF ANY KIND, either express or implied. See 00017 // the License for the specific language governing 00018 // permissions and limitations under the License. 00019 //---------------------------------------------------------------------- 00020 00021 `define ovm_register_sequence(TYPE_NAME, SEQUENCER) \ 00022 static bit is_registered_with_sequencer = SEQUENCER``::add(`"TYPE_NAME`"); \ 00023 SEQUENCER p_sequencer;\ 00024 virtual function void m_set_p_sequencer(); \ 00025 $cast(p_sequencer, get_sequencer());\ 00026 endfunction 00027 00028 00029 `define ovm_sequence_utils_begin(TYPE_NAME, DRIVER) \ 00030 `ovm_register_sequence(TYPE_NAME, DRIVER) \ 00031 `ovm_object_utils_begin(TYPE_NAME) \ 00032 00033 00034 `define ovm_sequence_utils_end \ 00035 `ovm_object_utils_end \ 00036 00037 00038 `define ovm_sequence_utils(TYPE_NAME, DRIVER) \ 00039 `ovm_sequence_utils_begin(TYPE_NAME,DRIVER) \ 00040 `ovm_sequence_utils_end \ 00041 00042 00043 //----------------------------------------------------------------------------- 00044 // 00045 // MACRO: ovm_package 00046 // 00047 // Use `ovm_package to define the SV package and to create a bogus type to help 00048 // automate triggering the static initializers of the package. 00049 // Use ovm_end_package to endpackage. 00050 //----------------------------------------------------------------------------- 00051 00052 `define ovm_package(PKG) \ 00053 package PKG; \ 00054 class ovm_bogus_class extends ovm::ovm_sequence; endclass 00055 00056 `define ovm_end_package \ 00057 endpackage 00058 00059 00060 //----------------------------------------------------------------------------- 00061 // 00062 // MACRO: ovm_sequence_library_package 00063 // 00064 // Use `ovm_sequence_library_package to automate triggering of packages static 00065 // initializers. ovm_package creates a bogus type which gets referred to by 00066 // ovm_sequence_library_package to make a package-based variable of the bogus 00067 // type. 00068 //----------------------------------------------------------------------------- 00069 00070 `define ovm_sequence_library_package(PKG_NAME) \ 00071 import PKG_NAME``::*; \ 00072 PKG_NAME``::ovm_bogus_class M_``PKG_NAME``ovm_bogus_class 00073 00074 00075 //------------------------------------------------------------------------------ 00076 // 00077 // MACRO: ovm_do 00078 // 00079 //------------------------------------------------------------------------------ 00080 00081 // This macro takes as an argument a ovm_sequence_item variable or object. 00082 // Memory is allocated using the factory and is assigned to the macro arguement. 00083 // ovm_sequence_item's are randomized using late-randomization. 00084 // See the "ovm_do item Flow in Pull Mode" and the "ovm_do Subsequence Flow" 00085 // diagrams for further details. 00086 00087 `define ovm_do(OVM_SEQUENCE_ITEM) \ 00088 begin \ 00089 ovm_virtual_sequencer ovs; \ 00090 ovm_sequence os; \ 00091 OVM_SEQUENCE_ITEM = new(`"OVM_SEQUENCE_ITEM`");\ 00092 if ($cast(ovs, m_sequencer)) \ 00093 if(!$cast(os, OVM_SEQUENCE_ITEM)) \ 00094 ovm_report_fatal("ITMVSQ", "Cannot do items in a virtual sequence."); \ 00095 $cast(OVM_SEQUENCE_ITEM , create_item(OVM_SEQUENCE_ITEM, m_sequencer)); \ 00096 start_item(OVM_SEQUENCE_ITEM); \ 00097 assert(OVM_SEQUENCE_ITEM.randomize()) else begin \ 00098 ovm_report_warning("RNDFLD", "Randomization failed in ovm_do action"); \ 00099 end \ 00100 finish_item(OVM_SEQUENCE_ITEM);\ 00101 end 00102 00103 00104 //------------------------------------------------------------------------------ 00105 // 00106 // MACRO: ovm_do_with 00107 // 00108 //------------------------------------------------------------------------------ 00109 00110 // Similar to ovm_do with in-line constraints provided as a 2nd argument. 00111 // The user must supply brackets around the constraints. 00112 00113 `define ovm_do_with(OVM_SEQUENCE_ITEM, CONSTRAINTS) \ 00114 begin \ 00115 ovm_virtual_sequencer ovs; \ 00116 ovm_sequence os; \ 00117 OVM_SEQUENCE_ITEM = new(`"OVM_SEQUENCE_ITEM`");\ 00118 if ($cast(ovs, m_sequencer)) \ 00119 if(!$cast(os, OVM_SEQUENCE_ITEM)) \ 00120 ovm_report_fatal("ITMVSQ", "Cannot do items in a virtual sequence."); \ 00121 $cast(OVM_SEQUENCE_ITEM , create_item(OVM_SEQUENCE_ITEM, m_sequencer)); \ 00122 start_item(OVM_SEQUENCE_ITEM); \ 00123 assert(OVM_SEQUENCE_ITEM.randomize() with CONSTRAINTS ) else begin \ 00124 ovm_report_warning("RNDFLD", "Randomization failed in ovm_do_with action"); \ 00125 end \ 00126 finish_item(OVM_SEQUENCE_ITEM);\ 00127 end 00128 00129 00130 //------------------------------------------------------------------------------ 00131 // 00132 // MACRO: ovm_create 00133 // 00134 //------------------------------------------------------------------------------ 00135 00136 // This macro takes as an argument a ovm_sequence_item variable or object. 00137 // Memory is allocated using the factory and is assigned to the macro arguement. 00138 00139 `define ovm_create(OVM_SEQUENCE_ITEM) \ 00140 begin \ 00141 OVM_SEQUENCE_ITEM = new(`"OVM_SEQUENCE_ITEM`");\ 00142 $cast(OVM_SEQUENCE_ITEM , create_item(OVM_SEQUENCE_ITEM, m_sequencer)); \ 00143 end\ 00144 00145 00146 //------------------------------------------------------------------------------ 00147 // 00148 // MACRO: ovm_send 00149 // 00150 //------------------------------------------------------------------------------ 00151 00152 // Takes as an argument a ovm_sequence_item object (likely created with 00153 // create_item). 00154 // Memory is not allocated. 00155 // Sequence items are sent to the DRIVER with standard processing. 00156 00157 00158 `define ovm_send(OVM_SEQUENCE_ITEM) \ 00159 begin \ 00160 start_item(OVM_SEQUENCE_ITEM); \ 00161 finish_item(OVM_SEQUENCE_ITEM);\ 00162 end\ 00163 00164 00165 //------------------------------------------------------------------------------ 00166 // 00167 // MACRO: ovm_rand_send 00168 // 00169 //------------------------------------------------------------------------------ 00170 00171 // Takes as an argument a ovm_sequence_item object (likely created with 00172 // create_item). 00173 // Memory is not allocated. 00174 // Sequence items are sent to the DRIVER with standard processing. 00175 // ovm_sequence_item's are randomized using late-randomization. 00176 00177 `define ovm_rand_send(OVM_SEQUENCE_ITEM) \ 00178 begin \ 00179 start_item(OVM_SEQUENCE_ITEM); \ 00180 assert(OVM_SEQUENCE_ITEM.randomize()) else begin \ 00181 ovm_report_warning("RNDFLD", "Randomization failed in ovm_rand_send action"); \ 00182 end \ 00183 finish_item(OVM_SEQUENCE_ITEM);\ 00184 end\ 00185 00186 00187 //------------------------------------------------------------------------------ 00188 // 00189 // MACRO: ovm_rand_send_with 00190 // 00191 //------------------------------------------------------------------------------ 00192 00193 // Similar to ovm_rand_send with in-line constraints provided as a 2nd argument 00194 // The user must supply brackets around the constraints. 00195 00196 00197 `define ovm_rand_send_with(OVM_SEQUENCE_ITEM, CONSTRAINTS) \ 00198 begin \ 00199 start_item(OVM_SEQUENCE_ITEM); \ 00200 assert(OVM_SEQUENCE_ITEM.randomize() with CONSTRAINTS ) else begin \ 00201 ovm_report_warning("RNDFLD", "Randomization failed in ovm_rand_send_with action"); \ 00202 end \ 00203 finish_item(OVM_SEQUENCE_ITEM);\ 00204 end\ 00205 00206 00207 `define ovm_declare_sequence_lib \ 00208 protected bit m_set_sequences_called = 1; \ 00209 /* used to store the string names of the sequence types */ \ 00210 static protected string m_static_sequences[$]; \ 00211 static function bit add(string type_name); \ 00212 m_static_sequences.push_back(type_name); \ 00213 return 1; \ 00214 endfunction\ 00215 function void ovm_update_sequence_lib();\ 00216 if(this.m_set_sequences_called) begin \ 00217 set_sequences_queue(m_static_sequences); \ 00218 this.m_set_sequences_called = 0;\ 00219 end\ 00220 endfunction 00221 00222 00223 `define ovm_update_sequence_lib \ 00224 if(!sequence_ids.exists("ovm_random_sequence")) \ 00225 add_sequence("ovm_random_sequence"); \ 00226 if(!sequence_ids.exists("ovm_exhaustive_sequence")) \ 00227 add_sequence("ovm_exhaustive_sequence"); \ 00228 begin \ 00229 ovm_virtual_sequencer tmp; \ 00230 if(!$cast(tmp, this)) \ 00231 if(!sequence_ids.exists("ovm_simple_sequence")) \ 00232 add_sequence("ovm_simple_sequence"); \ 00233 end \ 00234 ovm_update_sequence_lib(); \ 00235 00236 00237 `define ovm_update_sequence_lib_and_item(USER_ITEM) \ 00238 ovm_factory::set_inst_override({get_full_name(), "*.item"}, \ 00239 "ovm_sequence_item", `"USER_ITEM`"); \ 00240 `ovm_update_sequence_lib \ 00241 00242 00243 `define ovm_sequencer_utils_begin(TYPE_NAME) \ 00244 `ovm_declare_sequence_lib \ 00245 `ovm_component_utils_begin(TYPE_NAME) 00246 00247 00248 `define ovm_sequencer_utils_end \ 00249 `ovm_component_utils_end 00250 00251 00252 `define ovm_sequencer_utils(TYPE_NAME) \ 00253 `ovm_sequencer_utils_begin(TYPE_NAME) \ 00254 `ovm_sequencer_utils_end 00255 00256 00257 //----------------------------------------------------------------------------- 00258 // MACRO: ovm_do_seq 00259 // This macro is used by virtual sequences to execute driver sequences 00260 //----------------------------------------------------------------------------- 00261 00262 `define ovm_do_seq(OVM_SEQ, SEQR_CONS_IF) \ 00263 begin \ 00264 ovm_virtual_sequencer vs; \ 00265 if(!$cast(vs, m_sequencer)) \ 00266 ovm_report_fatal("INVACT", \ 00267 "Cannot execute `ovm_do_seq on this sequencer."); \ 00268 OVM_SEQ = new( `"OVM_SEQ`");\ 00269 $cast(OVM_SEQ , create_item(OVM_SEQ, SEQR_CONS_IF.seqrb_ref)); \ 00270 start_item(OVM_SEQ); \ 00271 assert(OVM_SEQ.randomize()) else begin \ 00272 ovm_report_warning("RNDFLD", \ 00273 "Randomization failed in ovm_do_seq action"); \ 00274 end \ 00275 finish_item(OVM_SEQ);\ 00276 end \ 00277 00278 00279 //----------------------------------------------------------------------------- 00280 // MACRO: ovm_do_seq_with 00281 // Exactly like ovm_do_seq except supports inline constraints. 00282 //----------------------------------------------------------------------------- 00283 00284 `define ovm_do_seq_with(OVM_SEQ, SEQR_CONS_IF, CONSTRAINTS) \ 00285 begin\ 00286 ovm_virtual_sequencer vs; \ 00287 if(!$cast(vs, m_sequencer)) \ 00288 ovm_report_fatal("INVACT", \ 00289 "Cannot execute `ovm_do_seq_with on this sequencer."); \ 00290 OVM_SEQ = new( `"OVM_SEQ`");\ 00291 $cast(OVM_SEQ , create_item(OVM_SEQ, SEQR_CONS_IF.seqrb_ref)); \ 00292 start_item(OVM_SEQ); \ 00293 assert(OVM_SEQ.randomize() with CONSTRAINTS ) else begin \ 00294 ovm_report_warning("RNDFLD", \ 00295 "Randomization failed in ovm_do_seq_with action"); \ 00296 end \ 00297 finish_item(OVM_SEQ);\ 00298 end\ 00299 00300 00301 //------------------------------------------------------------------------------ 00302 // 00303 // MACRO: ovm_create_seq 00304 // 00305 //------------------------------------------------------------------------------ 00306 00307 // This macro takes as an argument a ovm_sequence_item variable or object. 00308 // Memory is allocated using the factory and is assigned to the macro arguement. 00309 00310 `define ovm_create_seq(OVM_SEQ, SEQR_CONS_IF) \ 00311 begin \ 00312 ovm_virtual_sequencer vs; \ 00313 if(!$cast(vs, m_sequencer)) \ 00314 ovm_report_fatal("INVACT", \ 00315 "Cannot execute `ovm_create_seq on this sequencer."); \ 00316 OVM_SEQ = new(`"OVM_SEQ`");\ 00317 $cast(OVM_SEQ, create_item(OVM_SEQ, SEQR_CONS_IF.seqrb_ref)); \ 00318 end\ 00319 00320
![]() 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 Version: 1.4.6 Mon Sep 29 14:20:12 2008 |