# Assertion for a signal to rise before an offset

**URL:** <https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, Assertion-system-verilog, rose, assertion, past\
**Created:** [February 23, 2019, 5:26pm UTC](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780 "2019-02-23T17:26:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sowmya.ragav](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/a587f6/32.png) [@sowmya.ragav](https://verificationacademy.com/forums/u/sowmya.ragav)\
**Post date:** [February 23, 2019, 5:26pm UTC](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780/1 "2019-02-23T17:26:15Z")

</div>

Hi,

I have an assertion question.

In my assertion, an offset should determine how much earlier to send a signal prior to a signal with value incrementing in every clock cycle. Below is my assertion.

property delay\_assert(a,offset,b);  
int v,s;  
@(posedge clk) disable iff(reset)  
(rose(a), v= offset, s=b) |-\> ((a,v=v-1)[\*0:] ##1 (v==0 && s==s+1));  
endproperty

The signal b value doesn’t match with the incrementing values in the waveform. I tried using $past as well but it doesn’t work. Any lead would be helpful.

---

<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:** [February 24, 2019, 5:32pm UTC](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780/2 "2019-02-24T17:32:37Z")

</div>

_In reply to [sowmya.ragav](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780):_

> **Requiremens** In my assertion, an offset should determine how much earlier to send a signal prior to a signal with value incrementing in every clock cycle.

That requirement is ambiguous. Do you mean to say:  
_Following the rise of signal “a”, the 32-bit signal “b” should be incremented after an offset of a number of system clocks. The value of that offset is stored in an 8-bit register. During that offset time, signal “a” shall remain in the logical high state._  
With the above requirements, I would write:

```verilog

property delay_assert(a,offset,b);
 bit[7:0] v_offset; 
 bit[[31:0] v_b;  
 @(posedge clk) disable iff(reset)
 ($rose(a), v_offset= offset, v_b=b) |-> 
   first_match((a,v_offset=v_offset - 1'b1)[*0:$] ##1 v_offset==0) ##0 
   $changed(b) && b==v_b+1'b1);
endproperty 

```

I understand that you hastily wrote your requirements for the assertion for this forum. However, requirements really need to be better defined. For your benefit and this audience, I recommend that you take a look at my book (below) that goes ito great details about defining requirements and verification plans.  
**FREE BOOK: Component Design by Example  
… A Step-by-Step Process Using VHDL with UART as Vehicle**

> **[cmpts\_free.pdf](https://systemverilog.us/cmpts_free.pdf)**
>
> 70.20 KB

Ben Cohen  
[http://www.systemverilog.us/](http://www.systemverilog.us/) [ben@systemverilog.us](mailto:ben@systemverilog.us)  
For training, consulting, services: contact [Home - My cvcblr](http://cvcblr.com/home)

- [SVA Handbook 4th Edition, 2016 ISBN 978-1518681448](http://goo.gl/JOfuEB)
- A Pragmatic Approach to VMM Adoption 2006 ISBN 0-9705394-9-5
- Using PSL/SUGAR for Formal and Dynamic Verification 2nd Edition, 2004, ISBN 0-9705394-6-0
- [Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn 978-1539769712](https://goo.gl/d10QHh)
- Component Design by Example ", 2001 ISBN 0-9705394-0-1
- VHDL Coding Styles and Methodologies, 2nd Edition, 1999 ISBN 0-7923-8474-1
- VHDL Answers to Frequently Asked Questions, 2nd Edition ISBN 0-7923-8115

* * *

1. [https://verificationacademy.com/news/verification-horizons-march-2018-issue](https://verificationacademy.com/news/verification-horizons-march-2018-issue)
2. [SVA: Package for dynamic and range delays and repeats - SystemVerilog - Verification Academy](https://verificationacademy.com/forums/systemverilog/sva-package-dynamic-and-range-delays-and-repeats)
3. SVA in a UVM Class-based Environment  
[https://verificationacademy.com/verification-horizons/february-2013-volume-9-issue-1/SVA-in-a-UVM-Class-based-Environment](https://verificationacademy.com/verification-horizons/february-2013-volume-9-issue-1/SVA-in-a-UVM-Class-based-Environment)

---

<div class="post-metadata">

**Author:** ![sowmya.ragav](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/a587f6/32.png) [@sowmya.ragav](https://verificationacademy.com/forums/u/sowmya.ragav)\
**Post date:** [February 24, 2019, 6:12pm UTC](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780/3 "2019-02-24T18:12:54Z")

</div>

_In reply to [ben@SystemVerilog.us](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780/2):_

Hi,  
Thank you very much for your reply. I am sorry if my requirements were not clear. b is a signal which contains values incrementing from 0 to 10 and keeps repeating for the entire time. When the value of signal b changes, at that point signal a which is 1 bit should rise before an offset. rise of signal a should happen before every start time of values changing in signal b by an offset.

---

<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:** [February 24, 2019, 6:28pm UTC](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780/4 "2019-02-24T18:28:51Z")

</div>

_In reply to [sowmya.ragav](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780/3):_

I believe my assertion does that. My rewrite of the requirements says what you expressed, but is forward looking

---

<div class="post-metadata">

**Author:** ![sowmya.ragav](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/a587f6/32.png) [@sowmya.ragav](https://verificationacademy.com/forums/u/sowmya.ragav)\
**Post date:** [February 24, 2019, 6:44pm UTC](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780/5 "2019-02-24T18:44:26Z")

</div>

_In reply to [ben@SystemVerilog.us](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780/4):_

I tried your assertion but the value of b doesn’t change when offset becomes 0. Is there anyway I can find the change of b and check for signal a. I tried the below code too but it said illegal operand for constant expression

property delay\_assert(a,offset,b);  
@(posedge clk) disable iff(reset)  
$changed(b) |-\> ($past(a,offset)==1);  
endproperty

---

<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:** [February 24, 2019, 8:45pm UTC](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780/6 "2019-02-24T20:45:44Z")

</div>

_In reply to [sowmya.ragav](https://verificationacademy.com/forums/t/assertion-for-a-signal-to-rise-before-an-offset/35780/5):_

Good solution with one big EXCEPTION!  
**$changed(b) |-\> ($past(a,offset)==1);**  
Requires “offset” to be static and NOT dynamic. Thus

```verilog

 int offset=7; 
 let static_offset=6; 
 $changed(b) |-> ($past(a,offset)==1); // ERROR !!!!
 $changed(b) |-> ($past(a,static_offset)==1); // OK
 

```

As a general comment, the above styles of assertions is generally of poor style because it is not forward looking. It is saying if something happens, then something else before that must have happened. I pefer the forward looking approach that says, if something happens, then now or later on something else must happen. My solution does that:

```verilog

($rose(a), v_offset= offset, v_b=b) |-> // something happens 
   first_match((a,v_offset=v_offset - 1'b1)[*0:$] ##1 v_offset==0) ##0 
    // after an offset time set dynamically when that something did happen
   $changed(b) && b==v_b+1'b1); // 2 other things happen

```

Ben Cohen  
[http://www.systemverilog.us/](http://www.systemverilog.us/) [ben@systemverilog.us](mailto:ben@systemverilog.us)  
For training, consulting, services: contact [Home - My cvcblr](http://cvcblr.com/home)

- [SVA Handbook 4th Edition, 2016 ISBN 978-1518681448](http://goo.gl/JOfuEB)
- A Pragmatic Approach to VMM Adoption 2006 ISBN 0-9705394-9-5
- Using PSL/SUGAR for Formal and Dynamic Verification 2nd Edition, 2004, ISBN 0-9705394-6-0
- [Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn 978-1539769712](https://goo.gl/d10QHh)
- Component Design by Example ", 2001 ISBN 0-9705394-0-1
- VHDL Coding Styles and Methodologies, 2nd Edition, 1999 ISBN 0-7923-8474-1
- VHDL Answers to Frequently Asked Questions, 2nd Edition ISBN 0-7923-8115

* * *

1. [Verification Horizons - March 2018 Issue | Verification Academy](https://verificationacademy.com/news/verification-horizons-march-2018-issue)
2. [SVA: Package for dynamic and range delays and repeats | Verification Academy](https://verificationacademy.com/forums/systemverilog/sva-package-dynamic-and-range-delays-and-repeats)
3. SVA in a UVM Class-based Environment  
[SVA in a UVM Class-based Environment | Verification Horizons | Verification Academy](https://verificationacademy.com/verification-horizons/february-2013-volume-9-issue-1/SVA-in-a-UVM-Class-based-Environment)  
**FREE BOOK: Component Design by Example  
… A Step-by-Step Process Using VHDL with UART as Vehicle**  
[http://systemverilog.us/cmpts\_free.pdf](http://systemverilog.us/cmpts_free.pdf)
