Jump to content
matteodc

Can't call wait() in the put method of a tlm_blocking_put_if

Recommended Posts

Hi,

when I try to do this:

typedef tlm::tlm_blocking_put_if<DATA_TYPE> TLM_BUS_IF_TYPE; 

template < class M >
   class chan : public TLM_BUS_IF_TYPE, public sc_core::sc_channel
   {   
    public:
      SC_HAS_PROCESS(chan);
      chan(sc_core::sc_module_name nm) :
      sc_core::sc_channel(nm)
      { 
       SC_THREAD(put); 
      };

         virtual void put(const DATA_TYPE &t) {

                  wait(m_delay); <- it stops here

          };
   };

I get:

 

error C2440: 'static_cast' : cannot convert from 'void (__thiscall E::chan<M>::* )(const E::DATA_TYPE &)' to 'sc_core::SC_ENTRY_FUNC'

 

Any idea?

Thanks

 

Share this post


Link to post
Share on other sites

Methods registered as processes via SC_THREAD are not allowed to have arguments and must have the signature:

void METHODNAME(void);

Think of it this way: When you register a method to be used as a SystemC process, you are telling the simulator kernel to invoke the method for you, and you are also implicitly stating you will not be invoking it yourself.

 

I suspect you simply need to remove the SC_THREAD registration. put(data) will be called from another thread process, and hence does not need a process  locally. If your channel requires a local process, it will need to be something that is not part of the interface class.

Share this post


Link to post
Share on other sites

I have removed SC_THREAD and added a wait() in the put method:

virtual void put(const DATA_TYPE &t) {

                  wait(); <- it stops here

          };

But I get,

SC_REPORT_ERROR( SC_ID_WAIT_NOT_ALLOWED_, "\n        "
             "in SC_METHODs use next_trigger() instead" );
        break;
    }

It is quite clear.

 

If I add next_trigger(), I get:

    SC_REPORT_ERROR( SC_ID_NEXT_TRIGGER_NOT_ALLOWED_, "\n        "
             "in SC_THREADs and SC_CTHREADs use wait() instead" );
    }

And this is the reason I put SC_THREAD..

 

How to solve it?

Thanks

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

×