Jump to content
Ramarao V

how can i know which event triggered a process?

Recommended Posts

Hi, All

 

there are 10 array of systemc events 

sc_event e[10]; 

and there is a systemc process which is sensitive above mentioned 10 events

my doubt is how can i know which event triggered my process

Share this post


Link to post
Share on other sites

Simple answer: there really is no straightforward way to do this. Of course if you wanted to get into the internals of the SystemC implementation, it is possible; however, that completely violates the standard.

As to why this is not allowed: performance. The desire to have efficiency overrides the desire for corner cases such as yours.

How can you work around this? Several possible approaches, but here one I would use:

 Create a new event class that adds tracking and an API to access it. This is easy to do if you know your C++ and SystemC well enough.

Trivial outline of concept::

static const sc_core::sc_process_handle NONEXISTANT;
struct Tracked_Event {
    void notify( void ); // sets m_process_handle and notifies m_event
    void notify( sc_core::sc_time delay ); // same except waits for delay
    sc_process_handle get_trigger( void ) { return m_process_handle; }
    void clear( void ) { m_process_handle = NONEXISTANT; };
  private:
    sc_core::sc_event    m_event;
    sc_core::sc_processhandle m_process_handle;
};
struct Event_array
{
    Event_array( int depth );
    void wait( void ); // clears all m_process on entry, then waits for an m_event
    Tracked_event operator[]( int );
    sc_vector<sc_core::sc_process_handle> get_trigger_list( void );
private:
    sc_vector<Tracked_Event> m_event_array;
    sc_core::uint64          m_delta_count;
};

 

Share this post


Link to post
Share on other sites

SystemC 2.3.2 (and later) does support a query whether an event was triggered in the previous delta cycle (or immediately in the current evaluation cycle).  This is similar to the sc_signal<>::event() function.  With this, you can ask every element in your array, whether it was triggered and may have caused a wakeup of the process.  Of course, multiple events can have triggered simultaneously and will only cause a single wakeup of the process.

for( const auto ev& : e ) {
  if ( ev.triggered() ) {
    // ... 
  }
}

Hope that helps,
  Philipp

Share this post


Link to post
Share on other sites

Responding to Phillip:

 I'm guessing this is coming up for the next update of the standard and is currently under consideration. I guess I need to find more time to get synced up to the latest additions since 2.3.

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

×