Jump to content

When exactly an event is servicd

Recommended Posts

I have an event handling method, It is sensitive to thean event. and generates a notify event, though notiying it,

I want to insert calling a new (lengthy) procedure, for example refreshing the graphic display, or stepwise operation.

That is the chain of  event handling is suspended, I need to change some activity, like pressing the "Step" knob.


Can I keep event handling activity in this without making troubles in handling? Or, is there some tested idea for

implementing an interactive SystemC program?


//    DEBUG_PRINT_SC("Waiting for instruction");

   ---- // intercept here





Share this post

Link to post
Share on other sites


you need to be aware that SystemC does not run threads concurrently rather in an sequential manner. This means other threads and functions are only executed  when your Next_event_thread() is suspended i.e. calls wait(). As long as code gets executed in the '-- // intercept here' region the rest of the simulation is  suspended. This is no issue at all for the simulation.

From your question I derive that you are going to implement a GUI on top of a simulation. Here it is a bad idea to run the GUI in the SystemC simulation (OS-)Thread. It would be better to create an OS-thread running the simulation (essentially the sc_main() function) independent from the GUI thread. But then you need to syncronize the two threads using the usual means (atomic variables, mutexes, semaphores, ...) and let them cmmunicate. This way your GUI will not freeze when the simulation is running.

I hope I got your question right and answered it.

Best regards


Share this post

Link to post
Share on other sites

SystemC behaves in almost identical manner to other event driven simulators (e.g. Verilog and VHDL). The simulator provides a co-operative multitasking model to simplify the programming paradigm. SC_THREAD processes yield by calling wait() and SC_METHOD processes yield by returning.

There are 3 semantics for event notification:

  1. notify() immediate
  2. notify(SC_ZERO_TIME) at the end of the current delta cycle
  3. notify(NON_ZERO) scheduled to occur at a scheduled time in the future

Furthermore, you need to be aware that SystemC is not inherently thread safe.

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