add test case for https://github.com/nmigen/nmigen/issues/344
authorJacob Lifshay <programmerjake@gmail.com>
Wed, 1 Apr 2020 03:23:14 +0000 (20:23 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Wed, 1 Apr 2020 03:23:14 +0000 (20:23 -0700)
src/test_run_simulation_bug.py [new file with mode: 0644]

diff --git a/src/test_run_simulation_bug.py b/src/test_run_simulation_bug.py
new file mode 100644 (file)
index 0000000..df4bb89
--- /dev/null
@@ -0,0 +1,30 @@
+from nmigen import Signal, Module, Elaboratable
+from nmigen.compat.sim import run_simulation
+
+# test for https://github.com/nmigen/nmigen/issues/344
+
+
+class MyModule(Elaboratable):
+    def __init__(self):
+        self.a = Signal()
+
+    def elaborate(self, platform):
+        m = Module()
+        m.d.sync += self.a.eq(~self.a)
+        return m
+
+
+def test1():
+    dut = MyModule()
+
+    def generator():
+        for _i in range(10):
+            print((yield dut.a))
+            yield
+
+    run_simulation(dut, generator(),
+                   vcd_name="test_run_simulation_bug.vcd")
+
+
+if __name__ == '__main__':
+    test1()