Jump to content

SC_METHOD Dynamic sensitivity modification outside the process


KiranK

Recommended Posts

Hello everyone,

I want to restore a triggered SC_METHOD process to its static sensitivity at immediate notification once some conditions qualify. We can use sc_trigger() to restore its sensitivity to static but in my case it won't help. 

I will elaborate the situation here, assume process A is been triggered to execute at time 't' after 'now', but in between the 't' and 'now', some conditions wants process A to restore it to its static sensitivity and my question is how to do it?

Thanks!

Link to comment
Share on other sites

You can restore a process' sensitivity only while executing the process prior to yielding. If that is the case, simply invoke next_trigger(void). Once you have yielded (returned), you will have to wait until you are triggered. If you don't call next_trigger() at all inside your method, then static sensitivity is implied for the next invocation.

Static sensitivity is really just a precompiled list of of or conditions and is not really different from dynamic sensitivity anyhow. It is called static because it is established prior to the start of simulation (normally during construction). For dynamic processes, it concept is similar, but the "static" list is established prior to sc_spawn.

So a simple solution is to add an event designed to get your waiting SC_METHOD back to reset the sensitivity. This can be done with 1 sc_event and a bool. I will illustrate in a followup post.

Link to comment
Share on other sites

Silly me, I was quite mistaken in my simple solution (and it only took me a few minutes after posting to realize it); however, this exercise reminded me of a 2011 feature: reset. This works for SC_METHOD processes, but is inconvenient for SC_THREADs. I enjoyed working the puzzle.

You can see a full working example here: https://www.edaplayground.com/x/39QM

Outline:

  1. When registering your SC_METHOD process capture the process handle and specify dont_initialize().
  2. At the start of your method implementation, check for the trigger state of reset_event and return immediately if triggered.
  3. To reset static sensitivity, simply issue reset on the process. Include a comment that you are simply interrupting.

Note 1: This assumes you are using a version of SystemC 2.3.3 or later. If using 2.3, you will need to add a bool flag that is set at the time of invoking reset and cleared inside the process upon detection.

Note 2: You could also use reset_signal_is(); however, that would require adding deassertion and would be messier in my opinion.

An alternate and less intrusive method would be to simply add an interrupt event into the sc_event_or_list every time you change sensitivity:

  1. next_trigger(some_event | interrupt_event);
  2. next_trigger(time_delay, interrupt_event);

Unfortunately, this doesn't work for sc_event_and_list; however, you can synthesize that situation with another process. I will leave that for you to figure out.

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