Fork join_any runs in the background. How to stop that


task ABC; 
 fork 
 wait (condition) begin
 end
 wait (condition) begin
 end
 wait (condition)  begin
 end
 join_any 
endtask 

task CDE; 
 fork 
 wait (condition) begin
 end
 wait (condition) begin
 end
 wait (condition)  begin
 end
 join_any 
endtask 
  1. In this task ABC wait statement finish execution and goes in the task CDE wait statement , in the background it is still checking for the task ABC remaining wait statements and that gets executes. So how to stop fork join_any to run in the background. i used disable fork and disable with label name but that is not working for me.
  2. for all the wait statements how to put timeout condition to stop the execution once timer is done.

In reply to bijalthakkar:

I assume somewhere you have

begin
  ABC(); 
  CDE();
end

You should have been able to put diable fork statement before the end of each task. You need to explain what “not working” means.

A timeout would be just another condition

task ABC; 
 fork 
 wait (condition) begin
 end
 wait (condition) begin
 end
 wait (condition)  begin
 end
 #timeout_delay;
 join_any 
 disable fork;
endtask 

Also, yo need to make sure there is no semicolon between the wait (condition) and the begin end. Otherwise that creates two processes instead of one.

Hi Dave,
Thanks for the response.

yes their are multiple wait statements in each task waiting for the same condition. I am not using ; after the wait statement.


module top;
// clk generation 

b<=1'b1; 
c<=1'b1; 
endmodule 

task A;
fork 
wait(condition=b) begin 
B; 
end
wait(condition=c) begin 
C;
end
wait(condition=d) begin 
D;
end 
join_any
endtask  

task B;
fork
wait(condition=c) begin 
C1;
end
wait(condition=d) begin 
D;
end
wait(condition=e) begin 
E;
end 
join_any
endtask 


Here in the top I am driving b=1’b1 so wait statement is satisfied and it will go to task B. Then i am driving c=1’b1 so it is expected that as it is task B it will make task B’s condition=c and call the task C1 and not the task A’s condition=c and execute that C. If I tried doing the disable fork in the task A it does not proceed to task B and kill everything.So i want to use disable fork so that it should not go to task A and satisfy that condition. I am using +UVM_TIMEOUT as I have multiple wait statements.
Thanks.

In reply to bijalthakkar:

You are still missing too much code to help. What calls task A and B.

I am calling the task in the run phase inside the driver class in the forever loop.


module top;
// clk generation 
 
b<=1'b1; 
c<=1'b1; 
endmodule 

task driver::run_phase(...);
    forever begin 
    seq_item_port.get_next_item();
    send_to_dut();
   seq_item_port.item_done();
   end
endtask 

task send_to_dut();
fork 
 case(condition)
     A:  begin 
         A;
         end 
     B:  begin 
          B;
         end
  endcase 
join_none 
endtask 

task A;
fork 
wait(condition=b) begin 
B; 
end
wait(condition=c) begin 
C;
end
wait(condition=d) begin 
D;
end 
join_any
endtask  
 
task B;
fork
wait(condition=c) begin 
C1;
end
wait(condition=d) begin 
D;
end
wait(condition=e) begin 
E;
end 
join_any
endtask 

I am calling in the drivers run_phase inside the forever loop. Here in the top I am driving b=1’b1 so wait statement is satisfied and it will go to task B. Then i am driving c=1’b1 so it is expected that as it is task B it will make task B’s condition=c and call the task C1 and not the task A’s condition=c and execute that C. If I tried doing the disable fork in the task A it does not proceed to task B and kill everything.So i want to use disable fork so that it should not go to task A and satisfy that condition. I am using +UVM_TIMEOUT as I have multiple wait statements.Please let me know.
Thanks.