Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/vsc/model/rand_info_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@ def process_fieldref(self, fm):
self._randset_field_m[f] = ex_randset
ex_randset.add_field(f)

for f, s in self._active_randset.dist_field_m.items():
if f in ex_randset.dist_field_m.keys():
ex_randset.dist_field_m[f].extend(s)
else:
ex_randset.dist_field_m[f] = s

for c in self._active_randset.constraints():
ex_randset.add_constraint(c)

Expand Down
37 changes: 37 additions & 0 deletions ve/unit/test_constraint_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,43 @@ def dist_a(self):
self.fail("Value " + str(c.a) + " illegal")
print("hist: " + str(hist))

def test_dist_multiple_dists_in_randset(self):

@vsc.randobj
class my_c(object):

def __init__(self):
self.a = vsc.rand_bit_t()
self.b = vsc.rand_bit_t()
self.en = vsc.rand_bit_t()

@vsc.constraint
def multi_dists(self):
vsc.dist(self.a, [
vsc.weight(0, 1),
vsc.weight(1, 99999)])
vsc.dist(self.b, [
vsc.weight(0, 1),
vsc.weight(1, 99999)])
with vsc.implies(self.en == 0):
self.a == 0
self.b == 0

c = my_c()

hist = 2*[0]

for i in range(100):
with c.randomize_with() as it:
it.en == 1
hist[0] += c.a
hist[1] += c.b

print("hist: " + str(hist))
for h in hist:
self.assertGreater(h, 95)


def test_dist_array_elems(self):

@vsc.randobj
Expand Down