ovm_random_stimulus.svh

Go to the documentation of this file.
00001 // $Id: a00263.html,v 1.1 2009/01/07 19:29:56 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 
00023 // A general purpose unidirectional random stimulus class.
00024 //
00025 // If you want to do stuff before or after the run method,
00026 // extend this class, define your own run, and call
00027 // super.run( . ). This will be the case, for example when
00028 // you need a non random initialisation sequence before you
00029 // do some constraint random testing.
00030 //
00031 
00032 // The ovm_stimulus class generates streams of trans_type
00033 // transactions. These streams may be generated by the
00034 // randomize method of trans_type, or the randomize method
00035 // of one of its subclasses.  The stream may go
00036 // indefinitely, until terminated by a call to
00037 // stop_stimulus_generation, or we may specify the maximum
00038 // number of transactions to be generated.
00039 //
00040 // By using inheritance, we can add directed initialization
00041 // or tidy up sequences to the random stimulus generation.
00042 
00043 class ovm_random_stimulus #(type trans_type=ovm_transaction)
00044   extends ovm_component;
00045 
00046   const static string type_name = "ovm_random_stimulus #(trans_type)";
00047 
00048   typedef ovm_random_stimulus #(trans_type) this_type;
00049   `ovm_component_param_utils(this_type)
00050 
00051   // blocking_put_port is the port used to send the   
00052   // generated stimulus to the rest of the testbench  
00053                                                       
00054   ovm_blocking_put_port #( trans_type ) blocking_put_port;
00055 
00056   local bit m_stop = 0;
00057 
00058   // Constructor
00059   //
00060   // We must always specify a local name. We should not
00061   // specify a parent if this component is instantiated
00062   // inside the environment class. We should specify a
00063   // parent is this component is instantiated inside another
00064   // named component.
00065   //
00066   // The constructor also displays the string obtained from
00067   // get_randstate during construction.  set_randstate can
00068   // be then used to regenerate precisely the same sequence
00069   // of transactions for debugging purposes.
00070 
00071   function new( string name ,
00072                 ovm_component parent );
00073 
00074     string seed_str;
00075 
00076     super.new( name , parent );
00077     m_stop = 0;
00078 
00079     blocking_put_port = new("blocking_put_port" , this );
00080     
00081     $sformat( seed_str  , "rand state is %s" , get_randstate() );
00082 
00083     ovm_report_info("ovm_stimulus" , seed_str );
00084   endfunction
00085 
00086 
00087   virtual function string get_type_name();
00088     return type_name;
00089   endfunction
00090 
00091   // Generate stimulus is the main user visible method.
00092   //
00093   // If t is not specified, we will use the randomize method
00094   // in trans_type to generate transactions.  If t is
00095   // specified, we will use the randomize method in t to
00096   // generate transactions - so t must be a subclass of
00097   // trans_type.
00098   //
00099   // max_count is the maximum number of transactions to be
00100   // generated. A value of zero indicates no maximum - in
00101   // this case, generate_stimulus will go on indefinitely
00102   // unless stopped by some other process
00103   //
00104   // The transactions are cloned before they are sent out 
00105   // over the blocking_put_port
00106 
00107   virtual task generate_stimulus( trans_type t = null , 
00108                                   input int max_count = 0 );
00109 
00110     trans_type temp;
00111     
00112     if( t == null ) t = new;
00113     
00114     for( int i = 0; 
00115       (max_count == 0 || i < max_count) && !m_stop; 
00116        i++ ) begin
00117 
00118        assert( t.randomize() );
00119       
00120        $cast( temp , t.clone() );
00121        ovm_report_info("stimulus generation" ,   
00122                            temp.convert2string() ); 
00123        blocking_put_port.put( temp );
00124     end
00125   endtask
00126   
00127   // This method stops the generation of stimulus.
00128   //
00129   // If a subclass of this method has forked additional
00130   // processes, those processes will also need to be
00131   // stopped in an overridden version of this method
00132   
00133   virtual function void stop_stimulus_generation;
00134     m_stop = 1;
00135   endfunction
00136   
00137 endclass : ovm_random_stimulus

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