Fork join_none

module fork_test();
initial begin
for (int j=0; j<3; j++)
begin

fork

$display(j);

join_none

end
end
endmodule

when i am running the above code getting output below like this
3
3
3
please explain me how getting the output

[i]In reply to anvesh dangeti:[/i

When fork join_none is used, the parent process continues to execute concurrently with all the processes spawned by the fork. The spawned processes do not start executing until the parent thread executes a blocking statement or terminates.

The parent thread is here a for loop. The process inside the parent thread that is spawned inside the fork is $display.

So in this case, $dispaly does not execute until the parent thread terminates (for loop completes the iteration for 3 times)as there are no blocking statements in the parent thread. By the time the $display executes the for loop has gone through the 3 iterations., so the value of j displayed will be 3.

Regards,
Shanthi

module fork_test1;
initial begin
for (int j=0; j<3; j++)
begin
#1;
fork

$display(j);

join_none

end
end
endmodule

when i am putting delay #1.the output below like this
output:
1
2
3

It is because before going for next iteration the previous iteration encounters a blocking or delay statement i.e. #1 which makes the scheduled fork-join_none statement to execute with the current value of the j. As per LRM for Fork-Join_None :
The spawned processes do not start executing until the parent thread executes a blocking statement or terminates

Thanks

In reply to anvesh dangeti:

Look at this thread.