Module 5 — Functional Coverage
Measuring whether your constrained-random stimulus actually exercised the scenarios that matter: covergroups, coverpoints, cross coverage, and the bins that shape how values are bucketed and scored.
📑 Table of Contents
44Covergroup
A covergroup is a user-defined container for functional coverage collection — it groups related coverpoints and crosses, and is sampled either automatically (on a clock event) or manually via .sample().
Covergroups are commonly instantiated inside a monitor (sampling actual DUT-observed values) rather than inside the transaction class itself — this measures what the DUT actually did, not just what stimulus was generated.
45Coverpoint
A coverpoint tracks the values (or value ranges/bins) taken by a single variable or expression during simulation, reporting what percentage of its defined bins were hit.
If you don't specify explicit bins, SystemVerilog auto-creates bins for the coverpoint's full value range, up to option.auto_bin_max bins (default 64) — beyond that, values get grouped into equal-sized ranges automatically.
46Cross Coverage
cross coverage tracks combinations of two or more coverpoints together — critical for catching bugs that only appear under specific combinations of conditions (e.g., "write while FIFO nearly full"), which individual coverpoints alone can't reveal.
A cross's total bin count is (roughly) the product of the number of bins in each crossed coverpoint. Crossing two coverpoints with 20 bins each yields up to 400 cross bins — use ignore_bins aggressively to prune combinations that are unreachable or uninteresting, or coverage closure becomes unmanageable.
47Bins
Bins define how a coverpoint's value space is bucketed for coverage counting — a single value, a range, an array of bins, or a transition sequence can each become its own bin.
| Bin Style | Syntax | Use Case |
|---|---|---|
| Single value | bins z = {0}; | Track one specific important value |
| Range | bins r = {[1:63]}; | Group a contiguous range as one coverage goal |
| Array of bins | bins b[] = {...}; | Track each listed value independently |
| Transition | bins t = (A => B); | Coverage of state/sequence transitions over time |
48Ignore Bins
ignore_bins explicitly excludes specific values or combinations from coverage counting entirely — they're removed from both the coverage total and the hit count, as if they didn't exist.
Coverage closure meetings live and die by "100% coverage" claims. ignore_bins lets the team formally exclude values that are structurally unreachable (e.g., reserved address space, unsupported opcode encodings), keeping the reported percentage meaningful instead of artificially capped below 100%.
49Illegal Bins
illegal_bins marks values that should never occur — if the coverpoint samples a value falling into an illegal bin, the simulator raises a runtime error, actively flagging a bug rather than passively excluding the value.
| Bin Type | Effect on Coverage % | Effect if Sampled | Intent |
|---|---|---|---|
| Normal bin | Counted, contributes to % | Increments hit count | Expected, interesting values |
| ignore_bins | Excluded entirely | Silently not counted | Structurally unreachable / uninteresting values |
| illegal_bins | Excluded entirely | Runtime error raised | Values that indicate a genuine bug if ever seen |
"What's the difference between ignore_bins and illegal_bins?" Both remove the value from coverage math, but illegal_bins additionally triggers a simulation error the moment it's sampled — ignore_bins is silent. Mixing these up in an interview is a common stumble.
🎯 Module 5 Recap
covergroupis the container; it must be constructed withnew()like a class object, and samples automatically on a clocking event or manually via.sample().coverpointtracks one variable or expression's value distribution.crosstracks combinations across coverpoints — watch out for bin-count explosion.binscan be single values, ranges, arrays of bins, or value-transition sequences.ignore_binssilently excludes values from coverage;illegal_binsexcludes them AND raises a runtime error if hit.
📚 Next up — Module 6: Assertions (immediate & concurrent assertions, properties, sequences, implication & repetition operators)
↑ Back to Table of Contents
Comments
Post a Comment