← Design Verification Interviews
Interview Question · Code Reading
The Monitor That Copied to an Int
The Question
The interviewer asks
A read monitor copies the DUT's rdata into an int before comparing it with the expected value. The DUT never reset the upper nibble. What does this print, and what has the monitor hidden?
module tb;
// A read monitor copies the bus into an int before checking it.
logic [7:0] rdata;
int seen;
initial begin
rdata = 8'bxxxx_0101; // the DUT never reset the upper nibble
seen = rdata; // the monitor's copy
$display("rdata=%b seen=%0d", rdata, seen);
end
endmodule
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
It prints rdata=xxxx0101 seen=5. The copy into the two-state int turns every x and z bit into 0. So the copy looks like a clean 5, and any check after it passes. Keep DUT-facing data in four-state types such as logic, and test it with $isunknown before any conversion to a two-state type.
- The DUT drives 10xz
The DUT drives
4'b10xz: bit 1 is unknown and bit 0 is not driven at all. The monitor copies this one value into two variables. - Copy into logic
The
logiccopy stores all four symbols, soseen4reads10xz, exactly the bits the DUT drove.Follow the calls, values and waits
- data 10xz: DUT output dut_q → seen4
- Copy into bit
The
bitcopy turns eachxandzbit into 0, with no warning.seen2holds1000, a value the DUT never drove.Follow the calls, values and waits
- data 10xz, stored as 1000: DUT output dut_q → seen2
- Check both copies
$isunknown(seen4), a built-in that tests for anyxorzbit, returns 1, so the four-state path can report the unknown bits. On the two-state path,seen2 == 4'b1000is 1 and the check passes.More context
The four-state path still needs
$isunknownfirst:seen4 != 4'b1000isx, and anifwhose condition isxtakes theelsebranch, as the next section and the example show.Follow the calls, values and waits
- data 10xz: seen4 → Unknown check
- data 1000: seen2 → Value compare
Read the diagram as text
- DUT output dut_q: logic [3:0], drives 10xz
- seen4: logic [3:0]: keeps x and z
- seen2: bit [3:0]: only 0 and 1
- Unknown check: $isunknown(seen4) is 1
- Value compare: seen2 == 4'b1000 is 1
- DUT output dut_q → seen4: seen4 = dut_q
- DUT output dut_q → seen2: seen2 = dut_q
- seen4 → Unknown check
- seen2 → Value compare
The information is lost at the assignment to the two-state variable, before any check runs.
| Two-state (0, 1) | Four-state (0, 1, x, z) |
|---|---|
bit, byte, shortint, int, longint | logic, reg, integer, time, every net |
Only the right-hand column can hold an unknown. int and integer are both 32-bit signed, but only integer is four-state.
Self-Check
Tick each key point you covered in your answer.
What Interviewers Listen For (Fresher)
A good fresher answer sorts the types into two-state and four-state at once. It predicts that the code prints seen=5 before anyone runs it.
What Interviewers Listen For (Junior)
A good junior answer moves the unknown check in front of the copy. It names $isunknown as the check to use.
What Interviewers Listen For (Senior)
A good senior answer names the trade-off: two-state data simulates faster but hides unknown bits. It keeps every field sampled from the DUT four-state and flags any int on an interface in review.
Cross-Questions
Where the interviewer goes next. Open a node to practise that follow-up.
WhyWhat IfProve ItBreak ItCompareScale It
- The Monitor That Copied to an Int
-
WhyWhy Two-State Types ExistL1 Junior
If four-state types are safer, why does SystemVerilog have two-state types at all?
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 two-state bit needs half the storage and simpler arithmetic, which matters for large arrays, scoreboards and counters. Two-state types also match C, so they map cleanly across DPI, and random variables are generated as two-state values. Testbench-internal data rarely needs x, so it is the natural home for them.
Self-Check
Tick each key point you covered in your answer.
Misconception
"Two-state types exist for synthesis."
Synthesis maps both families to the same gates; x is a simulation concept. The reasons are simulation speed, memory and C compatibility.
Source Sutherland, RTL Modeling with SystemVerilog for Simulation and Synthesis, ch. 3.3
-
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.
-
What IfA Floating Bus in a Two-State VariableL1 Junior
Asked if they only mention x
What if the DUT releases the bus (drives z) instead of leaving it x?
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
The result is the same: z also converts to 0 in a two-state variable, so an undriven bus reads as zeros.
$isunknowntreats z like x, so the same check before the copy catches both.Self-Check
Tick each key point you covered in your answer.
Misconception
"A z reads as 1, because the bus floats high."
Pull-ups exist only if the design models them with a
pullupor atri1net. A plain z converts to 0 in two-state.Source IEEE 1800-2017 §6.11.2
-
Prove ItSolve 1.1.3: The False-Pass MonitorSimulator-graded
Show it, don't just say it: this Silicon Lab problem is graded by the simulator.
-
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)
What People Get Wrong
Common wrong answers and why they fail. Run It shows the wrong belief failing on a real simulator.
Misconception
"int is four-state, like integer; only bit is two-state."
int belongs to the two-state family with byte and longint. The twin copies xxxx0101 into an int and gets a clean 5; a logic copy keeps the x.
Run It
The monitor copies an x-carrying bus into an int. Is the x still there?
seen=00000101 FAIL: int is two-state; the x became 0 and the copy looks like a clean 5See the Fix
module tb;
logic [7:0] rdata;
logic [7:0] seen; // the fix: keep the copy four-state
initial begin
rdata = 8'bxxxx_0101;
seen = rdata;
$display("seen=%b", seen[7:0]);
if ($isunknown(seen)) $display("PASS: the copy still carries the x, so the check can report it");
else $display("FAIL: int is two-state; the x became 0 and the copy looks like a clean 5");
end
endmodule
Prints: seen=xxxx0101 PASS: the copy still carries the x, so the check can report it
Half-Truth
"Make everything two-state; it simulates faster."
The speed-up is real for counters and testbench bookkeeping. On data sampled from the DUT, it hides a missing reset or an undriven bus. The monitor exists to catch exactly those bugs.
Tool as Truth
"Our Verilator runs never showed an x on that bus, so it is always initialised."
Verilator is a two-state simulator: unknowns are not modelled, so it cannot show one. Reset and X checks need a four-state simulator.
Source ASIC Point engine notes (Verilator 5.052 SVA probes), row "x/z values"