Disable fork label does not disable the thread

Hi All, I have the following code:

  fork: ptime_check
      begin
        test_p[0] = process::self();
        wait(xyz == 1);
      end
      begin
        test_p[1] = process::self();
        #1us;
        `uvm_error("xyz not set after 1us delay")
      end
  join_none
  wait(test_p[0] != null);
  test_p[0].await();
  `uvm_info("TEST", "Killing timeout process. Seen xyz", UVM_LOW)
  disable ptime_check;

result:

5us: uvm_test_top [TEST] Killing timeout process. Seen xyz
5.7us: uvm_test_top xyz not set after 1us delay

Why doesn’t disable ptime_check kill the second begin…end? Am I doing something wrong? I confirm that test_p[1].kill() instead of disable ptime_check works.

Thanks in advance.

In reply to ledzep_1988:

It would help to provide a complete runnable example like below which works on 3 of the simulators on www.edaplayground.com

module top;
  
  int xyz;
  process test_p[2];
  
  initial #10ns xyz = 1;
  
  initial begin
    fork: ptime_check
      begin
        test_p[0] = process::self();
        wait(xyz == 1);
      end
      begin
        test_p[1] = process::self();
        #1us;
        $error("xyz not set after 1us delay");
      end
  join_none
  wait(test_p[0] != null);
  test_p[0].await();
    $error("Killing timeout process. Seen xyz");
  disable ptime_check;
  end
endmodule

Note that the kill() method is preferred since it is not globally applied compared with disabling a named block

Hi,

is it necessary to use the process to disable the fork?

I have the following example.

module test;
  
  initial begin
    fork : fork_1
      begin : begin_1_fork_1
        #10ns;
        $display("%s(%0d) @%0t : Fork_1 Process_1 Completed", `__FILE__, `__LINE__,$time);
      end : begin_1_fork_1
      begin : begin_2_fork_1
        #25ns;
        $display("%s(%0d) @%0t : Fork_1 Process_2 Completed", `__FILE__, `__LINE__,$time);
      end : begin_2_fork_1
    join_any : fork_1
    
    $display("%s(%0d) @%0t : Disabling Fork_1", `__FILE__, `__LINE__,$time);
    disable fork_1;
    $display("%s(%0d) @%0t : Disabled Fork_1", `__FILE__, `__LINE__,$time);
  end
  
  initial begin
    fork : fork_2
      begin : begin_1_fork_2
        #150ns;
        $display("%s(%0d) @%0t : Fork_2 Process_1 Completed", `__FILE__, `__LINE__,$time);
      end : begin_1_fork_2
      begin : begin_2_fork_2
        #125ns;
        $display("%s(%0d) @%0t : Fork_2 Process_2 Completed", `__FILE__, `__LINE__,$time);
      end : begin_2_fork_2
    join_any : fork_2
    
    $display("%s(%0d) @%0t : Disabling Fork_2", `__FILE__, `__LINE__,$time);
    disable fork_2;
    $display("%s(%0d) @%0t : Disabled Fork_2", `__FILE__, `__LINE__,$time);
  end
  
endmodule : test

I have observed that for some of the simulators this code is working for some the code is not working. Can you please help?

Results

testbench.sv(10) @10 : Fork_1 Process_1 Completed
testbench.sv(18) @10 : Disabling Fork_1
testbench.sv(20) @10 : Disabled Fork_1
testbench.sv(14) @25 : Fork_1 Process_2 Completed
testbench.sv(31) @125 : Fork_2 Process_2 Completed
testbench.sv(35) @125 : Disabling Fork_2
testbench.sv(37) @125 : Disabled Fork_2
testbench.sv(27) @150 : Fork_2 Process_1 Completed

In reply to tejwanikrishna:

Your code works as I would expect on 3 out of 4 simulators on www.edaplayground.com. They all interpret the statement “The disable statement shall terminate the activity of a task or a named block” in section 9.6.2 Disable statement to include the processes spawned by a fork statement.

This Mentor/Siemens EDA sponsored public forum is not for discussing tool specific usage or issues. Please contact your tool vendor directly for support.