back.pysim: fix scope screwup.
authorwhitequark <whitequark@whitequark.org>
Wed, 26 Jun 2019 05:22:09 +0000 (05:22 +0000)
committerwhitequark <whitequark@whitequark.org>
Wed, 26 Jun 2019 05:22:09 +0000 (05:22 +0000)
nmigen/back/pysim.py

index c07677f998ed8ab84fed32659b47983f5791780a..42f99542b29d6be764127417a46b6427bc11ca84 100644 (file)
@@ -329,7 +329,9 @@ class _StatementCompiler(StatementVisitor):
                     mask  = "1" * len(value)
                 mask  = int(mask,  2)
                 value = int(value, 2)
-                check = lambda test: test & mask == value
+                def make_check(mask, value):
+                    return lambda test: test & mask == value
+                check = make_check(mask, value)
             cases.append((check, self.on_statements(stmts)))
         def run(state):
             test_value = test(state)