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

Incorrect behavior of implies constraint #35

Closed ShraddhaDevaiya closed 4 years ago

ShraddhaDevaiya commented 4 years ago

Hi @mballance , I was trying to use implies constraint. But sometimes, it is giving wrong values. Following is the code for it :

import vsc

@vsc.randobj
class my_s(object):
    def __init__(self):
        super().__init__()
        self.a = vsc.rand_bit_t(2)
        self.b = vsc.rand_bit_t(2)

        @vsc.constraint
        def ab_con(self):
             with vsc.implies(self.a == 1):
                self.b == 1

item = my_s()

for i in range(10):
    item.randomize()
    print("A = ",item.a,", B = ",item.b)

And following is the output for this :

A =  2 , B =  3
A =  3 , B =  3
A =  2 , B =  0
A =  0 , B =  2
A =  3 , B =  2
A =  1 , B =  2
A =  0 , B =  2
A =  1 , B =  2
A =  1 , B =  3
A =  2 , B =  1

As we can see, for A=1 there are different values of B, which is not correct according to our example code. Can you please take a look at this?

ShraddhaDevaiya commented 4 years ago

Got the issue, Some syntax mistake is there.