can i use a variable in repeat operator ?
for example
seq s1;
property check;
@ (posedge clk)
$rose(enable) |-> s1[*no_of_repeatition] |=> $rose(done);
endproperty
can i use a variable in repeat operator ?
for example
seq s1;
property check;
@ (posedge clk)
$rose(enable) |-> s1[*no_of_repeatition] |=> $rose(done);
endproperty
In reply to bassem yasser:
No. The repeat must be a constant. However… See
Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact Home - My cvcblr
See Paper: 1) VF Horizons:PAPER: SVA Alternative for Complex Assertions | Verification Academy
2) http://systemverilog.us/vf/SolvingComplexUsersAssertions.pdf
Bringing this thread back to life…I often see the following solution, but I’m not sure how it impacts performance, and I’m pretty sure it won’t scale beyond variables that are a few bit long.
logic clk;
logic req;
logic ack;
logic [3:0] gap;
genvar gap_count;
generate
for (gap_count = 0; gap_count<$bits(gap); gap_count++)
assert property (@(posedge clk) ((gap == gap_count) && req) |-> ##gap_count ack);
endgenerate
In reply to avidan.efody:
You can also use my sva package in item 1 in my signature below.
Ben
Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact Home - My cvcblr
** SVA Handbook 4th Edition, 2016 ISBN 978-1518681448
…
In reply to bassem yasser:
logic s1;
bit[5:0]no_of_repetition;
property check;
int count=0;
@ (posedge clk)
$rose(enable) |-> (s1,count=count+1)[*1:$] ##1 $rose(done) ##0 (count == no_of_repetition);
endproperty
This is what you meant, I reckon.
In reply to Shubhabrata:
// Bad assertion
(s1,count=count+1)[*1:$] ##1 $rose(done) ##0 (count == no_of_repetition);
required a first_match because if for example, no_of_repetition==4 and s1==1 for 15 cycles, and done occurs at the 7th cycle, the assertion will fail only when s1==0.
//Corrected assertion
property check;
int count=0;
@ (posedge clk)
$rose(enable) |->
first_match((s1,count=count+1)[*1:$] ##1 $rose(done)) ##0 (count == no_of_repetition);
endproperty
In reply to ben@SystemVerilog.us:
Yup, got it. This assertion will fail because I am highlighting infinite consecutive repetition of signal-s1. For this, we need to use first_match, right? But I have read somewhere probably in some thread here or on any website that we use this construct if this problem occurs on the antecedent side. Could you tell me about this?
Another thing, I just observed. The example you mentioned, according to that assertion will fail at the 7th cycle when done will be asserted. But our requirement is something else, I guess. It’s been said that after 4th cycle assertion should pass.
property check;
int count=0;
@ (posedge clk)
$rose(enable) |->
(s1,count=count+1)[*1:$] ##1(count == no_of_repetition) ##0 $rose(done);
endproperty
I think this one is doable and we don’t need to use first_match.
In reply to Shubhabrata:
first_match(s1,count=count+1)[*1:$] ##1(count == no_of_repetition) ##0 $rose(done);
at the very first match of (s1,count=count+1)[*1:$] ##1(count == no_of_repetition) then
if $rose(done) is true assertion PASSes else assertion fails.
No other threads is considered.
Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
** SVA Handbook 4th Edition, 2016 ISBN 978-1518681448
…