Source – SV Verification Directory
Wait Fork
The wait fork statement is used to wait until all the forked processes is completed.
Syntax: Wait Fork
fork
// process 1
// process 2
// process 3
join_none // (join, join_any)
wait fork;
Example Code: Wait Fork
module tb_fork_join_wait;
initial begin
fork
#2 $display("t = %0t, fork 1 => process 1", $time);
#10 $display("t = %0t, fork 1 => process 2", $time);
#5 $display("t = %0t, fork 1 => process 3", $time);
join_any
$display("--------------- Exited Fork 1 ---------------");
end
initial begin
fork
#3 $display("t = %0t, fork 2 => process 1", $time);
#6 $display("t = %0t, fork 2 => process 2", $time);
#1 $display("t = %0t, fork 2 => process 3", $time);
join_none
wait fork;
$display("--------------- Exited Fork 2 ---------------");
end
endmodule