From: whitequark Date: Thu, 15 Aug 2019 02:42:14 +0000 (+0000) Subject: hdl.xfrm: sample cache should be per-fragment. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=37fb67c0fd51638fb724d74669d5acef644a2177;p=nmigen.git hdl.xfrm: sample cache should be per-fragment. --- 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):