The same example directory contains an example that uses hacprsim's channel features and commands, called channel-source-sink.v, See Channel Commands. The HAC source file contains only declarations for a pair of e1of2 channels – the rest is set up in Verilog.
In the Verilog source, we connect the L and R channel
rails with delay-elements.
Using $prsim_cmd
, we configure L as a source
and R as a sink, as one normally would in an hacprsim session.
Here's the important part!
The channel-reset and channel-release commands
inject events into hacprsim's event queue, however the host Verilog
simulator is not aware of direct updates to that event queue!
(This is also the case when you invoke $prsim_cmd("set ...");
.)
To notify the Verilog simulator and synchronize its main event queue,
we need to invoke $prsim_sync() immediately after any command
that affects the hacprsim event queue,
including channel-reset[-all] and channel-release[-all].
Prior to channel-release[-all],
we also call $prsim_sync() to flush out any remaining
events in hacprsim that have not caught up to the present time.
Until there is any other user-driven change to the hacprsim event queue, there should be no need to call $prsim_sync() again.