In reply to dave_59:
In reply to ssakshi:
Please use code tags making your code easier to read. I have added them for you.
Because the first iteration of the fork does not begin execution until the section iteration hits the #1. j will have already advanced to 1.
module fork_test1;
initial
for (int j=0; j<3; j++)
begin
$display($time, "#####");
#1;
fork
automatic int k = j;
$display(j,,k);
join_none
end
endmodule:fork_test1
Thanks for the explanation. But I made a small change in the above code :
module fork_test1;
initial
for (int j=0; j<3; j++)
begin
$display($time, "#####");
#1;
fork
$display(j,,k);
join_none
end
endmodule:fork_test1
Now too will it display
1
2
3
???