pyvsc icon indicating copy to clipboard operation
pyvsc copied to clipboard

Few issues in functional coverage for Enum types

Open hodjat91 opened this issue 5 years ago • 2 comments

Hi Matthew,

I have this small test program:

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


@vsc.covergroup
class my_cg(object):
    def __init__(self, a, b):  
        super().__init__()
        self.cp1 = vsc.coverpoint(a,
                                  bins=dict(
                                      a=vsc.bin_array([], [1, 15])
                                  ))

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


a = 1
b = my_e.A
cg = my_cg(lambda: a, lambda: b)
cg.sample()
vsc.report_coverage(details=True)

1- Although b = my_e.A in the above example, results show a hit for the second bin of cp2:

CVP cp2 : 50.000000%
Bins:
    my_e.B : 0
    my_e.B : 1

To confirm this issue, if I change it to b = my_e.B in the example, I get 0% coverage (it's probably due to something like a delayed append to the list).

2- It works for IntEnum types and I get 50% coverage for the cp2. However, it doesn't work for Enum types: if I change my_e(IntEnum) to my_e(Enum), I'll get 0% coverage for cp2 which is not correct.

3- When the coverage report shows the individual bins for cp2, the key for all individual bins is the last member of Enum (my_e.B in this example):

CVP cp2 : 0.000000%
Bins:
   my_e.B : 0
   my_e.B : 0

Thanks, Hodjat

hodjat91 avatar Aug 07 '20 06:08 hodjat91

Hi Hodjat, Actually, I stumbled over this issue before seeing this report. There were a couple issues -- one with converting the enum value to an 'int' for sampling and one with naming of enum-type bins. Both should be resolved in 0.1.1. Please reopen this if not.

Best Regards, Matthew

mballance avatar Aug 08 '20 22:08 mballance

Hi Matthew,

Thanks a lot for fixing this issue, it's a big help. However, the second bullet (works for IntEnum but does not for Enum) still exists, which actually is not a big deal. Moreover, I think given the fact that I'm not a collaborator on this repo, I cannot re-open my own issue if you (as a repo collaborator) closed it.

Thanks, Hodjat

hodjat91 avatar Aug 08 '20 22:08 hodjat91