# Need to Use Variable in Assertions ## Delay

**URL:** <https://verificationacademy.com/forums/t/need-to-use-variable-in-assertions-delay/28779>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog\
**Created:** [August 30, 2013, 7:27pm UTC](https://verificationacademy.com/forums/t/need-to-use-variable-in-assertions-delay/28779 "2013-08-30T19:27:06Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![user49](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/user49/32/4533_2.png) [@user49](https://verificationacademy.com/forums/u/user49)\
**Post date:** [November 7, 2015, 5:46pm UTC](https://verificationacademy.com/forums/t/need-to-use-variable-in-assertions-delay/28779/10 "2015-11-07T17:46:16Z")

</div>

_In reply to [Elbosily](https://verificationacademy.com/forums/t/need-to-use-variable-in-assertions-delay/28779/9):_  
Some comments

```verilog

// 1) Following assertion can never fail because if the *0:$] and b==0
($rose(a), v=delay+1'b1) |-> (v>0, v=v-1'b1)[*0:$] ##1 v==0 ##0 b == 1;

// 2) Following assertion CAN fail because of the first_match() if b==0
($rose(a), v=delay+1'b1) |-> 
     first_match((v>0, v=v-1'b1)[*0:$] ##1 v==0) ##0 b == 1;

// 3) Consider the following example 
int v=5;
ap_1: assert property( x|-> ##2 b ##v c); // illegal in 1800'2012

/* If the variable used to define the delay has values that are within a constraint
range, such as between 0 and 7 (or 15, or at most 32) one can use the generate statement, which appears much simpler than the use of local variables and the sequence_match_item. Example: */
generate for (genvar g_i=0; g_i<8; g_i++) begin
  ap_delay_gen: assert property (v==g_i && $rose(a) |-> ##g_i b);
end endgenerate 

// 4) When a parameter is used, the value is static (and does not change) after elaboration, prior to sim. 
                    

```

Ben [SystemVerilog.us](http://SystemVerilog.us)

---

_[View the full topic](https://verificationacademy.com/forums/t/need-to-use-variable-in-assertions-delay/28779)._
