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