Jump to content
Sign in to follow this  

User defined systemc port

Recommended Posts

Hello guys,


I'd like to have an input port whose type is user defined. In the code below, I'm trying to use the user defined class mem_req_c as the input port type.


SC_MODULE(req_buffer_m) {

   sc_in<bool >  clk;
   sc_in<sc_logic >  reset;
   sc_in<sc_logic >  insert;
   sc_in<sc_logic >  remove;
   sc_in<mem_req_c >  din;

//   sc_out<mem_req_c > dout;


Nevertheless, I get the following error when compiling:


g++ -g -Wno-deprecated -Wall -I. -I.. -I/usr/share/systemc-2.3/include -c sc_main.cpp
In file included from /usr/share/systemc-2.3/include/sysc/communication/sc_clock_ports.h:31:0,
                 from /usr/share/systemc-2.3/include/systemc:79,
                 from /usr/share/systemc-2.3/include/systemc.h:244,
                 from sc_main.cpp:8:
/usr/share/systemc-2.3/include/sysc/communication/sc_signal_ports.h: In member function ‘void sc_core::sc_in<DATA>::end_of_elaboration() [with T = mem_req_c]’:
sc_main.cpp:56:1:   instantiated from here
/usr/share/systemc-2.3/include/sysc/communication/sc_signal_ports.h:304:6: error: no matching function for call to ‘sc_trace(sc_core::sc_trace_file*&, const mem_req_c&, std::string&)’
/usr/share/systemc-2.3/include/sysc/communication/sc_signal_ports.h:304:6: note: candidates are:
/usr/share/systemc-2.3/include/sysc/tracing/sc_trace.h:195:1: note: void sc_core::sc_trace(sc_core::sc_trace_file*, const sc_dt::sc_bit&, const string&)
/usr/share/systemc-2.3/include/sysc/tracing/sc_trace.h:195:1: note:   no known conversion for argument 2 from ‘const mem_req_c’ to ‘const sc_dt::sc_bit&’


The error disappears if I declare that mem_req_c is a subclass of sc_logic... but I wonder why this is necessary. Any ideas?

Share this post

Link to post
Share on other sites


As SystemC is basically a C++ library, you could just declare/define an interface

and then have a class that implements that interface. This will in essence create

a custom/user-defined channel. You can then specify what exactly can be carried

via that channel. Hope that helps.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this