I have stumbled upon e code written like that:
event a is cycle @b;
Removing the 'cycle' from this event, made no difference in behavior.
What is the meaning of cycle here?
Thanks
I have stumbled upon e code written like that:
event a is cycle @b;
Removing the 'cycle' from this event, made no difference in behavior.
What is the meaning of cycle here?
Thanks
From the e LRM:
"Represents one cycle of an event. With no explicit sampling event specified, this represents one cycle of the default sampling event. With a sampling event specified, cycle is equivalent to “@sampling-event @any”. You can use the cycle expression to override the default sampling event taken from the context."
A use for it is the following:
some_tcm() @clk is {
message(LOW, "This is synced at clock");
wait @rise_async;
message(LOW, "This is synced at the first clk after rise_async");
wait cycle @rise_async;
message(LOW, "This is synced exactly at rise_async");
stop_run();
};
some_tcm()
specifies @clk
as a sampling event. Say you have another asynchronous event @rise_async
which will get triggered in between clock edges. If you do a simple wait @rise_async
the TCM will wait until the first trigger of @clk
after @rise_async
(effectively a @rise_async @clk
). If you do a wait cycle @rise_async
, then you have overridden the sampling event and the TCM will wait exactly until @rise_async
happens.
"event a is cycle @b;" is a trick to respond to event triggering, but do so at the end of the current tick. For example, the following code would print "hello world", instead of "world hello" if we did "on b".
event b;
event a is cycle @b;
foo() is {
emit b;
message(NONE, "hello");
};
on a {
message(NONE, "world");
};