I have a test bench with an event counter that can be triggered by multiple tasks. I want to count all the events - even simultaneous ones.
Something like this:
module top;
event incr_cnt_now;
int total_cnt;
always @ (incr_cnt_now)
total_cnt++;
// in task a
@ (posedge clk)
if (some_condition)
-> incr_cnt_now;
// in task b
@ (posedge clk)
if (some_other_condition)
-> incr_cnt_now;
The problem is that if the two (or more in the real code) event triggers happen at the exact same time, total_cnt is only incremented once. I've looked at the LRM and some websites and tried .triggered and nonblocking events (->>) but I'm obviously missing something. I have a temporary hack with multiples of #1 (assuming that's the global precision) in the different tasks but that's really ugly.
Please set me straight!