Blocking (=) and non-blocking (<=) assignments in Verilog differ in when the left-hand side is updated. A blocking assignment updates its target immediately, so the next statement in the same block sees the new value. A non-blocking assignment samples the right-hand side now but updates the target at the end of the time step, so every statement in the block sees the old values. Neither is faster or "more correct" on its own; the rule that keeps you out of trouble is non-blocking for clocked logic, blocking for combinational logic.
I know people who swear by blocking and some who swear by non-blocking. So here are some thoughts, with every example below compiled and simulated so you can see the behavior rather than take it on trust.
Key takeaways
- There is very little difference in simulation speed between the two, and no errors if either is used correctly.
- With non-blocking assignments inside
always @(posedge clk), statement order does not matter and every assigned reg becomes a flip-flop. - With blocking assignments, statement order changes the hardware: reversing two lines can add or remove a flip-flop.
- Blocking assignments between modules clocked on the same edge create simulation races; non-blocking assignments remove them.
- The widely taught guideline:
<=in sequential blocks,=in combinational blocks, and never mix both on the same variable.
How the simulator schedules each kind
The Verilog standard (IEEE 1364, now folded into IEEE 1800 SystemVerilog) splits each simulation time step into regions. Blocking assignments execute in the active region, in order, as the statements run. Non-blocking assignments evaluate their right-hand side in the active region but queue the update for the NBA (non-blocking assignment) region, which runs after all active events at that time have finished. That single scheduling rule explains every example in this post.
| Property | Blocking = | Non-blocking <= |
|---|---|---|
| When the target updates | Immediately, before the next statement | End of the time step (NBA region) |
| Does statement order matter? | Yes | No, within one block |
| Natural use | Combinational logic, temporary variables | Flip-flops and latches |
| Race risk between clocked blocks | High | Removed for same-edge transfers |
The rule of thumb in plain words
Think of a clock edge as a photograph. With non-blocking assignments, every flip-flop in the design looks at the photograph taken just before the edge and then updates together, the way real hardware does. With blocking assignments, each line updates straight away, so a line further down sees a value that has already moved on. That is perfect for working out a combinational result step by step, and it is exactly wrong for a bank of flip-flops that should all sample at the same instant.
So the practical guidance is short:
- Clocked block (
always @(posedge clk)oralways_ff): use<=for every register. - Combinational block (
always @(*)oralways_comb): use=, and assign every output on every path so no latch appears. - Never assign the same variable with both kinds, and never assign the same variable from two different blocks.
Follow those three lines and the arguments below stop mattering in practice. The deep dive shows why, with compiled and simulated examples.
Deep dive: the numbers and details
This part holds the figures, equations and worked examples. Skip it if the overview is all you need.
Myth or fact 1: non-blocking tells you what becomes a flip-flop
Some people like non-blocking because you can tell that a reg on the left-hand side of <= is going to be a flip-flop after synthesis. That is a fact for edge-triggered blocks, and the order of the statements does not change it.
/* example 1a */
reg a, b, c;
always @(posedge clock)
begin
b <= a; /* b and c will be flip-flops */
c <= b;
end
/* example 1b */
reg a, b, c;
always @(posedge clock)
begin
c <= b;
b <= a; /* b and c will be flip-flops */
end
Both describe a two-stage shift register: a reaches b after one clock and c after two.
Myth or fact 2: with blocking, order changes the hardware
/* example 2a */
reg a, b, c;
always @(posedge clock)
begin
b = a;
c = b;
/* c gets the new b, which is a. b and c hold the same value,
so synthesis builds one flip-flop and b is merged into c. */
end
/* example 2b */
reg a, b, c;
always @(posedge clock)
begin
c = b;
b = a;
/* Both b and c will be flip-flops, because these two lines are reversed. */
end
In example 2a we could replace the two assignments with c = a; b = a;. In fact b is the same as c and one of them can be eliminated. Examples 1a, 1b and 2b are functionally the same. Example 2a is functionally different from 2b only because of the order of the statements.
Simulation result
Driving a from 0 to 1 and printing after each rising edge gives:
t=20 1a: b=1 c=0 | 2a: b=1 c=1 | 2b: b=1 c=0
t=30 1a: b=1 c=1 | 2a: b=1 c=1 | 2b: b=1 c=1
Examples 1a and 2b delay c by a second clock; example 2a moves a into c in a single clock. Checked with Icarus Verilog 12.0.
Myth or fact 3: blocking uses less simulator memory
Some people like blocking because it can take less memory in the simulator.
/* example NON-BLOCKING_MEMORY */
reg a, b, c;
always @(posedge clock)
begin
b <= a; /* the scheduled update for b holds the new value (a) */
c <= b; /* while b itself still holds its value from before the edge */
end
/* example BLOCKING_MEMORY */
reg a, b, c;
always @(posedge clock)
begin
// b needs only one storage location
c = b;
b = a;
end
Note that I am talking about simulator memory, not flip-flop count after synthesis. A non-blocking assignment needs somewhere to hold the pending value until the NBA region. In most cases the simulator has to keep the value before and after the clock edge anyway when a reg goes between modules, so that modules appear to execute in parallel, so there may be no saving. With modern simulators the difference is small; treat this as a minor point rather than a reason to choose blocking.
Myth or fact 4: blocking shows resource sharing more clearly
Some people like blocking because you can see sharing of resources more readily.
// example 5: shared sum through a blocking temporary
reg [15:0] a, b, c, d, e, f, j, k, g, h;
reg [18:0] x; // eight 16-bit values need 19 bits
reg [19:0] y, z; // nine 16-bit values need 20 bits
always @(posedge clock)
begin
x = a + b + c + d + e + f + j + k;
y <= x + g;
z <= x + h;
end
// example 6: same function written twice
reg [15:0] a, b, c, d, e, f, j, k, g, h;
reg [19:0] y, z;
always @(posedge clock)
begin
y <= (a + b + c + d + e + f + j + k) + g;
z <= (a + b + c + d + e + f + j + k) + h;
end
Even the cheapest synthesizer should share the adder logic in example 5, but a slightly smarter one is needed to spot the common sub-expression in example 6. Most current tools handle both.
Two fixes from the original version of this post. First, the widths: the original declared x, y and z as 17 bits, which silently truncates. The sum of eight 16-bit values can reach 8 × 65,535 = 524,280, which needs 19 bits, and adding a ninth needs 20. With all inputs at 65,535, a 19-bit y wrapped to 65,527 in simulation instead of 589,815. Second, example 5 now uses blocking only for the temporary x and non-blocking for the registered outputs. If x is used only inside this block it is a wire after synthesis, not a flip-flop; if another block reads it, it becomes a register and the mix of styles invites a race.
Fact: non-blocking removes same-edge races between modules
You will have fewer problems with race conditions in simulation if you always use non-blocking assignments inside always @(posedge clock) blocks where you want flip-flops. Here is the classic race, written with blocking assignments:
// file xyz.v
module xyz(a, b, clk);
input b, clk;
output a;
reg a;
always @(posedge clk)
a = b;
endmodule
// file abc.v
module abc(b, c, clk);
input c, clk;
output b;
reg b;
always @(posedge clk)
b = c;
endmodule
Some simulators will execute module abc first and then module xyz. This effectively transfers the contents of c to a in one clock cycle, which is what people call a simulator race condition. Other simulators execute xyz first and then abc, giving a different result. The standard allows either order, and in many simulators the user cannot control it.
Change both assignments to <= and the race disappears: both right-hand sides are sampled before either target updates. In simulation with Icarus Verilog 12.0, c going high reached b after one edge and a only after the second, which is what two real flip-flops in series do.
Common mistakes
- Using blocking assignments in a clocked block that other clocked blocks read: the result depends on simulator order.
- Using non-blocking in a combinational
always @(*)block: it simulates, but needs extra passes and can mislead when a temporary is read in the same block. - Mixing
=and<=on the same variable: most lint tools flag it and some synthesis tools reject it. - Reading a blocking temporary from another block: it turns into a register and the race returns.
- Undersized result widths on sums, as in the original example 5.
How interviewers probe this
- "Swap two non-blocking lines. Does the circuit change?" (No.)
- "Swap two blocking lines in a clocked block. How many flip-flops now?" (Examples 2a and 2b.)
- "Write a swap of two registers without a temporary." (
a <= b; b <= a;works; the blocking version does not.) - "Why does this testbench pass on one simulator and fail on another?" (A same-edge race.)
Frequently asked questions
Is non-blocking slower to simulate?
Very slightly at most, because the update is queued. In practice the difference is rarely measurable, and the race safety is worth far more.
Can I use blocking in a sequential block at all?
Yes, for a temporary that is read only later in the same block, as with x in example 5. Keep it local and never read it elsewhere.
Does synthesis care which one I use?
Synthesis follows the simulation semantics, so the order effects shown in examples 2a and 2b also appear in the netlist. That is why a mismatch between RTL simulation and gate-level simulation often traces back to assignment style.
Where does the "non-blocking for sequential" rule come from?
It is the coding guideline popularized by Clifford Cummings in his SNUG 2000 paper, "Nonblocking Assignments in Verilog Synthesis, Coding Styles That Kill!" (Internet Archive copy), and it is now the default in most company style guides.
Further reading
- Clifford E. Cummings, "Nonblocking Assignments in Verilog Synthesis, Coding Styles That Kill!", SNUG San Jose 2000 (Internet Archive copy): the eight coding guidelines and the scheduling regions explained in detail.
- IEEE 1800-2023 SystemVerilog standard: the scheduling semantics chapter defines the active and NBA regions used above.


Nice examples.
ReplyDeleteI have seen people asking situations of only race conditions in verilog assignments. This is comprehensive in the sense that both simulator and synthesizer are discussed.
Great job!