soc/interconnect/csr: Replace level with sort and fix targets compilation.

This commit is contained in:
Florent Kermarrec 2022-10-21 18:54:12 +02:00
parent 14b2829a5f
commit 096f2184e6
2 changed files with 7 additions and 8 deletions

View file

@ -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,12 +540,11 @@ 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:
if sort:
r = _sort_gathered_items(r)
return r
return gatherer

View file

@ -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.