sc_cthread_process.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_cthread_process.h -- Clocked thread declarations
00021 
00022   Original Author: Andy Goodrich, Forte Design Systems, 4 August 2005
00023 
00024 
00025  *****************************************************************************/
00026 
00027 /*****************************************************************************
00028 
00029   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00030   changes you are making here.
00031 
00032       Name, Affiliation, Date:
00033   Description of Modification:
00034 
00035  *****************************************************************************/
00036 
00037 // $Log: sc_cthread_process.h,v $
00038 // Revision 1.1.1.1  2006/12/15 20:31:37  acg
00039 // SystemC 2.2
00040 //
00041 // Revision 1.4  2006/04/11 23:13:20  acg
00042 //   Andy Goodrich: Changes for reduced reset support that only includes
00043 //   sc_cthread, but has preliminary hooks for expanding to method and thread
00044 //   processes also.
00045 //
00046 // Revision 1.3  2006/01/13 18:44:29  acg
00047 // Added $Log to record CVS changes into the source.
00048 //
00049 
00050 #if !defined(sc_cthread_process_h_INCLUDED)
00051 #define sc_cthread_process_h_INCLUDED
00052 
00053 #include "sysc/kernel/sc_thread_process.h"
00054 
00055 namespace sc_core {
00056 
00057 
00058 // friend function declarations
00059     void wait( sc_simcontext* );
00060     void wait( const sc_event&,
00061               sc_simcontext* );
00062     void wait( sc_event_or_list&,
00063               sc_simcontext* );
00064     void wait( sc_event_and_list&,
00065               sc_simcontext* );
00066     void wait( const sc_time&,
00067               sc_simcontext* );
00068     void wait( const sc_time&, const sc_event&,
00069               sc_simcontext* );
00070     void wait( const sc_time&, sc_event_or_list&,
00071               sc_simcontext* );
00072     void wait( const sc_time&, sc_event_and_list&,
00073               sc_simcontext* );
00074 
00075     void sc_cthread_cor_fn( void* );
00076 
00077     void halt( sc_simcontext* );
00078     void wait( int,
00079               sc_simcontext* );
00080 
00081 //==============================================================================
00082 // sc_cthread_process -
00083 //
00084 //==============================================================================
00085 class sc_cthread_process : public sc_thread_process {
00086 
00087     friend class sc_module;
00088     friend class sc_process_handle;
00089     friend class sc_process_table;
00090     friend class sc_thread_process;
00091     friend class sc_simcontext;
00092 
00093     friend void wait( sc_simcontext* );
00094     friend void wait( const sc_event&,
00095               sc_simcontext* );
00096     friend void wait( sc_event_or_list&,
00097               sc_simcontext* );
00098     friend void wait( sc_event_and_list&,
00099               sc_simcontext* );
00100     friend void wait( const sc_time&,
00101               sc_simcontext* );
00102     friend void wait( const sc_time&, const sc_event&,
00103               sc_simcontext* );
00104     friend void wait( const sc_time&, sc_event_or_list&,
00105               sc_simcontext* );
00106     friend void wait( const sc_time&, sc_event_and_list&,
00107               sc_simcontext* );
00108 
00109     friend void sc_cthread_cor_fn( void* );
00110 
00111     friend void halt( sc_simcontext* );
00112     friend void wait( int,
00113               sc_simcontext* );
00114 
00115   public:
00116     sc_cthread_process( const char* name_p, bool free_host,
00117         SC_ENTRY_FUNC method_p, sc_process_host* host_p,
00118         const sc_spawn_options* opt_p );
00119     virtual ~sc_cthread_process();
00120 
00121     virtual void dont_initialize( bool dont );
00122     virtual const char* kind() const
00123         { return "sc_cthread_process"; }
00124 
00125   protected:
00126     sc_cthread_handle next_exist();
00127     void set_next_exist( sc_cthread_handle next_p );
00128 
00129 private:
00130 
00131     sc_cthread_process( const char*   nm,
00132             SC_ENTRY_FUNC fn,
00133             sc_process_host*    host );
00134 
00135     virtual void prepare_for_simulation();
00136 
00137 
00138     bool eval_watchlist();
00139     bool eval_watchlist_curr_level();
00140 
00141     void wait_halt();
00142 
00143 };
00144 
00145 //------------------------------------------------------------------------------
00146 //"sc_cthread_process existence chain manipulations"
00147 //
00148 //------------------------------------------------------------------------------
00149 inline sc_cthread_handle sc_cthread_process::next_exist()
00150 {
00151     return (sc_cthread_handle)m_exist_p;
00152 }
00153 
00154 inline void sc_cthread_process::set_next_exist(sc_cthread_handle next_p)
00155 {
00156     m_exist_p = next_p;
00157 }
00158 
00159 //------------------------------------------------------------------------------
00160 //"sc_cthread_process::wait_halt"
00161 //
00162 //------------------------------------------------------------------------------
00163 inline void sc_cthread_process::wait_halt()
00164 {
00165     m_wait_cycle_n = 0;
00166     suspend_me();
00167     throw sc_halt();
00168 }
00169 
00170 } // namespace sc_core
00171 
00172 #endif // !defined(sc_cthread_process_h_INCLUDED)

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