SystemVerilog fork join_any

fork join_any

Fork-Join_any will be unblocked after the completion of any of the Processes.

SystemVerilog Fork Join any
SystemVerilog Fork Join any

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

Click to execute on

❮ Previous Next ❯