sc_module.h
来自「基于4个mips核的noc设计」· C头文件 代码 · 共 563 行 · 第 1/2 页
H
563 行
void watching( const sc_signal_bool_deval& s ) { ::watching( s, simcontext() ); } // These are protected so that user derived classes can refer to them. sc_sensitive sensitive; sc_sensitive_pos sensitive_pos; sc_sensitive_neg sensitive_neg; // Function to set the stack size of the current (c)thread process. void set_stack_size( size_t ); int append_port( sc_port_base* );private: bool m_end_module_called; sc_pvector<sc_port_base*>* m_port_vec; int m_port_index; sc_name_gen* m_name_gen; sc_pvector<sc_object*> m_child_objects;public: void defunct() { } // positional binding methods (cont'd) void operator () ( const sc_bind_proxy& p001, const sc_bind_proxy& p002 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p003 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p004 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p005 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p006 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p007 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p008 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p009 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p010 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p011 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p012 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p013 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p014 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p015 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p016 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p017 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p018 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p019 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p020 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p021 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p022 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p023 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p024 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p025 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p026 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p027 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p028 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p029 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p030 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p031 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p032 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p033 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p034 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p035 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p036 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p037 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p038 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p039 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p040 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p041 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p042 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p043 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p044 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p045 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p046 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p047 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p048 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p049 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p050 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p051 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p052 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p053 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p054 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p055 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p056 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p057 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p058 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p059 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p060 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p061 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p062 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p063 = SC_BIND_PROXY_NIL, const sc_bind_proxy& p064 = SC_BIND_PROXY_NIL );};extern sc_module* sc_module_dynalloc(sc_module*);#define SC_NEW(x) sc_module_dynalloc(new x);// this must be undefined for VC6 because it messes up stack when// member functions casts are performed#ifndef SC_USE_MEMBER_FUNC_PTR#ifndef SC_USER_DEFINED_MAX_NUMBER_OF_PROCESSES// the value below defines max number of processes per module#define SC_VC6_MAX_NUMBER_OF_PROCESSES 10#endif// the following code is designed to circumvent the following VC6 bugs:// 1) violation of 9.8/1 about type names lookup// 2) the linkage of the local class static f-n is made external// 3) lack of partial specialization// 4) member functions casts screw up the stack// this helper class has two sets of pointers: one for member functions// and the other for static functions. For each member function a static// function is created that performs conversion and calls member function.template<class T>struct sc_vc6_process_helper_class{ int counter; // array of member functions typedef void (T::*mf_type)(); mf_type mfa[SC_VC6_MAX_NUMBER_OF_PROCESSES]; typedef void (*sf_type)(sc_module* b); // array of static member functions sf_type sfa[SC_VC6_MAX_NUMBER_OF_PROCESSES]; // VC6 lacks partial specialization support // using explicit specialization instead template<int W> struct process_helper { static void smf(sc_module* b) { (static_cast<T*>(b)->*(static_cast<T*>(b)->sc_vc6_process_helper.mfa)[W-1])();} // recursively generate other functions process_helper<W-1> hlp; process_helper(sf_type* sfa_):hlp(sfa_) { sfa_[W-1] = smf; } }; template<> struct process_helper<0> { process_helper<0>(sf_type* sfa){}; }; process_helper<SC_VC6_MAX_NUMBER_OF_PROCESSES> helper; sc_vc6_process_helper_class():helper(sfa){counter = -1;} sc_vc6_process_helper_class& operator = (const sc_vc6_process_helper_class&); sc_vc6_process_helper_class& operator = (mf_type f) { counter++; if(counter>=SC_VC6_MAX_NUMBER_OF_PROCESSES) SC_REPORT_ERROR( SC_ID_VC6_MAX_PROCESSES_EXCEEDED_, sc_string::to_string("%d( max %d)\n" "you can increase this number. For example, to set it to 20 do this\n" "before including ""systemc.h"" in your code include these two lines:\n" "#define SC_USER_DEFINED_MAX_NUMBER_OF_PROCESSES\n" "#define SC_VC6_MAX_NUMBER_OF_PROCESSES 20\n", counter+1, SC_VC6_MAX_NUMBER_OF_PROCESSES).c_str()); mfa[counter]=f; return *this; } operator sf_type () { if(counter<0) SC_REPORT_ERROR( SC_ID_VC6_PROCESS_HELPER_, "Reading before initialization."); return sfa[counter]; }}; #define SC_DECL_HELPER_STRUCT(module_tag, func) \ sc_vc6_process_helper = &module_tag::func#define SC_MAKE_FUNC_PTR(module_tag, func) sc_vc6_process_helper#else#define SC_DECL_HELPER_STRUCT(module_tag, func) /*EMPTY*//* Converting `void (module_tag::*)()' to `void (sc_module::*)()' is OK as long as the dynamic type is correct. C++ Standard 5.4 "Explicit type conversion", clause 7: a pointer to member of derived class type may be explicitly converted to a pointer to member of an unambiguous non-virtual base class type. */#define SC_MAKE_FUNC_PTR(module_tag, func) \ static_cast<SC_ENTRY_FUNC>(&module_tag::func)#endif// To further simplify the syntax, consider the following.#define SC_MODULE(user_module_name) \ struct user_module_name : sc_module#ifdef SC_USE_MEMBER_FUNC_PTR#define SC_CTOR(user_module_name) \ typedef user_module_name SC_CURRENT_USER_MODULE; \ user_module_name( sc_module_name )// the SC_HAS_PROCESS macro call must be followed by a ;#define SC_HAS_PROCESS(user_module_name) \ typedef user_module_name SC_CURRENT_USER_MODULE#else#define SC_CTOR(user_module_name) \ typedef user_module_name SC_CURRENT_USER_MODULE; \ sc_vc6_process_helper_class<user_module_name> sc_vc6_process_helper; \ user_module_name( sc_module_name )// the SC_HAS_PROCESS macro call must be followed by a ;#define SC_HAS_PROCESS(user_module_name) \ typedef user_module_name SC_CURRENT_USER_MODULE; \ sc_vc6_process_helper_class<user_module_name> sc_vc6_process_helper#endif#define declare_thread_process(handle, name, module_tag, func) \ sc_thread_handle handle; \ { \ SC_DECL_HELPER_STRUCT( module_tag, func ); \ handle = simcontext()->register_thread_process( name, \ SC_MAKE_FUNC_PTR( module_tag, func ), this ); \ sc_module::sensitive << handle; \ sc_module::sensitive_pos << handle; \ sc_module::sensitive_neg << handle; \ }#define declare_method_process(handle, name, module_tag, func) \ sc_method_handle handle; \ { \ SC_DECL_HELPER_STRUCT( module_tag, func ); \ handle = simcontext()->register_method_process( name, \ SC_MAKE_FUNC_PTR( module_tag, func ), this ); \ sc_module::sensitive << handle; \ sc_module::sensitive_pos << handle; \ sc_module::sensitive_neg << handle; \ }#define declare_cthread_process(handle, name, module_tag, func, edge) \ sc_cthread_handle handle; \ { \ SC_DECL_HELPER_STRUCT( module_tag, func ); \ handle = simcontext()->register_cthread_process( name, \ SC_MAKE_FUNC_PTR( module_tag, func ), this ); \ sc_module::sensitive.operator() ( handle, edge ); \ }#define SC_THREAD(func) \ declare_thread_process( func ## _handle, \ #func, \ SC_CURRENT_USER_MODULE, \ func )#define SC_METHOD(func) \ declare_method_process( func ## _handle, \ #func, \ SC_CURRENT_USER_MODULE, \ func )#define SC_CTHREAD(func, edge) \ declare_cthread_process( func ## _handle, \ #func, \ SC_CURRENT_USER_MODULE, \ func, \ edge )// ----------------------------------------------------------------------------// TYPEDEFS// ----------------------------------------------------------------------------typedef sc_module sc_channel;typedef sc_module sc_behavior;#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?