Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with build_coverpoint() method for enum/list type #21

Closed
hodjat91 opened this issue Jul 25, 2020 · 3 comments
Closed

Issue with build_coverpoint() method for enum/list type #21

hodjat91 opened this issue Jul 25, 2020 · 3 comments

Comments

@hodjat91
Copy link
Collaborator

Hi Matthew,

I need to define some coverpoints with enum/list type, but I guess build_coverpoint() method doesn't work properly if cp_t=enum type or cp_t=list type. It throws a ZeroDivisionError due to not properly detecting the coverItems.

Thanks,
Hodjat

@mballance
Copy link
Member

Hi Hodjat,
Interesting... I thought I had a test for coverpoints on enum types, but perhaps not. Can you add a testcase for both cases (enum, list) to the issue?

Thanks,
Matthew

@hodjat91
Copy link
Collaborator Author

hodjat91 commented Jul 25, 2020

Hi Matthew,

There is actually separate tests for the covergroup and coverage report, but not a combination for a coverpoint with cp_t=enum type and the coverage report. Here is a small test:

import vsc
from enum import IntEnum, auto
from vsc import *


class my_e(IntEnum):
    A = auto()
    B = auto()


my_l = ["one", "two"]


@covergroup
class my_covergroup(object):
    def __init__(self, a, b, c):  # Need to use lambda for non-reference values
        super().__init__()
        self.cp1 = coverpoint(a,
                              options=dict(
                                  auto_bin_max=64
                              ),
                              bins=dict(
                                  a=bin_array([], [1, 15])
                              ))

        self.cp2 = coverpoint(b, cp_t=my_e)

        self.cp3 = coverpoint(c, cp_t=my_l)


a = 1
b = my_e.A
c = "one"
cg = my_covergroup(lambda: a, lambda: b, lambda: c)

cg.sample()

cg.dump()

vsc.report_coverage(details=True)

-Hodjat

@mballance
Copy link
Member

mballance commented Jul 26, 2020

Hi Hodjat,
Okay, there might be a couple of issues here. I uncovered a few issues with coverpoints on enumerated types. These are resolved now, and the only change needed to the enumerated-type portion of your test is that you need to wrap the parameter value for cp_t with enum_t:

def __init__(self):
self.with_sample(dict(
a=vsc.enum_t(my_e)))
self.a_cp = vsc.coverpoint(self.a)

The coverpoint on a string is a different story. PyVSC doesn't currently support coverpoints on string values -- not to say that it shouldn't ;-). Is there a reason you need to use a string instead of an enum? If so, please open a separate enhancement request for that.
By the way, I've released version 0.0.8 with the fixes needed for coverpoints on enum types.

Thanks and Best Regards,
Matthew

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

No branches or pull requests

2 participants