Skip to content

Commit e44244b

Browse files
committed
0.8.7
- (#199) - Correct how the swizzler handles 'not inside'. It was incorrectly treating it the same as 'inside' Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
1 parent cec1810 commit e44244b

File tree

5 files changed

+111
-3
lines changed

5 files changed

+111
-3
lines changed

doc/Changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
## 0.8.7
3+
- (#199) - Correct how the swizzler handles 'not inside'. It was incorrectly treating
4+
it the same as 'inside'
5+
26
## 0.8.6
37
- (#191) - Fix from @alwilson to ensure proper priority of dist vs soft constraints
48
- (exp) - Add experimental covergroup callback

etc/ivpm.info

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
name=pyvsc
3-
version=0.8.6
3+
version=0.8.7
44

src/vsc/visitors/variable_bound_visitor.py

+4
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ def visit_expr_fieldref(self, e):
371371
# bounds.add_propagator(self._propagator)
372372
else:
373373
raise Exception("Field " + e.fm.fullname + " not in map")
374+
375+
def visit_expr_unary(self, e):
376+
# Ignore negated terms
377+
pass
374378

375379
def visit_scalar_field(self, f:FieldScalarModel):
376380
if self.phase == 0:

ve/unit/test_covergroup_sampling.py

+46-1
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,49 @@ def callback(bin, hit):
266266
branchInstr.randomize()
267267
# Note: Call 'sample_cb' instead of 'sample'
268268
branchInstr_cg.sample_cb(branchInstr)
269-
print(branchInstr)
269+
print(branchInstr)
270+
271+
def test_discussion_196(self):
272+
cp_dict = {
273+
'cp_a': {'bin_num':7},
274+
'cp_b': {'bin_num':7},
275+
'cp_op':{'bin_num':8}
276+
}
277+
278+
@vsc.covergroup
279+
class my_covergroup(vsc.util.CovergroupCallbackBase):
280+
def __init__(self):
281+
super().__init__()
282+
self.with_sample(
283+
a=vsc.uint32_t(),
284+
b=vsc.uint32_t(),
285+
op=vsc.bit_t(3)
286+
)
287+
self.cp_a = vsc.coverpoint(self.a, bins={
288+
"bin" : vsc.bin_array([cp_dict['cp_a']['bin_num']],
289+
[1, 866],
290+
[867, 1300000000],
291+
[1300000000, 1456798755],
292+
[1456798756, 2456798755],
293+
[2456798756, 3099999999],
294+
[3100000000, 3294967294],
295+
[3294967295, 4294967295])
296+
})
297+
self.cp_b = vsc.coverpoint(self.b, bins={
298+
"bin" : vsc.bin_array([cp_dict['cp_b']['bin_num']],
299+
[1, 866],
300+
[867, 1300000000],
301+
[1300000000, 1456798755],
302+
[1456798756, 2456798755],
303+
[2456798756, 3099999999],
304+
[3100000000, 3294967294],
305+
[3294967295, 4294967295])
306+
})
307+
self.cp_op = vsc.coverpoint(self.op, bins={
308+
"bin" : vsc.bin_array([cp_dict['cp_op']['bin_num']],
309+
[0, 7])
310+
})
311+
312+
cg = my_covergroup()
313+
cg.sample(136956257, 4172973468, 5)
314+
vsc.report_coverage(details=True)

ve/unit/test_random_dist.py

+56-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'''
66
from vsc_test_case import VscTestCase
77
import vsc
8+
from enum import IntEnum
89

910
class TestRandomDist(VscTestCase):
1011

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

804-
805+
def test_dist_enum_not_inside(self):
806+
class TestIntEnum(IntEnum):
807+
A = 0 #
808+
B = 1 #
809+
C = 2 #
810+
D = 3 #
811+
E = 11 #
812+
F = 5 #
813+
G = 6 #
814+
H = 7 #
815+
I = 15 #
816+
J = 10 #
817+
K = 14 #
818+
L = 8 #
819+
M = 9 #
820+
N = 4 #
821+
O = 128 #
822+
P = 129 #
823+
Q = 0x82 #
824+
R = 0x8A #
825+
S = 0xff #
826+
827+
@vsc.randobj
828+
class cls(object):
829+
830+
def __init__(self):
831+
self.r_op = vsc.rand_enum_t(TestIntEnum)
832+
833+
@vsc.constraint
834+
def c_op2(self):
835+
self.r_op.not_inside(vsc.rangelist(
836+
TestIntEnum.A,
837+
TestIntEnum.B
838+
))
839+
840+
obj = cls()
841+
n_iter = 64*10
842+
843+
hist_v1 = {}
844+
for v in TestIntEnum:
845+
hist_v1[int(v)] = 0
846+
847+
for i in range(n_iter):
848+
obj.randomize(debug=False)
849+
850+
hist_v1[int(obj.r_op)] += 1
851+
852+
# print("hist_v1: " + str(hist_v1))
853+
854+
# Check all values
855+
for k,v in hist_v1.items():
856+
if k in [TestIntEnum.A, TestIntEnum.B]:
857+
self.assertEqual(v, 0)
858+
else:
859+
self.assertNotEqual(v, 0)

0 commit comments

Comments
 (0)