Systemverilog assertions

Hello,
I have written the assertion for the following scenario and for some clock ticks the assertions are failing ,please correct me if i have written the assertion wrong.

consider these signals [15:0]signal,[4:0]a,b,c
a= signal[0:4] i.e 5bits
b= signal[5:9] i.e 5bits
c =signal[10:14] 5bits
scenario:**when a is equal to any value from o to 31 ,then in the next 4 cycles ,either b or c should be equal to a and in these 4 cycles a value should not be equal to previous value.
**
example : when a==25, then in the next 4 cycles ,either b==25 or c==25 and in these 4 cycles a !=25

 
property p;
   @(posedge CLK) (a==5'd1||a==5'b0) |=> ##[0:3]( ((b==$past(a,1)) ||(c==$past(a,1))) &&(!$stable(a)) );
endproperty

In reply to vinayks:
How is (a==5’d1||a==5’b0) anywhere close to meaning “a is equal to any value from 0 to 31”
Based on your example, I think you meant to say:

“When a is equal to any value from 0 to 31 ,then in the next 4 cycles ,either b or c should be equal to what a was in the first cycle, and a cannot be the same as it was in the first cycle.”

property p;
   int v;
   @(posedge CLK) (a inside {0:31]}, v = a) |=> (v inside {b,c} && a != v)[*4];
endproperty

In reply to dave_59:

yea dave your understanding is correct i was meant to say “a” can take any values from 0 to 31.

I tried this logic,the assertions are failing through out the simulation.

one more doubt is when ever a changes,whether v will change or it will be a constant through out the 4 cycles.

In reply to vinayks:

I would really help to show a complete example showing examples of when your assertion should pass and when it should not

In reply to dave_59:
testbench http://SystemVerilog.us/vf/a4bc.sv


 // "When a is equal to any value from 0 to 31 ,then in the next 4 cycles ,
  //either b or c should be equal to what a was in the first cycle, 
  // and a cannot be the same as it was in the first cycle."
 property p_a4bc;
    int v;
    @(posedge clk) (a inside {[0:31]}, v = a) |-> ##[1:4] (v == b || v==c) and 
                                                  ##1 (a != v)[*4];
 endproperty
 ap_p_a4bc: assert property(p_a4bc);  

http://SystemVerilog.us/vf/a4bc.sv
Image: http://SystemVerilog.us/vf/a4bc.png

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact http://cvcblr.com/home.html
** SVA Handbook 4th Edition, 2016 ISBN 978-1518681448

  1. SVA Package: Dynamic and range delays and repeats SVA: Package for dynamic and range delays and repeats - SystemVerilog - Verification Academy
  2. Free books: Component Design by Example https://rb.gy/9tcbhl
    Real Chip Design and Verification Using Verilog and VHDL($3) https://rb.gy/cwy7nb
  3. Papers:

In reply to ben@SystemVerilog.us:

Is this the correct SVA based on the problem statement?
we store a value in cycle1 and then in
cycle2,3,4,5 we have one of b or c matching the a value in cycle1 and we also ensured ‘a’ value in cycles 2-5 is not matching it’s value in cycle1

we use [*4] as we are maintaining the check for 4 cycles from 2-5. Based on the problem statement it looks like a hard constraint to maintain the check for 4 consecutive cycles and is not optional. If it was optional then using ##[m:n] was appropriate.

Please correct me if I am wrong.

property p_a4bc;
int v;
@(posedge clk) (a inside {[0:31]}, v = a) |=> ((v == b || v==c) and (a != v))[*4];
//cycle1 //cycle2,3,4,5
endproperty
ap_p_a4bc: assert property(p_a4bc);

In reply to hsam:

  • Different meaning
|=> ((v == b || v==c) and (a != v))[*4];
// Above says the 1 cycle sequence (v == b || v==c) is sequence ANDed
// with the 1 cycle sequence (a != v)
// That ANDing is repeated 4 times.
// For success, the match MUST occur at everyone of those cycles.
// Note: Because these are 1 cycle occurrences, I claim that the consequent is equivalent to
((v == b || v==c) && (a != v))[*4];
// This is not you intent, per your requirements
//
##[1:4] (v == b || v==c) and
##1 (a != v)[*4];
// Says, I have 2 concurrent sequences, each lasts 4 cycles.
// In these 4 cycles, two things must occur:
// 1) v == b || v==c) must occur at least once
// 2) (a != v)  must occur during all these 4 cycles.
//
// .. Based on the problem statement it looks like a hard constraint to maintain
// the check for 4 consecutive cycles and is not optional.
// If it was optional then using ##[m:n] was appropriate.
property p_a4bc_optional;
int v;
@(posedge clk) (a inside {[0:31]}, v = a) |->
##[1:4] (v == b || v==c) and // (v == b || v==c)  occurs at least once
##[1:4] (a != v); // a !=v occurss at least once
endproperty
ap_p_a4b_optional: assert property(p_a4bc_optional)

  • You use the non-overlapping implication operator |=>
    I generally prefer to use the overlapping implication operator |->
    Note:****|=> is equivalent to ##1 |->
    This is because the consequent is a property. Using the incorrect equivalent of |-> ##1
    you would get antecedent |-> ##1 property. and that is illegal
  • The reason I prefer (personal preference) to use the |-> ##1 sequence
    is because it read better. It’s similar to if(antecedent_is _a_match) then at next cycle.
    There is no mental effort to go through the conversion of what this |=> is, though I know what it is. For example,

a |=> ##[0:3] b; // reads as at next, then from that current point to the next 3 cycles
a |-> ##[1:4] b; // reads as the next 1 to 4 cycles

Maybe a bit crazy, but this is how I see it. :)

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact http://cvcblr.com/home.html
** SVA Handbook 4th Edition, 2016 ISBN 978-1518681448

  1. SVA Package: Dynamic and range delays and repeats SVA: Package for dynamic and range delays and repeats | Verification Academy
  2. Free books: Component Design by Example FREE BOOK: Component Design by Example … A Step-by-Step Process Using VHDL with UART as Vehicle | Verification Academy
    Real Chip Design and Verification Using Verilog and VHDL($3) https://rb.gy/cwy7nb
  3. Papers: