00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
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
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
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;
00152 std::size_t m_stack_size;
00153 std::vector<sc_process_monitor*> m_monitor_q;
00154
00155 private:
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 = ⪙
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 = ⪙
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 = ⪙
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 = ⪙
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 }
00266
00267 #endif // !defined(sc_method_process_h_INCLUDED)