back.pysim: undriven comb signals should return to reset value.
authorwhitequark <whitequark@whitequark.org>
Fri, 14 Dec 2018 09:12:38 +0000 (09:12 +0000)
committerwhitequark <whitequark@whitequark.org>
Fri, 14 Dec 2018 09:12:38 +0000 (09:12 +0000)
nmigen/back/pysim.py
nmigen/fhdl/ir.py

index 9716ff2a2f096d61a5ddb5323090f6e63db9d31f..c228611f7722ef0cc700df2544f33ee2556282a6 100644 (file)
@@ -326,8 +326,13 @@ class Simulator:
                     self._sync_signals.update(signals)
                     self._domain_signals[domain].update(signals)
 
+            statements = []
+            for signal in fragment.iter_comb():
+                statements.append(signal.eq(signal.reset))
+            statements += fragment.statements
+
             compiler = _StatementCompiler()
-            funclet  = compiler(fragment.statements)
+            funclet  = compiler(statements)
             for signal in compiler.sensitivity:
                 self._add_funclet(signal, funclet)
             for domain, cd in fragment.domains.items():
index 8c8b7a91e89eab688d6174c8804ab755d0b7c11a..493aa2f61c6243ec4f983fba67a9b34a376b504a 100644 (file)
@@ -39,7 +39,8 @@ class Fragment:
                 yield domain, signal
 
     def iter_comb(self):
-        yield from self.drivers[None]
+        if None in self.drivers:
+            yield from self.drivers[None]
 
     def iter_sync(self):
         for domain, signals in self.drivers.items():