Note:
SystemVerilog 3.0 provided a process statement, which gave the same functionality
as the fork...join_none construct. SystemVerilog 3.1 deprecates the process statement,
in favor of fork...join_none.
Automatic variables
declared in the scope of the fork…join block shall be initialized to the
initialization value whenever execution enters their scope, and before any
processes are spawned. 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
The example above
generates the output 123.
task
do_n_way( int N );
process job[1:N];
for
( int j = 1; j <= N; j++ )
fork
automatic int k = j;
begin job[j] = process::self(); ... ; end
join_none
wait ( job[N] != null ); // wait for last process to start
for( int
j = 1; j <= N; j++ ) // wait for
all processes to start
wait( job[j] != null );
job[1].await(); //
wait for first process to finish
for
( int k = 1; k <= N; k++ ) begin
if
( job[k].status != process::FINISHED )
job[k].kill();
end
endtask