HDL & Verification
What is the common guideline for choosing assignment types in Verilog?
- AUse only blocking assignment (=) everywhere
- BUse nonblocking (<=) for clocked sequential logic and blocking (=) in combinational always blocks
- CMix both arbitrarily in the same always block
Show answer and explanation
Answer: B. Use nonblocking (<=) for clocked sequential logic and blocking (=) in combinational always blocks
Writing sequential logic with nonblocking assignments matches hardware where all flip-flops capture values simultaneously, so results do not depend on statement order or on the execution order of other always blocks. Combinational logic naturally computes intermediate values from top to bottom, so blocking assignments are used there. It is also important not to mix the two within one always block.
- A. Blocking in sequential logic often yields unintended circuits.
- B. Correct. It keeps simulation and hardware behavior consistent.
- C. Mixing makes behavior hard to follow and error-prone.