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

sum constraint on rand_list_t needs constraints applied on elements #68

Closed edcote closed 3 years ago

edcote commented 3 years ago

May or may not be an issue. Let's discuss first.

self.max_width = vsc.rand_list_t(vsc.rand_bit_t(32), 8)

...

#with vsc.foreach(self.max_width) as it:
#  it >= 0
#  it <= 100

self.max_width.sum <= 4096

I found I needed to uncomment the block for the sum constraint to apply.

mballance commented 3 years ago

Hmm... I'm wondering if overflow is provoking this. What if you limited the range (uncomment the foreach) such that overflow could still occur?

edcote commented 3 years ago

Sure enough. An overflow case. Reducing 32 to say 8 corrects the problem.

edcote commented 3 years ago

Marked closed, but would be awesome if the overflow could be reported :)

mballance commented 3 years ago

Yes. And, really, I'd consider this a bug -- at least from the perspective that the behavior is different from what a user would intuitively expect. I'm pretty sure there's a solution. Let me think about it a bit.

mballance commented 3 years ago

I've updated the width of the sum to be (elem_width + clog2(array_size-1)) to account for overflow, and confirmed that the testcase above works properly.