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.
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
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