# Infinite Loop using While

**URL:** <https://verificationacademy.com/forums/t/infinite-loop-using-while/30511>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, Infinite-loop\
**Created:** [April 1, 2015, 7:56am UTC](https://verificationacademy.com/forums/t/infinite-loop-using-while/30511 "2015-04-01T07:56:27Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [April 2, 2015, 1:03am UTC](https://verificationacademy.com/forums/t/infinite-loop-using-while/30511/11 "2015-04-02T01:03:34Z")

</div>

_In reply to [haykp](https://verificationacademy.com/forums/t/infinite-loop-using-while/30511/10):_

It’s most likely due to a race condition between spi\_sck and spi\_cs. You are essentially evaluating spi\_cs after the @(posedge spi\_sck). If it is 1, then it waits for the next @(posedge spi\_sck). If spi\_sck doesn’t have a posedge after spi\_cs is 0, then you will be stuck waiting for the nest @(posedge spi\_sck), which when that occurs, spi\_cs is back to the value of 1.

---

_[View the full topic](https://verificationacademy.com/forums/t/infinite-loop-using-while/30511)._
