← Design Verification Interviews
Interview Question · Code Writing
A Check for Unknown Bits
The Question
The interviewer asks
Write a check that reports when a data bus has any x or z bit. A candidate wrote if (data == 8'bx) error++;. Why does it never fire?
You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
With x bits in an operand, == returns x, and an if treats x as false. So the error line never runs. Use $isunknown(data), which is true when any bit is x or z. In a design, write it as a concurrent assertion gated by the valid signal: valid |-> !$isunknown(data).
Read the diagram as text
- data = 8'bxxxx_0101: The upper four bits were never driven
- data == 8'bx: The result is x, not 1
- if treats x as false: error++ never runs: caught=0
- $isunknown(data): True when any bit is x or z
- The check fires: caught=1
- data = 8'bxxxx_0101 → data == 8'bx
- data == 8'bx → if treats x as false: x
- data = 8'bxxxx_0101 → $isunknown(data)
- $isunknown(data) → The check fires: 1
Measured: the twin prints caught=0, and the fixed version prints caught=1.
Self-Check
Tick each key point you covered in your answer.
What Interviewers Listen For (Fresher)
A good fresher answer explains why == with an x bit gives x, which the if treats as false. It then writes $isunknown.
What Interviewers Listen For (Junior)
A good junior answer gates the check with valid. It explains that the bus may legally be x when nothing is being sent.
What Interviewers Listen For (Senior)
A good senior answer runs X checks on a four-state simulator as part of reset sign-off. It knows a two-state engine cannot show an x at all.
Cross-Questions
Where the interviewer goes next. Open a node to practise that follow-up.
WhyWhat IfProve ItBreak ItCompareScale It
- A Check for Unknown Bits
-
CompareThree Ways to Ask Whether a Value Is UnknownL1 Junior
Compare
$isunknown(r),r === 'xandr == 'xas checks for an unknown bus.2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
$isunknownis true when any bit is x or z, which is the check you want.===compares x and z bits literally, sor === 'xis true only when every bit is x and misses a half-driven bus.==returns x whenever an operand has an x bit, so it never gives a clean true. The run shows all three onxxxx0101.Three checks on r = 8'bxxxx_0101Check Result Why $isunknown(r)1 At least one bit is x or z r === 'x0 True only if every bit is x r == 'xx Any x bit makes ==return xThe values are the output of the run on this question.
RUNIcarus Verilog · in your browserExpected:isunknown=1 case_eq_all_x=0 logic_eq=xSelf-Check
Tick each key point you covered in your answer.
What Interviewers Listen For (Junior)
A good junior answer predicts all three results for a partly unknown value before running the code.
Misconception
"Write
if (r == 'x)to catch an unknown bus."==with an x operand yields x, andiftreats x as false, so that branch can never run. The run printslogic_eq=x.Source IEEE 1800-2017 §11.4.5
-
Break ItAn Unknown Check That Fires Every Idle CycleL1 JuniorL2 Mid-Level
You add
assert property (@(posedge clk) !$isunknown(rdata));and it fails on almost every cycle of a passing test. What is wrong with the check?log t=15 a_known failed: rdata=xxxxxxxx rvalid=0 t=25 a_known failed: rdata=xxxxxxxx rvalid=0 t=35 rvalid=1 rdata=3c (scoreboard OK) t=45 a_known failed: rdata=xxxxxxxx rvalid=02:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
The bus is allowed to be unknown when nothing is being transferred; only data that
rvalidmarks as valid must be known. Writervalid |-> !$isunknown(rdata), and check the qualifier itself with a separate unconditional!$isunknown(rvalid)after reset.An unreset register on the read bus In cycles 0 to 3, rdata is x while rvalid is 0, which is legal. A check gated by rvalid fails only at cycle 4.
Self-Check
Tick each key point you covered in your answer.
Wrong Altitude
"Reset
rdatain the DUT so the assertion stays quiet."That adds reset logic to a datapath to satisfy a wrong check. Many designs leave data unreset on purpose to save area; the protocol only promises known data when it is valid.
-
WhyWhy Teams Assert That Data Is KnownL1 Junior
Why add
!$isunknownchecks at all, if the scoreboard compares the data anyway?2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
A scoreboard may convert the data to a two-state type, where x becomes 0, or compare with
!=, where x hides. An X check at the interface catches an undriven or unreset bus at the cycle it appears. It also points straight at the interface instead of at a later data mismatch.Reset never arrives: the DUT drives x, the monitor stores 0 The DUT drives x, the monitor copies it into an
int, and the checker compares 0 with 0. A!$isunknowncheck on the DUT side would fire at the read.Self-Check
Tick each key point you covered in your answer.
Half-Truth
"X bugs are only an RTL simulation artefact."
An x in RTL often marks a real missing reset or undriven signal, which becomes a random value in silicon.
Source Sutherland, RTL Modeling with SystemVerilog for Simulation and Synthesis, appendix C
-
What IfLimiting Active Bits with CountonesL1 Junior
Asked if they mention
$onehotWhat if up to two of eight channels may be active at once?
$onehotno longer fits.2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Write
$countones(active) <= 2.$countonesreturns the number of 1 bits, so any limit works. Pair it with a cover for exactly two active channels, so the test shows that the limit case really happened.Self-Check
Tick each key point you covered in your answer.
Misconception
"Write
active inside {0, 1, 2}."That compares the vector's value, not its number of set bits. Value 3 has two bits set but is rejected, and value 2 has one bit set.
Source IEEE 1800-2017 §20.9
-
Scale ItKeeping Unknowns Visible Across a Chip-Level BenchL3 Senior
At chip level much of the environment is two-state, and the emulation runs are two-state too. How do you stop X bugs from escaping?
2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Draw the line at the DUT boundary: interfaces and monitors stay four-state, and every bus gets a
valid |-> !$isunknown(data)assertion bound to it. Reset and power-up scenarios run on a four-state simulator as a sign-off item. Emulation normally runs two-state; X modes exist but cost speed, so reset-state X checks belong in four-state simulation. Two-state is allowed only behind that boundary, where speed matters and nothing samples the DUT.Self-Check
Tick each key point you covered in your answer.
What Interviewers Listen For (Senior)
A good senior answer says which runs can see an x and which cannot. It makes the four-state reset run a sign-off item, not a hope.
Half-Truth
"Emulation covers it; it runs a million times more cycles."
Emulation normally runs two-state, so a missing reset reads as 0 or 1. X modes exist but cost speed, so treat reset-state X checks as a four-state simulation item.
Source ASIC Point engine notes (Verilator 5.052 SVA probes), row "x/z values" (how a two-state engine reads an X)
-
Prove ItSolve 1.1.1: Unknown-Bit CounterSimulator-graded
Show it, don't just say it: this Silicon Lab problem is graded by the simulator.
What People Get Wrong
Common wrong answers and why they fail. Run It shows the wrong belief failing on a real simulator.
Misconception
"data == 'x finds an unknown bus."
The comparison result is x, and the if takes the false branch. The twin's bus has four x bits and nothing is caught.
Run It
A bus with an undriven upper nibble, checked two ways.
caught=0 FAIL: == with x bits gives x, the if treats x as false, so nothing was caughtSee the Fix
module tb;
logic [7:0] data = 8'bxxxx_0101; // upper nibble never driven
int caught = 0;
initial begin
assert (!$isunknown(data)) else caught++; // the fix
$display("caught=%0d", caught);
if (caught) $display("PASS: $isunknown saw the x bits");
end
endmodule
Prints: caught=1 PASS: $isunknown saw the x bits
Tool as Truth
"My Verilator run never fires $isunknown, so the bus is clean."
Verilator is two-state, so x does not exist in its runs. Check unknowns on a four-state simulator.
Source ASIC Point engine notes (Verilator 5.052 SVA probes), row "x/z values"
Missed Corner
Checks !$isunknown(data) on every cycle, ungated.
Most buses are allowed to float when idle. The check then fails on every idle cycle and people learn to ignore it.
Source Mehta, SystemVerilog Assertions and Functional Coverage (3rd ed.), §9.2