Question

Can anyone please tell me the difference between non-blocking begin-end in a procedural block and fork-join. One of my friends told me that the latter in non-synthesizable and are used only in testbenches. Is it true? Are there other differences?

Was it helpful?

Solution

There is no such thing as a non-blocking begin/end construct in Verilog/SystemVerilog. A begin/end block executes each statement in serial order, blocking execution of the next statement until the previous statement completes. The end of the block is reached after the last statement completes. A fork/join executes each statement simultaneously at the same time, and the join of the block is reach after all statements complete.

If there is only one statement in each kind of block, there is no behavioral difference between the two, but basic synthesis tools will not accept fork/join constructs. And there are many other ways of using fork/join that you could write that are behaviorally equivalent to writing the same thing with just begin/end inside of multiple always blocks, but are not considered synthesizable. This is because synthesis tools rely on recognizing templates of coding styles, and have limited resources to support multiple styles of writing code.

OTHER TIPS

Yes your friend is telling the truth. Fork-join blocks are not synthesizable while begin-end blocks are synthesizable.

There is also a difference between these two blocks. Let's write two snippets of code.

initial
begin
    begin 
        A <= 0;
        A <= #5 1;
        A <= #10 2;
    end
    $display($time);
end
initial
begin
    fork 
        A = 0;
        A = #5 1;
        A = #10 2;
    join
    $display($time);
end

In the first block of code, the begin-end block is executed and completed at time 0 and display function will display 0. However, A will change at time 5 and 15.

In the second block of code, the fork-join block is completed at time 10 and display function will display 10 this time.

There are similarities but they are not equivalent due to the nature of blocking and non-blocking assignments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top