Hello,
I’m trying to understand fork ~join_none statmenet.
module disable_fork;
initial begin
$display("-----------------------------------------------------------------");
fork
//-------------------
//Process-1
//-------------------
begin
$display($time,"\tProcess-1 of fork-1 Started");
#5;
$display($time,"\tProcess-1 of fork-2 Finished");
end
//-------------------
//Process-2
//-------------------
$display("-----------------------------------------------------------------");
$display($time,"\tAfter a0");
$display("-----------------------------------------------------------------");
begin
$display($time,"\tProcess-2 of fork-1 Started");
#20;
$display($time,"\tProcess-2 of fork-2 Finished");
end
$display("-----------------------------------------------------------------");
$display($time,"\tAfter a1");
$display("-----------------------------------------------------------------");
join_any
$display("-----------------------------------------------------------------");
$display($time,"\tAfter fork1");
$display("-----------------------------------------------------------------");
//-------------------
//fork-2
//-------------------
fork
//-------------------
//Process-1
//-------------------
begin
$display($time,"\tProcess-3 of fork-1 Started");
#5;
$display($time,"\tProcess-3 of fork-2 Finished");
end
//-------------------
//Process-2
//-------------------
begin
$display($time,"\tProcess-4 of fork-1 Started");
#20;
$display($time,"\tProcess-4 of fork-2 Finished");
end
join_none
// disable fork;
$display("-----------------------------------------------------------------");
$display($time,"\tAfter disable-fork");
$display("-----------------------------------------------------------------");
fork
//-------------------
//Process-1
//-------------------
begin
$display($time,"\tProcess-5 of fork-1 Started");
#5;
$display($time,"\tProcess-5 of fork-2 Finished");
end
//-------------------
//Process-2
//-------------------
begin
$display($time,"\tProcess-6 of fork-1 Started");
#20;
$display($time,"\tProcess-6 of fork-2 Finished");
end
join_any
fork
//-------------------
//Process-1
//-------------------
begin
$display($time,"\tProcess-7 of fork-1 Started");
#5;
$display($time,"\tProcess-7 of fork-2 Finished");
end
//-------------------
//Process-2
//-------------------
begin
$display($time,"\tProcess-8 of fork-1 Started");
#20;
$display($time,"\tProcess-8 of fork-2 Finished");
end
join_any
end
endmodule
there are some fork~join_any and fork~join_none statements.
And I can get the below results.
-----------------------------------------------------------------
0 Process-1 of fork-1 Started
-----------------------------------------------------------------
-----------------------------------------------------------------
0 After fork1
-----------------------------------------------------------------
-----------------------------------------------------------------
0 After disable-fork
-----------------------------------------------------------------
0 Process-5 of fork-1 Started
0 Process-6 of fork-1 Started
0 Process-3 of fork-1 Started
0 Process-4 of fork-1 Started
0 After a0
-----------------------------------------------------------------
0 Process-2 of fork-1 Started
-----------------------------------------------------------------
0 After a1
-----------------------------------------------------------------
5 Process-1 of fork-2 Finished
5 Process-5 of fork-2 Finished
5 Process-7 of fork-1 Started <----- why consumed time 5?
5 Process-8 of fork-1 Started <----- why consumed time 5?
5 Process-3 of fork-2 Finished
10 Process-7 of fork-2 Finished
20 Process-6 of fork-2 Finished
20 Process-4 of fork-2 Finished
20 Process-2 of fork-2 Finished
25 Process-8 of fork-2 Finished
But I coundn’t undersatnd
5 Process-7 of fork-1 Started
5 Process-8 of fork-1 Started
they are supposed to start in 0 time not 5. it also implemented as process-5,process-6 so I expected 7 and 8 also will happen 0 time but it does not.
Could you guide me how to implement and undersatnd in multiple fork ~ join( none, any)?