Fork-Join_any will be unblocked after the completion of any of the Processes.
2.1、fork join any example,
In the below example,fork block will be blocked until the completion of any of the Process Process-1 or Process-2.
Both Process-1 and Process-2 will start at the same time, Process-1 will finish at 5ns and Process-2 will finish at 20ns.
fork-join_any will be unblocked at 5ns.
module fork_join;
initial begin
$display("-----------------------------------------------------------------");
fork
//Process-1
begin
$display($time,"\tProcess-1 Started");
#5;
$display($time,"\tProcess-1 Finished");
end
//Process-2
begin
$display($time,"\tProcess-2 Started");
#20;
$display($time,"\tProcess-2 Finished");
end
join_any
$display($time,"\tOutside Fork-Join");
$display("-----------------------------------------------------------------");
end
endmodule
Simulator output:
--------------------------------------------------------
0 Thread-1 Started
0 Thread-2 Started
5 Thread-1 Finished
5 Outside Fork-Join
-----------------------------------------------------------------
20 Process-2 Finished
Processes inside the fork-join_none block will be started at the same time, fork block will not wait for the completion of the Process inside the fork-join_none.
3.1、fork join_none example,
In the below example, The fork will start Process-1 and Process-2 at the same time, and it will come out of the block. Process-1 and Process-2 will be executed until the completion.
module fork_join_none;
initial begin
$display("-----------------------------------------------------------------");
fork
//Process-1
begin
$display($time,"\tProcess-1 Started");
#5;
$display($time,"\tProcess-1 Finished");
end
//Process-2
begin
$display($time,"\tProcess-2 Startedt");
#20;
$display($time,"\tProcess-2 Finished");
end
join_none
$display($time,"\tOutside Fork-Join_none");
$display("-----------------------------------------------------------------");
end
endmodule