ruwan2 Posted June 30, 2014 Report Share Posted June 30, 2014 Hi, When I try the following module, I find that the blue color initialization works while the red part is used, it does not work. SC_MODULE(mytop) { sc_signal<bool> mysig; sc_clock clk; myclk mod; SC_CTOR(mytop) : mysig("mysig"), mod("mod"), clk("ccllkk", 20, 0.5) { mod.outp(); mod.CLK(clk); } }; SC_MODULE_EXPORT(mytop); .......... SC_MODULE(mytop) { sc_signal<bool> mysig; line 7: sc_clock clk("myclock", 20, 0.5); myclk mod; SC_CTOR(mytop) : mysig("mysig"), mod("mod") { mod.outp(); mod.CLK(clk); } }; SC_MODULE_EXPORT(mytop); ......... When the above red cannot pas compilation, the error messages are: # # clk_g_head.cpp:7: error: expected identifier before string constant # clk_g_head.cpp:7: error: expected ',' or '...' before string constant # clk_g_head.cpp: In constructor 'mytop::mytop(sc_core::sc_module_name)': # clk_g_head.cpp:13: error: no match for call to '(sc_core::sc_in<bool>) (<unresolved overloaded function type>)' # C:\modeltech_10.1c\include\systemc/sc_signal_ports.h:640: note: candidates are: void sc_core::sc_in<bool>::operator()(const sc_core::sc_signal_in_if<bool>&) # C:\modeltech_10.1c\include\systemc/sc_signal_ports.h:649: note: void sc_core::sc_in<bool>::operator()(sc_core::sc_port<sc_core::sc_signal_in_if<bool>, 1, SC_ONE_OR_MORE_BOUND>&) # C:\modeltech_10.1c\include\systemc/sc_signal_ports.h:658: note: void sc_core::sc_in<bool>::operator()(sc_core::sc_port<sc_core::sc_signal_inout_if<bool>, 1, SC_ONE_OR_MORE_BOUND>&) # ** Error: (sccom-6142) Compilation failed. # # # ** Error: C:/modeltech_10.1c/win32/sccom failed. # Error in macro C:\Users\Jeff\modelsim_systemC\clk_gen\run1.do line 25 # C:/modeltech_10.1c/win32/sccom failed. # while executing # "sccom -g myclk.cpp clk_g_head.cpp" # # Model Technology ModelSim SE sccom 10.1c compiler 2012.07 Jul 27 2012 # # Exported modules: # mytop # # Model Technology ModelSim SE sccom 10.1c compiler 2012.07 Jul 27 2012 What is wrong? Please help me because I am new to both SystemC and C++ yet. Thanks again. Quote Link to comment Share on other sites More sharing options...
apfitch Posted June 30, 2014 Report Share Posted June 30, 2014 C++ before C++11 does not allow initialisation of non-static class members at declaration (which is what your red example is trying to do). So you must use a member initializer list (your blue example) regards Alan ruwan2 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.