In SystemC, what is the syntax to use events as module input/outputs.
I have a worker module and I want to send it an event to preempt what it's currently doing from a scheduler module.
sc_port<preempt_event_if> preempt_event;
I'm declaring an interface within the worker module shown above.
The interface is defined as the following:
class preempt_event_if : virtual public sc_interface
{
public:
virtual const sc_event& preempt_event() const = 0;
};
The channel which uses the event defines it as the following:
const sc_event& preempt_event() const { return preempt_interrupt; }
Which where preempt_interrupt is a SystemC event that gets notified from within the channel's functions.
SystemC events are used mainly to schedule a process for execution and do not hold any state that can be queried, so there is nothing for you to know if the event has occurred or not.
You need to use a
sc_bufferfor that purpose. Just declare an input port ofbooltype in the worker:and an output port of
booltype in the scheduler:and bind both to a buffer instance:
In the scheduler module you can write a value of
trueto that buffer:and in the worker you can check for
posedgecondition or wait forposedge_event: