Skip to content

Fix NotImplementedError when constructing a cross containing wildcard bins#271

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-notimplementederror-cross-coverpoint
Draft

Fix NotImplementedError when constructing a cross containing wildcard bins#271
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-notimplementederror-cross-coverpoint

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

CoverpointBinSingleWildcardModel never implemented get_bin_range(), so constructing any vsc.cross that references a coverpoint with wildcard_bin entries crashed during _build_ignore_map() finalization.

@vsc.covergroup
class Cg:
    def __init__(self):
        self.with_sample(dict(it=Item()))
        self.wildcard_cp = vsc.coverpoint(
            self.it.x,
            bins={"low": vsc.wildcard_bin("0b0???????"), "high": vsc.wildcard_bin("0b1???????")}
        )
        self.plain_cp = vsc.coverpoint(self.it.y, bins={"a": vsc.bin([0, 127]), "b": vsc.bin([128, 255])})
        self.cross = vsc.cross([self.wildcard_cp, self.plain_cp])  # raised NotImplementedError

Changes

  • CoverpointBinSingleWildcardModel.get_bin_range() — implements the missing method by iterating over wildcard_binspec.specs and expanding each (value, mask) pair into concrete (low, high) ranges via WildcardBinFactory.valmask2binlist(), returning them as a combined tuple. Consistent with the single-bin contract (n_bins = 1) shared by CoverpointBinSingleRangeModel and CoverpointBinSingleValModel.

  • test_coverage_cross.test_cross_with_wildcard_bins — adds a regression test covering the exact failure scenario: a cross between a wildcard-binned and a plain-binned coverpoint, verifying construction succeeds and the cross produces the correct 4-bin structure.

Original prompt

This section details on the original issue you should resolve

<issue_title>NotImplementedError when defining a cross that contains a coverpoint with wildcard bins</issue_title>
<issue_description>### Description

Defining a vsc.cross that includes a coverpoint using vsc.wildcard_bin raises a NotImplementedError during covergroup construction. The crash occurs because CoverpointBinSingleWildcardModel.get_bin_range() is not implemented, and PyVSC calls it internally when building the cross ignore map.

Minimal Reproducible Example

@vsc.randobj
class Item:
    def __init__(self):
        self.x = vsc.rand_uint8_t()
        self.y = vsc.rand_uint8_t()

@vsc.covergroup
class Cg:
    def __init__(self):
        self.with_sample(dict(it=Item()))
        self.options.name = "cg"

        self.wildcard_cp = vsc.coverpoint(
            self.it.x,
            bins={
                "low":  vsc.wildcard_bin("0b0???????"),
                "high": vsc.wildcard_bin("0b1???????")
            }
        )

        self.plain_cp = vsc.coverpoint(
            self.it.y,
            bins={
                "a": vsc.bin([0, 127]),
                "b": vsc.bin([128, 255])
            }
        )

        # cross containing a coverpoint with wildcard_bins
        self.cross = vsc.cross([self.wildcard_cp, self.plain_cp])

try:
    cg = Cg()
    print("OK")
except Exception as e:
    print(f"FAILED: {type(e).__name__}: {e}")

Expected behavior

The cross is constructed successfully. Wildcard bin ranges are expanded and used for cross bin mapping.

Actual output

FAILED: NotImplementedError: 

Root Cause

CoverpointBinSingleWildcardModel inherits get_bin_range() from CoverpointBinModelBase which raises NotImplementedError. During cross finalization, _build_ignore_map() calls get_bin_range() on every bin of every coverpoint in the cross - including wildcard bins - causing the crash.

Suggested Fix

Implement get_bin_range() in CoverpointBinSingleWildcardModel by expanding the (value, mask) pairs in wildcard_binspec.specs using WildcardBinFactory.valmask2binlist().</issue_description>

<agent_instructions>Add a testcase covering this situation. Investigate and implement a fix</agent_instructions>

Comments on the Issue (you are @copilot in this section)


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

…et_bin_range

Co-authored-by: mballance <1340805+mballance@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix NotImplementedError for wildcard bins in cross Fix NotImplementedError when constructing a cross containing wildcard bins Mar 16, 2026
Copilot AI requested a review from mballance March 16, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NotImplementedError when defining a cross that contains a coverpoint with wildcard bins

2 participants