00001
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
00055
00056
00057
00058 #ifndef SC_MODULE_H
00059 #define SC_MODULE_H
00060
00061 #include "sysc/kernel/sc_kernel_ids.h"
00062 #include "sysc/kernel/sc_lambda.h"
00063 #include "sysc/kernel/sc_module_name.h"
00064 #include "sysc/kernel/sc_process.h"
00065 #include "sysc/kernel/sc_sensitive.h"
00066 #include "sysc/kernel/sc_time.h"
00067 #include "sysc/kernel/sc_wait.h"
00068 #include "sysc/kernel/sc_wait_cthread.h"
00069 #include "sysc/kernel/sc_process_host.h"
00070 #include "sysc/utils/sc_list.h"
00071 #include "sysc/utils/sc_string.h"
00072
00073
00074 namespace pinapa {
00075 class get_value;
00076 class simcontext;
00077 }
00078
00079
00080 namespace sc_core {
00081
00082 class sc_name_gen;
00083 template<class T> class sc_in;
00084 template<class T> class sc_signal;
00085
00086
00087
00088
00089
00090
00091
00092
00093 struct sc_bind_proxy
00094 {
00095 sc_interface* iface;
00096 sc_port_base* port;
00097
00098 sc_bind_proxy();
00099 sc_bind_proxy( sc_interface& );
00100 sc_bind_proxy( sc_port_base& );
00101 };
00102
00103
00104 extern const sc_bind_proxy SC_BIND_PROXY_NIL;
00105
00106
00107
00108
00109
00110
00111
00112
00113 class sc_module
00114 : public sc_process_host
00115 {
00116 friend class sc_module_name;
00117 friend class sc_module_registry;
00118 friend class sc_object;
00119 friend class sc_port_registry;
00120 friend class sc_simcontext;
00121
00122 public:
00123 sc_simcontext* sc_get_curr_simcontext()
00124 { return simcontext(); }
00125
00126
00127 const char* gen_unique_name( const char* basename_, bool preserve_first );
00128
00129 virtual const char* kind() const
00130 { return "sc_module"; }
00131
00132 protected:
00133
00134
00135 virtual void before_end_of_elaboration();
00136
00137 void construction_done();
00138
00139
00140 virtual void end_of_elaboration();
00141
00142 void elaboration_done( bool& );
00143
00144
00145 virtual void start_of_simulation();
00146
00147 void start_simulation();
00148
00149
00150 virtual void end_of_simulation();
00151
00152 void simulation_done();
00153
00154 void sc_module_init();
00155
00156
00157 sc_module( const char* nm );
00158 sc_module( const std::string& nm );
00159 sc_module( const sc_module_name& nm );
00160 sc_module();
00161
00162 public:
00163
00164
00165 virtual ~sc_module();
00166
00167
00168
00169 sc_module& operator << ( sc_interface& );
00170 sc_module& operator << ( sc_port_base& );
00171
00172 sc_module& operator , ( sc_interface& interface_ )
00173 { return operator << ( interface_ ); }
00174
00175 sc_module& operator , ( sc_port_base& port_ )
00176 { return operator << ( port_ ); }
00177
00178
00179
00180 const ::std::vector<sc_object*>& get_child_objects() const;
00181
00182 protected:
00183
00184 void add_child_object( sc_object* );
00185 void remove_child_object( sc_object* );
00186
00187
00188 void end_module();
00189
00190
00191
00192 void dont_initialize();
00193
00194
00195 void reset_signal_is( const sc_in<bool>& port, bool level );
00196 void reset_signal_is( const sc_signal<bool>& sig, bool level );
00197
00198
00199
00200 void wait()
00201 { ::sc_core::wait( simcontext() ); }
00202
00203
00204
00205
00206 void wait( const sc_event& e )
00207 { ::sc_core::wait( e, simcontext() ); }
00208
00209 void wait( sc_event_or_list& el )
00210 { ::sc_core::wait( el, simcontext() ); }
00211
00212 void wait( sc_event_and_list& el )
00213 { ::sc_core::wait( el, simcontext() ); }
00214
00215 void wait( const sc_time& t )
00216 { ::sc_core::wait( t, simcontext() ); }
00217
00218 void wait( double v, sc_time_unit tu )
00219 { ::sc_core::wait( sc_time( v, tu, simcontext() ), simcontext() ); }
00220
00221 void wait( const sc_time& t, const sc_event& e )
00222 { ::sc_core::wait( t, e, simcontext() ); }
00223
00224 void wait( double v, sc_time_unit tu, const sc_event& e )
00225 { ::sc_core::wait(
00226 sc_time( v, tu, simcontext() ), e, simcontext() ); }
00227
00228 void wait( const sc_time& t, sc_event_or_list& el )
00229 { ::sc_core::wait( t, el, simcontext() ); }
00230
00231 void wait( double v, sc_time_unit tu, sc_event_or_list& el )
00232 { ::sc_core::wait( sc_time( v, tu, simcontext() ), el, simcontext() ); }
00233
00234 void wait( const sc_time& t, sc_event_and_list& el )
00235 { ::sc_core::wait( t, el, simcontext() ); }
00236
00237 void wait( double v, sc_time_unit tu, sc_event_and_list& el )
00238 { ::sc_core::wait( sc_time( v, tu, simcontext() ), el, simcontext() ); }
00239
00240
00241
00242
00243 void next_trigger()
00244 { ::sc_core::next_trigger( simcontext() ); }
00245
00246
00247
00248
00249 void next_trigger( const sc_event& e )
00250 { ::sc_core::next_trigger( e, simcontext() ); }
00251
00252 void next_trigger( sc_event_or_list& el )
00253 { ::sc_core::next_trigger( el, simcontext() ); }
00254
00255 void next_trigger( sc_event_and_list& el )
00256 { ::sc_core::next_trigger( el, simcontext() ); }
00257
00258 void next_trigger( const sc_time& t )
00259 { ::sc_core::next_trigger( t, simcontext() ); }
00260
00261 void next_trigger( double v, sc_time_unit tu )
00262 { ::sc_core::next_trigger(
00263 sc_time( v, tu, simcontext() ), simcontext() ); }
00264
00265 void next_trigger( const sc_time& t, const sc_event& e )
00266 { ::sc_core::next_trigger( t, e, simcontext() ); }
00267
00268 void next_trigger( double v, sc_time_unit tu, const sc_event& e )
00269 { ::sc_core::next_trigger(
00270 sc_time( v, tu, simcontext() ), e, simcontext() ); }
00271
00272 void next_trigger( const sc_time& t, sc_event_or_list& el )
00273 { ::sc_core::next_trigger( t, el, simcontext() ); }
00274
00275 void next_trigger( double v, sc_time_unit tu, sc_event_or_list& el )
00276 { ::sc_core::next_trigger(
00277 sc_time( v, tu, simcontext() ), el, simcontext() ); }
00278
00279 void next_trigger( const sc_time& t, sc_event_and_list& el )
00280 { ::sc_core::next_trigger( t, el, simcontext() ); }
00281
00282 void next_trigger( double v, sc_time_unit tu, sc_event_and_list& el )
00283 { ::sc_core::next_trigger(
00284 sc_time( v, tu, simcontext() ), el, simcontext() ); }
00285
00286
00287
00288
00289 bool timed_out()
00290 { return ::sc_core::timed_out( simcontext() ); }
00291
00292
00293
00294
00295 void halt()
00296 { ::sc_core::halt( simcontext() ); }
00297
00298 void wait( int n )
00299 { ::sc_core::wait( n, simcontext() ); }
00300
00301 void wait_until( const sc_lambda_ptr& l )
00302 { ::sc_core::wait_until( l, simcontext() ); }
00303
00304 void wait_until( const sc_signal_bool_deval& s )
00305 { ::sc_core::wait_until( s, simcontext() ); }
00306
00307 void at_posedge( const sc_signal_in_if<bool>& s )
00308 { ::sc_core::at_posedge( s, simcontext() ); }
00309
00310 void at_posedge( const sc_signal_in_if<sc_dt::sc_logic>& s )
00311 { ::sc_core::at_posedge( s, simcontext() ); }
00312
00313 void at_negedge( const sc_signal_in_if<bool>& s )
00314 { ::sc_core::at_negedge( s, simcontext() ); }
00315
00316 void at_negedge( const sc_signal_in_if<sc_dt::sc_logic>& s )
00317 { ::sc_core::at_negedge( s, simcontext() ); }
00318
00319 void watching( const sc_lambda_ptr& l )
00320 { ::sc_core::watching( l, simcontext() ); }
00321
00322 void watching( const sc_signal_bool_deval& s )
00323 { ::sc_core::watching( s, simcontext() ); }
00324
00325
00326
00327 sc_sensitive sensitive;
00328 sc_sensitive_pos sensitive_pos;
00329 sc_sensitive_neg sensitive_neg;
00330
00331
00332 void set_stack_size( size_t );
00333
00334 int append_port( sc_port_base* );
00335
00336 private:
00337 sc_module( const sc_module& );
00338
00339 private:
00340
00341 bool m_end_module_called;
00342 sc_pvector<sc_port_base*>* m_port_vec;
00343 int m_port_index;
00344 sc_name_gen* m_name_gen;
00345 sc_pvector<sc_object*> m_child_objects;
00346
00347 public:
00348
00349 void defunct() { }
00350
00351
00352
00353 void operator () ( const sc_bind_proxy& p001,
00354 const sc_bind_proxy& p002 = SC_BIND_PROXY_NIL,
00355 const sc_bind_proxy& p003 = SC_BIND_PROXY_NIL,
00356 const sc_bind_proxy& p004 = SC_BIND_PROXY_NIL,
00357 const sc_bind_proxy& p005 = SC_BIND_PROXY_NIL,
00358 const sc_bind_proxy& p006 = SC_BIND_PROXY_NIL,
00359 const sc_bind_proxy& p007 = SC_BIND_PROXY_NIL,
00360 const sc_bind_proxy& p008 = SC_BIND_PROXY_NIL,
00361 const sc_bind_proxy& p009 = SC_BIND_PROXY_NIL,
00362 const sc_bind_proxy& p010 = SC_BIND_PROXY_NIL,
00363 const sc_bind_proxy& p011 = SC_BIND_PROXY_NIL,
00364 const sc_bind_proxy& p012 = SC_BIND_PROXY_NIL,
00365 const sc_bind_proxy& p013 = SC_BIND_PROXY_NIL,
00366 const sc_bind_proxy& p014 = SC_BIND_PROXY_NIL,
00367 const sc_bind_proxy& p015 = SC_BIND_PROXY_NIL,
00368 const sc_bind_proxy& p016 = SC_BIND_PROXY_NIL,
00369 const sc_bind_proxy& p017 = SC_BIND_PROXY_NIL,
00370 const sc_bind_proxy& p018 = SC_BIND_PROXY_NIL,
00371 const sc_bind_proxy& p019 = SC_BIND_PROXY_NIL,
00372 const sc_bind_proxy& p020 = SC_BIND_PROXY_NIL,
00373 const sc_bind_proxy& p021 = SC_BIND_PROXY_NIL,
00374 const sc_bind_proxy& p022 = SC_BIND_PROXY_NIL,
00375 const sc_bind_proxy& p023 = SC_BIND_PROXY_NIL,
00376 const sc_bind_proxy& p024 = SC_BIND_PROXY_NIL,
00377 const sc_bind_proxy& p025 = SC_BIND_PROXY_NIL,
00378 const sc_bind_proxy& p026 = SC_BIND_PROXY_NIL,
00379 const sc_bind_proxy& p027 = SC_BIND_PROXY_NIL,
00380 const sc_bind_proxy& p028 = SC_BIND_PROXY_NIL,
00381 const sc_bind_proxy& p029 = SC_BIND_PROXY_NIL,
00382 const sc_bind_proxy& p030 = SC_BIND_PROXY_NIL,
00383 const sc_bind_proxy& p031 = SC_BIND_PROXY_NIL,
00384 const sc_bind_proxy& p032 = SC_BIND_PROXY_NIL,
00385 const sc_bind_proxy& p033 = SC_BIND_PROXY_NIL,
00386 const sc_bind_proxy& p034 = SC_BIND_PROXY_NIL,
00387 const sc_bind_proxy& p035 = SC_BIND_PROXY_NIL,
00388 const sc_bind_proxy& p036 = SC_BIND_PROXY_NIL,
00389 const sc_bind_proxy& p037 = SC_BIND_PROXY_NIL,
00390 const sc_bind_proxy& p038 = SC_BIND_PROXY_NIL,
00391 const sc_bind_proxy& p039 = SC_BIND_PROXY_NIL,
00392 const sc_bind_proxy& p040 = SC_BIND_PROXY_NIL,
00393 const sc_bind_proxy& p041 = SC_BIND_PROXY_NIL,
00394 const sc_bind_proxy& p042 = SC_BIND_PROXY_NIL,
00395 const sc_bind_proxy& p043 = SC_BIND_PROXY_NIL,
00396 const sc_bind_proxy& p044 = SC_BIND_PROXY_NIL,
00397 const sc_bind_proxy& p045 = SC_BIND_PROXY_NIL,
00398 const sc_bind_proxy& p046 = SC_BIND_PROXY_NIL,
00399 const sc_bind_proxy& p047 = SC_BIND_PROXY_NIL,
00400 const sc_bind_proxy& p048 = SC_BIND_PROXY_NIL,
00401 const sc_bind_proxy& p049 = SC_BIND_PROXY_NIL,
00402 const sc_bind_proxy& p050 = SC_BIND_PROXY_NIL,
00403 const sc_bind_proxy& p051 = SC_BIND_PROXY_NIL,
00404 const sc_bind_proxy& p052 = SC_BIND_PROXY_NIL,
00405 const sc_bind_proxy& p053 = SC_BIND_PROXY_NIL,
00406 const sc_bind_proxy& p054 = SC_BIND_PROXY_NIL,
00407 const sc_bind_proxy& p055 = SC_BIND_PROXY_NIL,
00408 const sc_bind_proxy& p056 = SC_BIND_PROXY_NIL,
00409 const sc_bind_proxy& p057 = SC_BIND_PROXY_NIL,
00410 const sc_bind_proxy& p058 = SC_BIND_PROXY_NIL,
00411 const sc_bind_proxy& p059 = SC_BIND_PROXY_NIL,
00412 const sc_bind_proxy& p060 = SC_BIND_PROXY_NIL,
00413 const sc_bind_proxy& p061 = SC_BIND_PROXY_NIL,
00414 const sc_bind_proxy& p062 = SC_BIND_PROXY_NIL,
00415 const sc_bind_proxy& p063 = SC_BIND_PROXY_NIL,
00416 const sc_bind_proxy& p064 = SC_BIND_PROXY_NIL );
00417
00418 };
00419
00420 extern sc_module* sc_module_dynalloc(sc_module*);
00421 #define SC_NEW(x) ::sc_core::sc_module_dynalloc(new x);
00422
00423
00424
00425
00426
00427
00428 #define SC_MODULE(user_module_name) \
00429 struct user_module_name : ::sc_core::sc_module
00430
00431 #define SC_CTOR(user_module_name) \
00432 \
00433 friend class ::pinapa::get_value; \
00434 \
00435 typedef user_module_name SC_CURRENT_USER_MODULE; \
00436 user_module_name( ::sc_core::sc_module_name )
00437
00438
00439 #define SC_HAS_PROCESS(user_module_name) \
00440 \
00441 friend class ::pinapa::get_value; \
00442 \
00443 typedef user_module_name SC_CURRENT_USER_MODULE
00444
00445
00446 #define declare_method_process(handle, name, host_tag, func) \
00447 { \
00448 ::sc_core::sc_method_process* handle = \
00449 simcontext()->register_method_process( name, \
00450 SC_MAKE_FUNC_PTR( host_tag, func ), this ); \
00451 sensitive << handle; \
00452 sensitive_pos << handle; \
00453 sensitive_neg << handle; \
00454 }
00455
00456 #define declare_thread_process(handle, name, host_tag, func) \
00457 { \
00458 ::sc_core::sc_thread_process* handle = \
00459 simcontext()->register_thread_process( name, \
00460 SC_MAKE_FUNC_PTR( host_tag, func ), this ); \
00461 sensitive << handle; \
00462 sensitive_pos << handle; \
00463 sensitive_neg << handle; \
00464 }
00465
00466 #define declare_cthread_process(handle, name, host_tag, func, edge) \
00467 { \
00468 ::sc_core::sc_cthread_process* handle = \
00469 simcontext()->register_cthread_process(name, \
00470 SC_MAKE_FUNC_PTR( host_tag, func ), this ); \
00471 sensitive.operator() ( handle, edge );\
00472 }
00473
00474 #define SC_CTHREAD(func, edge) \
00475 declare_cthread_process( func ## _handle, \
00476 #func, \
00477 SC_CURRENT_USER_MODULE, \
00478 func, \
00479 edge )
00480
00481 #define SC_METHOD(func) \
00482 declare_method_process( func ## _handle, \
00483 #func, \
00484 SC_CURRENT_USER_MODULE, \
00485 func )
00486
00487 #define SC_THREAD(func) \
00488 declare_thread_process( func ## _handle, \
00489 #func, \
00490 SC_CURRENT_USER_MODULE, \
00491 func )
00492
00493
00494
00495
00496
00497
00498
00499 typedef sc_module sc_channel;
00500 typedef sc_module sc_behavior;
00501
00502 }
00503
00504 #endif