HI.
I am not sure if wait fork is needed in below case?
fork
thread1;
thread2;
thread3;
wait fork;
join
According SV LRM 2009:
"The wait fork statement blocks process execution flow until all immediate child subprocesses (processes created by the current process, excluding their descendants) have completed their execution. "
Does fork/join also block process excution until all IMMEDIATE CHILD subprocesses? or fork/join blocks all active sub processes?
thanks in advance
If you use fork … join, all threads within the fork-join block have to complete before the fork-join completes. This is standard Verilog.
In SystemVerilog you can use fork - join_none or join_any, then you can use wait fork after the join_xxx statement to wait for all the threads in the fork-join_xxx to complete.
In your fork-join example, the wait fork is not required.
Also, the wait_fork has to be outside the fork-join_xxx statement.
Thanks mperyer.
I have a follow-up question regarding using fork/join on UVM seqs. Assume I have a scenario like : I have two virtual sequences which are extended from uvm_sequence and each one calls two sub seqs like
virtual_seq_A;
…
task body
fork
seq1.start(…);
seq2.start(…);
join
endtask
end virtual_seq_A
virtual_seq_B;
…
task body
fork
seq3.start(…);
seq4.start(…);
join
endtask
end virtual_seq_B
in my test or env, I want to run two virtual seqs in parallel :
class test extends uvm_tests;
…
task run_phase(…);
fork
virtual_seq_A.start(…);
virtual_seq_B.start(…);
wait fork;
join
endtask
endclass
my questions are :
Do I need a wait fork here ?
if i wan to excute the main process after all threads ( vir_seqA, vir_seqB, seq1…4)complete. how can i achieve it?
thanks in advance