In reply to dave_59:
Dave,
Thanks for the clarification.
I understand the need for the **automatic int index =i ; **
But I fail to understand what the 1800 statement (copied below) has to do as a rational
for the need of automatic int k = j;
1800: Within a fork-join_any or fork-join_none block, it shall be illegal to refer to formal arguments passed by reference other than in the initialization value expressions of variables declared in a block_item_declaration of the fork. These variables are useful in processes spawned by looping constructs to store unique, per-iteration data. For example:
initial
for( int j = 1; j <= 3; ++j )
fork
automatic int k = j; // local copy, k, for each value of j
#k $write( "%0d", k );
begin automatic int m = j; // the value of m is undetermined
...
end join_none
Also, can you give an example where a compiler would provide a violation of th2 1800 statement?
I also tried the 1800 example, but I saw no violation of the value of “m”
module test;
initial begin
for(int i = 0; i < 16; i++)
begin
fork
automatic int index =i ;
send(index);
begin
automatic int m = i; // the value of m is undetermined
send(m);
end
join_any
end
wait fork;
end
function automatic void send( ref int j);
j=j+2;
$display("driving %0d %t" , j, $realtime);
endfunction
endmodule
// sim
driving 2 0
driving 3 0
driving 3 0
driving 4 0
driving 4 0
driving 5 0
driving 5 0
..,
driving 16 0
driving 17 0
driving 17 0
driving 18 0