Covergroups

Covergroups provide hierarchy by grouping coverpoints and other covergroups. Call print_tree() on any covergroup to display how coverpoints and covergroups are organised.

Each covergroup should inherit from the Covergroup class. Coverpoints and covergroups are added during setup() using add_coverpoint() and add_covergroup(). You can override name, description, and (for coverpoints) motivation when adding a child:

class MyCovergroup(Covergroup):
    NAME = "my_covergroup"
    DESCRIPTION = "A group of coverpoints"

    def setup(self, ctx):
        self.add_coverpoint(MyCoverpoint())
        self.add_covergroup(
            NestedCovergroup(),
            name="nested_alias",
            description="Optional name override when adding",
        )

Coverpoints can also receive name, description, and motivation overrides via add_coverpoint(). Override tier and tags per instance by chaining set_tier() / set_tags() / add_tags() before passing the coverpoint to add_coverpoint():

        self.add_coverpoint(
            ChewToysByName(dog_names=["Barbara", "Connie", "Graham"]),
            name="chew_toys_by_name__group_a",
            description="Preferred chew toys by name (Group A)",
        )
        self.add_coverpoint(
            ChewToysByAgeAndFavLeg().set_tier(5).set_tags(["toys", "age", "legs"])
        )
Method Parameter Description
set_tier int Override the default tier for this instance
set_tags list[str] or str Override the default tags for this instance
add_tags list[str] or str Add to the default tags for this instance

You can also set TIER and TAGS as class attributes on the coverpoint class.


Smart sampling

If a covergroup only applies to a subset of trace data, override should_sample() to skip its children when the trace is not relevant. This is more efficient than checking relevance in every child coverpoint.

    def should_sample(self, trace):
        return trace.pet_type == "Dog"

By default should_sample() returns True.


Top-level coverage

The top of your coverage tree should be a Covertop subclass, not a plain Covergroup. See Covertop for filtering, sampling, and testbench integration.



Prev: Coverpoints
Next: Covertop