Jump to content

how can i know which event triggered a process?


Ramarao V

Recommended Posts

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;
};

 

Link to comment
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

Link to comment
Share on other sites

  • 3 weeks later...
  • 4 months later...
On 2/19/2019 at 6:03 PM, Philipp A Hartmann said:

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

Hi Philipp,

This is a great one!,

How can we come to know about the new features being added in every new release? 

Thanks

Link to comment
Share on other sites

7 hours ago, R.Adiga said:

How can we come to know about the new features being added in every new release?

If your company is an Accellera member already, I encourage you to join the SystemC language working group.

Otherwise, you can find some documentation about the changes in the RELEASENOTES file of each release (although this particular feature seems to miss an entry :-/).

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