In reply to dave_59:
Hello Dave,
While going through this informative post. I had a question related to lifetime of control variable of for-loop.
initial
begin
for(int j=1; j<=3; j++)
begin
fork
automatic int k = j;
#k $write($time,"k=%0d\n",k);
begin
automatic int m =j;
$display("m=%0d",m);
end
join_none
end
#100;
end
I want to understand the lifetime of j in this example. for-loop execution will get over at time zero and it will schedule 6 process which will spawn once simulator hit #100.
In above example j is available(m=j) irrespective of for-loop execution is over. Does that means j lifetime is also dependent on the process which are schedule while for-loop is executing ?