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

Share this post


Link to post
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 :-/).

Share this post


Link to post
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...