From 096f2184e67f9479c3f325944382acac42d08150 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 21 Oct 2022 18:54:12 +0200 Subject: [PATCH] soc/interconnect/csr: Replace level with sort and fix targets compilation. --- litex/soc/interconnect/csr.py | 11 +++++------ litex/soc/interconnect/csr_bus.py | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/litex/soc/interconnect/csr.py b/litex/soc/interconnect/csr.py index 8c40e3911..f40c2e638 100644 --- a/litex/soc/interconnect/csr.py +++ b/litex/soc/interconnect/csr.py @@ -525,7 +525,7 @@ def _sort_gathered_items(items): return sorted_items def _make_gatherer(method, cls, prefix_cb): - def gatherer(self, level=0): + def gatherer(self, sort=False): try: exclude = self.autocsr_exclude except AttributeError: @@ -540,13 +540,12 @@ 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)(level=level+1) + items = getattr(v, method)() prefix_cb(k + "_", items, prefixed) r += items - if level == 0: - return _sort_gathered_items(r) - else: - return r + if sort: + r = _sort_gathered_items(r) + return r return gatherer diff --git a/litex/soc/interconnect/csr_bus.py b/litex/soc/interconnect/csr_bus.py index a1c8e5740..815e80ff6 100644 --- a/litex/soc/interconnect/csr_bus.py +++ b/litex/soc/interconnect/csr_bus.py @@ -226,7 +226,7 @@ class CSRBankArray(Module): # --------------------- csrs = [] if hasattr(obj, "get_csrs"): - csrs = obj.get_csrs() + csrs = obj.get_csrs(sort=True) # Collect CSR Memories. # --------------------- @@ -252,7 +252,7 @@ class CSRBankArray(Module): # Collect CSR Constants. # ---------------------- if hasattr(obj, "get_constants"): - for constant in obj.get_constants(): + for constant in obj.get_constants(sort=True): self.constants.append((name, constant)) # Create CSRBank with CSRs found.