Hi, Dear,
Recently I am writing an assertion which would be used to check the behavior of a counter - SAMPCNT :
-
SAMPCNT will be inside 0 ~ 255.
-
Once the counter toggled, it will counter down from 255 to 0, previous SAMPCNT always be larger than current SAMPCNT.
-
Once the RESETSAMP asserted, the SAMPCNT will be reset to 255.
So what I write is that :
dpc_sampcnt_behavior_check : assert property ( @(SAMPCNT) (!$isunknown(SAMPCNT)) |->
( SAMPCNT >= 0 && SAMPCNT <= 255 ) &&
( $past(SAMPCNT) > SAMPCNT || ( $past(SAMPCNT) < SAMPCNT && SAMPCNT == 255 && RESETSAMP ) ) )
$display("SAMPCNT = [0x%0h]'d%0d, past(SAMPCNT) = [0x%0h]'d%0d, RESETSAMP = %0d", SAMPCNT, SAMPCNT, $past(SAMPCNT), $past(SAMPCNT), RESETSAMP);
else $error( $psprintf("ERROR RESETSAMP = %0d, SAMPCNT = [0x%0h]'d%0d, past(SAMPCNT) = [0x%0h]'d%0d", RESETSAMP, SAMPCNT, SAMPCNT, $past(SAMPCNT), $past(SAMPCNT)) );
However, I got assertion error as :
ncsim: *E,ASRTST (interface/counter_if.sv,718): (time 4815958196171 FS) Assertion tb_top.if_counter[0].dpc_sampcnt_behavior_check has failed
ERROR RESETSAMP = 0, SAMPCNT = [0xfd]'d253, past(SAMPCNT) = [0x6]'d6 → ERROR Message
SAMPCNT = [0xfc]'d252, past(SAMPCNT) = [0xff]'d255, RESETSAMP = 0 → DISPLAY Message
When I looked at waveform, I just found that the SAMPCNT behave as :
8 → 6 → 255 → 253 → 252 → 250 …
I have two questions :
-
Why the display message and error message is different for $past(SAMPCNT) ? The display message is what I expected …
-
When $past(SAMPCNT) = 6, I definitely expect SAMPCNT = 255, but how can it jump directly to 253 and skip 255 ? In which case, my assertion failed.
I am really thanking for your great help, I need support here, thanks ! thanks ! thanks !