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

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