Hi Team,
Please help me out the importance of #0 delay in systemveriog . How #0 delay the statement execution especially with fork join_none/join_any/join
I have tried the below code :
module test;
initial begin
$display("[%0t] Main Thread:: Fork join going to start",$time);
fork
print(20,"Thread1_0"); // thread 1
print(30,"Thread1_1"); // thread 2
print(10,"Thread1_2"); // thread 3
join_none
$display("[%0t] Main Thread:Fork join has finished",$time);
end
task print(int _time,string t_name);
#0; //Delayed the statement execution by delta time
$display("[%0t] %d %s",$time,_time,t_name);
endtask:print
endmodule:test
FIRST :: if we use #0 in the print task output is :
[0] Main Thread:: Fork join going to start
# [0] Main Thread:Fork join has finished
# [0] 10 Thread1_2
# [0] 10 Thread1_2
# [0] 10 Thread1_2
SECOND ::if i wont use #0 the output is :
[0] Main Thread:: Fork join going to start
# [0] Main Thread:Fork join has finished
# [0] 20 Thread1_0
# [0] 30 Thread1_1
# [0] 10 Thread1_2
I have changed the task print to task automatic print after that also without #0 statement output is same as SECOND.
Please provide inputs in understanding .
Thanks in advance