Blocking vs. Nonblocking Assignments in Verilog: When to Use = and <=

The difference between blocking and nonblocking assignments in Verilog is mainly about when the assigned variable changes during simulation.
A blocking assignment uses = and updates its target as the procedural statement executes. A nonblocking assignment uses <=: the right-hand side is evaluated when the statement runs, while the left-hand-side update is scheduled for later in the same simulation time step.
For synthesizable RTL, the practical rule is straightforward:
=) for combinational logic and nonblocking assignments (<=) for clocked sequential logic.
That rule is easy to memorize. The important part is understanding why it works, because assignment scheduling affects pipelines, state machines, race conditions, and what you eventually see in a waveform.
Blocking vs. Nonblocking in Verilog at a Glance
Blocking = |
Nonblocking <= |
|
|---|---|---|
| Update behavior | Target changes as the statement executes | Target update is scheduled |
| Later statements see | The updated value | The previous value until the scheduled update |
| Typical RTL use | Combinational logic | Clocked sequential logic |
| Verilog process | always @(*) |
always @(posedge clk) |
| SystemVerilog process | always_comb |
always_ff |
| Typical hardware intent | Logic calculation | Registers and state |
| Common mistake | Using statement order incorrectly | Using deferred updates for ordinary combinational dependencies |
The examples below omit some surrounding declarations when those declarations are not important to the point being demonstrated. In real code, declare signals using the appropriate reg, wire, or SystemVerilog logic type.
What Is a Blocking Assignment in Verilog?
A blocking assignment uses the equals sign:
temp = a & b;
The statement completes before the next procedural statement executes.
For example:
always @(*) begin
temp = a & b;
y = temp | c;
end
Suppose:
a = 1
b = 1
c = 0
The first statement calculates temp and immediately makes its new value available. The next statement therefore uses that new value:
temp = 1
y = 1
This matches the way we usually want to describe combinational calculations: calculate an intermediate result, then use it in the next expression.
What Is a Nonblocking Assignment in Verilog?
A nonblocking assignment uses <=:
always @(posedge clk) begin
q <= d;
end
When the rising clock edge occurs, the simulator evaluates d, but the update to q is scheduled rather than becoming visible immediately in the middle of that procedural execution.
The difference becomes important when registers depend on one another:
always @(posedge clk) begin
q1 <= d;
q2 <= q1;
end
At a rising edge, q1 captures the previous value of d, while q2 captures the previous value of q1.
That is what we expect from two physical flip-flops connected in series. Both sample their inputs on the same active clock edge.
The Shift-Register Example That Makes the Difference Clear
Consider a three-stage shift register:
in → [FF] → q1 → [FF] → q2 → [FF] → out
The intended behavior is for a bit to move forward by one register on each rising clock edge.
The usual implementation is:
always @(posedge clk) begin
q1 <= in;
q2 <= q1;
out <= q2;
end
Assume all registers begin at zero. Now apply a one-clock input pulse: in is 1 at the first sampling edge and returns to 0 before the next one.
| After edge | in sampled | q1 | q2 | out |
|---|---|---|---|---|
| Edge 1 | 1 | 1 | 0 | 0 |
| Edge 2 | 0 | 0 | 1 | 0 |
| Edge 3 | 0 | 0 | 0 | 1 |
| Edge 4 | 0 | 0 | 0 | 0 |
The pulse moves through the pipeline one register per clock.
Now replace the nonblocking assignments with blocking assignments:
always @(posedge clk) begin
q1 = in;
q2 = q1;
out = q2;
end
When in is 1, the simulator executes the statements in order. q1 immediately becomes 1, then q2 reads the newly updated q1, and finally out reads the newly updated q2.
The intended three-stage delay can therefore collapse in RTL simulation. This is the core reason blocking assignments are a poor choice for describing a chain of clocked registers.
Why Nonblocking Assignments Match Registers
Physical flip-flops sharing a clock do not execute one after another like software instructions.
For:
D → FF1 → FF2 → FF3
q1 q2 q3
an active clock edge conceptually does this:
FF1 samples D
FF2 samples the old q1
FF3 samples the old q2
Then the stored outputs change.
Nonblocking assignments naturally represent that relationship:
always @(posedge clk) begin
q1 <= d;
q2 <= q1;
q3 <= q2;
end
Every right-hand side is evaluated from the state that existed before the scheduled register updates become visible.
Why Blocking Assignments Work Well for Combinational Logic
Now consider a purely combinational calculation:
sum = a + b
result = sum ^ mask
A natural Verilog description is:
always @(*) begin
sum = a + b;
result = sum ^ mask;
end
The second line is supposed to use the result produced by the first. Blocking assignments make that dependency explicit and easy to read.
With SystemVerilog, the same intent is even clearer:
always_comb begin
sum = a + b;
result = sum ^ mask;
end
This is a good example of why assignment type should follow the hardware you are trying to describe rather than a preference for one operator over another.
Why Statement Order Matters With Blocking Assignments
Within procedural code, blocking statements execute in order.
Consider:
always @(*) begin
temp = a & b;
y = temp | c;
end
For comparison, this ordering is harder to reason about because y reads temp before temp is assigned for the current evaluation:
always @(*) begin
y = temp | c;
temp = a & b;
end
In combinational RTL, calculate an intermediate value before using it later in the same process.
temp must be calculated before it is used by y.
Reordering the calculation so an intermediate value is read before it has been assigned for the current evaluation is poor combinational coding style and can make simulation depend on an old value.
The practical rule is simple: in a combinational block, assign intermediate values before using them, and make sure every output and intermediate variable receives a value on every path.
This avoids both stale-value bugs and unintended latch inference.
Nonblocking Assignments Read the Previous State
Consider this clocked block:
always @(posedge clk) begin
a <= b;
c <= a;
end
Suppose before the edge:
a = 5
b = 9
c = 2
At the clock event, the expressions are evaluated from the existing state:
new a = old b = 9
new c = old a = 5
After the scheduled updates:
a = 9
c = 5
c does not become 9. That old-state behavior is one of the most important things to understand when reading sequential Verilog.
A Race Condition With Two Clocked Always Blocks
Assignment style matters even more when multiple processes respond to the same clock edge.
Consider:
reg a;
reg b;
always @(posedge clk)
a = b;
always @(posedge clk)
b = a;
Assume:
a = 0
b = 1
If the first block executes first, a becomes 1, and the second block can then read that new value. Both variables can end up as 1.
If the second block executes first, b becomes 0, and the first block can then read that new value. Both can instead end up as 0.
The result depends on which process the simulator schedules first. That is a race condition.
Now use nonblocking assignments:
always @(posedge clk)
a <= b;
always @(posedge clk)
b <= a;
Both right-hand sides are evaluated using the values that existed before either scheduled update:
old a = 0
old b = 1
After the edge:
a = 1
b = 0
The two registers swap values predictably.
Cliff Cummings' widely used SNUG paper on nonblocking assignments recommends nonblocking assignments for sequential logic and also gives another important rule: do not assign the same variable from more than one procedural block. Read the Cummings SNUG paper.
Give Each RTL Variable One Clear Procedural Owner
Even with correct assignment operators, this pattern is dangerous:
always @(posedge clk) begin
if (set_a)
q <= 1'b1;
end
always @(posedge clk) begin
if (clear_a)
q <= 1'b0;
end
Now two procedural blocks drive the same variable.
The behavior becomes difficult to reason about when both conditions are active, and synthesis tools may reject the construct or infer hardware that does not match the intended priority.
A cleaner structure gives q one owner:
always @(posedge clk) begin
if (clear_a)
q <= 1'b0;
else if (set_a)
q <= 1'b1;
end
The assignment type matters, but ownership matters too. For synthesizable RTL, each state variable should normally have one clear procedural driver.
Blocking vs. Nonblocking and the Event Scheduler
You do not need to memorize the entire Verilog or SystemVerilog event scheduler to write good RTL.
A useful simplified model is:
clock/event occurs
↓
procedural blocks execute
↓
blocking assignments update during execution
↓
nonblocking RHS expressions have been evaluated
↓
scheduled nonblocking updates become visible
The real SystemVerilog event model contains more scheduling regions than this simplified picture.
For normal synthesizable RTL, the important distinction is that = makes its procedural result available immediately, while <= separates evaluating the current state from updating stored state.
That separation is what makes nonblocking assignments useful for registers.
Do Not Mix Blocking and Nonblocking Assignments in the Same RTL Process
A simple, portable coding rule is:
always block.
AMD's current Vivado synthesis guidance recommends not mixing the two forms and warns that RTL may synthesize even though mixing assignment types can produce simulation errors. See AMD Vivado UG901.
Intel is stricter in Quartus Prime Pro Edition: its synthesis guidance says not to mix blocking and nonblocking assignments within an always block.
See Intel Quartus guidance.
So code such as this is not a good portable pattern:
always_ff @(posedge clk) begin
next_sum = a + b;
if (valid_in)
sum <= next_sum;
end
Even when next_sum is intended only as a temporary value, mixing assignment styles in one process can create a tool-portability problem.
A clearer implementation separates combinational calculation from registered state:
logic [8:0] next_sum;
logic [8:0] sum;
always_comb begin
next_sum = a + b;
end
always_ff @(posedge clk) begin
if (valid_in)
sum <= next_sum;
end
Now the architecture is explicit:
always_comb → calculation → blocking =
always_ff → state → nonblocking <=
This is easier to review, lint, simulate, and move between FPGA toolchains.
Never Mix Assignment Types on the Same Signal
This is particularly problematic:
always @(*) begin
if (sel)
y = a;
else
y <= b;
end
One branch uses blocking assignment and the other uses nonblocking assignment on the same signal.
Use one consistent combinational style instead:
always @(*) begin
if (sel)
y = a;
else
y = b;
end
Readable RTL should make the intended hardware obvious rather than requiring the reader to reason about mixed scheduling semantics.
Blocking vs. Nonblocking With Reset Logic
Reset does not change the basic assignment rule.
A synchronous register might be written:
always @(posedge clk) begin
if (!rst_n)
q <= 8'h00;
else
q <= d;
end
An asynchronously reset register might use:
always @(posedge clk or negedge rst_n) begin
if (!rst_n)
q <= 8'h00;
else
q <= d;
end
Both blocks describe sequential state, so both use nonblocking assignments.
The difference between synchronous and asynchronous reset is about when reset is recognized, not about changing the assignment operator.
For reset timing details, see our guide to Synchronous vs. Asynchronous Reset in Verilog .
Blocking vs. Nonblocking in a Finite State Machine
A common FSM structure separates the state register from combinational next-state logic:
reg [1:0] state;
reg [1:0] next_state;
always @(posedge clk) begin
if (!rst_n)
state <= 2'b00;
else
state <= next_state;
end
always @(*) begin
next_state = state;
case (state)
2'b00: begin
if (start)
next_state = 2'b01;
end
2'b01: begin
if (done)
next_state = 2'b10;
end
2'b10: begin
next_state = 2'b00;
end
default: begin
next_state = 2'b00;
end
endcase
end
The state register uses nonblocking assignment because it stores state. The next-state logic uses blocking assignment because it calculates a combinational value from the current state and inputs.
This split makes the hardware architecture visible directly in the code.
SystemVerilog Makes the Intent Clearer
If your flow supports SystemVerilog, specialized procedural blocks make the intent easier to review.
For combinational logic:
always_comb begin
y = (a & b) | c;
end
For sequential logic:
always_ff @(posedge clk) begin
q <= d;
end
always_comb → blocking =always_ff → nonblocking <=
Traditional Verilog remains completely usable:
always @(*) begin
y = a & b;
end
always @(posedge clk) begin
q <= d;
end
The same reasoning applies.
What About Testbenches?
The combinational-versus-sequential rule is primarily an RTL design guideline.
Testbenches have different scheduling requirements. For example, a simple testbench may use blocking assignments to sequence stimulus:
initial begin
rst_n = 1'b0;
valid = 1'b0;
#20;
rst_n = 1'b1;
@(negedge clk);
valid = 1'b1;
end
Changing stimulus away from the DUT's sampling edge is also a common way to avoid simple testbench/DUT races.
More advanced SystemVerilog environments can use clocking blocks and other verification-specific scheduling mechanisms.
If you are new to verification structure, start with What Is a Testbench in Verilog? Then see How to Write a Self-Checking Testbench in Verilog when you want the testbench to check expected behavior automatically.
How the Difference Appears in a Waveform
Return to the three-stage shift register and apply a one-clock pulse at the input.
The columns below show values after each rising edge.
With nonblocking assignments:
after edge 1 2 3 4
in sampled 1 0 0 0
q1 1 0 0 0
q2 0 1 0 0
out 0 0 1 0
The pulse advances one register stage per clock.
With blocking assignments executed in this order:
q1 = in;
q2 = q1;
out = q2;
the first input pulse can propagate through all three procedural assignments during the same clock event.
That difference is easy to spot in a waveform once you follow a transaction edge by edge.
For a practical workflow for doing that, see How to Read Verilog Waveforms: VCD, Timing, X/Z and Debugging .
Common Blocking and Nonblocking Mistakes
| Mistake | Better approach |
|---|---|
Blocking = in a clocked pipeline |
Use <= for each state register |
Nonblocking <= for normal combinational dependencies |
Use = in always @(*) or always_comb |
Mixing = and <= in one process |
Separate combinational and sequential logic |
| Different assignment types on one signal | Give the signal one consistent owner and style |
Same variable assigned from several always blocks |
Combine the state logic under one procedural owner |
Fixing scheduling bugs with arbitrary #1 delays |
Fix the RTL scheduling relationship |
| Assuming synthesis success proves correct semantics | Verify cycle-level simulation behavior too |
A Practical Code-Review Rule
Before reviewing the statements inside a block, first classify the block itself.
For:
always @(*)
ask:
Is this truly combinational, and are the assignments blocking?
For:
always @(posedge clk)
ask:
Is this storing state, and are the state updates nonblocking?
Then check whether every combinational output receives a value on every path, each persistent state variable has one procedural owner, assignment style is consistent, and pipeline latency matches the specification.
This catches many scheduling bugs before they turn into waveform-debugging sessions.
Blocking vs. Nonblocking Decision Table
| Situation | Recommended style |
|---|---|
always @(*) combinational logic |
Blocking = |
always_comb |
Blocking = |
always @(posedge clk) register logic |
Nonblocking <= |
always @(negedge clk) register logic |
Nonblocking <= |
always_ff |
Nonblocking <= |
| Reset branch in sequential process | Nonblocking <= |
| Pipeline registers | Nonblocking <= |
| FSM state register | Nonblocking <= |
| FSM next-state logic | Blocking = |
| Combinational intermediate calculation | Blocking = |
| Persistent state | Nonblocking <= |
These are coding guidelines rather than a replacement for understanding the simulator, but they produce RTL that is substantially easier to reason about and move between toolchains.
Assignment Style Starts With the Hardware Specification
Choosing = or <= is an implementation decision, but the correct architecture starts with timing requirements.
Suppose a specification says:
Capturedata_inon a rising clock edge whenvalid_inis asserted. Present the result two clock cycles later.
That describes registered state and pipeline latency.
The implementation might contain:
always @(posedge clk) begin
if (valid_in) begin
stage1 <= data_in;
stage2 <= stage1;
end
end
Now compare that with:
matchshall continuously indicate whetheraequalsb.
That describes combinational behavior:
always @(*) begin
match = (a == b);
end
If a specification does not define when an output changes, engineers can disagree not only about blocking versus nonblocking assignments, but about whether the output should be registered at all.
Our RTL Design Specification guide shows how to make clocking, latency, reset, and edge-case behavior explicit before implementation.
Blocking and Nonblocking Assignments in Generated RTL
The same discipline matters when RTL is generated from a specification.
Syntactically valid Verilog is not enough. The generated design still has to preserve combinational dependencies, register boundaries, pipeline latency, reset behavior, and state transitions.
When reviewing generated or handwritten RTL, the important questions are the same:
Are persistent state updates nonblocking?
Are combinational calculations blocking?
Does each state variable have one clear owner?
Does data advance by the expected number of cycles?
Does simulation match the timing contract?
SiliCode is designed around a specification-to-RTL-and-verification workflow, so generated behavior can be checked against intended cycle-level requirements rather than judged only by syntax.
The goal is not to assume that generated RTL is automatically correct. The useful workflow is to make the specification explicit, generate the implementation and verification artifacts, and inspect simulation evidence when behavior differs from what was expected.
Generate RTL and matching verification artifacts with SiliCode →
Frequently Asked Questions
What is the difference between blocking and nonblocking assignments in Verilog?
A blocking assignment (=) updates its procedural target as the statement executes. A nonblocking assignment (<=) evaluates the right-hand side and schedules the target update, which makes it suitable for modeling registers that sample old state on the same clock edge.
When should I use blocking assignments?
Use blocking assignments for ordinary combinational procedural logic, typically inside always @(*) or SystemVerilog always_comb.
When should I use nonblocking assignments?
Use nonblocking assignments for persistent sequential state such as registers, counters, pipeline stages, and FSM state registers.
Why are nonblocking assignments used for flip-flops?
Flip-flops sharing a clock sample their inputs on the same active edge. Nonblocking assignments let each register calculate its next value from the old state before the scheduled updates become visible.
Can blocking and nonblocking assignments synthesize?
Both forms are synthesizable in supported contexts, but that does not make them interchangeable. AMD warns against mixing them, while Intel Quartus Prime Pro Edition documents restrictions on mixing blocking and nonblocking assignments within the same always block.
Can I mix blocking and nonblocking assignments in one always block?
For portable RTL, avoid it. Keep combinational calculations in a blocking-assignment combinational process and persistent state in a nonblocking sequential process.
Should reset assignments use blocking or nonblocking?
When reset controls registers in a sequential process, the register assignments should normally remain nonblocking whether the reset itself is synchronous or asynchronous.
What is the safest rule for always_comb and always_ff?
Use blocking assignments in always_comb and nonblocking assignments for sequential state in always_ff.
Conclusion: Use the Operator That Matches the Hardware
The easiest way to remember blocking versus nonblocking assignments is to think about the intended hardware.
If you are describing a combinational calculation where an intermediate result should immediately be available to the next statement, use:
=
If you are describing stored state sampled on a clock edge, use:
<=
Keep combinational and sequential processes separate, give each state variable one clear procedural owner, and avoid mixing assignment styles inside an always block.
Then verify what matters at the hardware level: clock edges, register boundaries, state transitions, and pipeline latency.
If you want to apply that workflow to a real specification, try SiliCode to generate RTL with matching verification artifacts → and inspect the resulting cycle-level behavior before moving deeper into implementation.