Skip to content

Commit 1054e2c

Browse files
committed
bug in multiple inheritance fixed
1 parent 3991a76 commit 1054e2c

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

tools/bvdd.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class SBDD_s2o(SBDD):
150150
# single-byte decision diagram with input-sets-to-output mapping
151151
def __init__(self, s2o, **kwargs):
152152
self.s2o = s2o
153+
print("SBDD_s2o's init just finished execution.")
153154

154155
def __str__(self):
155156
if self.is_consistent() and self.number_of_distinct_outputs() == 1:

tools/cflobvdd.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ def __init__(self, level, number_of_input_bits, number_of_exits,
4141
self.number_of_paths_per_exit = number_of_paths_per_exit
4242
assert not number_of_inputs_per_exit or len(number_of_inputs_per_exit) == number_of_exits
4343
self.number_of_inputs_per_exit = number_of_inputs_per_exit
44+
45+
#### probably very bad practice, but a findable bug.
46+
if "s2o" in kwargs:
47+
print(kwargs)
48+
super().__init__(kwargs["s2o"])
49+
50+
print("BV_Grouping init just finished execution.")
4451

4552
def __repr__(self):
4653
return f"{self.level} w/ {self.number_of_input_bits} input bits & {self.number_of_exits} exits"
@@ -128,6 +135,7 @@ class BV_Dont_Care_Grouping(BV_Grouping):
128135
def __init__(self, number_of_input_bits):
129136
super().__init__(0, number_of_input_bits, 1, {1:2**number_of_input_bits}, {1:1})
130137

138+
131139
def __repr__(self):
132140
return "dontcare @ " + super().__repr__()
133141

@@ -218,7 +226,7 @@ class BV_Fork_Grouping(BV_Grouping, SBDD_s2o):
218226

219227
def __init__(self, s2o):
220228
assert 1 < len(s2o) <= 2**8
221-
number_of_paths_per_exit = dict([(i, inputs[i].bit_count()) for i in inputs])
229+
number_of_paths_per_exit = dict([(i, s2o[i].bit_count()) for i in s2o])
222230
super().__init__(level=0, number_of_input_bits=8, number_of_exits = len(s2o), number_of_paths_per_exit=number_of_paths_per_exit, number_of_inputs_per_exit=number_of_paths_per_exit, s2o=s2o)
223231

224232
def __repr__(self):
@@ -301,19 +309,10 @@ def representative(self):
301309
return BV_Fork_Grouping.representatives[self]
302310

303311
def projection_proto(number_of_input_bits):
304-
return BV_Fork_Grouping(dict([(i + 1, 2**i) for i in range(2**number_of_input_bits)]),
305-
number_of_input_bits).representative()
306-
307-
## TODO: at this point, pair_product(self, g2) and
308-
## triple_product(self, g2, g3) has been im-
309-
## lemented in the SBDD_s2o father class. t-
310-
## he problem is this version does not util-
311-
## ze the cache of BV_Grouping class. optio-
312-
## ns are using BV_grouping cache by implem-
313-
## enting a helper function here or using t-
314-
## he cached versions of SBDD classes (clea-
315-
## ner approach I suppose)
312+
return BV_Fork_Grouping(dict([(i + 1, 2**i) for i in range(2**number_of_input_bits)]),
313+
number_of_input_bits).representative()
316314

315+
317316
"""
318317
# def pair_product(self, g2):
319318
# assert isinstance(g2, BV_Grouping)
@@ -1272,4 +1271,13 @@ def test():
12721271
CFLOBVDD.projection(2, 0, 4, 4).ternary_apply_and_reduce(CFLOBVDD.projection(2, 2, 4, 4),
12731272
CFLOBVDD.projection(2, 3, 4, 4), lambda x, y, z: y if x else z, 4)
12741273
CFLOBVDD.projection(2, 0, 4, 4).ternary_apply_and_reduce(CFLOBVDD.projection(2, 2, 4, 4),
1275-
CFLOBVDD.projection(2, 3, 4, 4), lambda x, y, z: y if x else z, 4)
1274+
CFLOBVDD.projection(2, 3, 4, 4), lambda x, y, z: y if x else z, 4)
1275+
1276+
1277+
1278+
1279+
1280+
if __name__ == '__main__':
1281+
a = {2: 42, 16: 53}
1282+
b = BV_Fork_Grouping(a)
1283+

0 commit comments

Comments
 (0)