0
0
Verilogprogramming~10 mins

When to use blocking (combinational) in Verilog - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - When to use blocking (combinational)
Start Combinational Logic
Use Blocking Assignments (=)
Evaluate statements in order
Update variables immediately
Output combinational signals
End Combinational Logic
Blocking assignments (=) are used in combinational logic to evaluate statements in order and update variables immediately, reflecting real combinational behavior.
Execution Sample
Verilog
always @(*) begin
  a = b + c;
  d = a + 1;
end
This code uses blocking assignments to compute 'a' then 'd' in order, modeling combinational logic.
Execution Table
StepStatementVariable BeforeEvaluationVariable After
1a = b + c;b=2, c=3, a=0a = 2 + 3a=5
2d = a + 1;a=5, d=0d = 5 + 1d=6
3End always blocka=5, d=6No changea=5, d=6
💡 All statements executed in order with blocking assignments, variables updated immediately.
Variable Tracker
VariableStartAfter Step 1After Step 2Final
a0555
d0066
b2222
c3333
Key Moments - 2 Insights
Why do we use blocking assignments (=) in combinational logic?
Because blocking assignments update variables immediately in order, matching how combinational logic works, as shown in execution_table steps 1 and 2.
What happens if we use non-blocking assignments (<=) in combinational logic?
Non-blocking assignments delay updates until the end of the time step, which can cause incorrect intermediate values in combinational logic, unlike the immediate updates seen in the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the value of 'a' after step 1?
A0
B5
C6
D2
💡 Hint
Refer to the 'Variable After' column in row for step 1.
At which step does 'd' get its final value?
AStep 2
BStep 1
CStep 3
DNever
💡 Hint
Check the 'Variable After' column for 'd' in each step.
If we replaced '=' with '<=' in the code, how would the variable updates change?
AVariables update immediately in order
BVariables update randomly
CVariables update only at the end of the block
DVariables do not update
💡 Hint
See key_moments explanation about non-blocking assignments delaying updates.
Concept Snapshot
Use blocking assignments (=) in combinational always blocks.
Statements execute in order, variables update immediately.
This models real combinational logic behavior.
Avoid non-blocking (<=) in combinational logic to prevent incorrect delays.
Example:
always @(*) begin a = b + c; d = a + 1; end
Full Transcript
In Verilog, blocking assignments (=) are used in combinational logic blocks to ensure statements execute in order and variables update immediately. This matches how combinational circuits work in hardware. For example, in the code 'always @(*) begin a = b + c; d = a + 1; end', 'a' is updated first, then 'd' uses the new value of 'a'. The execution table shows step-by-step how variables change. Using non-blocking assignments (<=) here would delay updates and cause incorrect behavior. Remember to use blocking assignments for combinational logic to model immediate updates and ordered execution.