Jump to content

bind interface to port failed: interface already bound to port error


Recommended Posts

I have a scenario where I have a model (initiator) with following ports

     tlm::tlm_initiator_socket<32,tlm::tlm_base_protocol_types,0,SC_ZERO_OR_MORE_BOUND> Out;

and another model(target) with following ports

     tlm::tlm_target_socket<32,tlm::tlm_base_protocol_types,1,SC_ZERO_OR_MORE_BOUND> In[2];

When I connect them as

initiator_inst->Out.bind(target_inst->In[0]);
initiator_inst->Out.bind(target_inst->In[1]);

I get the following error

Error: (E107) bind interface to port failed: interface already bound to port: port 'init_inst.tlm_base_initiator_socket_0' (tlm_initiator_socket)
In file: ../../../../src/sysc/communication/sc_port.cpp:231
 

In above example, the Out socket has N=0 so it can connect to many number of sockets, then why I get this error

Thanks

SumitJ

Link to comment
Share on other sites

This happens because sc_port overloads operator[]. You need to use sc_vector

tlm::tlm_initiator_socket<32,tlm::tlm_base_protocol_types,0,SC_ZERO_OR_MORE_BOUND> Out;

SC_MODULE(Target) {
    sc_core::sc_vector< tlm::tlm_target_socket<32,tlm::tlm_base_protocol_types,1,SC_ZERO_OR_MORE_BOUND> > In;
	SC_CTOR(Target) : In("In", 2) { ... } //< Number of elemements selected via sc_vector constructor
}


initiator_inst->Out.bind(target_inst->In);

Note: Above is pseudo-code (i.e. not in all the right places), and I have not taken time to verify the detail, but the principle of using sc_vector is correct. You may need to consult the literature.

 

Link to comment
Share on other sites

Hi David

I can not use sc_vector here because in real scenario, I have a interconnect implemented with following ports

tlm::tlm_target_socket<32,tlm::tlm_base_protocol_types,0,SC_ZERO_OR_MORE_BOUND> In;

tlm::tlm_initiator_socket<32,tlm::tlm_base_protocol_types,1,SC_ZERO_OR_MORE_BOUND> Out[N];

and in my platform, there are a case when two Out socket of an interconnect instance connected to same In socket of other interconnect.

Thanks

SumitJ

Link to comment
Share on other sites

  • 3 weeks later...

The problem is that both sockets are binded to same target interface implementation. So:

In[0].get_interface() == In[1].get_interface();

When you bind same interface twice to a single port, SystemC considers this a design error.

Solution depends on your modeling needs. Usually TLM sockets are connected point-to-point and to model interconnect a separate module that forwards transactions from initiator to targets is created.

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.

Guest
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...