Calling non-automatic task within fork-join_none

Hi,
I am trying to run the following code and my output is not what I expected:

module top;
  task display(input int t_in, string name);
     #t_in $display("@%0t: %s", $time, name);
   endtask

   initial begin
     $display("@%0t: Main process started", $time);
     fork
       display(5, "Thread1");
       display(10, "Thread2");
       display(15, "Thread3");
     join_none
     $display("@%0t: Fork-join_none completed", $time);
    wait fork;
  end
endmodule

I am getting the following output (ACTUAL OUTPUT):

@0: Main process started
# @0: Fork-join_none completed
# @5: Thread3
# @10: Thread3
# @15: Thread3

But I am expecting the following output: (EXPECTED OUTPUT)

@0: Main process started
# @0: Fork-join_none completed
# @15: Thread3
# @15: Thread3
# @15: Thread3

So, my query is why t_in argument has not overridden when I called non-automatic task display() three times?

The t_in argument is being overwritten, just not necessarily before the #t_in delay expression gets evaluated. Once evaluated, the delay gets scheduled and does not update if the expression changes its value.

You’re printing $time, not the value of t_in.

  task display(input int t_in, string name);
     #t_in $display("Time : %0t, name = %s, t_in = %0d", $time, name,t_in);
   endtask
1 Like

Thanks Dave!!
Now I understood the point.
And thanks Hardik!!