ovm_random_stimulus.svh

Go to the documentation of this file.
00001 // $Id: ovm__random__stimulus_8svh-source.html,v 1.1 2008/10/07 21:54:43 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
00044   #(type trans_type=ovm_transaction)
00045   extends ovm_component;
00046 
00047   // blocking_put_port is the port used to send the   
00048   // generated stimulus to the rest of the testbench  
00049                                                       
00050   ovm_blocking_put_port #( trans_type ) blocking_put_port;
00051 
00052   local bit m_stop = 0;
00053 
00054   // Constructor
00055   //
00056   // We must always specify a local name. We should not
00057   // specify a parent if this component is instantiated
00058   // inside the environment class. We should specify a
00059   // parent is this component is instantiated inside another
00060   // named component.
00061   //
00062   // The constructor also displays the string obtained from
00063   // get_randstate during construction.  set_randstate can
00064   // be then used to regenerate precisely the same sequence
00065   // of transactions for debugging purposes.
00066 
00067   function new( string name ,
00068                 ovm_component parent );
00069 
00070     string seed_str;
00071 
00072     super.new( name , parent );
00073     m_stop = 0;
00074 
00075     blocking_put_port = new("blocking_put_port" , this );
00076     
00077     $sformat( seed_str  , "rand state is %s" , get_randstate() );
00078 
00079     ovm_report_info("ovm_stimulus" , seed_str );
00080   endfunction
00081 
00082   // Generate stimulus is the main user visible method.
00083   //
00084   // If t is not specified, we will use the randomize method
00085   // in trans_type to generate transactions.  If t is
00086   // specified, we will use the randomize method in t to
00087   // generate transactions - so t must be a subclass of
00088   // trans_type.
00089   //
00090   // max_count is the maximum number of transactions to be
00091   // generated. A value of zero indicates no maximum - in
00092   // this case, generate_stimulus will go on indefinitely
00093   // unless stopped by some other process
00094   //
00095   // The transactions are cloned before they are sent out 
00096   // over the blocking_put_port
00097 
00098   virtual task generate_stimulus( trans_type t = null , 
00099                                   input int max_count = 0 );
00100 
00101     trans_type temp;
00102     
00103     if( t == null ) t = new;
00104     
00105     for( int i = 0; 
00106       (max_count == 0 || i < max_count) && !m_stop; 
00107        i++ ) begin
00108 
00109        assert( t.randomize() );
00110       
00111        $cast( temp , t.clone() );
00112        ovm_report_info("stimulus generation" ,   
00113                            temp.convert2string() ); 
00114        blocking_put_port.put( temp );
00115     end
00116   endtask
00117   
00118   // This method stops the generation of stimulus.
00119   //
00120   // If a subclass of this method has forked additional
00121   // processes, those processes will also need to be
00122   // stopped in an overridden version of this method
00123   
00124   virtual function void stop_stimulus_generation;
00125     m_stop = 1;
00126   endfunction
00127   
00128 endclass : ovm_random_stimulus

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:20:12 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV