From a60a51c52fd3e5ab1b360f6532949dfeb8a24153 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 21 Oct 2022 16:04:23 +0200 Subject: [PATCH] interconnect/csr: Only sort gathered items at Module level. --- litex/soc/interconnect/csr.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/litex/soc/interconnect/csr.py b/litex/soc/interconnect/csr.py index ed69e516f..8c40e3911 100644 --- a/litex/soc/interconnect/csr.py +++ b/litex/soc/interconnect/csr.py @@ -517,6 +517,7 @@ def _sort_gathered_items(items): if sorted_items[i] is None: sorted_items[i] = CSR(name=f"reserved{i}") + # Verify all locations are filled. assert None not in sorted_items @@ -524,7 +525,7 @@ def _sort_gathered_items(items): return sorted_items def _make_gatherer(method, cls, prefix_cb): - def gatherer(self): + def gatherer(self, level=0): try: exclude = self.autocsr_exclude except AttributeError: @@ -539,10 +540,13 @@ def _make_gatherer(method, cls, prefix_cb): if isinstance(v, cls): r.append(v) elif hasattr(v, method) and callable(getattr(v, method)): - items = getattr(v, method)() + items = getattr(v, method)(level=level+1) prefix_cb(k + "_", items, prefixed) r += items - return _sort_gathered_items(r) + if level == 0: + return _sort_gathered_items(r) + else: + return r return gatherer