What is Nonblocking assignment?

Verilog's "<=" assignment, which evaluates every right-hand side at a time step before updating all left-hand sides together. It matches flip-flop behavior and is used for sequential logic.

Field: HDL & Verification

Japanese name: ノンブロッキング代入

How it works

A nonblocking assignment separates evaluating the right-hand side from updating the left-hand side. When the statement runs, the right-hand side is computed, but the left-hand side is not rewritten yet. The updates are applied together at a later stage of the same simulation time. Suppose a is 0 and b is 1 when 'a <= b; b <= a;' runs. The right-hand sides are evaluated with the old values, 1 and 0. Then a becomes 1 and b becomes 0, so the values are swapped.

Match with flip-flops

Flip-flops on the same clock all capture the values present just before the edge. A nonblocking assignment behaves the same way. With 'q1 <= d; q2 <= q1;' in a clocked block, q2 receives the value q1 had before the edge, so the result is a two-stage shift register. Swapping the two lines does not change the result. If another always block on the same clock reads q1, it also reads the value from before the edge. Differences caused by execution order therefore become less likely.

Points to watch

Reading the left-hand side on the line right after the assignment still shows the old value. If cnt is 3, for example, checking cnt on the line after 'cnt <= cnt + 1;' still gives 3. The value 4 becomes visible after the update has been applied. When the same variable is assigned twice in one block, the assignment written later remains. In a combinational always block, an intermediate value is used on the very next line, so blocking assignment is the usual choice.

Try it: questions about Nonblocking assignment

How does Verilog's nonblocking assignment (<=) behave?

  1. AThe left side updates immediately, and the next line sees the new value
  2. BAll right-hand sides at that time step are evaluated first, and then the left-hand sides are updated together
  3. CThe result is discarded and nothing changes
Show answer and explanation

Answer: B. All right-hand sides at that time step are evaluated first, and then the left-hand sides are updated together

With nonblocking assignment, at the clock edge every <= right-hand side is first evaluated using the old values, and only then are all left-hand sides updated together. This mirrors real hardware, where many flip-flops on the same clock capture their pre-edge inputs simultaneously. That is why nonblocking assignment is the rule for describing clocked sequential logic.

FAQ

The symbol <= also means 'less than or equal'. How are the two told apart?

By where the symbol appears. Right after the left-hand side of a statement it is an assignment, and inside an expression it is a comparison. For example, 'a <= b <= c;' assigns to a the result of testing whether b is less than or equal to c.

Does writing a nonblocking assignment produce a flip-flop?

The assignment symbol alone does not decide that. A signal becomes a flip-flop when it is assigned in a block triggered by a clock edge. If <= is used in a combinational block, synthesis normally still produces combinational logic.

Questions that mention Nonblocking assignment (2)

Nonblocking assignment appears in 3 practice questions across 1 topic, including HDL & Verification.

  1. In the code above, a = 0 and b = 1 just before a rising clock edge. What are a and b after the edge?
  2. The code above was written intending an accumulator that keeps adding the input in. Which pair correctly states the problem with this code and how to fix it?

Books on HDL & Verification Ad

As an Amazon Associate I earn from qualifying purchases.

Comparisons that include this term

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary