Working Of Wait fork Inside fork join



module Wait_fork_1_2;
  
  
initial begin  
  
  DELAY(10);  
 
fork
 begin
   
 fork  
  
  DELAY(5);

  DELAY(3);  

 join_any

wait fork;
$display(" Time:%0d ",$time," Done with wait fork ");

 end


join
  
  
end  
  


task automatic DELAY ( input int D );

fork

 begin

 #D;

 $display(" Done with Delay %0d ",D);
  
 end

join_none
  
endtask

  
endmodule



Shouldn’t wait fork wait for its Immediate Child Threads DELAY(3) & DELAY(5) [ DELAY(10) Is Another Process ] to Complete ?

Here is my Expected Output ::

Done with Delay 3
Done with Delay 5
Time:5 Done with wait fork
Done with Delay 10

Here is The Output I am Getting ::

Time:0 Done with wait fork
Done with Delay 3
Done with Delay 5
Done with Delay 10

In reply to Etrx91:

I ran this on 4 simulators, 2 gave the results you expected, and 2 gave the results you saw.

I believe the correct output according to the LRM is displaying “Done with wait fork” at time 0. All the threads that call DELAY() do not block, and the threads that display “done with display” are grandchildren descendants of the thread executing the wait fork statement.