# Assertion failing - no clue why!

**URL:** <https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393>\
**Category:** SystemVerilog\
**Tags:** System-Verilog, SystemVerilog, Assertion-system-verilog, assertion\
**Created:** [April 25, 2018, 9:50pm UTC](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393 "2018-04-25T21:50:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![somys](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@somys](https://verificationacademy.com/forums/u/somys)\
**Post date:** [April 25, 2018, 9:50pm UTC](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393/1 "2018-04-25T21:50:32Z")

</div>

I am writing this assertion on the output signals of a module:

Requirement:  
After the signal\_eop happens, data valid should remain low for that port\_id until signal\_sop occurs for that same port\_id.

property ChkDataValid;  
int id;  
@( posedge clk ) disable iff ( !rst\_l )  
( $rose(signal\_eop), id=src\_port)  
|=\> (!(data\_valid & (src\_port == id))) throughout ( (($rose(signal\_sop)) && (src\_port == id))[-\>1] );  
endproperty  
assert property ( ChkDataValid );

In my design, signal\_eop rises on 1st clock cycle when data\_valid=1 and src\_port=0 and then on 2nd clock cycle signal\_eop holds high but data\_valid transitions to 0 with src\_port=0. It fails on 2nd clock cycle.

please help me figure out what may be wrong with my assertion.

Thanks a lot.

---

<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:** [April 25, 2018, 11:21pm UTC](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393/2 "2018-04-25T23:21:10Z")

</div>

_In reply to [somys](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393):_  
You error is in the location of the “!” operator

```verilog

You have:  
(!(data_valid & (src_port==id))) throughout ( (($rose(signal_sop)) && (src_port == id))[->1] );

Should be: 
(!data_valid && src_port==id) throughout ($rose(signal_sop) && src_port==id)[->1];

```

BTW, you have way too many parentheses, makes code hard to follow.

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)
- [Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn 978-1539769712](https://goo.gl/d10QHh)
- 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
- 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

* * *

See Paper: [VF Horizons:PAPER: SVA Alternative for Complex Assertions | Verification Academy](https://verificationacademy.com/forums/systemverilog/vf-horizonspaper-sva-alternative-complex-assertions)

---

<div class="post-metadata">

**Author:** ![somys](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@somys](https://verificationacademy.com/forums/u/somys)\
**Post date:** [April 26, 2018, 4:56pm UTC](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393/3 "2018-04-26T16:56:07Z")

</div>

_In reply to [ben@SystemVerilog.us](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393/2):_

> _In reply to [somys](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393/2):_  
> You error is in the location of the “!” operator  
> You have:  
> (!(data\_valid & (src\_port==id))) throughout ( (($rose(signal\_sop)) && (src\_port == id))[-\>1] );  
> Should be:  
> (!data\_valid && src\_port==id) throughout ($rose(signal\_sop) && src\_port==id)[-\>1];

* * *

Thanks a lot for replying.

In my case, the src\_port can be different than “id” at times and for those id’s, data valid is allowed to be 1 after $rose(signal\_eop) is seen for a specific ID. data valid should be 0 until $rose(signal\_sop) is seen for that same ID.

Doesn’t your solution require data\_valid=0 and src\_port==id all the time? and not allow src\_port to be any different than that specific ID?

please explain since I am at loss with this understanding. Thanks a lot.

---

<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:** [April 26, 2018, 6:09pm UTC](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393/4 "2018-04-26T18:09:33Z")

</div>

_In reply to [somys](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393/3):_  
You need to clearly write your requirements in English.  
It sounds like what you want is that for every associated data\_valid && src\_port pair  
data\_valid==0 until ($rose(signal\_sop) && src\_port==id)[-\>1].

Is this what you want?  
See if this will work:

```verilog
 

 first_match(
     (!data_valid && src_port==id ##[0:$]src_port!=id) [*0:$] ##1 
      $rose(signal_sop) && src_port==id
             );

```

Ben [Ben@systemverilog.us](mailto:Ben@systemverilog.us)

---

<div class="post-metadata">

**Author:** ![somys](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@somys](https://verificationacademy.com/forums/u/somys)\
**Post date:** [April 26, 2018, 8:14pm UTC](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393/5 "2018-04-26T20:14:14Z")

</div>

_In reply to [ben@SystemVerilog.us](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393/4):_

Ben,  
thanks again. Would you please explain me this statement?

(!data\_valid && src\_port==id ##[0:$]src\_port!=id)

Does this mean data\_valid=0 when src\_port==id and then src\_port!=id after that until signal\_sop happens?  
I just need data\_valid=0 whenever src\_port==id after the signal\_eop. Other than that both data\_valid and src\_port can take any values until signal\_sop.

Thanks.

---

<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:** [April 26, 2018, 10:01pm UTC](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393/6 "2018-04-26T22:01:47Z")

</div>

_In reply to [somys](https://verificationacademy.com/forums/t/assertion-failing-no-clue-why/34393/5):_

```verilog
 
The sequence (à ##[0:$]b) is same as
a or a ##1 b or a ##2 b or... a ##n b

Thus, 

 (!data_valid && src_port==id ##[0:$]src_port!=id) [*0:$] ##1 
      $rose(signal_sop) && src_port==id
Says
 (!data_valid && src_port==I'd) can be followed by 0 or cycles of 
     src_port!=id). With the [*0:$] that sequence is repeated indefinitely until
      $rose(signal_sop) && src_port==id
Hope that clarifies things. The first_match is not really needed, but it is needed if you follow it with another test condition; I. E. first_match(some_sequence) ##0 seq

```

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