class disablefork;
int i;
task fork1stmt;
fork
begin : fork_1
#2ns;
$display("fork1stmt at %0tns", $time);
end
begin : fork_2
fork2stmt();
$display("fork2stmt at %0tns", $time);
end
join_none
disable fork_2;
endtask
task fork2stmt;
#10ns;
$display("Inside fork2stmt: fork2stmt at %0tns", $time);
endtask
endclass
module tb_top();
initial begin
disablefork disableforkex_i;
disableforkex_i = new();
disableforkex_i.fork1stmt();
end
endmodule
Result:
fork1stmt at 2ns
Inside fork2stmt: fork2stmt at 10ns
fork2stmt at 10ns
Question:
After exiting fork-join_none inside fork1stmt task, I expect disable fork2 to disable all of the pending threads in fork2stmt task.
But, the simulation waits for 10ns and prints the “Inside fork2stmt: fork2stmt at 10ns
fork2stmt at 10ns”. Why did the fork2 named block did not get disabled?