Parallel Process
Fork Join Basics
"Fork...Join" is an important concept in SystemVerilog. It is a key mechanism for implementing parallel processes and, therefore, is essential in constructing non-sequential code blocks.
Now let's briefly cover this topic.
Fork Join
In SystemVerilog, the fork
...join
construct is used to initiate concurrent processes. This means that all the statements enclosed within the fork
...join
block will start executing simultaneously (in parallel) when a fork
statement is encountered during the execution.
Here is a basic example of its use:
initial
begin
fork
begin : process_1
// code for process 1...
end
begin : process_2
// code for process 2...
end
join
end
In this example, process_1
and process_2
will start executing concurrently when the fork
statement is encountered. The initial block will not finish until both process_1
and process_2
have finished due to the join
statement.
join, join_any, join_none
SystemVerilog provides three types of join: join
, join_any
and join_none
.
join: The parent process will wait for all the child processes to finish.
join_any: The parent process will continue as soon as any one of the child processes finishes.
join_none: The parent process will continue immediately without waiting for any child processes to finish.
The animation below will help demonstrate the difference between the three.
<INSER ANIMATION>
The fork
...join
construct is very useful in verification for creating and controlling parallel threads, like running different test scenarios simultaneously or controlling multiple stimuli applied to a design-under-test.
Have a Question?
Feel free to ask your question in the comments below.
Please Login to ask a question.
Login Now