I don't know how to stop the running sequence in the virtual sequence

Hi, i want to know how to stop the running sequence

for example

/-----------------------------------
class vseq extend uvm_sequence;

  seq1 seq1;
  seq2 seq2;

  ...

  virtual task body();

     fork
       `uvm_do(seq1)
       `uvm_do(seq2)
     join_any
     disable fork;

     ...

  endtask

/-----------------------------------

if seq1 always finish before seq2, i want to stop the seq2
but, i couldn’t do it in the above way

what should i do?

In reply to HanP:

Using fork/join_any stops all process if 1 process has finished:

task body();
  fork
    `uvm_do(seq1)
    `uvm_do(seq2)
  join_any
endtask

In reply to chr_sue:

I already know that, it’s just an example. However, in my actual test, there is a lot of code behind fork-join_any. So, task body will end after a long time from fork-join_any.

The problem is that seq2 is still running after fork_fork_any.

In reply to HanP:

There might be another reason.
See my simple example for fork/join_any:

module top;
  bit clk;
  int cnt1 = 0;
  int cnt2 = 0;
  
  task mytask1 (int id, int max_cnt);
  forever begin
     @(posedge clk);
      if (cnt1 < max_cnt) begin
        cnt1++;
	$display("process = %d, cnt1 = %d", id, cnt1);
      end else begin
        $display("left task1 at %f", $realtime);
        break;
      end	
   end   
  endtask

  task mytask2 (int id, int max_cnt);
     forever begin
     @(posedge clk);
      if (cnt2 < max_cnt) begin
        cnt2++;
	$display("process = %d, cnt2 = %d", id, cnt2);
      end else begin
        $display("left task2 at %f", $realtime);
        break;
      end	
    end  
  endtask

always #5 clk = ~clk;

initial begin
  fork
    mytask1(.id(1), .max_cnt(5));
    mytask2(.id(2), .max_cnt(10));
  join_any
  $display("left fork/join_any at %f", $realtime);
  $stop;
end

endmodule

In reply to chr_sue:

IO had a clöser look to your code.
You are saying the following body task belongs to a virtual sequence:

virtual task body();
fork
`uvm_do(seq1)
`uvm_do(seq2)
join_any
disable fork;

...
endtask

This means seq1 and seq2 are running on the same sequencer. Is this what you want to do?
Did you try to run something like this:

task body();
 ...
 fork
   seq1.start(seqr1);
   seq2.start(seqr2);
 join_any
endtask

Hi HanP,
Can you please try the following code ?

module test;

  event ev1;
  process pid1, pid2;

  initial
    begin
      fork 
        begin
          pid1 = process::self();
          #3us;
          $display("Here1");
          ->ev1;
        end
        begin
          pid2 = process::self();
          #10us;
          $display("Here2");
        end
      join_none
      wait(ev1.triggered);
      pid2.kill();
    end
endmodule