# Break out of while loop after certain timeout

**URL:** <https://verificationacademy.com/forums/t/break-out-of-while-loop-after-certain-timeout/33347>\
**Category:** OVM\
**Tags:** OVM, timeout-value, loop, timeout\
**Created:** [July 27, 2017, 9:08pm UTC](https://verificationacademy.com/forums/t/break-out-of-while-loop-after-certain-timeout/33347 "2017-07-27T21:08:31Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [July 28, 2017, 5:56am UTC](https://verificationacademy.com/forums/t/break-out-of-while-loop-after-certain-timeout/33347/2 "2017-07-28T05:56:36Z")

</div>

_In reply to [nik\_88](https://verificationacademy.com/forums/t/break-out-of-while-loop-after-certain-timeout/33347):_

You use fork/join\_any for this

```verilog
fork 
   looping_code; //process 1
   #120us; //process 2
join_any
global_stop_request();

```

The statement after the join\_any starts when any one of the processes inside the fork/joia\_any completes. You can also use disable fork to kill any remaining processes.

There is a problem with your while loop though - it will gointo an infinite 0 delay loop when signal\_val == 0 is true. You need a blocking statement inside the loop so time can advance.

---

_[View the full topic](https://verificationacademy.com/forums/t/break-out-of-while-loop-after-certain-timeout/33347)._
