Jump to content

thread resets and events

Recommended Posts

Hi all, 

question about sc threads and events: 

In a Testbench monitor, i have something like this: 

  Monitor(const sc_module_name& n) 
    : Monitor_base(n)
    sensitive << clk.pos();

Somewhere deep in proc(), there is a wait like this: 


During the simulation, a synchronous reset is issued while proc() is waiting on the abovee negedge_event.

The reset is missed by proc(). 

This behavior is exhibited by both accellera and commercial simulators. 

I can easily re-write the code to a do-while loop and resovle the issue, but was just wondering, is this by design.

Is waiting on a specific event overriding all reset specs - is this by design or could this be revisited? 

thanks and regards, Fred

Share this post

Link to post
Share on other sites

Hello @fdoucet,

What your are trying to do here in this specific scenario is known as dynamic sensitivity.

Dynamic sensitivity replaces the default sensitivity of the registered SystemC process, once the event it triggered the default sensitivity would be restored for the corresponding process.

Here is a reference to the discussion before in this forum:


Hope it helps


Ameya Vikram Singh

Share this post

Link to post
Share on other sites

Hi Fred,

synchronous resets are indeed not triggering the process themselves (that's why it's called "synchronous) and instead are only checked when the process is triggered through other means.  Typically, this would be a trigger from the static sensitivity (clk.pos() in your case).

As @AmeyaVS correctly pointed out, dynamic sensitivity replaces the triggering behavior (not the reset specs).  So your synchronous reset would be checked only, when some_signal is de-asserted.  Asynchronous resets continue to fire.

A polling loop would be the most accurate way to model your design wrt. resets. If you know the reset signals at the point of that wait statement, you can approximate the behavior by waiting for either the signal or the reset (which will then reset the process)

wait( some_signal.negedge_event() | rst_n.negedge_event() );

Of course, this might be one clock cycle off.  To be correct, you need to have an event that's synchronous to the clock again:

sc_event thread_rst_ev;

  sensitive << clk.pos();

// ...

void thread_sync_reset() {
  if (rst_n == false)

// ...
wait( some_signal.negedge_event() | thread_rst_ev );

By the way: a smart wait_until( some_signal == false ), which supports (synchronous) resets and avoids polling internally would be a very useful feature for writing signal-level protocols.

Greetings from Duisburg,

Share this post

Link to post
Share on other sites

Hi guys, thanks for the reply. 

i agree wait_until is exactly what i'd need here (with support for multiple resets)

Long time ago, was there a wait_until() (implemented as a do/watching) constructs that got deprecated? 

regards, Fred

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