What is Four-state logic?
The four values used in HDL simulation: 0, 1, X (unknown) and Z (high impedance). Uninitialized or conflicting signals become X.
Japanese name: 4値論理
The four values used in HDL simulation: 0, 1, X (unknown) and Z (high impedance). Uninitialized or conflicting signals become X.
Japanese name: 4値論理
X means the simulator cannot tell whether a value is 0 or 1. Uninitialized registers, a wire driven by two outputs that disagree, and values computed from X inputs all become X. X propagates through logic, though not always: an AND with one input at 0 gives 0, while an AND with one input at 1 gives X. Z means nothing is driving the net, as on a tri-state line whose driver is disabled or an unconnected wire. When Z reaches a gate input, it is treated as X.
SystemVerilog also has two-state types such as bit and int, which hold only 0 and 1. They use less memory and simulate faster, but they start at 0 and cannot represent X, so bugs such as a missing reset can go unseen. A common split is the four-state logic type for design code and two-state types for testbench calculations. VHDL's std_logic goes further, with nine values including U for uninitialized and values for weak drive.
X or Z appearing in simulation waveforms is a strong clue to missing initialization or driver conflicts. Real hardware has no X, however, and a Verilog if statement treats an X condition as false, which can hide bugs (X-optimism). Gate-level simulation can err the other way, producing X for values that real hardware would resolve (X-pessimism). For comparisons, == yields X when X or Z bits leave it undecided whether the operands match, while === compares X and Z literally as values.
Answer: A. 0, 1, X (unknown) and Z (high impedance)
Besides 0 and 1, Verilog signals can be X (unknown) and Z (high impedance, undriven). Uninitialized registers and signals with conflicting drivers become X, while unconnected wires and tri-state lines whose drivers are disabled become Z. Spotting X or Z in simulation is a major clue to finding bugs.
As an Amazon Associate I earn from qualifying purchases.
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.