From 0c8c3c7cdf3bf75bbee89cb679c89b50f32be466 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 14 Dec 2018 08:51:36 +0000 Subject: [PATCH] back.pysim: fix completely broken codegen for Switch. --- nmigen/back/pysim.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nmigen/back/pysim.py b/nmigen/back/pysim.py index 0a9afec..d740ebd 100644 --- a/nmigen/back/pysim.py +++ b/nmigen/back/pysim.py @@ -169,14 +169,15 @@ class _StatementCompiler(StatementTransformer): mask = "1" * len(value) mask = int(mask, 2) value = int(value, 2) - cases.append((lambda test: test & mask == value, - self.on_statements(stmts))) + def make_test(mask, value): + return lambda test: test & mask == value + cases.append((make_test(mask, value), self.on_statements(stmts))) def run(state): test_value = test(state) for check, body in cases: if check(test_value): body(state) - return + return return run def on_statements(self, stmts): -- 2.30.2