sc_method_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_method_process.h -- Method process 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_method_process.h,v $
00038 // Revision 1.1.1.1  2006/12/15 20:31:37  acg
00039 // SystemC 2.2
00040 //
00041 // Revision 1.5  2006/04/11 23:13:21  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.4  2006/01/24 20:49:05  acg
00047 // Andy Goodrich: changes to remove the use of deprecated features within the
00048 // simulator, and to issue warning messages when deprecated features are used.
00049 //
00050 // Revision 1.3  2006/01/13 18:44:29  acg
00051 // Added $Log to record CVS changes into the source.
00052 //
00053 
00054 #if !defined(sc_method_process_h_INCLUDED)
00055 #define sc_method_process_h_INCLUDED
00056 
00057 #include "sysc/kernel/sc_process.h"
00058 #include "sysc/kernel/sc_spawn_options.h"
00059 #include "sysc/kernel/sc_cor.h"
00060 #include "sysc/kernel/sc_event.h"
00061 
00062 namespace sc_core {
00063 
00064 // friend function declarations
00065     void sc_method_cor_fn( void* );
00066     void sc_cmethod_cor_fn( void* );
00067     void sc_set_stack_size( sc_method_handle, std::size_t );
00068     class sc_event;
00069     class sc_module;
00070     class sc_process_table;
00071     class sc_process_handle;
00072     class sc_simcontext;
00073     class sc_runnable;
00074 
00075     void next_trigger( sc_simcontext* );
00076     void next_trigger( const sc_event&,
00077                   sc_simcontext* );
00078     void next_trigger( sc_event_or_list&,
00079                   sc_simcontext* );
00080     void next_trigger( sc_event_and_list&,
00081                   sc_simcontext* );
00082     void next_trigger( const sc_time&,
00083                   sc_simcontext* );
00084     void next_trigger( const sc_time&, const sc_event&,
00085                   sc_simcontext* );
00086     void next_trigger( const sc_time&, sc_event_or_list&,
00087                   sc_simcontext* );
00088     void next_trigger( const sc_time&, sc_event_and_list&,
00089                   sc_simcontext* );
00090 
00091 
00092 //==============================================================================
00093 // sc_method_process -
00094 //
00095 //==============================================================================
00096 class sc_method_process : public sc_process_b {
00097     friend void sc_method_cor_fn( void* );
00098     friend void sc_cmethod_cor_fn( void* );
00099     friend void sc_set_stack_size( sc_method_handle, std::size_t );
00100     friend class sc_event;
00101     friend class sc_module;
00102     friend class sc_process_table;
00103     friend class sc_process_handle;
00104     friend class sc_simcontext;
00105     friend class sc_runnable;
00106 
00107     friend void next_trigger( sc_simcontext* );
00108     friend void next_trigger( const sc_event&,
00109                   sc_simcontext* );
00110     friend void next_trigger( sc_event_or_list&,
00111                   sc_simcontext* );
00112     friend void next_trigger( sc_event_and_list&,
00113                   sc_simcontext* );
00114     friend void next_trigger( const sc_time&,
00115                   sc_simcontext* );
00116     friend void next_trigger( const sc_time&, const sc_event&,
00117                   sc_simcontext* );
00118     friend void next_trigger( const sc_time&, sc_event_or_list&,
00119                   sc_simcontext* );
00120     friend void next_trigger( const sc_time&, sc_event_and_list&,
00121                   sc_simcontext* );
00122 
00123   public:
00124     sc_method_process( const char* name_p, bool free_host,
00125         SC_ENTRY_FUNC method_p, sc_process_host* host_p,
00126         const sc_spawn_options* opt_p );
00127 
00128     virtual ~sc_method_process();
00129 
00130     virtual const char* kind() const
00131         { return "sc_method_process"; }
00132 
00133   protected:
00134     virtual void kill_process();
00135     sc_method_handle next_exist();
00136     sc_method_handle next_runnable();
00137     void clear_trigger();
00138     void next_trigger( const sc_event& );
00139     void next_trigger( sc_event_or_list& );
00140     void next_trigger( sc_event_and_list& );
00141     void next_trigger( const sc_time& );
00142     void next_trigger( const sc_time&, const sc_event& );
00143     void next_trigger( const sc_time&, sc_event_or_list& );
00144     void next_trigger( const sc_time&, sc_event_and_list& );
00145     void set_next_exist( sc_method_handle next_p );
00146     void set_next_runnable( sc_method_handle next_p );
00147     void set_stack_size( std::size_t size );
00148     bool trigger_dynamic( sc_event* );
00149 
00150   protected:
00151     sc_cor*                          m_cor;        // Thread's coroutine.
00152     std::size_t                      m_stack_size; // Thread stack size.
00153     std::vector<sc_process_monitor*> m_monitor_q;  // Thread monitors.
00154 
00155   private: // disabled
00156     sc_method_process( const sc_method_process& );
00157     const sc_method_process& operator = ( const sc_method_process& );
00158 
00159 };
00160 
00161 
00162 inline
00163 void
00164 sc_method_process::next_trigger( const sc_event& e )
00165 {
00166     clear_trigger();
00167     e.add_dynamic( this );
00168     m_event_p = &e;
00169     m_trigger_type = EVENT;
00170 }
00171 
00172 inline
00173 void
00174 sc_method_process::next_trigger( sc_event_or_list& el )
00175 {
00176     clear_trigger();
00177     el.add_dynamic( this );
00178     m_event_list_p = &el;
00179     m_trigger_type = OR_LIST;
00180 }
00181 
00182 inline
00183 void
00184 sc_method_process::next_trigger( sc_event_and_list& el )
00185 {
00186     clear_trigger();
00187     el.add_dynamic( this );
00188     m_event_list_p = &el;
00189     m_event_count = el.size();
00190     m_trigger_type = AND_LIST;
00191 }
00192 
00193 inline
00194 void
00195 sc_method_process::next_trigger( const sc_time& t )
00196 {
00197     clear_trigger();
00198     m_timeout_event_p->notify_internal( t );
00199     m_timeout_event_p->add_dynamic( this );
00200     m_trigger_type = TIMEOUT;
00201 }
00202 
00203 inline
00204 void
00205 sc_method_process::next_trigger( const sc_time& t, const sc_event& e )
00206 {
00207     clear_trigger();
00208     m_timeout_event_p->notify_internal( t );
00209     m_timeout_event_p->add_dynamic( this );
00210     e.add_dynamic( this );
00211     m_event_p = &e;
00212     m_trigger_type = EVENT_TIMEOUT;
00213 }
00214 
00215 inline
00216 void
00217 sc_method_process::next_trigger( const sc_time& t, sc_event_or_list& el )
00218 {
00219     clear_trigger();
00220     m_timeout_event_p->notify_internal( t );
00221     m_timeout_event_p->add_dynamic( this );
00222     el.add_dynamic( this );
00223     m_event_list_p = &el;
00224     m_trigger_type = OR_LIST_TIMEOUT;
00225 }
00226 
00227 inline
00228 void
00229 sc_method_process::next_trigger( const sc_time& t, sc_event_and_list& el )
00230 {
00231     clear_trigger();
00232     m_timeout_event_p->notify_internal( t );
00233     m_timeout_event_p->add_dynamic( this );
00234     el.add_dynamic( this );
00235     m_event_list_p = &el;
00236     m_event_count = el.size();
00237     m_trigger_type = AND_LIST_TIMEOUT;
00238 }
00239 
00240 inline
00241 void sc_method_process::set_next_exist(sc_method_handle next_p)
00242 {
00243     m_exist_p = next_p;
00244 }
00245 
00246 inline
00247 sc_method_handle sc_method_process::next_exist()
00248 {
00249     return (sc_method_handle)m_exist_p;
00250 }
00251 
00252 
00253 inline
00254 void sc_method_process::set_next_runnable(sc_method_handle next_p)
00255 {
00256     m_runnable_p = next_p;
00257 }
00258 
00259 inline
00260 sc_method_handle sc_method_process::next_runnable()
00261 {
00262     return (sc_method_handle)m_runnable_p;
00263 }
00264 
00265 } // namespace sc_core
00266 
00267 #endif // !defined(sc_method_process_h_INCLUDED)

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