# Detecting live-lock using SV assertion

**URL:** <https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, assertion\
**Created:** [April 20, 2020, 7:54pm UTC](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469 "2020-04-20T19:54:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashokmehta72](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/ecd19e/32.png) [@ashokmehta72](https://verificationacademy.com/forums/u/ashokmehta72)\
**Post date:** [April 20, 2020, 7:54pm UTC](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469/1 "2020-04-20T19:54:03Z")

</div>

Hi,

Live-lock is when two states of a SM keep bouncing between each other in perpetuity. For example, S1 transitions to S2 and S2 transitions to S1. And this keeps going on forever prohibiting state machine to advance.

From SV assertion point of view, I’m trying to write an assertion when on detection of such bouncing states (for, let’s say 32 transitions), the assertion fails.

I know how to write an assertion for a dead-lock but not sure how to write an assertion for live-lock.

Any ideas?

Thanks much.

---

<div class="post-metadata">

**Author:** ![user49](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/user49/32/1084_2.png) [@user49](https://verificationacademy.com/forums/u/user49)\
**Post date:** [April 20, 2020, 9:05pm UTC](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469/2 "2020-04-20T21:05:47Z")

</div>

_In reply to [a72](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469):_  
Is this what you are looking for?

```verilog

bit lk;
function void set_lk(bit x);
  lk=x;
endfunction 

assert property(@ (posedge clk) 
  (st==S1 && !lk, set_lk(1)) |-> 
     not((st==S1 ##1 st==S2) [*32])) 
           set_lk(0); else set_lk(0));

```

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

---

<div class="post-metadata">

**Author:** ![ashokmehta72](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/ecd19e/32.png) [@ashokmehta72](https://verificationacademy.com/forums/u/ashokmehta72)\
**Post date:** [April 20, 2020, 9:33pm UTC](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469/3 "2020-04-20T21:33:06Z")

</div>

_In reply to [ben@SystemVerilog.us](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469/2):_

Thanks but I am not sure, I fully understand the use of set\_1k.

---

<div class="post-metadata">

**Author:** ![ashokmehta72](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/ecd19e/32.png) [@ashokmehta72](https://verificationacademy.com/forums/u/ashokmehta72)\
**Post date:** [April 20, 2020, 9:49pm UTC](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469/4 "2020-04-20T21:49:22Z")

</div>

_In reply to [a72](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469/3):_

But the following core assertion should work.

not((st==S1 ##1 st==S2) [\*32]))

thanks.

---

<div class="post-metadata">

**Author:** ![user49](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/user49/32/1084_2.png) [@user49](https://verificationacademy.com/forums/u/user49)\
**Post date:** [April 21, 2020, 12:20am UTC](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469/5 "2020-04-21T00:20:36Z")

</div>

_In reply to [a72](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469/4):_

not((st==S1 ##1 st==S2) [\*32])) should work.

I was not clear on the requirements. I used the set\_1k to exclude  
other st==S1 from refiring until the triggered assertion passes or fail.  
But on 2nd thoughts, you don’t need it.  
Ben [systemverilog.us](http://systemverilog.us)

---

<div class="post-metadata">

**Author:** ![ashokmehta72](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/ecd19e/32.png) [@ashokmehta72](https://verificationacademy.com/forums/u/ashokmehta72)\
**Post date:** [April 21, 2020, 6:38pm UTC](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469/6 "2020-04-21T18:38:59Z")

</div>

_In reply to [ben@SystemVerilog.us](https://verificationacademy.com/forums/t/detecting-live-lock-using-sv-assertion/37469/5):_

Thanks, Ben.
