Oscar Posted March 4, 2017 Report Share Posted March 4, 2017 Hi, i am trying to declare an sc_port from which i want to send a struct (ressource) between two different modules. I declared an interface and a channel to implements the send and receive interface methods but i am experiencing two errors. The first one is C2011 'class ' type redefinition, the second one is C2504 base class undefined. Now the Interface is very simple: //comm_interface.h class comm_send_interface : virtual public sc_interface { public: virtual bool send(ressource) = 0; // send a ressource virtual void reset() = 0; // empty ressource list }; class comm_recv_interface : virtual public sc_interface { public: virtual bool recv(ressource &) = 0; // receive a ressource }; The channel where i implement the methods looks like this: //comm_channel.h #include "comm_interface.h" class comm_channel : public sc_module, public comm_send_interface, public comm_recv_interface { private: ressource rdata[9]; int i; //sc_event send_event, recv_event; public: comm_channel(sc_module_name rc_channel) : sc_module(rc_channel), i(0) {} bool send(ressource r); // write bool recv(ressource & r); // read void reset(); //void register_port(sc_port_base & port_, const char * if_typename_); }; bool comm_channel :: send(ressource r) { if (i < 10) { rdata[i++] = r; //recv_event.notify(); return true; } //wait(send_event); return false; } bool comm_channel :: recv(ressource &r) { if (i > 0) { r = rdata[--i]; return true; //read_event.notify; } return false; } void comm_channel :: reset() { i = 0; } And here i declare the sc_port to send and receive the "ressource". #ifndef ROBOT__H #define ROBOT__H #include "systemc.h" #include "ressource.h" //interface #include "comm_interface.h" struct robot : sc_module { sc_port<comm_recv_interface> rinput; sc_port<comm_send_interface> routput; ressource r; void drill(); void insert(); void tight(); SC_CTOR(robot) { //... }; #endif // ROBOT__H Can you help me with the Problem?! Thanks in advanced! Quote Link to comment Share on other sites More sharing options...
maehne Posted March 5, 2017 Report Share Posted March 5, 2017 Your problem is not SystemC-specific, as you are not following basic rules of C++ programming: To use classes of SystemC like sc_core::sc_interface or sc_core::sc_module, you have to #include the respective header (in our case <systemc>) before. You haven't done so in your headers comm_interface.h and comm_channel.h Also, your headers comm_interface.h and comm_channel.h seem to lack #include guards, which cause the type redefinition errors. I encourage you to not use the header <systemc> and not <systemc.h> to avoid public namespace pollution. Then, you have to prefix most SystemC classes with the sc_core:: namespace prefix. In function scope, you can avoid this by adding "using" declarations for the symbols/namespaces you plan to use in the current scope. AmeyaVS 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.