I came across this question on youtube : and did not understand why at 5us, the task sub_run_a did not execute while task b did? Is it expected or simulator dependent? I expected to see
sub_run_a(): ping at time 5000
- Does fork join_none get lower precedence when controls hits a $display statement?
The display output :
sub_run_a(): ping at time 1000
sub_run_a(): ping at time 2000
sub_run_a(): ping at time 3000
sub_run_a(): ping at time 4000
sub_run_b() finished
time before disable fork: 5000
V C S S i m u l a t i o n R e p o r t
Time: 15000 ns
----Code ----
// Task A. This task runs for 50us
task sub_run_a();
while ($time < 50us) begin
#1us;
$display("sub_run_a(): ping at time %d", $time);
end
endtask : sub_run_a
// Task B. This task runs for 5us
task sub_run_b();
#5us;
$display("sub_run_b() finished");
endtask : sub_run_b
// Task C. This task runs for 10us
task sub_run_c();
#10us;
$display("sub_run_c() finished");
endtask : sub_run_c
// You have the following task that forks off the tasks above.
// 1) assuming we start at time 0, how much time elapses before we reach "disable fork"
// 2) when we execute the "disable fork", which tasks get killed?
task run();
fork
sub_run_a();
join_none
fork
sub_run_b();
sub_run_c();
join_any
$display("time before disable fork: %d", $time);
disable fork;
#10us;
endtask : run
module top;
initial begin
run();
end
endmodule
Quoting the original link here, in case to be compliant with any terms of usage policy: https://www.youtube.com/watch?v=U68g-LXk81g
Thanks.