Skip to content

Commit

Permalink
0.8.7
Browse files Browse the repository at this point in the history
- (#199) - Correct how the swizzler handles 'not inside'. It was incorrectly treating
           it the same as 'inside'

Signed-off-by: Matthew Ballance <[email protected]>
  • Loading branch information
mballance committed Nov 25, 2023
1 parent cec1810 commit e44244b
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

## 0.8.7
- (#199) - Correct how the swizzler handles 'not inside'. It was incorrectly treating
it the same as 'inside'

## 0.8.6
- (#191) - Fix from @alwilson to ensure proper priority of dist vs soft constraints
- (exp) - Add experimental covergroup callback
Expand Down
2 changes: 1 addition & 1 deletion etc/ivpm.info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

name=pyvsc
version=0.8.6
version=0.8.7

4 changes: 4 additions & 0 deletions src/vsc/visitors/variable_bound_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ def visit_expr_fieldref(self, e):
# bounds.add_propagator(self._propagator)
else:
raise Exception("Field " + e.fm.fullname + " not in map")

def visit_expr_unary(self, e):
# Ignore negated terms
pass

def visit_scalar_field(self, f:FieldScalarModel):
if self.phase == 0:
Expand Down
47 changes: 46 additions & 1 deletion ve/unit/test_covergroup_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,49 @@ def callback(bin, hit):
branchInstr.randomize()
# Note: Call 'sample_cb' instead of 'sample'
branchInstr_cg.sample_cb(branchInstr)
print(branchInstr)
print(branchInstr)

def test_discussion_196(self):
cp_dict = {
'cp_a': {'bin_num':7},
'cp_b': {'bin_num':7},
'cp_op':{'bin_num':8}
}

@vsc.covergroup
class my_covergroup(vsc.util.CovergroupCallbackBase):
def __init__(self):
super().__init__()
self.with_sample(
a=vsc.uint32_t(),
b=vsc.uint32_t(),
op=vsc.bit_t(3)
)
self.cp_a = vsc.coverpoint(self.a, bins={
"bin" : vsc.bin_array([cp_dict['cp_a']['bin_num']],
[1, 866],
[867, 1300000000],
[1300000000, 1456798755],
[1456798756, 2456798755],
[2456798756, 3099999999],
[3100000000, 3294967294],
[3294967295, 4294967295])
})
self.cp_b = vsc.coverpoint(self.b, bins={
"bin" : vsc.bin_array([cp_dict['cp_b']['bin_num']],
[1, 866],
[867, 1300000000],
[1300000000, 1456798755],
[1456798756, 2456798755],
[2456798756, 3099999999],
[3100000000, 3294967294],
[3294967295, 4294967295])
})
self.cp_op = vsc.coverpoint(self.op, bins={
"bin" : vsc.bin_array([cp_dict['cp_op']['bin_num']],
[0, 7])
})

cg = my_covergroup()
cg.sample(136956257, 4172973468, 5)
vsc.report_coverage(details=True)
57 changes: 56 additions & 1 deletion ve/unit/test_random_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'''
from vsc_test_case import VscTestCase
import vsc
from enum import IntEnum

class TestRandomDist(VscTestCase):

Expand Down Expand Up @@ -801,4 +802,58 @@ def ab_c(self):
c.randomize(debug=False)
print("[%d] a=%d b=%d" % (i, c.a, c.b))


def test_dist_enum_not_inside(self):
class TestIntEnum(IntEnum):
A = 0 #
B = 1 #
C = 2 #
D = 3 #
E = 11 #
F = 5 #
G = 6 #
H = 7 #
I = 15 #
J = 10 #
K = 14 #
L = 8 #
M = 9 #
N = 4 #
O = 128 #
P = 129 #
Q = 0x82 #
R = 0x8A #
S = 0xff #

@vsc.randobj
class cls(object):

def __init__(self):
self.r_op = vsc.rand_enum_t(TestIntEnum)

@vsc.constraint
def c_op2(self):
self.r_op.not_inside(vsc.rangelist(
TestIntEnum.A,
TestIntEnum.B
))

obj = cls()
n_iter = 64*10

hist_v1 = {}
for v in TestIntEnum:
hist_v1[int(v)] = 0

for i in range(n_iter):
obj.randomize(debug=False)

hist_v1[int(obj.r_op)] += 1

# print("hist_v1: " + str(hist_v1))

# Check all values
for k,v in hist_v1.items():
if k in [TestIntEnum.A, TestIntEnum.B]:
self.assertEqual(v, 0)
else:
self.assertNotEqual(v, 0)

0 comments on commit e44244b

Please sign in to comment.