ovm_sequence_defines.svh

Go to the documentation of this file.
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_typewide_sequence(`"TYPE_NAME`");
00023 
00024 `define ovm_declare_p_sequencer(SEQUENCER) \
00025   SEQUENCER p_sequencer;\
00026   virtual function void m_set_p_sequencer();\
00027     super.m_set_p_sequencer(); \
00028     assert($cast(p_sequencer, m_sequencer)) else \
00029         ovm_report_fatal("DCLPSQ", \
00030         $psprintf("%m Error casting p_sequencer, please verify that this sequence/sequence item is intended to execute on this type of sequencer")); \
00031   endfunction  
00032 
00033 `define ovm_sequence_utils_begin(TYPE_NAME, SEQUENCER) \
00034   `ovm_register_sequence(TYPE_NAME, SEQUENCER) \
00035   `ovm_declare_p_sequencer(SEQUENCER) \
00036   `ovm_object_utils_begin(TYPE_NAME)
00037 
00038 `define ovm_sequence_utils_end \
00039   `ovm_object_utils_end
00040 
00041 `define ovm_sequence_utils(TYPE_NAME, SEQUENCER) \
00042   `ovm_sequence_utils_begin(TYPE_NAME,SEQUENCER) \
00043   `ovm_sequence_utils_end
00044 
00045 //-----------------------------------------------------------------------------
00046 //
00047 // MACRO: ovm_package
00048 //
00049 // Use `ovm_package to define the SV package and to create a bogus type to help 
00050 // automate triggering the static initializers of the package.
00051 // Use ovm_end_package to endpackage.
00052 //-----------------------------------------------------------------------------
00053 
00054 `define ovm_package(PKG) \
00055   package PKG; \
00056   class ovm_bogus_class extends ovm::ovm_sequence;\
00057   endclass
00058 
00059 `define ovm_end_package \
00060    endpackage
00061 
00062 
00063 //-----------------------------------------------------------------------------
00064 //
00065 // MACRO: ovm_sequence_library_package
00066 //
00067 // Use `ovm_sequence_library_package to automate triggering of packages static 
00068 // initializers.  ovm_package creates a bogus type which gets referred to by 
00069 // ovm_sequence_library_package to make a package-based variable of the bogus
00070 // type.
00071 //-----------------------------------------------------------------------------
00072 
00073 `define ovm_sequence_library_package(PKG_NAME) \
00074   import PKG_NAME``::*; \
00075   PKG_NAME``::ovm_bogus_class M_``PKG_NAME``ovm_bogus_class
00076 
00077 
00078 //------------------------------------------------------------------------------
00079 //
00080 // MACRO: ovm_create
00081 //
00082 //------------------------------------------------------------------------------
00083 
00084 // This macro takes as an argument a ovm_sequence_item variable or object.  
00085 // Memory is allocated using the factory and is assigned to the macro arguement.
00086 
00087 `define ovm_create(OVM_SEQUENCE_ITEM) \
00088   begin \
00089   ovm_object_wrapper w_; w_ = OVM_SEQUENCE_ITEM.get_type(); \
00090   $cast(OVM_SEQUENCE_ITEM , create_item(w_, m_sequencer, `"OVM_SEQUENCE_ITEM`"));\
00091   end\
00092 
00093 //------------------------------------------------------------------------------
00094 //
00095 // MACRO: ovm_do
00096 //
00097 //------------------------------------------------------------------------------
00098 
00099 // This macro takes as an argument a ovm_sequence_item variable or object.  
00100 // Memory is allocated using the factory and is assigned to the macro arguement.
00101 // ovm_sequence_item's are randomized using late-randomization.
00102 // See the "ovm_do item Flow in Pull Mode" and the "ovm_do Subsequence Flow" 
00103 // diagrams for further details.
00104 
00105 `define ovm_do(OVM_SEQUENCE_ITEM) \
00106   begin \
00107   OVM_SEQUENCE_ITEM = new(""); \
00108   `ovm_create(OVM_SEQUENCE_ITEM) \
00109   start_item(OVM_SEQUENCE_ITEM); \
00110   assert(OVM_SEQUENCE_ITEM.randomize()) else begin \
00111     ovm_report_warning("RNDFLD", "Randomization failed in ovm_do action"); \
00112   end \
00113   finish_item(OVM_SEQUENCE_ITEM); \
00114   end
00115 
00116 `define ovm_do_pri(OVM_SEQUENCE_ITEM, PRIORITY) \
00117   begin \
00118   `ovm_create(OVM_SEQUENCE_ITEM) \
00119   start_item(OVM_SEQUENCE_ITEM, PRIORITY); \
00120   assert(OVM_SEQUENCE_ITEM.randomize()) else begin \
00121     ovm_report_warning("RNDFLD", "Randomization failed in ovm_do action"); \
00122   end \
00123   finish_item(OVM_SEQUENCE_ITEM, PRIORITY); \
00124   end
00125 
00126 //------------------------------------------------------------------------------
00127 //
00128 // MACRO: ovm_do_with
00129 //
00130 //------------------------------------------------------------------------------
00131 
00132 // Similar to ovm_do with in-line constraints provided as a 2nd argument.
00133 // The user must supply brackets around the constraints.
00134 
00135 `define ovm_do_with(OVM_SEQUENCE_ITEM, CONSTRAINTS) \
00136   begin \
00137   OVM_SEQUENCE_ITEM = new(""); \
00138   `ovm_create(OVM_SEQUENCE_ITEM) \
00139   start_item(OVM_SEQUENCE_ITEM);\
00140   assert(OVM_SEQUENCE_ITEM.randomize() with CONSTRAINTS ) else begin \
00141     ovm_report_warning("RNDFLD", "Randomization failed in ovm_do_with action"); \
00142   end\
00143   finish_item(OVM_SEQUENCE_ITEM);\
00144   end
00145 
00146 `define ovm_do_pri_with(OVM_SEQUENCE_ITEM, PRIORITY, CONSTRAINTS) \
00147 begin \
00148   OVM_SEQUENCE_ITEM = new(""); \
00149   `ovm_create(OVM_SEQUENCE_ITEM) \
00150   start_item(OVM_SEQUENCE_ITEM, PRIORITY);\
00151   assert(OVM_SEQUENCE_ITEM.randomize() with CONSTRAINTS ) else begin \
00152     ovm_report_warning("RNDFLD", "Randomization failed in ovm_do_with action"); \
00153   end\
00154   finish_item(OVM_SEQUENCE_ITEM, PRIORITY);\
00155   end
00156 
00157 //------------------------------------------------------------------------------
00158 //
00159 // MACRO: ovm_send
00160 //
00161 //------------------------------------------------------------------------------
00162 
00163 // Takes as an argument a ovm_sequence_item object (likely created with 
00164 // create_item).  
00165 // Memory is not allocated. 
00166 // Sequence items are sent to the DRIVER with standard processing.
00167 
00168 
00169 `define ovm_send(OVM_SEQUENCE_ITEM) \
00170   begin \
00171   start_item(OVM_SEQUENCE_ITEM); \
00172   finish_item(OVM_SEQUENCE_ITEM);\
00173   end\
00174   
00175 `define ovm_send_pri(OVM_SEQUENCE_ITEM, PRIORITY) \
00176   begin \
00177   start_item(OVM_SEQUENCE_ITEM, PRIORITY); \
00178   finish_item(OVM_SEQUENCE_ITEM, PRIORITY);\
00179   end\
00180   
00181 
00182 //------------------------------------------------------------------------------
00183 //
00184 // MACRO: ovm_rand_send
00185 //
00186 //------------------------------------------------------------------------------
00187 
00188 // Takes as an argument a ovm_sequence_item object (likely created with 
00189 // create_item).  
00190 // Memory is not allocated. 
00191 // Sequence items are sent to the DRIVER with standard processing.
00192 // ovm_sequence_item's are randomized using late-randomization.
00193 
00194 `define ovm_rand_send(OVM_SEQUENCE_ITEM) \
00195   begin \
00196   start_item(OVM_SEQUENCE_ITEM); \
00197   assert(OVM_SEQUENCE_ITEM.randomize()) else begin \
00198     ovm_report_warning("RNDFLD", "Randomization failed in ovm_rand_send action"); \
00199   end \
00200   finish_item(OVM_SEQUENCE_ITEM);\
00201   end\
00202 
00203 `define ovm_rand_send_pri(OVM_SEQUENCE_ITEM, PRIORITY) \
00204   begin \
00205   start_item(OVM_SEQUENCE_ITEM, PRIORITY); \
00206   assert(OVM_SEQUENCE_ITEM.randomize()) else begin \
00207     ovm_report_warning("RNDFLD", "Randomization failed in ovm_rand_send action"); \
00208   end \
00209   finish_item(OVM_SEQUENCE_ITEM, PRIORITY);\
00210   end\
00211 
00212 
00213 //------------------------------------------------------------------------------
00214 //
00215 // MACRO: ovm_rand_send_with
00216 //
00217 //------------------------------------------------------------------------------
00218 
00219 // Similar to ovm_rand_send with in-line constraints provided as a 2nd argument
00220 // The user must supply brackets around the constraints.
00221 
00222 
00223 `define ovm_rand_send_with(OVM_SEQUENCE_ITEM, CONSTRAINTS) \
00224   begin \
00225   start_item(OVM_SEQUENCE_ITEM); \
00226   assert(OVM_SEQUENCE_ITEM.randomize() with CONSTRAINTS ) else begin \
00227     ovm_report_warning("RNDFLD", "Randomization failed in ovm_rand_send_with action"); \
00228   end \
00229   finish_item(OVM_SEQUENCE_ITEM);\
00230   end\
00231 
00232 `define ovm_rand_send_pri_with(OVM_SEQUENCE_ITEM, PRIORITY, CONSTRAINTS) \
00233   begin \
00234   start_item(OVM_SEQUENCE_ITEM, PRIORITY); \
00235   assert(OVM_SEQUENCE_ITEM.randomize() with CONSTRAINTS ) else begin \
00236     ovm_report_warning("RNDFLD", "Randomization failed in ovm_rand_send_with action"); \
00237   end \
00238   finish_item(OVM_SEQUENCE_ITEM, PRIORITY);\
00239   end\
00240 
00241 
00242 `define ovm_declare_sequence_lib \
00243   protected bit m_set_sequences_called = 1;    \
00244   static protected string m_static_sequences[$]; \
00245   static function bit add_typewide_sequence(string type_name); \
00246     m_static_sequences.push_back(type_name); \
00247     return 1; \
00248   endfunction\
00249   static function bit remove_typewide_sequence(string type_name); \
00250     for (int i = 0; i < m_static_sequences.size(); i++) begin \
00251       if (m_static_sequences[i] == type_name) \
00252         m_static_sequences.delete(i); \
00253     end \
00254     return 1;\
00255   endfunction\
00256   function void ovm_update_sequence_lib();\
00257     if(this.m_set_sequences_called) begin \
00258       set_sequences_queue(m_static_sequences); \
00259       this.m_set_sequences_called = 0;\
00260     end\
00261   endfunction\
00262 
00263 `define ovm_update_sequence_lib \
00264   m_add_builtin_seqs(0); \
00265   ovm_update_sequence_lib();
00266 
00267 
00268 `define ovm_update_sequence_lib_and_item(USER_ITEM) \
00269   factory.set_inst_override_by_type( \
00270     ovm_sequence_item::get_type(), USER_ITEM::get_type(), \
00271     {get_full_name(), "*.item"}); \
00272   m_add_builtin_seqs(1); \
00273   ovm_update_sequence_lib();
00274 
00275 `define ovm_sequencer_utils_begin(TYPE_NAME) \
00276   `ovm_declare_sequence_lib \
00277   `ovm_component_utils_begin(TYPE_NAME)
00278 
00279 `define ovm_sequencer_param_utils_begin(TYPE_NAME) \
00280   `ovm_declare_sequence_lib \
00281   `ovm_component_param_utils_begin(TYPE_NAME)
00282 
00283 `define ovm_sequencer_utils_end \
00284   `ovm_component_utils_end
00285 
00286 `define ovm_sequencer_utils(TYPE_NAME) \
00287   `ovm_sequencer_utils_begin(TYPE_NAME) \
00288   `ovm_sequencer_utils_end
00289 
00290 `define ovm_sequencer_param_utils(TYPE_NAME) \
00291   `ovm_sequencer_param_utils_begin(TYPE_NAME) \
00292   `ovm_sequencer_utils_end
00293 
00294 //-----------------------------------------------------------------------------
00295 // MACRO: ovm_create_on
00296 // This macro is used by virtual sequences to execute driver sequences
00297 //-----------------------------------------------------------------------------
00298 
00299 `define ovm_create_on(OVM_SEQUENCE_ITEM, SEQUENCER_REF) \
00300   begin \
00301   ovm_object_wrapper w_; w_ = OVM_SEQUENCE_ITEM.get_type(); \
00302   $cast(OVM_SEQUENCE_ITEM , create_item(w_, SEQUENCER_REF, `"OVM_SEQUENCE_ITEM`"));\
00303   end
00304 
00305 `define ovm_create_seq(OVM_SEQ, SEQR_CONS_IF) \
00306   begin \
00307   `ovm_create_on(OVM_SEQ, SEQR_CONS_IF.consumer_seqr) \
00308   end
00309 
00310 //-----------------------------------------------------------------------------
00311 // MACRO: ovm_do_on
00312 // This macro is used by virtual sequences to execute driver sequences
00313 //-----------------------------------------------------------------------------
00314 
00315 `define ovm_do_on(OVM_SEQUENCE_ITEM, SEQUENCER_REF) \
00316   begin \
00317   `ovm_create_on(OVM_SEQUENCE_ITEM, SEQUENCER_REF) \
00318   start_item(OVM_SEQUENCE_ITEM); \
00319   assert(OVM_SEQUENCE_ITEM.randomize()) else begin \
00320     ovm_report_warning("RNDFLD", "Randomization failed in ovm_do action"); \
00321   end \
00322   finish_item(OVM_SEQUENCE_ITEM); \
00323   end
00324 
00325 `define ovm_do_seq(OVM_SEQ, SEQR_CONS_IF) \
00326   begin \
00327   `ovm_do_on(OVM_SEQ, SEQR_CONS_IF.consumer_seqr) \
00328   end
00329 
00330 `define ovm_do_on_pri(OVM_SEQUENCE_ITEM, SEQUENCER_REF, PRIORITY) \
00331   begin \
00332   `ovm_create_on(OVM_SEQUENCE_ITEM, SEQUENCER_REF) \
00333   start_item(OVM_SEQUENCE_ITEM, PRIORITY); \
00334   assert(OVM_SEQUENCE_ITEM.randomize()) else begin \
00335     ovm_report_warning("RNDFLD", "Randomization failed in ovm_do action"); \
00336   end \
00337   finish_item(OVM_SEQUENCE_ITEM, PRIORITY); \
00338   end
00339 
00340 // Similar to ovm_do with in-line constraints provided as a 2nd argument.
00341 // The user must supply brackets around the constraints.
00342 
00343 `define ovm_do_on_with(OVM_SEQUENCE_ITEM, SEQUENCER_REF, CONSTRAINTS) \
00344   begin \
00345   `ovm_create_on(OVM_SEQUENCE_ITEM, SEQUENCER_REF) \
00346   start_item(OVM_SEQUENCE_ITEM);\
00347   assert(OVM_SEQUENCE_ITEM.randomize() with CONSTRAINTS ) else begin \
00348     ovm_report_warning("RNDFLD", "Randomization failed in ovm_do_with action"); \
00349   end\
00350   finish_item(OVM_SEQUENCE_ITEM);\
00351   end
00352 
00353 `define ovm_do_seq_with(OVM_SEQ, SEQR_CONS_IF, CONSTRAINTS) \
00354   begin\
00355   `ovm_do_on_with(OVM_SEQ, SEQR_CONS_IF.consumer_seqr, CONSTRAINTS) \
00356   end
00357 
00358 `define ovm_do_on_pri_with(OVM_SEQUENCE_ITEM, SEQUENCER_REF, PRIORITY, CONSTRAINTS) \
00359   begin \
00360   `ovm_create_on(OVM_SEQUENCE_ITEM, SEQUENCER_REF) \
00361   start_item(OVM_SEQUENCE_ITEM, PRIORITY);\
00362   assert(OVM_SEQUENCE_ITEM.randomize() with CONSTRAINTS ) else begin \
00363     ovm_report_warning("RNDFLD", "Randomization failed in ovm_do_with action"); \
00364   end\
00365   finish_item(OVM_SEQUENCE_ITEM, PRIORITY);\
00366   end
00367 

Intelligent Design Verification
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
Doxygen Version: 1.5.5
Wed Jan 7 19:27:18 2009
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV