hello, can anyone check why i am getting this type of output while using fork join_any?
code:-
module test;
int a;
initial begin
fork
begin
$display($realtime,,,,,,"before disable");
end
begin
repeat(10) begin
$display($realtime,,,,,,"a = %0d",a++);
end
end
join_any
disable fork;
$display($realtime,,,,,,"after disable");
end
endmodule
Actual output from questasim:-
0 before disable
0 a = 0
0 a = 1
0 a = 2
0 a = 3
0 a = 4
0 a = 5
0 a = 6
0 a = 7
0 a = 8
0 a = 9
0 after disable
expected output :
0 before disable
0 after disable
In reply to shanthi:
But many processes run at zero simulation time, that differentiation has to be done by the tool.
Ex -
fork
thread1 display1
thread2 display2
thread3 display3
join
multiple process in fork join at zero simulation time, but still tool executes them one by one.
output will be: -
display1
display2
display3
This is a race condition. The only guaranteed output is that if printed, “a=0…a=9” must be in order, and that the "after disable must be the last output line. So technically the following is another valid output
hi Dave, In this all the display statements will be executed in active region and at 0 time so the order of the display is as the user’s order of the display statements so why the #0 before disable is in between and now as per your output the #0 before disable can be any where but before the #0 after disable right?
module test;
int a;
initial begin
fork
begin
$display($realtime,“before disable”);
end
/*
begin
repeat(10)begin
$display($realtime,“a = %0d”,a++);
end
end
*/
begin
$display($realtime,,,,,,"after disable");
end
join_any
/*
disable fork;
$display($realtime,,,,,,"after disable");