Parallel tasks

In reply to Moein75:
The issue of using a fork join_any for each group of the loop variable i is taht it joins just that group (e.g., group 0, but not group1)

Can you do something like this where done is a common variable to the t_master task
and any forked task return a 1 to done.
The return end the t_master task


automatic task run(inout bit done); // example of one task
  ....
  done=1; 
endtask 

automatic task t_master(int v);
  bit done;
  for (int i = 1; i<=v; i=i+1) begin
    fork
    // NEED THE FOLLOWING as explained below 
      automatic int j = i; // Updated 6/27/
      gen[j].run(done); // 
      drv[j].run(done);
      model[j].run(done);
    join_any
  end
  wait(done); 
  return;
endtask
  
// For v==2, the for loop will create 
fork          
    gen[0].run(done);
    drv[0].run(done);
    model[0].run(done);
join_any 
fork  
    gen[1].run(done);
    drv[1].run(done);
    model[1].run(done);
join_any
wait(done); return;
// since any task sets the done to 1, the t_master will end. 

I used this technique to kill multiple threads in my modeling of SVA.
See my paper Understanding the SVA Engine Using the Fork-Join Model Verification Horizons Using a model, the paper addresses important concepts about attempts and threads. Emphasizes the total independence of attempts.
Ben Cohen
Ben@systemverilog.us
Link to the list of papers and books that I wrote, many are now donated.
http://systemverilog.us/vf/Cohen_Links_to_papers_books.pdf
or Cohen_Links_to_papers_books - Google Docs

Getting started with verification with SystemVerilog