From 40abaef85816f9702d92a5369ff1f2627820b8ad Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 15 Aug 2019 02:42:14 +0000 Subject: [PATCH] hdl.xfrm: sample cache should be per-fragment. --- nmigen/hdl/xfrm.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nmigen/hdl/xfrm.py b/nmigen/hdl/xfrm.py index 5da98f1..921bcae 100644 --- a/nmigen/hdl/xfrm.py +++ b/nmigen/hdl/xfrm.py @@ -491,8 +491,8 @@ class SampleDomainInjector(ValueTransformer, StatementTransformer): class SampleLowerer(FragmentTransformer, ValueTransformer, StatementTransformer): def __init__(self): - self.sample_cache = ValueDict() - self.sample_stmts = OrderedDict() + self.sample_cache = None + self.sample_stmts = None def _name_reset(self, value): if isinstance(value, Const): @@ -527,13 +527,14 @@ class SampleLowerer(FragmentTransformer, ValueTransformer, StatementTransformer) self.sample_cache[value] = sample return sample - def on_fragment(self, fragment): - new_fragment = super().on_fragment(fragment) + def map_statements(self, fragment, new_fragment): + self.sample_cache = ValueDict() + self.sample_stmts = OrderedDict() + new_fragment.add_statements(map(self.on_statement, fragment.statements)) for domain, stmts in self.sample_stmts.items(): new_fragment.add_statements(stmts) for stmt in stmts: new_fragment.add_driver(stmt.lhs, domain) - return new_fragment class SwitchCleaner(StatementVisitor): -- 2.30.2