Fork join_none disable block is not working

always @(*)
begin //{
if (...) 
  begin //{
         fork : LABELA
            begin 
              .....
            end
         join_none

  end //}
else if(....)
   begin //{
      disable LABELA;
      .....
    end //}
end//}

LABELA is not getting disabled. Please help

In reply to shamsheer:

Please use code tags making your code easier to read. I have added them for you.

And please see this article about posting better questions. The way your code is written, we have no way of knowing if

  • the fork ever got executed
  • the disable ever got executed
  • the fork finished before the disable

In reply to dave_59:

Hello Dave,

Thanks for adding code tags.
While fork (LABELA) is getting executed, disable LABELA statement was hit. But the fork (LABELA ) was not disabled.

In reply to shamsheer:

You are still not showing enough code that might explain what might be going wrong. You might trydisable fork; instead.

In reply to dave_59:

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 shamsheer:

What you see is a Simulator Issue probably

2 out of 3 Simulators give an Output ( which is I believe is correct ) ::

0 time C
2 time C
3 time D is 0

After the following changes ::


always @(*)
  begin
 
    if(i == 1)
    begin
        fork
          begin:A // Naming after begin instead of fork !!
        ........... 

All 3 Simulators give Output ::

0 time C
2 time C
3 time D is 0

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.