From: whitequark Date: Fri, 14 Dec 2018 09:12:38 +0000 (+0000) Subject: back.pysim: undriven comb signals should return to reset value. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f3f3f05154aa39d18bfa252b067df2e8f63a7477;p=nmigen.git back.pysim: undriven comb signals should return to reset value. --- diff --git a/nmigen/back/pysim.py b/nmigen/back/pysim.py index 9716ff2..c228611 100644 --- a/nmigen/back/pysim.py +++ b/nmigen/back/pysim.py @@ -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(): diff --git a/nmigen/fhdl/ir.py b/nmigen/fhdl/ir.py index 8c8b7a9..493aa2f 100644 --- a/nmigen/fhdl/ir.py +++ b/nmigen/fhdl/ir.py @@ -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():