I'm trying to create an abstract SystemC class and multiple derived concrete classes using inheritance. This way I can achieve polymorphism on them and behave them as the same kind of object. When I try to do that I get the error below:
Error: (E109) complete binding failed: port not bound: port 'Module2.port_1' (sc_out)
In file: ../../../src/sysc/communication/sc_port.cpp:235
Below is the MWE to reproduce the error:
#include <systemc>
using namespace sc_core;
class AbstractModule : public sc_module
{
public:
sc_in<double> input;
sc_out<double> output;
AbstractModule(const sc_module_name &name) : sc_module(name) {}
};
class Module1 : public AbstractModule
{
public:
SC_HAS_PROCESS(Module1);
Module1(const sc_module_name &name) : AbstractModule(name)
{ }
};
class Module2 : public AbstractModule
{
public:
SC_HAS_PROCESS(Module2);
Module2(const sc_module_name &name) : AbstractModule(name)
{ }
};
int sc_main(int argc, char *argv[])
{
Module1 m1("Module1");
Module2 m2("Module2");
AbstractModule *am1 = &m1, *am2 = &m2;
sc_start();
return 0;
}
Is there something wrong with the class definitions?