Jump to content

When exactly an event is servicd


katang

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?

 

Next_event_thread(void)
{
  while(true)
  {
//    DEBUG_PRINT_SC("Waiting for instruction");
    wait(Next_event); 

   ---- // intercept here

      wait(WAIT_TIME);
      MyObject->MEvents->norify();

}

 

 

Link to comment
Share on other sites

Hi,

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

-Eyck

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

Link to comment
Share on other sites

  • 2 months 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...