Jump to content

SC_ID_SC_EXPORT_HAS_NO_INTERFACE_


matteodc

Recommended Posts

Hi,

I have two sc_module s both with an sc_export, templated with tlm::tlm_blocking_put_if<std::vector<bool> > .

I connect the upper level sc_export to the lower level one, in the constructor of the sc_module.

class E_top : sc_core::sc_module, tlm::tlm_blocking_put_if<std::vector<bool> {
   public:
      sc_export< tlm::tlm_blocking_put_if<std::vector<bool> > > in_port;
      E_top(sc_core::sc_module_name name) :
         sc_module ( name),
         in_port("input_port"), 
         m_C_top("c")
      {
         m_payload.reserve(8);
         m_C_top.in_port(in_port); <--it stops here
      }
      virtual void put(const std::vector<bool> &t) {
         m_payload=t;
         in_port->put(m_payload);
       };
   private:
      C_top m_C_top; 
      std::vector<bool> m_payload; 
   };

I guess the interface is null, SC_ID_SC_EXPORT_HAS_NO_INTERFACE_ is a good hint:

 

sc_export.h:

   operator IF& ()
    {
    if ( m_interface_p == 0 )
    {
->        SC_REPORT_ERROR(SC_ID_SC_EXPORT_HAS_NO_INTERFACE_,name());
    }
    return *m_interface_p;
    }

How to solve it?

Thanks

Link to comment
Share on other sites

Ok, I have added this channel:

class chan : public tlm::tlm_blocking_put_if<std::vector<bool>, public sc_core::sc_channel
{
   
 public:
   chan(sc_core::sc_module_name nm) : sc_core::sc_channel(nm) {};
      virtual void put(const std::vector<bool> &t) {
         m_payload=t;
       };
private:
      std::vector<bool> m_payload; 
};

and I have bound it in the C_top sc_module constructor:

in_port(m_C_top.in_port);

It works fine.

Is this the correct way?

Thanks

Link to comment
Share on other sites

As you've noticed and David confirmed, exports need to be bound to an interface implementation before they can be bound hierarchically.

 

I've noticed that you implement the interface already in your "E_top" module (side note: you may want to inherit publicly from sc_module). In this case, you probably intend to bind this implementation to the export?

in_port(*this); // <-- bind E_top implementation to export
m_C_top.in_port(in_port);

This is a fairly well-known modeling pattern together with exports.

 

hth,
Philipp

 

NB: I would recommend to avoid using std::vector<bool>.

Edited by Philipp A. Hartmann
Link to comment
Share on other sites

Thanks David.

 

Thanks Philipp,

I moved the implementation of the interface inside a sc_channel, as I am reusing the same channel in multiple places.

Now the code is similar to this:

typedef std::vector<bool> DATA_TYPE;  
typedef tlm::tlm_blocking_put_if<DATA_TYPE> TLM_BUS_IF_TYPE;
typedef sc_core::sc_export< TLM_BUS_IF_TYPE > TARGET_PORT_TYPE;
typedef sc_core::sc_port< TLM_BUS_IF_TYPE, 0, SC_ZERO_OR_MORE_BOUND > INITIATOR_PORT_TYPE;

...

SC_MODULE(E_top) {
   public:
      TARGET_PORT_TYPE in_port; 
      INITIATOR_PORT_TYPE out_port; 
      SC_CTOR(E_top) :
         in_port("input_port"),
         out_port("output_port"),
         p_e(new e),         
         m_chan("chan",p_e, &out_port)
         {
          in_port.bind(m_chan);  
         }
   private:
      boost::shared_ptr<e> p_e; 
      chan<e> m_chan; //!SystemC Channel
   };

You are right, I will change the DATA_TYPE to be something else.

Thanks

Regards

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