Hello, I am writing code to do the following:
Execute task A in parallel 10 times, and call task B only after task A has finished executing 10 times.
The way I thought of going about this is to have a for loop, with each iteration executing in parallel. But I do not get the expected output.
module fork_join;
event a;
task A(input int i);
$display("Task A. Time = %0t, i = %0d", $time, i);
endtask
task B(i);
$display("Task B. Time = %0t, i = %0d", $time, i);
endtask
initial begin
for(int j = 0; j < 10; j++) begin
fork
A(j);
join_none
end
->a;
@(a);
B(2);
end
endmodule
Now when I run this code, I get the following output:
Task A. Time = 0, i = 10
repeated 10 times. But what I should be seeing is the value of i having the values 0 to 9 with each iteration of the for loop executed in parallel. How can I go about this?
Moreover, I see time = 0 being displayed 10 times even without the fork join. I realize this is because they are under one initial block which executes at time 0. But how can I actually see whether they execute in parallel or not if time = 0 prints for all iterations with and without the fork?