Fork..join for multiple analysis_port.write() in monitor

In reply to mperyer:

Thanks for the suggestion.

Currently what I did was, instead of having a forever loop in each tasks, I did it this way

task run_phase();
     forever 
     begin
       @(posedge intf.clk);

       fork
          rdat_cyc(txn);
          wr_cyc(txn);
          rd_cyc(txn);
          idl_cyc(txn);
       join
     end
endtask: run_phase

The code showing above looks fine right?

Another question, when both rdat_cyc and wr_cyc tasks are being called, (no matter how it still execute sequentially, let say rdat_cyc execute first) only the code in rdat_cyc will be executed, until it finish executing all codes in the rdat_cyc task, then the code in wr_cyc task will only start executing, is this correct? I ask this question because I want to make sure there is no random execution between two tasks.

Thanks for your help!