|
|
|
|
|
|
|
|
|
|
|
|
Process Control
|
|
|
SystemVerilog provides constructs that allow one process to terminate or wait for the completion of other processes. The wait fork construct waits for the completion of processes. The disable fork construct stops the execution of processes. |
|
|
|
|
|
|
|
|
|
|
|
Wait fork
|
|
|
The wait fork statement is used to ensure that all child processes (processes created by the calling process) have completed their execution. |
|
|
|
|
|
Verilog terminates a simulation run when there is no further activity of any kind. SystemVerilog adds the ability to automatically terminate the simulation when all its program blocks finish executing (i.e, they reach the end of their execute block), regardless of the status of any child processes |
|
|
|
|
|
|
|
|
|
|
|
Example - wait fork
|
|
|
|
|
|
1 module fork_join_wait_process();
2
3 task automatic print_value;
4 input [7:0] value;
5 input [7:0] delay;
6 begin
7 #(delay) $display("@%g Passed Value %d Delay %d",
8 $time, value, delay);
9 end
10 endtask
11
12 initial begin
13 fork
14 #1 print_value (10,7);
15 #1 print_value (8,5);
16 #1 print_value (4,2);
17 join_none
18 #5 ;
19 fork
20 #1 print_value (1,1);
21 #1 print_value (2,2);
22 #1 print_value (3,3);
23 join_any
24 $display("@%g Came out of fork-join", $time);
25 // Wait till all the forks (threads are completed their execution)
26 wait fork;
27 $display("@%g All threads completed execution", $time);
28 #20 $finish;
29 end
30
31 endmodule
You could download file fork_join_wait_process.sv here
|
|
|
|
|
|
Simulator Output |
|
|
|
|
|
@3 Passed Value 4 Delay 2
@6 Passed Value 8 Delay 5
@7 Passed Value 1 Delay 1
@7 Came out of fork-join
@8 Passed Value 10 Delay 7
@8 Passed Value 2 Delay 2
@9 Passed Value 3 Delay 3
@9 All threads completed execution
|
|
|
|
|
|
disable fork
|
|
|
The disable fork statement terminates all descendants of the calling process as well as the descendants of the process descendants. In other words, if any of the child processes have descendants of their own, the disable fork statement shall terminate them as well. |
|
|
|
|
|
Example - disable fork
|
|
|
|
|
|
1 module fork_join_disable_process();
2
3 task automatic print_value;
4 input [7:0] value;
5 input [7:0] delay;
6 begin
7 #(delay) $display("@%g Passed Value %d Delay %d",
8 $time, value, delay);
9 end
10 endtask
11
12 initial begin
13 fork
14 #1 print_value (10,7);
15 #1 print_value (8,5);
16 #1 print_value (4,2);
17 join_none
18 $display("@%g Came out of fork-join", $time);
19 // terminate all the theads
20 #5 disable fork;
21 $display("@%g All threads are disabled", $time);
22 #20 $finish;
23 end
24
25 endmodule
You could download file fork_join_disable_process.sv here
|
|
|
|
|
|
Simulator Output |
|
|
|
|
|
@0 Came out of fork-join
@3 Passed Value 4 Delay 2
@5 All threads are disabled
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|