Measure planned scenarios, cross important conditions, and close holes without confusing activity with correctness.
Functional coverage measures verification-plan situations reached in simulation. It answers “did we exercise this case?” Scoreboards and assertions answer “was the result correct?”
Define goals independently of RTL
Complete coverage means defined bins were reached, not that every feature exists and works. A missing requirement can remain invisible even with full code coverage.
Each coverpoint measures a dimension. Crosses combine their bins; choose combinations tied to requirements or risks and exclude genuinely impossible combinations.
Values outside explicit bins do not contribute to that goal. illegal_bins provides diagnostics, but keep a checker that records and reports failures. Cartesian products can quickly create many bins.
Construct the covergroup, for example command_cg command_cov = new();. One instance per measurement role is often simpler than one per transaction.
Measure accepted transactions
class packet_coverage; covergroup packet_cg with function sample(packet_t tr); cp_length: coverpoint tr.length { bins single = {1}; bins small = {[2:15]}; bins large = {[16:255]}; } endgroup function new(); packet_cg = new(); endfunction function void sample_observed(packet_t observed_packet); // Called by the monitor after reconstructing an accepted transfer. packet_cg.sample(observed_packet); endfunctionendclass
The monitor calls sample() after reconstruction. This avoids counting generated objects never accepted, or changed or interrupted before reaching the DUT.
For a clocked covergroup, sampling conditions must match real transfers. Do not count stalled cycles as new commands.
Explain holes before closing them
For an empty bin, check reachability, stimulus constraints, sampling time, and the requirement itself. Several valid seeds may suffice; otherwise adjust a distribution or add a directed case.
A hole may also require a monitor correction or justified exclusion. Changing bins merely to improve the percentage does not strengthen verification.
Combine coverage with correctness
Closure requires passing tests, clean assertions, reached or justified goals, and resolved bug decisions. Review exclusions when the design changes. Separate failed simulations before merging: their new bins are not evidence of valid behavior.