fvutils / pyvsc

Python packages providing a library for Verification Stimulus and Coverage
https://fvutils.github.io/pyvsc
Apache License 2.0
113 stars 26 forks source link

Support for Wildcard bins #77

Closed aneels3 closed 3 years ago

aneels3 commented 3 years ago

Hi @mballance I have a use-case where I need the wildcard bins. For eg. I have to implement this using pyvsc coverpoint.

coverpoint binary[15:0] {
         wildcard bins addi = { 16'b000_1xxx_x000_0001,
                                16'b000_x1xx_x000_0001};
}

Is it possible to have the above feature with pyvsc? Any workaround would be appreciated!

Thanks

mballance commented 3 years ago

Hi @aneels3, Good suggestion. Let me give this a bit more thought. One question is whether there is a good way to represent this in Python other than just using strings. From a mechanics perspective, it's just a mask operation. Thanks for the suggestion, and I'll respond here after I've had time to consider.

Best Regards, Matthew

aneels3 commented 3 years ago

Hi @mballance Did you get a chance to look at this?

mballance commented 3 years ago

Hi @aneels3, Yes, I refreshed my memory on what SV supports. It seems that both individual coverpoints (as you show above) and coverpoint arrays support wildcards. Can I assume that you're initially only interested in using wildcards with individual bins?

There isn't really a good way to represent 'x' in Python, so my thinking is to have the user express both a value and a mask. Using this approach, your example above might look something like:

vsc.coverpoint(self.binary, bins={
    "addi" : wildcard_bins(
        (0b000_1000_0000_0001,
         0b111_1000_0111_1111),
        (0b000_0100_0000_0001,
         0b111_0100_0111_1111))
    })

The first element in the tuple is the bin value, and the second is the mask. Any '0' bit in the mask is treated as don't-care. Will this work for your use-case?

aneels3 commented 3 years ago

Hi @mballance Agreed with the above approach. I think this will work for my use case if the mask works like "x" in SV wildcard bins.

In my example, there are 4 x and there would be 16 possibilities of it (If we split that with possible values). If it provides me the same working then it should be fine.

Note: I forgot 1 zero previously (it's should be 16'b0000_1xxx_x000_0001).

Anyways, it should work for any bit length we provide.

Thanks for the effort. Looking forward to see this feature in the upcoming release.

Regards, Anil

mballance commented 3 years ago

Hi @aneels3, I've added initial support for wildcard bins in the 0.5.2 release. You can find documentation here: https://pyvsc.readthedocs.io/en/latest/coverage.html#wildcard-bins-single

I'm closing this issue, since the feature is implemented.

Best Regards, Matthew