← Design Verification Interviews
Interview Question · Code Writing
Bins for a Wide Range of Lengths
The Question
The interviewer asks
A packet length runs from 1 to 1024 bytes. Write the coverpoint bins. What goes wrong with one big bin, or with one bin per value?
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
Write bins for the corners and a few ranges: min = {1}, max = {1024}, a value next to each end, and mid[4] for the middle. One bin over [1:1024] is covered by the first packet, so it can never show a hole. One bin per value makes 1024 bins that a regression will not fill. Take the ranges from the spec, such as the sizes where the design changes behaviour.
sample() calls.Read the diagram as text
- Test loop: stimulus 1, then stimulus 2
- len_auto: 16 automatic bins, 0 to 15
- len_each: 8 bins, one per length 1 to 8
- len_classes: 3 bins: one, short_, long_
- len_coarse: 1 bin for lengths 1 to 8
- Test loop → len_auto: sample
- Test loop → len_each: sample
- Test loop → len_classes: sample
- Test loop → len_coarse: sample
When the long packets were missing, len_each read 50% and len_classes read 66.67%. The single wide bin len_coarse still read 100%.
Self-Check
Tick each key point you covered in your answer.
What Interviewers Listen For (Fresher)
A good fresher answer writes separate bins for 1 and 1024. It explains that one big bin reads 100% after the first packet.
What Interviewers Listen For (Junior)
A good junior answer takes the range edges from the design, such as buffer sizes. It adds bins for the values just below and just above each edge.
What Interviewers Listen For (Mid-Level)
A good mid-level answer counts how many bins the model has. It then estimates whether the regression can really fill them all.
Cross-Questions
Where the interviewer goes next. Open a node to practise that follow-up.
WhyWhat IfProve ItCompareScale It
- Bins for a Wide Range of Lengths
-
WhyWhere the Leftover Values GoL1 Junior
Why might
bins mid[4] = {[2:1023]}not give four equal bins?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 range holds 1022 values, which does not divide by 4. Each bin gets 255 values, and the last bin also takes the 2 left over, so it holds 257. If an edge matters, don't leave it to the division; give it a named bin.
Bin Values How many mid[0]2 to 256 255 mid[1]257 to 511 255 mid[2]512 to 766 255 mid[3]767 to 1023 257 1022 values split four ways: 255 each, and the last bin takes the 2 left over.
Self-Check
Tick each key point you covered in your answer.
Spec Misquote
"The tool rounds and spreads the extra values over the first bins."
The standard puts every leftover value in the last bin.
Source IEEE 1800-2017 §19.5.1
-
CompareFixed Bin Arrays vs Named RangesL1 JuniorL2 Mid-Level
Compare
mid[4] = {[64:1022]}with ranges you name yourself, likesmall,mediumandjumbo.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 fixed array splits the range by arithmetic, so a design threshold can fall in the middle of a bin. Named ranges follow the spec, so each bin means something and the report is readable. Use arrays for a quick spread across a range that has no special points. Use named ranges wherever the design changes behaviour.
Fixed array, mid[4]Named ranges Bin edges Split by arithmetic Taken from the spec A design threshold Can fall inside a bin Sits on a bin edge Report mid[0] to mid[3] small, medium, jumbo Use it for A quick spread with no special points Ranges where the design changes behaviour Self-Check
Tick each key point you covered in your answer.
Half-Truth
"More bins in the array always means better coverage."
More bins only means finer slices. If a threshold is not on a bin edge, no number of slices isolates it.
Source Spear & Tumbush, SystemVerilog for Verification (3rd ed.), §9.7 (PDF p375)
-
What IfBins Around a Buffer BoundaryL1 JuniorL2 Mid-Level
Asked if they name a buffer size
The design stores packets in 256-byte buffers. Which lengths deserve their own bins, and why?
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
Give 255, 256 and 257 their own bins, and the same for 511 to 513 if two buffers chain. Off-by-one bugs live exactly there: the packet that just fits, and the one that spills into a second buffer by one byte. Write them as
bins at_256[] = {255, 256, 257};beside the wider ranges.Self-Check
Tick each key point you covered in your answer.
Missed Corner
"256 alone is the corner."
The spill to a second buffer happens at 257, and an off-by-one in the "fits" check shows up at 255 or 256. You need both sides.
Source Mehta, SystemVerilog Assertions and Functional Coverage (3rd ed.), §27.1 (PDF p502)
-
Scale ItBins That Follow a Design ParameterL2 Mid-Level
The same length coverpoint must work for designs built with different
MAX_LENvalues. How do you write it?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
Pass the limit in as a covergroup argument,
covergroup cg(int max_len);, and use it in the bins, such asbins max = {max_len};. Each instance then gets bins for its own design. The standard allows this, but check your tool. The coverage build used on this site rejects covergroup arguments inside bins.Self-Check
Tick each key point you covered in your answer.
Tool as Truth
"Covergroup arguments can't be used in bins; my simulator rejects it."
The standard allows covergroup arguments in bin expressions. Rejection is a tool limit; parameters or generated code work around it.
Source IEEE 1800-2017 §19.3; ASIC Point engine notes (Verilator master b8e7f1e coverage build)
-
Prove ItSolve 7.5.8: Two Coverpoints for the FIFOSimulator-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.
Missed Corner
"One bin over the legal range is enough; it reaches 100%."
It reaches 100% on the first packet, whatever its length. The twin sends only 1 to 64 bytes and still reads 100%.
Run It
A regression that only sends short packets.
coverage=100.00 FAIL: one bin over 1 to 1024 reads 100% though no packet was longer than 64See the Fix
module tb;
bit [10:0] len;
covergroup cg;
cp: coverpoint len {
bins min = {1};
bins small_ = {[2:63]};
bins mid[4] = {[64:1022]};
bins near_max = {1023};
bins max = {1024};
}
endgroup
cg c = new();
initial begin
// The regression only ever sent packets of 1 to 64 bytes.
for (int i = 1; i <= 64; i++) begin len = 11'(i); c.sample(); end
$display("coverage=%0.2f", c.get_coverage());
if (c.get_coverage() == 100.0) $display("FAIL: one bin over 1 to 1024 reads 100%% though no packet was longer than 64");
else $display("PASS: the corner and range bins show the long packets never happened");
end
endmodule
Prints: coverage=37.50 PASS: the corner and range bins show the long packets never happened
Half-Truth
"bins each[] = {[1:1024]} is the thorough choice."
It needs at least 1024 packets, one of every length. The twin sends 512 different lengths and fills half.
Run It
One bin per legal length.
coverage=50.00 after 512 packets of different lengths FAIL: 1024 one-value bins need at least 1024 packets; this model cannot close in a normal regression