module a();
reg [3:0] i,j,k;
always @(*)
begin
if(i == 1)
begin
fork : A
begin
#4;
$display("%0t time A is %0d",$time,i);
#2;
$display("%0t time B is %0d",$time,i);
end
join_none
end
else if(j == 1)
begin
disable A;
$display("%0t time D is %0d",$time,k);
end
else
$display("%0t time C ",$time);
end
initial
begin
i = 0;
j = 0;
k = 0;
#1;
i = 1;
#1;
i = 0;
#1;
j = 1;
#1;
end
endmodule
Sorry dave. I could not share actual code. So, I created the above one.
Here is the output for the above one when I ran in eda playground
0 time C
2 time C
3 time D is 0
5 time A is 0
7 time B is 0
If disable A, would have worked . I should nt have seen time A and time B displays.
In reply to ABD_91:
The disabled fork construct gives the same result on all simulators on EDAplayground.
If this code was inside a class, the disable fork statement is preferred since it would be instance specific. Also putting a fork/join_none inside a always @* block is very dangerous because if you were to change multiple variables at the same time, there’s no guarantee if the block would fire once or multiple times for each change.