c++ - SystemC: Multiple module implementations in single cpp file -
edit: solution found moving sc_has_process(module);
statements .cpp file class definition in header file.
i writing module in systemc has small sub-modules. keep of declarations in single header file, , implementation on single .cpp file. don't think there inherently wrong approach, getting error related use of sc_has_process macro redefining sc_current_user_module.
in file included /.../systemc/2.3.1/include/systemc:72:0, src/decoder.cpp:39: /.../systemc/2.3.1/include/sysc/kernel/sc_module.h:403:30: error: conflicting declaration ‘typedef struct fifo_shift sc_current_user_module’ typedef user_module_name sc_current_user_module ^ src/decoder.cpp:146:1: note: in expansion of macro ‘sc_has_process’ sc_has_process(fifo_shift); ^ /.../systemc/2.3.1/include/sysc/kernel/sc_module.h:403:30: error: ‘sc_current_user_module’ has previous declaration ‘typedef struct decoder sc_current_user_module’ typedef user_module_name sc_current_user_module ^ src/decoder.cpp:50:1: note: in expansion of macro ‘sc_has_process’ sc_has_process(decoder);
the error seems second use of 'sc_has_process'. general format of code follows (with portions removed brevity).
in 'decoder.h':
sc_module(fifo_shift) { public: /* port declarations */ /* variable declarations */ fifo_shift(sc_module_name nm, int chunk_size_in); ~fifo_shift(); /* member functions */ private: /* private variables */ }; /* other modules */ sc_module(decoder) { public: /* port declarations */ /* variable declarations */ decoder(sc_module_name nm, int num_mac_in); // constructor ~decoder(); // destructor /* member functions */ private: /* private variables */ };
in 'decoder.cpp':
/* first use of sc_has_process */ sc_has_process(decoder); decoder::decoder(sc_module_name nm, int num_mac_in) : /* member variable init */ { /* initializing of dynamic variables */ /* connect sub-modules */ /* specify thread process */ sc_thread(do_decoder); sensitive << clk.pos(); } // destructor decoder::~decoder() { /* delete dynamic variables */ } void decoder::do_decoder() { /* process implementation */ } /* second use of sc_has_process */ sc_has_process(fifo_shift); fifo_shift::fifo_shift(sc_module_name nm, int chunk_size_in) : /* member variable init */ { // create thread , specify sensitivity sc_thread(do_fifo_shift); sensitive << clk.pos(); } // destructor fifo_shift::~fifo_shift() { /* delete dynamic variables */ } // function perform opperation void fifo_shift::do_fifo_shift() { /* process implementation */ } /* additional module implementations */
is there way accomplish format multiple implementations of modules in single file using sc_has_process macro? new systemc, hoping there simple solution have not found through searching web.
the ieee 1666-2011 lrm (that standard definition systemc) says
macro sc_has_process shall used within class definition, constructor body, or member function body of module. name of module class being constructed shall passed argument macro. macro invocation shall terminated semicolon.
it looks you're using macro in global scope.
if haven't already, can download copy of lrm here.
Comments
Post a Comment