4 process and execution

In reply to Ravi007:
I am presuming that your “process” is a task.
Below is an example. Change the conditions as needed.


import uvm_pkg::*; `include "uvm_macros.svh"
module top;
    bit clk, a, b;
    event e1, e2, e3, e4; 
    default clocking @(posedge clk); endclocking
        initial forever #10 clk=!clk;   
        /* There are 4 processes. Among them in the 1st 3 processes, 
        all 3 must get triggered at the same time and run in parallel. 
        The 4th process should start after any one process in the 2nd and 3rd gets over 
        and the 1st process should also get over. 
        When the 4th process starts executing, the pending process 
        that did not get over must still continue their execution. Note : 
        If the 1st process get over quickly then you must wait for anyone 
        process in the 2nd and 3rd process to get over before starting with the 4th process. */
        
        task automatic c_master(); 
            bit[1:3] done; 
            fork
                c_p(1, done); // process p1
                c_p(2, done); // p2
                c_p(3, done); // p3
            join_none 
            wait(done); // any one 
            if(done[1]) wait((done[2] || done[3]) ); 
            else wait((done[2] || done[3]) && done[1]);
            fork
                c_p4(4); // the 4, done is optional 
            join_none 
        endtask 
        
        // task automatic c_p(int unit, inout bit[1:3] done); *** BAD ***
        task automatic c_p(int unit, ref bit[1:3] done);
            bit[4:0] delay; 
            if (!randomize(delay)) `uvm_error("MYERR", "This is a randomize error")
            repeat(delay+1) @(posedge clk); 
            if(unit==1) -> e1; else if(unit==2) -> e2; else if(unit==3) -> e3;
            $display("%t unit= %d", $realtime, unit); 
            done[unit]=1'b1;
        endtask
        
        task automatic c_p4(int unit);
            repeat(4) @(posedge clk); 
            $display("%t c_p4= %d", $realtime, unit); 
            -> e4; 
        endtask
        
        // Start the main task here 
        initial begin  
            #10 fork c_master(); join_none
        end

        
        initial begin 
            bit va, vb;
            repeat(200) @(posedge clk); 
            $finish; 
        end  
    endmodule   
#                  190 unit=           1
#                  230 unit=           3
#                  230 unit=           2
#                  310 c_p4=           4

 

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact Home - My cvcblr


  1. SVA Alternative for Complex Assertions
    Verification Horizons - March 2018 Issue | Verification Academy
  2. SVA: Package for dynamic and range delays and repeats | Verification Academy
  3. SVA in a UVM Class-based Environment
    SVA in a UVM Class-based Environment | Verification Horizons | Verification Academy