The wait_var() system task blocks the calling process until one of the variables in its arguments list changes values.Only true value changes unblock the process. Reassigning the same value does not unblock. If more than one variable is specified, a change to any of the variables unblocks the process.
EXAMPLE : wait_var() program main {
call();
delay(40);
printf(" END OF SIMUALTION \n");
}
task call(){
reg[7:0] data ;
integer i;
fork
{
while(1)
{ wait_var(data);
printf("time = %0d has changed to: %d\n",get_time(LO),data);
}
}
{
for (i=0;i<10;i++){
data= random();
delay(10);}
}
join all
}
RESULTS
time = 0 has changed to: 0 time = 10 has changed to: 156 time = 20 has changed to: 14 time = 30 has changed to: 12 time = 40 has changed to: 06 time = 50 has changed to: 119 time = 60 has changed to: 82 time = 70 has changed to: 223 time = 80 has changed to: 115 time = 90 has changed to: 195