Jump to content
taog

TLM Socket can not be inherited?

Recommended Posts

I want to create a SystemC class as a derivative of another SystemC class like below:

struct A : public sc_module
{
    ...
    tlm_utils::multi_passthrough_target_socket<A, 32, tlm::tlm_base_protocol_types, 0, sc_core::SC_ZERO_OR_MORE_BOUND> tsocket;
    ...
};

struct B : public A
{
    ...
};

struct C : public sc_module

{

  ...
  tlm_utils::multi_passthrough_initiator_socket<C, 32, tlm::tlm_base_protocol_types, 0, sc_core::SC_ZERO_OR_MORE_BOUND> isocket;
  ...

};

Then I need to bind B to C

B b;

C c;

C->isocket.bind(b->tsocket);

But, I will get some runtime error like below:

Error: (E120) sc_export instance has no interface: B.tsocket
In file: /home/tools/vcs/mx-2017.12-1/include/systemc231/sysc/communication/sc_export.h:162

Does SystemC do not support such a use case? Or I only need to do some “cast” to bind this socket? I'm not sure if it will bring some side-effect.

Share this post


Link to post
Share on other sites

You need to register callbacks to them so that they are bound to an interface. See Unbound multi_passthrough_initiator_socket/multi_passthrough_target_socket

In general I would discourage the use of them (or at least suggest to carefully think about their use) as they have several drawbacks: you cannot bind a target socket to a multi_passthrough_target_socket and you cannot bind in before_end_of_elaboration (see also Is there any order requirement for binding multi_passthrough_initiator_sockets?).

BR

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

×