all about vlsi DV
Good catch โ youโre right ๐
Coverage without code feels abstract, and interviews do expect you to have at least seen and reasoned through covergroups.
Below is a revised Coverage โ Part 1, still medium length, but now grounded with runnable SystemVerilog code, while keeping theory light and memorable.
Coverage in SystemVerilog (Part 1) โ Why Random Tests Alone Are Not Enough (With Code)
๐๐ง๐ญ๐ซ๐จ๐๐ฎ๐๐ญ๐ข๐จ๐ง
Alice has done a lot already:
random stimulus
constraints
assertions
Her simulation runs clean. No errors.
Bob now asks the uncomfortable question:
โHow do you know you actually tested anything meaningful?โ
Silence usually follows.
This is why coverage exists โ to measure what really happened, not what could have happened.
๐๐ก๐๐ญ ๐๐ฌ ๐๐จ๐ฏ๐๐ซ๐๐ ๐ ๐ข๐ง ๐๐ฒ๐ฌ๐ญ๐๐ฆ๐๐๐ซ๐ข๐ฅ๐จ๐ ?
Google Featured Snippet Target)
๐๐จ๐ฏ๐๐ซ๐๐ ๐ ๐ข๐ง ๐๐ฒ๐ฌ๐ญ๐๐ฆ๐๐๐ซ๐ข๐ฅ๐จ๐ ๐ฆ๐๐๐ฌ๐ฎ๐ซ๐๐ฌ ๐ฐ๐ก๐ข๐๐ก ๐ฏ๐๐ฅ๐ฎ๐๐ฌ, ๐ฌ๐๐๐ง๐๐ซ๐ข๐จ๐ฌ, ๐จ๐ซ ๐๐๐ก๐๐ฏ๐ข๐จ๐ซ๐ฌ ๐ก๐๐ฏ๐ ๐จ๐๐๐ฎ๐ซ๐ซ๐๐ ๐๐ฎ๐ซ๐ข๐ง๐ ๐ฌ๐ข๐ฆ๐ฎ๐ฅ๐๐ญ๐ข๐จ๐ง, ๐ก๐๐ฅ๐ฉ๐ข๐ง๐ ๐ช๐ฎ๐๐ง๐ญ๐ข๐๐ฒ ๐ฏ๐๐ซ๐ข๐๐ข๐๐๐ญ๐ข๐จ๐ง ๐๐จ๐ฆ๐ฉ๐ฅ๐๐ญ๐๐ง๐๐ฌ๐ฌ.
Coverage does not check correctness.
Coverage checks exploration.
๐๐ฅ๐ข๐๐ & ๐๐จ๐ ๐๐๐ง๐ญ๐๐ฅ ๐๐จ๐๐๐ฅ
Alice generates tests
Bob observes execution
Bob keeps counters:
โThis happenedโ
โThis never happenedโ
Coverage is Bobโs notebook, not Aliceโs logic.
๐ ๐ข๐ซ๐ฌ๐ญ ๐๐๐ฌ๐ญ๐: ๐ ๐ฎ๐ง๐๐ญ๐ข๐จ๐ง๐๐ฅ ๐๐จ๐ฏ๐๐ซ๐๐ ๐ ๐ฐ๐ข๐ญ๐ก ๐๐๐๐ฅ ๐๐จ๐๐
Letโs start simple and concrete.
Alice wants to know:
Did addr ever take low values?
Did it ever take high values?
She doesnโt care how it was generated โ only if it happened.
๐๐๐ฌ๐ข๐ ๐๐จ๐ฏ๐๐ซ๐ ๐ซ๐จ๐ฎ๐ฉ ๐๐ฑ๐๐ฆ๐ฉ๐ฅ๐ (๐๐ฎ๐ง๐ง๐๐๐ฅ๐)
module basic_coverage;
int addr;
covergroup addr_cg;
coverpoint addr {
bins low = {[0:3]};
bins mid = {[4:7]};
bins high = {[8:15]};
}
endgroup
addr_cg cg = new();
initial begin
repeat (10) begin
addr = $urandom_range(0,15);
cg.sample();
$display("addr = %0d", addr);
end
end
endmodule
๐๐ก๐๐ญ ๐๐ฌ ๐๐๐ฉ๐ฉ๐๐ง๐ข๐ง๐ ๐๐๐ซ๐ (๐๐๐ซ๐ฒ ๐๐ฆ๐ฉ๐จ๐ซ๐ญ๐๐ง๐ญ)
covergroup defines what to observe
coverpoint defines which signal
bins define interesting value ranges
sample() records the current value
Alice does not force values.
She only measures what occurs.
๐๐ก๐ฒ ๐๐ก๐ข๐ฌ ๐๐ฌ ๐๐จ๐ฐ๐๐ซ๐๐ฎ๐ฅ (๐๐ง๐ญ๐๐ซ๐ฏ๐ข๐๐ฐ ๐๐ง๐ฌ๐ข๐ ๐ก๐ญ)
Even if:
addr never becomes 15
simulation passes
Coverage will clearly show:
โhigh bin was never hitโ
This tells Alice:
testbench is incomplete
constraints or stimulus must improve
๐๐จ๐ฏ๐๐ซ๐๐ ๐ ๐ฏ๐ฌ ๐๐ฌ๐ฌ๐๐ซ๐ญ๐ข๐จ๐ง๐ฌ (๐๐ฅ๐๐๐ซ ๐๐ข๐๐๐๐ซ๐๐ง๐๐)
Letโs compare with an assertion.
assert (addr < 16)
else $error("Invalid addr");
Assertion checks correctness
Coverage checks occurrence
Interview-safe sentence:
Assertions catch bugs; coverage reveals blind spots.
๐๐จ๐๐ ๐๐จ๐ฏ๐๐ซ๐๐ ๐ ๐ฏ๐ฌ ๐ ๐ฎ๐ง๐๐ญ๐ข๐จ๐ง๐๐ฅ ๐๐จ๐ฏ๐๐ซ๐๐ ๐ (๐๐ข๐ญ๐ก ๐๐จ๐ง๐ญ๐๐ฑ๐ญ)
Tools automatically collect code coverage:
line coverage
branch coverage
toggle coverage
Alice does not write code for that.
Functional coverage is:
written by Alice
based on design intent
scenario-driven
This is why functional coverage matters more in interviews.
๐๐ฅ๐ข๐๐ ๐๐๐ค๐๐ฌ ๐๐ญ ๐๐จ๐ซ๐ ๐๐๐๐ฅ๐ข๐ฌ๐ญ๐ข๐
Now Alice wants to see:
read vs write operations
not just raw values
๐๐ฎ๐ง๐ง๐๐๐ฅ๐ ๐๐ฑ๐๐ฆ๐ฉ๐ฅ๐ โ ๐๐ฎ๐ฅ๐ญ๐ข๐ฉ๐ฅ๐ ๐๐จ๐ฏ๐๐ซ๐ฉ๐จ๐ข๐ง๐ญ๐ฌ
module op_coverage;
bit write;
int addr;
covergroup op_cg;
coverpoint write {
bins read = {0};
bins write = {1};
}
coverpoint addr {
bins low = {[0:3]};
bins high = {[12:15]};
}
endgroup
op_cg cg = new();
initial begin
repeat (20) begin
write = $urandom_range(0,1);
addr = $urandom_range(0,15);
cg.sample();
$display("write=%0d addr=%0d", write, addr);
end
end
endmodule
๐๐ก๐๐ญ ๐๐ฅ๐ข๐๐ ๐๐๐๐ซ๐ง๐ฌ ๐๐ซ๐จ๐ฆ ๐๐ก๐ข๐ฌ
After simulation:
Did both read and write occur?
Were both low and high addresses exercised?
No guessing.
Coverage data answers directly.
๐๐จ๐ฆ๐ฆ๐จ๐ง ๐๐๐ ๐ข๐ง๐ง๐๐ซ ๐๐ข๐ฌ๐ญ๐๐ค๐๐ฌ (๐๐ข๐ญ๐ก ๐๐จ๐๐ ๐๐จ๐ง๐ญ๐๐ฑ๐ญ)
Forgetting to call sample()
Assuming coverage samples automatically
Writing coverage without knowing intent
Sampling at the wrong time
Interviewers often ask:
โWhen does coverage get sampled?โ
Correct answer:
When sample() is called (unless clocked).
๐๐ง๐ ๐๐๐ซ๐ฒ ๐๐ฆ๐ฉ๐จ๐ซ๐ญ๐๐ง๐ญ ๐๐ง๐ญ๐๐ซ๐ฏ๐ข๐๐ฐ ๐๐จ๐ข๐ง๐ญ
Coverage does not improve tests automatically.
Alice must:
look at coverage reports
identify holes
improve stimulus or constraints
Coverage is feedback, not magic.
๐๐ง๐ญ๐๐ซ๐ฏ๐ข๐๐ฐ ๐๐ฎ๐๐ฌ๐ญ๐ข๐จ๐ง๐ฌ ๐๐จ๐ฎ ๐๐๐ง ๐๐จ๐ฐ ๐๐ง๐ฌ๐ฐ๐๐ซ
What is functional coverage?
What are covergroups and coverpoints?
What are bins?
How is coverage different from assertions?
Does coverage affect simulation behavior?
All answerable from this article.
๐๐ง๐ ๐๐๐ง๐ญ๐๐ง๐๐ ๐ญ๐จ ๐๐๐ฆ๐๐ฆ๐๐๐ซ (๐๐ง๐ข๐ฉ๐ฉ๐๐ญ + ๐๐ง๐ญ๐๐ซ๐ฏ๐ข๐๐ฐ ๐ ๐ซ๐ข๐๐ง๐๐ฅ๐ฒ)
Functional coverage measures which scenarios occurred during simulation, independent of correctness.
๐๐ก๐๐ญโ๐ฌ ๐๐๐ฑ๐ญ
๐ ๐๐๐ฑ๐ญ ๐๐ซ๐ญ๐ข๐๐ฅ๐:
Coverage in SystemVerilog (Part 2) โ Cross Coverage, Bins, and Interview Traps