Skip to content

Commit 17be208

Browse files
committed
0.5.6
- (#nobug) Fix for random instability Signed-off-by: Matthew Ballance <[email protected]>
1 parent 9cd3ca9 commit 17be208

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

doc/Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
## 0.5.6
3+
- (#nobug) Fix for random instability
24
## 0.5.5
35
- (#nobug) Work on removing undesirable sources of randomness
46
due to use of sets/maps.

etc/ivpm.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
name=pyvsc
3-
version=0.5.5
3+
version=0.5.6
44

src/vsc/model/rand_set.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ def __init__(self, order=-1):
3939
self.all_field_l = []
4040

4141
self.constraint_s :Set[ConstraintModel] = set()
42+
self.constraint_l : List[ConstraintModel] = []
4243
self.soft_constraint_s : Set[ConstraintModel] = set()
44+
self.soft_constraint_l : List[ConstraintModel] = []
4345
self.soft_priority = 0
4446
self.dist_field_m = {}
4547

@@ -50,13 +52,13 @@ def __init__(self, order=-1):
5052
def build(self, btor, constraint_l):
5153
for f in self.all_field_l:
5254
f.build(btor)
53-
for c in self.constraint_s:
55+
for c in self.constraint_l:
5456
c.build(btor)
5557

5658
def dispose(self):
5759
for f in self.all_field_l:
5860
f.dispose()
59-
for c in self.constraint_s:
61+
for c in self.constraint_l:
6062
c.dispose()
6163

6264
def add_field(self, f):
@@ -65,7 +67,7 @@ def add_field(self, f):
6567
if f.is_used_rand:
6668
self.field_rand_l.append(f)
6769
self.all_field_l.append(f)
68-
70+
6971
def fields(self):
7072
return self.all_field_l
7173

@@ -77,13 +79,18 @@ def all_fields(self)->List[FieldModel]:
7779

7880
def add_constraint(self, c):
7981
if isinstance(c, ConstraintSoftModel):
80-
self.soft_constraint_s.add(c)
82+
if c not in self.soft_constraint_s:
83+
self.soft_constraint_s.add(c)
84+
self.soft_constraint_l.append(c)
8185
else:
82-
self.constraint_s.add(c)
86+
if c not in self.constraint_s:
87+
self.constraint_s.add(c)
88+
self.constraint_l.append(c)
8389

84-
def constraints(self) ->Set[ConstraintModel]:
85-
return self.constraint_s
90+
def constraints(self) ->List[ConstraintModel]:
91+
return self.constraint_l
8692

87-
def soft_constraints(self) -> Set[ConstraintSoftModel]:
88-
return self.soft_constraint_s
93+
def soft_constraints(self) -> List[ConstraintSoftModel]:
94+
return self.soft_constraint_l
95+
8996

src/vsc/model/rand_set_dispose_visitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self):
1818
def dispose(self, rs : RandSet):
1919
for f in rs.fields():
2020
f.accept(self)
21-
for c in rs.constraint_s:
21+
for c in rs.constraints():
2222
c.accept(self)
2323

2424
def visit_scalar_field(self, f:FieldScalarModel):

src/vsc/model/rand_set_node_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ def build(self, rs : RandSet):
2121
self.phase = 0
2222
for f in rs.fields():
2323
f.accept(self)
24-
for c in rs.constraint_s:
24+
for c in rs.constraints():
2525
c.accept(self)
2626
self.phase = 1
27-
for c in rs.constraint_s:
27+
for c in rs.constraints():
2828
c.accept(self)
2929

3030
def visit_constraint_stmt_enter(self, c:ConstraintModel):

ve/unit/test_constraint_expr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def ab_c(self):
9696
self.b < 128
9797

9898
my_i = my_c()
99-
with my_i.randomize_with() as it:
99+
with my_i.randomize_with(debug=1) as it:
100100
it.c == (it.a + it.b)
101101
self.assertEqual(my_i.c, (my_i.a+my_i.b))
102102

0 commit comments

Comments
 (0)