Jump to content

How to force the update of a sc_signal<bool>?


Diego

Recommended Posts

Hello, 

I'm implementing a class where I want to expose the state of a module, which is determined by a sc_signal<bool>. The closed/opened state of an electrical sca_rswitch to be more precise. The API client must be able to set the state and reads the same value if a get is called.

As far as I understood, doing the following is not enough, because the signal will be updated only in the "update" phase.

sc_signal<bool> my_signal;
my_signal =  true;
ASSERT(signal, true);


My question is how can I manually force the update phase? I've been using sc_start with zero time to achieve this:

sc_signal<bool> my_signal;
my_signal =  true;
sc_start(sc_core::SC_ZERO_TIME);
ASSERT(signal, true);

But I believe there's a better way. It has also the drawback that after doing this, the simulation is already started, which limits the manipulation of other parameters.

I appreciate any feedback. Thanks

Link to comment
Share on other sites

Because I need to bind it with a sc_in<bool>. Reading the documentation I understood that it would be necessary to bind it with a sc_signal<bool>. I've just try binding with a pure bool and it does not seems to compile. Am I missing something?

Link to comment
Share on other sites

sc_signal is designed to model concurrent assignment and therefore requires update at the after the current delta cycle completes. What you are asking for is a channel that doesn't care about race conditions. For that you can write your own implementation, but it sounds dangerous to me.

If you don't understand the above, you probably need to either read the standard specification thoroughly or take a god course on SystemC fundamentals. SystemC is not something you can just learn on the job. I've seen too many engineers fall flat on their faces due to misunderstanding the fundamentals of discrete event-driven simulation and the mechanisms of SystemC.

Make sure you have a solid C++ background as well.

 

Link to comment
Share on other sites

  • 4 weeks later...

@Diego: What the above replies by @karthickg and @David Black are not taking into account is that you are using the sca_eln:sca_de::sca_rswitch from the SystemC AMS extensions. Its ctrl input will get sampled with the time step associated with the cluster of instantiated ELN modules. Therefore, you need to ensure that the SystemC simulation time advances when executing your embedded software in the TLM/DE part of your model. To this end, you will need to issue wait statements in the appropriate places, e.g., inside the instruction set simulator / CPU model executing your embedded software or inside the API calls, which interact with the hardware. It heavily depends on the modeling style of the rest of your system. Anyway, reading the boolean control signal in the get() member function is the right approach to reflect the state of the sca_rswitch.

Link to comment
Share on other sites

  • 2 weeks later...

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