00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2005 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 #ifndef SC_COR_H 00037 #define SC_COR_H 00038 00039 00040 #include <cassert> 00041 #include <cstdlib> 00042 00043 namespace sc_core { 00044 00045 class sc_simcontext; 00046 00047 00048 // ---------------------------------------------------------------------------- 00049 // TYPEDEF : sc_cor_fn 00050 // 00051 // Function type for creating coroutines. 00052 // ---------------------------------------------------------------------------- 00053 00054 typedef void (sc_cor_fn)( void* ); 00055 00056 00057 // ---------------------------------------------------------------------------- 00058 // CLASS : sc_cor 00059 // 00060 // Coroutine abstract base class. 00061 // ---------------------------------------------------------------------------- 00062 00063 class sc_cor 00064 { 00065 protected: 00066 00067 // constructor 00068 sc_cor() {} 00069 00070 public: 00071 00072 // destructor 00073 virtual ~sc_cor() {} 00074 00075 // switch stack protection on/off 00076 virtual void stack_protect( bool enable ) {} 00077 00078 private: 00079 00080 // disabled 00081 sc_cor( const sc_cor& ); 00082 sc_cor& operator = ( const sc_cor& ); 00083 }; 00084 00085 00086 // ---------------------------------------------------------------------------- 00087 // CLASS : sc_cor_pkg 00088 // 00089 // Coroutine package abstract base class. 00090 // ---------------------------------------------------------------------------- 00091 00092 class sc_cor_pkg 00093 { 00094 public: 00095 00096 // constructor 00097 sc_cor_pkg( sc_simcontext* simc ) 00098 : m_simc( simc ) { assert( simc != 0 ); } 00099 00100 // destructor 00101 virtual ~sc_cor_pkg() {} 00102 00103 // create a new coroutine 00104 #if( defined(_MSC_VER) && _MSC_VER < 1300 ) 00105 virtual sc_cor* create( 00106 size_t stack_size, sc_cor_fn* fn, void* arg ) = 0; 00107 #else 00108 virtual sc_cor* create( 00109 std::size_t stack_size, sc_cor_fn* fn, void* arg ) = 0; 00110 #endif // ( defined(_MSC_VER) && _MSC_VER < 1300 ) 00111 00112 // yield to the next coroutine 00113 virtual void yield( sc_cor* next_cor ) = 0; 00114 00115 // abort the current coroutine (and resume the next coroutine) 00116 virtual void abort( sc_cor* next_cor ) = 0; 00117 00118 // get the main coroutine 00119 virtual sc_cor* get_main() = 0; 00120 00121 // get the simulation context 00122 sc_simcontext* simcontext() 00123 { return m_simc; } 00124 00125 private: 00126 00127 sc_simcontext* m_simc; 00128 00129 private: 00130 00131 // disabled 00132 sc_cor_pkg(); 00133 sc_cor_pkg( const sc_cor_pkg& ); 00134 sc_cor_pkg& operator = ( const sc_cor_pkg& ); 00135 }; 00136 00137 } // namespace sc_core 00138 00139 #endif 00140 00141 // Taf!
1.5.1