Unknown Values at Chip Level
Find where unknown values come from at integration, and how RTL hides them and gates invent them. Then check for them where a block takes the value.
You Will Be Able To
- Name the sources of unknown values at chip level: unreset flip-flops, undriven inputs, switched-off domains, unwritten memory.
- Explain X-optimism in RTL and X-pessimism in gates with one example of each.
- Say why the chip bench, on Verilator, cannot show an unknown at all.
- Decide when an unknown at a boundary is a bug and when it is allowed.
- Lesson
- V8.6
- Time
- 28 min
- Runs on
- Your browser
- Check
- 5 questions
A gate-level run fails where every RTL run passed: one signal shows x for a cycle. Is it a real bug, or the simulator?
Both answers happen. This lesson gives you the rules for telling them apart.
- Control / FSM
- Bus
- Peripheral
- Manager
- Data
- Control
- A source of x
The flip-flop has no reset, so simulation starts it at x. On silicon it powers up 0 or 1, and nobody knows which.
- The mux decides
With a known select, the x passes only when its input is chosen. With an unknown select, the answer depends on how the mux is modelled.
- The boundary
At a pad or a bus the value leaves one block for another. That is where an unknown can start to cost something.
- Who takes it
An unknown nobody takes is harmless. An unknown a manager takes as data, or a block takes as control, is a bug.
Read the diagram as text
- Flip-flop, no reset: x until first written
- A known value: a reset register
- Select: known, or itself x
- Mux: RTL if, ?:, or gates
- Pad or bus: the boundary
- Whoever takes it: a manager, the board
- Flip-flop, no reset → Mux: x
- A known value → Mux: 1
- Select → Mux: select
- Mux → Pad or bus: x, 1, or a guess
- Pad or bus → Whoever takes it: taken now?
The structure of the runnable example below, and of the boot ROM's read port (rtl/ap_ahb_rom.sv): hrdata has no reset.
Before You Start
Read Passive Checkers: Bind and Listen first. The Design Verification Fundamentals track explains x in a waveform; the Formal track's X-Propagation lesson teaches the formal check.
| Question | |
|---|---|
| 1 | Where do unknown values come from when blocks are joined into a chip? |
| 2 | What is X-optimism, and where does it hide a bug? |
| 3 | What is X-pessimism, and why does it raise false alarms? |
| 4 | Why can a checker bound into the chip bench never see an x? |
| 5 | When is an unknown at a boundary a bug? |
The Idea: Unknown Is a Simulator's Word for "Could Be Either"
Silicon has no x. Every flip-flop powers up as 0 or 1. A four-state simulator writes x for "this could be either", so you can see which values your design never set. That is useful, as long as the simulator tells the truth.
It does not always. RTL code such as an if statement treats an unknown condition as false and picks one branch. The result looks clean, but the real chip might have taken the other branch. That is X-optimism: a real unknown hidden. A gate netlist goes the other way. Each gate sees only its own inputs, so a mux whose two inputs are equal can still produce x. That is X-pessimism: a false unknown invented.
At chip level the question is where unknowns come from and who takes them. A register with no reset is fine if it is written before anyone reads it. The same register read as data in the first cycle is a bug.
New Words
| Word | Meaning |
|---|---|
| Unknown (x) | The four-state value for "could be 0 or 1"; z means nothing drives the wire. |
| Four-state simulator | A simulator that keeps 0, 1, x and z, such as Icarus. |
| Two-state simulator | A simulator that keeps only 0 and 1, such as Verilator: an x becomes 0. |
| X-optimism | RTL that turns an unknown into a known value, such as an if with an unknown condition taking its else branch. |
| X-pessimism | A gate model that turns a value that is really known into x, because it cannot see two inputs agree. |
| Corruption | The value a power-aware simulation gives the outputs of a switched-off domain: x in four-state, or a fixed pattern in two-state. |
The Smallest Example: One Mux, Three Models
An unreset flip-flop q (still x) and a known 1 feed a 2:1 mux. Model the mux three ways: an if statement, the ?: operator, and AND-OR gates. Then try a second mux whose two inputs are both the known 1.
| Inputs | if (s) ... else ... | s ? a : b | (s & a) | (~s & b) |
|---|---|---|---|
| q = x, k = 1 | 1: takes else | x: inputs differ | x |
| k = 1, k = 1 | 1: takes else | 1: inputs agree | x: gates cannot see it |
From IEEE 1800 clauses 12.4 and 11.4.11 and the gate truth tables; the runnable example below prints the same on Icarus.
Read the second row. Both inputs are 1, so the real mux gives 1 whatever the select. The if and the ?: both say 1. The gates say x. That x is false: pessimism. Now the first row: the if says 1, but if the select were really 1, the pad would carry the unknown q. That 1 is a guess: optimism.
The Rules
Rule 1: Know the sources.
At integration: flip-flops with no reset, inputs nobody drives, outputs of a switched-off domain, memory words nobody wrote.
Rule 2: RTL can hide an unknown.
An if or case with an unknown select picks a branch; the result looks known when the chip might differ.
Rule 3: Gates can invent an unknown.
A gate network can give x where every resolution of the inputs gives the same value.
Rule 4: Check where the value is taken.
An unknown at a boundary is a bug only when a block takes it. Read data is taken at its data phase, a control wire always.
Rule 5: Control is never allowed to be unknown.
A select, an enable or a ready that is x may start a transfer or not. Flag it at every edge out of reset.
Rule 6: A two-state simulator cannot see any of this.
Verilator turns x into 0. X checks need a four-state simulator, or a formal X-propagation check.
Sources for These Rules
An if with an x or z condition takes the else branch: IEEE 1800 clause 12.4. The conditional operator merges both values bit by bit when its condition is ambiguous: clause 11.4.11. $isunknown: clause 20.9.
X-state checks (uninitialized registers, unguarded x-propagation, use of uninitialized values) and partial reset: MEHTA-DV 10.8.
Verilator is two-state (facts ledger TL-020). The site's two-state power-aware runs use an all-ones corruption pattern; the four-state check is the offline E4 Icarus run (facts §27.19).
The Lab: The Same Mux on Two Simulators, Then the ROM
First the toy of the worked example, on the site's Icarus, which keeps four states:
q (unreset) = x
pad from q or k: if 1, ?: x, gates x
pad from k or k: if 1, ?: 1, gates xRule 2 in the second line: the if prints 1, a value the chip might not give. Rule 3 in the third: the gates print x although both inputs are 1. Give the select a known 0 and every model agrees, because nothing is left to guess:
q (unreset) = x
pad from q or k: if 1, ?: 1, gates 1
pad from k or k: if 1, ?: 1, gates 1Now the same source on Verilator 5.052, the simulator of the chip bench:
q (unreset) = 0
pad from q or k: if 1, ?: 1, gates 1
pad from k or k: if 1, ?: 1, gates 1Rule 6. The unreset q prints 0, and the select's x became 0 too. Every model agrees, and no unknown is left to see. So a checker bound into the chip bench can never report an x. The X checker of this module runs on Icarus with recorded wires.
Last, the chip's own boot ROM. Stage E16 recorded it as RTL and as a generic NAND netlist from Yosys, with the same stimulus on Icarus. Its read-data register hrdata has no reset. Here are the first two rows of both views:
| Cycle | resetn | hsel | RTL | Gates |
|---|---|---|---|---|
| 0 | 0 | 0 | xxxx_xxxx | xxxx_xxxx |
| 1 | 1 | 1 | 5555_5553 | 5555_5553 |
RTL and Gates give hrdata in hex; xxxx_xxxx means all 32 bits unknown. tools/fixtures/soc-gate-waves.json (Icarus Verilog version 12.0 (stable); Yosys 0.70+290), 7 rows in all.
Rule 4 at work. In cycle 0 the register is unknown in both views, and that is allowed: no read has completed, so nobody takes it. In cycle 1 the first read loads a clean word into both. The rest of the recording is the first graded problem: find where the two views part, and why.
Why It Is Built This Way
Why not reset every flip-flop? Reset costs area and routing: every reset flop needs the reset net. Data registers such as hrdata are written before they are read, so a reset buys nothing. The cost moves to verification, which must prove that the unknown is never taken.
Why run on Verilator at all, if it cannot see x? Because it is fast: the chip bench runs hundreds of thousands of cycles a second. Teams split the work. The fast two-state bench runs the regression, and a four-state simulation, a gate-level run or a formal X check covers the unknowns.
Traps
The first trap is optimism mistaken for health. An RTL case statement has an unknown select after a missed reset, falls to its default branch, and the test passes. On silicon the select powers up 1, and the chip takes the other branch. Look for unknown selects with a checker, not for unknown outputs.
The second trap is chasing a pessimistic x. A gate-level run shows x on a bus, and the team starts tracing the netlist by hand. Replaying the run with the unknown input forced to 0 and then to 1 would have given the same value both times. The x was the simulator's. Replay each resolution before you call it a bug.
The third trap is the X checker that shouts. It flags every x on hrdata. The reset cycles alone fill the log, and the team switches the checker off. A checker must flag an unknown only in the cycle it is taken.
At Scale
This section looks ahead. ap_soc's X sources fit on one page; a large chip's do not.
Formal X-propagation
Formal apps prove that no unknown from an unreset flop or a switched-off domain reaches a chosen output, for every input.
Gate-level runs, chosen
Teams run a few gate-level tests per release, around reset and power switching, where X problems live.
Simulator X modes
Commercial simulators offer modes that make RTL more pessimistic, so optimism shows earlier.
Try It
Run it: the if prints 1, the ?: and the gates print x; with equal inputs only the gates print x.
Set the select to a known 0 (the predict question below). Which models disagree now?
Change k to 0. Which model's answer for "q or k" changes?
q (unreset) = x pad from q or k: if 1, ?: x, gates x pad from k or k: if 1, ?: 1, gates xCheck Yourself
Common Mistakes
Wrong Trust a clean RTL value when a select may be unknown.
An if takes its else branch on an unknown select; the chip may take the other.
Fix Check selects and enables for unknowns with a four-state checker.
Wrong Treat every x in a gate-level run as a bug.
Gates can invent x where every resolution gives the same value.
Fix Replay the run with the unknown input at 0 and at 1 first.
Wrong Bind an X checker into a Verilator bench.
Verilator is two-state; x becomes 0 and the checker never fires.
Fix Run X checks on a four-state simulator or with a formal tool.
Remember
- Unknowns come from unreset flops, undriven inputs, switched-off domains and unwritten memory.
- RTL can hide an unknown (optimism); gates can invent one (pessimism).
- Check for unknowns where a value is taken: data at its data phase, control at every edge.
- Verilator is two-state; X checks need a four-state simulator or formal.