Ways to make calls of two tasks to execute concurrently?

Hi
For the sake of completeness, an example of where the task forks to perform the two subtasks in parallel and then waits until they have both finished is below. You could also replace “join” with “join_none” to have the main task exit immediately, leaving the two subtasks to run completely asynchronously.

However, as has already been suggested, a purer UVM style of independent drivers and monitors would be a better investment of your time. While knowledge of fork/join is very useful, it leads to more convoluted and non-standard coding in this case with more potential for bugs or hidden dependencies which mean that the DUT is not stimulated as randomly as possible.

	
task run(int num_packet=4);
for(int i=0; i<num_packet;i++) begin
  @(posedge vi.clk)
  $display("==========time=%0d:Sending packet #%0d==========",$time, i+1);

  fork
    begin
      drv.send_packet();
      $display("==========time=%0d:Sent packet #%0d=========",$time, i+1);
    end
    begin
      mon.collect_packet();
      $display("==========time=%0d:Collected packet #%0d=========",$time, i+1);
    end 
  join
endtask