Write a passive checker that reports an unknown value at a chip boundary only when it matters. That is on a control wire out of reset, or in read data a manager takes. It runs on recorded four-state wires of the chip's boot ROM.
Hardware context: The boot ROM of ap_soc v1.5 as RTL and as a gate netlist, and a toy mux on two simulators. An X checker on the ROM's read port.
An unknown value is not always a bug. A register with no reset is unknown until it is written, and that is fine if nobody reads it first. A useful X checker therefore watches a boundary with a rule: when is an unknown a real problem?
The boundary here is the AHB-Lite read port of the boot ROM of ap_soc v1.5. Write x_watch. At each rising edge while the ROM's resetn is 1, count one error if either holds. One: any control wire is unknown, from the manager (hsel, hready, htrans, hwrite) or from the ROM (hreadyout, hresp). Two: the previous edge accepted a read, hreadyout is 1, and hrdata has an unknown bit. Count at most one error per edge, and remember the kind of the first: 1 for control, 2 for data. A read counts as accepted only when hsel, hready and htrans[1] are known 1 and hwrite is known 0.
Why not on the chip bench? It runs on Verilator, which has only two states. An unknown becomes 0 there, so a checker bound into it could never fire. This problem runs on the four-state Icarus engine instead. The bench replays wires that a probe recorded from the ROM's RTL and from its gate netlist, cycle by cycle.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
trace_no | 3 | input of each check |
Full specification
| Kind | When it counts | Why |
|---|---|---|
| 1 control | Any of hsel, hready, htrans, hwrite, hreadyout, hresp has an unknown bit | Every block on the bus acts on these every cycle; an unknown one can start a transfer, or not |
| 2 data | A known read was accepted at the previous edge, hreadyout is 1 now, and hrdata has an unknown bit | This is the edge a manager takes the word |
| none | hrdata unknown in any other cycle | Nobody takes it; an unreset read register is allowed to be unknown |
rst_n is the checker's own reset: it clears errors, first and any state you keep. resetn is the ROM's reset as observed; while it is not 1, count nothing and forget any accepted read.
$isunknown(v) is 1 when any bit of v is x or z (IEEE 1800 clause 20.9). Test each wire on its own: on Icarus 12, $isunknown of a concatenation can miss an unknown bit (facts ledger TL-009). A comparison with == against an x gives x, never 1.
Examples
Example 1
RTL: Two Reads, a Write That Answers ERROR, Another Read- Input
reset, two reads, a write that answers ERROR, a read
- Output
errors = 0, first = 0
Out of reset the read data is unknown in the idle cycles, because hrdata has no reset. No read completes there, so nothing counts. Every read that completes returns a known word.
Example 2
Gates: One Read with an Unknown Select, the Address Held- Input
the E16 stimulus: one read with an unknown select and the address held
- Output
errors = 1, first = 1
The unknown select is a control wire: one error, kind 1. The netlist then shows unknown read data. The edge with the unknown select accepted no known read, so that data is not counted.
Example 3
RTL: A Read of a Word the Image Never Wrote, Then an Unknown Select- Input
a read of a word the image never wrote, then a cycle with an unknown select
- Output
errors = 2, first = 2
Word 12 is beyond the 8 words of the image. Its read completes with all 32 bits unknown: an error of kind 2. The later unknown select adds one of kind 1.
Constraints and Contract
- Keep the module name and every port.
- Read only: drive nothing but errors and first.
- Each case reports {errors, first} at the end of one trace.
Hints
Hint 1
Keep one bit of state: did the previous edge accept a known read?
Hint 2
Use === 1'b1 to ask "known 1"; an if with an unknown condition takes its else branch.
Hint 3
The ROM's outputs are control wires too. What happens to them if the reset never came?
What the grader checks: Eight traces of the ROM's read port: four scenarios, each as RTL and as a Yosys NAND netlist. Icarus Verilog version 12.0 (stable) recorded them. The checker is not bound into the live chip bench, which is two-state. The traces are zero-delay; a real netlist with delays can show other unknowns.
8 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 problems on this path