Protected Course Page
Enter the password to view Day 25 of the UVM 30-Day plan.
Day 25: Coverage Closure — Analyzing Holes, Writing Directed Sequences, and Knowing When Enough is Enough
A 30-day SystemVerilog/UVM verification series. Yesterday you ran the regression. Today you look at the number it produced and decide whether it means anything.
Coverage closure is the part of verification that most looks like engineering and least looks like it. You have a coverage database. It says 87%. That 87% is the number everyone reports on, and it is the number nobody believes. The work of closure is to find out what the 13% actually represents, decide which holes matter, and close them — or decide that a specific hole is out of scope and document that decision.
This is not a mechanical process. It is a sequence of judgment calls, and today is about making those calls well.
1. Reading the Coverage Report
Every coverage report has the same structure. A hierarchy of covergroups, each with coverpoints and crosses, each with bins and hit counts. The number at the top is an average. The information is at the bottom.
GROUP / COVERPOINT BINS HITS %
fifo_coverage 10 8 80.00
cp_wr 2 2 100.00
cp_rd 2 2 100.00
cp_wdata 4 3 75.00
zero 1 1 100.00
max 1 0 0.00 <-- hole
low 1 1 100.00
high 1 1 100.00
cross_wr_rd 4 3 75.00
wr_only 1 1 100.00
rd_only 1 1 100.00
idle 1 1 100.00
both 1 0 0.00 <-- hole
Two holes. Both are visible at a glance. The bulk of closure work is reading a report like this and figuring out why each hole is empty.
| Hole type | What it means | Fix |
|---|---|---|
| Zero-hit bin with an obvious stimulus | The test never drove the condition | Directed sequence |
| Zero-hit bin with no obvious stimulus | Either the coverage is wrong (condition unreachable) or the DUT is constrained so it never occurs | Review the coverage model against the spec |
| Low-hit bin (1 or 2 hits) | The condition is rare but reachable | Directed sequence or tighter constraint |
| Illegal cross bin | The DUT cannot legally reach the combination | Exclude with ignore_bins and document why |
2. Three Ways to Close a Hole
Pattern A: directed sequence
Write a sequence that drives exactly the missing condition. This is the cleanest closure method because the test's purpose is obvious from its name.
// cp_wdata.max is at 0%. Add a sequence that writes 0xFF.
class fifo_write_max_seq extends uvm_sequence #(fifo_tx);
`uvm_object_utils(fifo_write_max_seq)
virtual task body();
repeat (20) begin
`uvm_do_with(req, { req.wr_en == 1; req.wdata == 8'hFF; })
end
endtask
endclass
Run it once in the regression. The bin goes to 100%.
Pattern B: tighter constraint
If the hole is empty because the random distribution does not reach the corner, tighten the constraint on the sequence that runs in the regression:
class fifo_write_seq extends uvm_sequence #(fifo_tx);
// ...
constraint c_corner_weight {
// Bias the random toward the corners
wdata dist {
8'h00 := 5,
8'hFF := 5,
[8'h01:8'hFE] := 90
};
}
endclass
Tighter constraints let the existing regression close more coverage per run. They are slower per test but produce more useful results overall.
Pattern C: exclude with documentation
Some holes are unreachable by design. A cross between "read at empty" and "read at full" cannot happen because the FIFO cannot be both at once. Exclude it and write down why:
cross_wr_rd: cross cp_wr, cp_rd {
// This cross cannot be hit — the bus cannot issue simultaneous wr+rd
ignore_bins impossible = binsof(cp_wr) intersect {1} &&
binsof(cp_rd) intersect {1};
}
The exclusion is now in the code. The next person to look at the report sees it, sees the comment, and does not waste time trying to close it.
3. Coverage Feedback on Constraints
Some teams go further: they use coverage from the previous regression to tighten constraints for the next regression. If a corner has never been hit, tighten the constraint toward it. If a bin is being hit thousands of times, loosen the constraint to let randomness find other bins.
// Pseudocode: a "coverage-aware" sequence
class adaptive_write_seq extends uvm_sequence #(fifo_tx);
// Read the coverage database at build time (not shown — project-specific)
// and adjust constraint weights accordingly.
constraint c_adaptive {
wdata dist {
8'hFF := corner_needs_ff ? 50 : 5,
8'h00 := corner_needs_00 ? 50 : 5,
[8'h01:8'hFE] := 90
};
}
endclass
This is powerful and, in the wrong hands, dangerous. If the adaptive logic is wrong, coverage plateaus without anyone noticing. It works well when a small number of clearly-defined corners can be steered toward, and poorly when it is applied everywhere.
4. The Verification Plan
Coverage closure without a verification plan is closure against an arbitrary set of coverpoints. The plan is the list of conditions the DUT must handle, and each condition should map to one or more covergroups. Closure means: every line of the plan has been hit.
| Plan line | Covergroup / bin | Status |
|---|---|---|
| Write to full FIFO | cp_full intersect {1} on wr_en | Closed |
| Read from empty FIFO | cp_empty intersect {1} on rd_en | Closed |
| Wrap-around pointer | cp_wr_ptr max → zero | Open |
| Simultaneous wr+rd | cross_wr_rd / both | Ignored (impossible) |
When the report and the plan disagree — a bin is hit but the plan line is marked "open" — one of them is wrong. Every bin should have a plan line, and every plan line should have a bin. This is the discipline that makes "87% coverage" meaningful instead of an arbitrary number.
5. When Coverage is Enough
This is the only question in coverage closure that matters, and there is no universal answer. The practical criteria:
- Every plan line is closed or documented as out of scope. No "open" without a reason.
- No zero-hit bin remains that the spec says is reachable. The DUT is required to handle it; the testbench must reach it.
- Regressions from the last week have not found new bugs in covered behavior. If coverage is high but bugs keep appearing, the coverage model is incomplete.
- Regressions have not found new bugs in uncovered behavior either. If bugs are appearing in regions with no coverage at all, the plan needs to grow.
- Sign-off on the plan by the design and verification leads. Not because they have final authority, but because they can add plan lines nobody thought of.
Numbers are the wrong question. The right question is "have we closed the gaps the plan identified, and do we trust the plan?" A team at 70% with a trustworthy plan is in better shape than a team at 95% with a broken one.
6. What Day 26 Will Add
Tomorrow: VIP Integration. You have built a full testbench by hand. The reality of a real project is that most of it comes from existing Verification IP — a bus agent, a memory model, a reference model. Tomorrow covers how to take a VIP, wire it into your environment, and get the parts that matter without inheriting every quirk of the vendor's architecture.
7. Quiz
Ten questions on coverage reports, closure strategies, and judgment calls.
Coming Up Next: Day 26 — VIP Integration
- What a VIP provides — driver, monitor, protocol assertions, coverage, sequence library.
- Integrating a VIP into your env — the layers that are yours, the layers that are the VIP's.
- Extending a VIP — factory overrides and callbacks for the cases the VIP does not cover.
- Debugging a VIP — how to tell whether a failure is in the DUT, your testbench, or the VIP.
Series: 30 days of SystemVerilog/UVM verification. Day 25's judgment calls.
No comments:
Post a Comment