I am a beginner with assertions. I was trying to write an assertion to ensure a signal comes up only a fixed number of times. For example 5 times in 100 clock cycles. When I wrote down the assertion, I found one more thing which I am not able to understand:
property p (bit ck1, bit ck2);
@(posedge ck2) (ck2==1);
endproperty
This property always evaluates to FAIL when asserted even though we wait for posedge on the same signal.
So my question is 2 fold:
How do I write the assertion to ensure a signal comes up only n times in 100 clock cycles. For example n = 5.
Why does the property above always evaluate to fail when asserted? - Is it possible to clock on the same signal and assert a property on the same signal?
In reply to sphen:
The reason your assertion always fails is that the Boolean expression (ck2==1) uses the sampled value of ck2, which is the value it has at the beginning of the of the time slot when @(posedge cl2) happens. So that will always be 0 (or X).
You need to be more specific about your condition, but I’ll assume you meant to say you want to check when signal is true n time in any overlapping 100 clock cycles. The most efficient way to do that would be to create 100 bit shift register with a 1 set each time your signal is true and assert that the count of ones is 5.
Hi Dave, I was studying this problem too, and thought that that Nonconsecutive operator would be a robust way to check that the signal in question was asserted 5 times;
Nonconsecutive Repetition
Nonconsecutive repetition specifies finitely many iterative matches of the operand Boolean expression, with a delay of one or more clock ticks from one match of the operand to the next successive match and no match of the operand strictly in between. The overall repetition sequence matches at or after the last iterative match of the operand, but before any later match of the operand.
In reply to ljgiordano:
The repetition operators have two problems with the requirement here.
There are no cycle bounds for the overall operation. You would have to create a counter to count the number of cycles. And the repetition operators are good for matching “at least N” repetitions - you need a little more to catch the extra occurrences.