Skip to content

Commit 2b34221

Browse files
committed
fix regressions due to new latch2init map
1 parent 14bedff commit 2b34221

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

aiger/aig.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,15 @@ def simulate(self, input_seq, latches=None):
163163
return [sim.send(inputs) for inputs in input_seq]
164164

165165
def cutlatches(self, latches, check_postcondition=True):
166-
ilatch_lens = bind(self).Recur(LatchIn) \
167-
.Filter(lambda x: x.name in latches)
168-
169-
latch2init = dict(self.latch2init)
170-
l_map = {
171-
n: (cmn._fresh(), latch2init[n]) for (n,) in ilatch_lens.collect()
172-
}
166+
l_map = {n: (cmn._fresh(), init) for (n, init) in self.latch2init}
173167

174168
assert len(
175169
set(fn.pluck(0, l_map.values())) & (self.inputs | self.outputs)
176170
) == 0
177171

178-
aig = ilatch_lens.modify(lambda x: Input(l_map[x.name][0]))
172+
aig = bind(self).Recur(LatchIn) \
173+
.Filter(lambda x: x.name in latches) \
174+
.modify(lambda x: Input(l_map[x.name][0]))
179175

180176
_cones = {(l_map[k][0], v) for k, v in aig.latch_map if k in latches}
181177
aig = aig._replace(
@@ -242,28 +238,29 @@ def _unroll():
242238
return unrolled
243239

244240
def _to_aag(self):
245-
aag, max_idx, l_map = _to_aag(
241+
aag, max_idx, lit_map = _to_aag(
246242
self.cones | self.latch_cones,
247243
AAG({}, {}, {}, [], self.comments),
248244
)
249245

250246
# Check that all inputs have a lit.
251247
for name in filter(lambda x: x not in aag.inputs, self.inputs):
252-
aag.inputs[name] = l_map[name] = 2 * max_idx
248+
aag.inputs[name] = lit_map[name] = 2 * max_idx
253249
max_idx += 1
254250

255251
# Update cone maps.
256-
aag.outputs.update({k: l_map[cone] for k, cone in self.node_map})
252+
aag.outputs.update({k: lit_map[cone] for k, cone in self.node_map})
257253
latch2init = dict(self.latch2init)
258254
for name, cone in self.latch_map:
259-
if name not in l_map:
260-
lit = l_map[name] = 2 * max_idx
255+
latch = LatchIn(name)
256+
if latch not in lit_map:
257+
lit = lit_map[latch] = 2 * max_idx
261258
max_idx += 1
262259
else:
263-
lit = l_map[LatchIn(name)]
260+
lit = lit_map[latch]
264261

265-
init = latch2init[name]
266-
ilit = l_map[cone]
262+
init = int(latch2init[name])
263+
ilit = lit_map[cone]
267264
aag.latches[name] = lit, ilit, init
268265

269266
return aag

0 commit comments

Comments
 (0)