Jump to content

How can I identify which port has changed value when using a multiport

Recommended Posts


When using a multiport port type as follows:

struct M:sc_module{

sc_port<sc_signal_in_if<sc_dt::sc_logic>, 32, SC_ZERO_OR_MORE_BOUND> prt_input;

void end_of_eleaboration(){


for(int i=0;i<prt_input.size();i++)

sensitive << prt_input->value_changed_event();





Is there any way to capture the port index "i" which changed the value and caused the method to be called?



Link to post
Share on other sites

First, you have an error in your example corrected below:

for(int i=0;i<prt_input.size();i++)

  sensitive << prt_input[i]->value_changed_event();


Second, you can use a recent addition to SystemC (if using version 2.3.3 or later) using the new sc_event::triggered() method, which returns true if the event happened in the immediately preceding delta-cycle. You would simply apply this to the default_event() method present in most channels. A less general approach could also be used with sc_signal channel, which has always provided the event() method for the same effect, but won't work on other channels. Of course you can apply this to any method returning events of other types (e.g. sc_fifo_in_if::data_written_event()). This can also be used with SC_THREADs with the sc_event_or_list.

I illustrate the more general approach on EDAplayground here: https://edaplayground.com/x/4kgB

Link to post
Share on other sites


1 hour ago, OMark said:

Unfortunately I am using the SystemC 2.3.1. What is the best solution to capture the triggered event on the multiport and related port index in this case?

@David Black answered this above: The sc_signal_in_if provides member function event(), which "shall return the value true if and only if the value of the channel was written or modified in the immediately preceding delta cycle and at the current simulation time." [IEEE Std 1666-2011, clause 6.13]. I.e., instead of accessing the event and calling triggered(), you could directly call port->event() to check whether an event happened.

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