# Wait for signal value in a task with timeout

**URL:** <https://verificationacademy.com/forums/t/wait-for-signal-value-in-a-task-with-timeout/34702>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, timeout-value\
**Created:** [July 19, 2018, 5:48am UTC](https://verificationacademy.com/forums/t/wait-for-signal-value-in-a-task-with-timeout/34702 "2018-07-19T05:48:15Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![VE1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/54ee81/32.png) [@VE1](https://verificationacademy.com/forums/u/VE1)\
**Post date:** [April 4, 2022, 6:31pm UTC](https://verificationacademy.com/forums/t/wait-for-signal-value-in-a-task-with-timeout/34702/5 "2022-04-04T18:31:42Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/wait-for-signal-value-in-a-task-with-timeout/34702/4):_

> _In reply to [shaygueta](https://verificationacademy.com/forums/t/wait-for-signal-value-in-a-task-with-timeout/34702/4):_  
> Just fork the timeout delay.

```verilog
task automatic timeout(ref logic signal,input logic value,input time timeout_value);
bit timed_out;
fork begin
fork
begin
#timeout_value;
`uvm_error(....
timed_out = '1;
end
join_none
wait(signal === value || timed_out);
disable fork;
end join
endtask

```

Note the enclosing fork/join is needed to prevent the disable fork from killing other child threads that may have been spawned before calling this task.

HI Dave :  
1 can I use disable {name of fork} instead of the guard fork/join here ? i.e  
wait(signal === value || timed\_out);  
disable \< name of fork process\>; // assume there is name of fork/join\_none  
2. Do you recommend always use a guard fork/join when there is disable fork ? for example  
in run\_phase(uvm\_phase phase);

Thanks

---

_[View the full topic](https://verificationacademy.com/forums/t/wait-for-signal-value-in-a-task-with-timeout/34702)._
