Jump to content

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?

Link to comment
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.


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...