SumitK Posted March 10, 2017 Report Posted March 10, 2017 Hi With the following code, I am getting the error "Error: (E513) an sc_module_name parameter for your constructor is required" I am not able to understand why ? Can anyone help please #include <iostream> #include <systemc.h> using namespace std; class Foo: public virtual sc_module { public: Foo(sc_module_name val) { } }; class Bar : public virtual sc_module { public: Bar(sc_module_name name) : foo(name) { } Foo foo; }; int sc_main(int argc, char* argv[]){ Bar b("b"); sc_start(); return 0; } Thanks Sumit Quote
Suman Reddy Posted March 10, 2017 Report Posted March 10, 2017 Hey try this alternative solution, its working for me class Bar : public virtual sc_module { Foo foo; public: Bar(sc_module_name a) : foo((const char*)(a)) { } }; I wonder why your solution is not working even though the base class overloaded with sc_module_name parameter constructor Quote
ralph.goergen Posted March 13, 2017 Report Posted March 13, 2017 Hi, You have to forward the module name to the base class constructor: foo(sc_core::sc_module_name name) : sc_module(name) {} Or use SC_CTOR instead. Greetings Ralph Quote
SumitK Posted March 14, 2017 Author Report Posted March 14, 2017 Hi Ralph I tried as you suggested(see below). I still have the same issue. #include <iostream> #include <systemc.h> using namespace std; class Foo: public virtual sc_module { public: Foo(sc_module_name name):sc_module(name) { } }; class Bar : public virtual sc_module { public: Foo foo; Bar(sc_module_name name) : foo(name) { } }; int sc_main(int argc, char* argv[]){ Bar b("b"); sc_start(); return 0; } Thanks Sumit Quote
ralph.goergen Posted March 15, 2017 Report Posted March 15, 2017 Hi Sumit. what you are doing here is a hierarchical module. foo is a member, i.e. a submodule of bar. They should not have the same name. If you want bar to be derived from foo, then derive bar from foo instead of sc_module. Then, you instantiation will work. If you want foo to be a submodule of bar, let the derivation as is but fix your initializer lists. You need to forward the name argument to the base class constructor in every class derived from sc_module, i.e. in bar as well. Furthermore, the submodule foo should not have the same name as its parent bar. // constructor Bar(sc_core::sc_module_name name) : sc_module(name) // forward name to base class constructor , foo("foo") // name submodule foo 'foo' { ... Or use the SC_CTOR macro that handles this for you. Greetings Ralph Quote
Philipp A Hartmann Posted April 11, 2017 Report Posted April 11, 2017 Side note: You can't use virtual inheritance with SystemC modules. See the following thread for a related discussion: Your example doesn't require this, so it should be fine to simply drop the virtual keyword in the sc_module inheritance. Hope that helps, Philipp swami-cst 1 Quote
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.