Reputation: 2774
With reference to question SystemC module not working with SC_THREAD, a timed simulation is imitated using next_trigger()
. As I understood from this article, this restarts the thread after the specified time:
next_trigger(double, sc_time_unit)
: The process shall be triggered when specified time has elapsed.
I.e. it effectively executes the operations after the occurrence of this instruction after the time specified, but also executes the operations found before that instruction. I have the feeling that the repeated utilization of next_trigger
within an SC_THREAD
may result in 'glitches' in the simulation.
Q1: Is my feeling correct?
Q2: Is there another possibility to delay execution (something that suspending the thread for the given time, rather than restarting it)
Upvotes: 0
Views: 766
Reputation: 1054
First of all next_trigger can only be used with SC_METHOD
's as mentioned here:
next_trigger()
is used with process methods, one's which are not threads.
Here are a few pointer's in term of SystemC processes:
SC_METHOD
's are processes which must complete it's execution at one pass.(e.g.: a simple function call)while(1)
loops in SC_METHOD
's.SC_THREAD
's are processes which are separate thread of execution, one must explicitly use wait()
statements here to synchronize the SystemC kernel simulation. This is the place where you will mostly find while(1)
(infinite) loops in use.For suspending the thread for some simulation time you can use the wait()
statement to introduce the perceived delay.
But for better understanding you need to understand the difference between static and dynamic sensitivity in SystemC refer here for more information.
Upvotes: 2