module tb;
initial begin
$display ("[%0t] Main Thread: Fork join going to start", $time);
fork
print (20, "Thread1_0");
print (30, "Thread1_1");
print (10, "Thread2");
join_none
$display ("[%0t] Main Thread: Fork join has finished", $time);
end
// Note that this is not an automatic task, its static
task print (int _time, string t_name); // here this task should be automatic to operate properly
#(_time) $display ("[%0t] %s", $time, t_name);
endtask
endmodule
idont know why when we remove the automatic " making the task static" affect the functionality of the code
the output in case of static will be like this
[0] Main Thread: Fork join going to start
[0] Main Thread: Fork join has finished
[10] Thread2
[20] Thread2
[30] Thread2
why the static type affect the string value passed to the task and doesn’t affect the int time variable passed
i didn’t understand the code provider explanation
Without automatic keyword, the same display task with different string tags will produce the same display message. This is because multiple threads call the same task and share the same variable in tool simulation memory. In order for different threads to initiate different copies of the same task, automatic keyword has to be used.