ashwathgan Posted May 13, 2015 Report Share Posted May 13, 2015 Hi From what I have seen, SystemC throws error while attempting to use Inheritance/polymorphism. For example I have a Task SC_MODULE(Task) { sc_in<bool> in; sc_in<bool> out; void cliamResource() {....} void claimMemory() {......} SC_CTOR(Task) {} }; Like Wise i have a Resource Module : And then I have number of C++ classes( class A, class B which defines each function I am using). But I am not able to inherit these normal c++ classes like SC_MODULE(Task) : public A \\ where A is a Class A {}; Can anyone help me how t sort this out (or) Is it possible to inherit C++ classes ?? I have a error like : class or struct definition is missing Thanks Quote Link to comment Share on other sites More sharing options...
David Black Posted May 13, 2015 Report Share Posted May 13, 2015 Instead of using the SC_MODULE macro, try using a standard declaration: struct Task : sc_core::sc_module, A { ... }; maehne 1 Quote Link to comment Share on other sites More sharing options...
ashwathgan Posted May 18, 2015 Author Report Share Posted May 18, 2015 Thank a lot sir, It worked, but I have a small issue with the constructor For example I have a Base class and I derive it in a SystemC Module as follows: Class Base { int h; void some_function() {..... } and then I have my derived class of SystemC as follows: class TaskA : public sc_module, public base { sc-in<bool> a; sc_out<bool> b; Base b; // Instantiating a object from base Class ... .... SC_CTOR(TaskA) : b ("base") { } }; ERROR: No Default Constructor exists for "base" class. if its is normal c++, I can sort it out, but Im unable to figure out wat to do with this SC_CTOR macro. Thanks Quote Link to comment Share on other sites More sharing options...
matteodc Posted May 18, 2015 Report Share Posted May 18, 2015 Hi, This is the macro: #define SC_CTOR(user_module_name) \ typedef user_module_name SC_CURRENT_USER_MODULE; \ user_module_name( ::sc_core::sc_module_name ) you can use a standard constructor instead of the macro: typedef TaskA SC_CURRENT_USER_MODULE; TaskA(sc_core::sc_module_name name) : sc_module (name), b ("base"){} For your error: When you declare a non-default constructor for a class, the compiler does not generate a default one anymore. So you have to provide your own. Quote Link to comment Share on other sites More sharing options...
ashwathgan Posted May 18, 2015 Author Report Share Posted May 18, 2015 Thanks its fixed now 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.