From f3f3f05154aa39d18bfa252b067df2e8f63a7477 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 14 Dec 2018 09:12:38 +0000 Subject: [PATCH] back.pysim: undriven comb signals should return to reset value. --- nmigen/back/pysim.py | 7 ++++++- nmigen/fhdl/ir.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) 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(): -- 2.30.2