sc_cor.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2006 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 2.4 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 /*****************************************************************************
00019 
00020   sc_cor.h -- Coroutine abstract base classes.
00021 
00022   Original Author: Martin Janssen, Synopsys, Inc., 2001-12-18
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029   changes you are making here.
00030 
00031       Name, Affiliation, Date:
00032   Description of Modification:
00033 
00034  *****************************************************************************/
00035 
00036 // $Log: sc_cor.h,v $
00037 // Revision 1.1.1.1  2006/12/15 20:31:36  acg
00038 // SystemC 2.2
00039 //
00040 // Revision 1.3  2006/01/13 18:44:29  acg
00041 // Added $Log to record CVS changes into the source.
00042 //
00043 
00044 #ifndef SC_COR_H
00045 #define SC_COR_H
00046 
00047 
00048 #include <cassert>
00049 #include <cstdlib>
00050 
00051 namespace sc_core {
00052 
00053 class sc_simcontext;
00054 
00055 
00056 // ----------------------------------------------------------------------------
00057 //  TYPEDEF : sc_cor_fn
00058 //
00059 //  Function type for creating coroutines.
00060 // ----------------------------------------------------------------------------
00061 
00062 typedef void (sc_cor_fn)( void* );
00063 
00064 
00065 // ----------------------------------------------------------------------------
00066 //  CLASS : sc_cor
00067 //
00068 //  Coroutine abstract base class.
00069 // ----------------------------------------------------------------------------
00070 
00071 class sc_cor
00072 {
00073 protected:
00074 
00075     // constructor
00076     sc_cor() {}
00077 
00078 public:
00079 
00080     // destructor
00081     virtual ~sc_cor() {}
00082 
00083     // switch stack protection on/off
00084     virtual void stack_protect( bool enable ) {}
00085 
00086 private:
00087 
00088     // disabled
00089     sc_cor( const sc_cor& );
00090     sc_cor& operator = ( const sc_cor& );
00091 };
00092 
00093 
00094 // ----------------------------------------------------------------------------
00095 //  CLASS : sc_cor_pkg
00096 //
00097 //  Coroutine package abstract base class.
00098 // ----------------------------------------------------------------------------
00099 
00100 class sc_cor_pkg
00101 {
00102 public:
00103 
00104     // constructor
00105     sc_cor_pkg( sc_simcontext* simc )
00106         : m_simc( simc ) { assert( simc != 0 ); }
00107 
00108     // destructor
00109     virtual ~sc_cor_pkg() {}
00110 
00111     // create a new coroutine
00112 #if( defined(_MSC_VER) && _MSC_VER < 1300 )
00113    virtual sc_cor* create(
00114         std::size_t stack_size, sc_cor_fn* fn, void* arg ) = 0;
00115 #else
00116    virtual sc_cor* create(
00117         std::size_t stack_size, sc_cor_fn* fn, void* arg ) = 0;
00118 #endif // ( defined(_MSC_VER) && _MSC_VER < 1300 )
00119 
00120     // yield to the next coroutine
00121     virtual void yield( sc_cor* next_cor ) = 0;
00122 
00123     // abort the current coroutine (and resume the next coroutine)
00124     virtual void abort( sc_cor* next_cor ) = 0;
00125 
00126     // get the main coroutine
00127     virtual sc_cor* get_main() = 0;
00128 
00129     // get the simulation context
00130     sc_simcontext* simcontext()
00131         { return m_simc; }
00132 
00133 private:
00134 
00135     sc_simcontext* m_simc;
00136 
00137 private:
00138 
00139     // disabled
00140     sc_cor_pkg();
00141     sc_cor_pkg( const sc_cor_pkg& );
00142     sc_cor_pkg& operator = ( const sc_cor_pkg& );
00143 };
00144 
00145 } // namespace sc_core
00146 
00147 #endif
00148 
00149 // Taf!

Generated on Wed Jan 21 15:32:09 2009 for SystemC by  doxygen 1.5.5