What is best way to build a fork/join_xx strategy which blocks on one particular task, then un-blocks when that task finishes, ignoring what the others have done.
In this example three threads are launched, how can we block until run_control task completes, then move on to the test finished task.
The example finish time should be 2 (maybe 3 ??).
Its almost like a wait_fork, but only wait for one thread.
The use case is for a testbench which launches gen,driver,monitor and scoreboard.
I want to launch them all in parallel, but only wait for the scoreboard to finish.
Looking for a SystemVerilog answer; realize the advanced three letter methodologies have more powerful ways to do this in a testbench.
This code is kind of the base for the question:
How can the :main block be modified to give the specified behavior?
Would like to avoid the use of semaphores, seems like this would be an every day thing to do.
module test;
task run_long;
for(int i=0;i < 7;i++)
begin
$display("*******long time = %0d",$time);
#1;
end
endtask
task run_short;
for(int i=0;i < 1;i++)
begin
$display("*short time = %0d",$time);
#1;
end
endtask
task run_control;
for(int i=0;i < 2;i++)
begin
$display("***control time = %0d",$time);
#1;
end
endtask
task test_finished;
$display("Test finished %0d",$time);
endtask
initial
begin :main
fork
run_long;
run_short;
run_control;
join;
test_finished;
end :main
endmodule
Here is one thing I tried
initial
begin :main
fork
fork
run_long;
run_short;
join_none;
//
run_control;
//
join_any;
test_finished;
end :main
This produces the output
Test finished 0
***control time = 0
*******long time = 0
*short time = 0
***control time = 1
*******long time = 1
*******long time = 2
*******long time = 3
*******long time = 4
*******long time = 5
*******long time = 6
Which is not desired because the test is still waiting for the long time thread to run.