Hardware interview practice
SystemVerilog logic, bit, and wire 4-State Types
A signal is assigned only in one always_ff block, and the verification environment must be able to observe X and Z values. Which declaration best matches that intent?
Answer choices
- A. bit q;
- B. int unsigned q;
- C. wire q;
- D. logic q;
Concise answer
The answer and the key reason
Deeper explanation
Work through the implementation and tradeoffs
SystemVerilog separates the signal’s value domain from how it is driven. The logic data type retains unknown and high-impedance values, which is important when the verification environment must detect initialization or connectivity problems. In contrast, bit is two-state and coerces away X/Z information, making it unsuitable for this requirement.
An always_ff block models sequential procedural assignment and imposes a single-writer discipline on its left-hand variables. A plain logic declaration expresses that intent directly. A wire is a resolved net intended for structural or continuous driving; although nets are also four-state by default, choosing one here would conflict with the specified procedural ownership rather than clarify it.
What to remember
- logic preserves X and Z
- always_ff needs procedural storage
- wire models a driven net
Practice the complete prompt
