katang Posted May 8, 2018 Report Share Posted May 8, 2018 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(); } Quote Link to comment Share on other sites More sharing options...
Eyck Posted May 9, 2018 Report Share Posted May 9, 2018 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 Quote Link to comment Share on other sites More sharing options...
David Black Posted May 9, 2018 Report Share Posted May 9, 2018 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: notify() immediate notify(SC_ZERO_TIME) at the end of the current delta cycle 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. Quote Link to comment Share on other sites More sharing options...
DS1701 Posted July 10, 2018 Report Share Posted July 10, 2018 Hi @David Black event.cancel(); event.notify(SC_ZERO_TIME); Can you explain it mean when use cancel() above code ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.