Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 26 additions and 6 deletions.
  1. +8 −0 migen/bank/csrgen.py
  2. +18 −6 migen/bank/description.py
View
8 migen/bank/csrgen.py
@@ -4,6 +4,14 @@
from migen.bus import csr
from migen.bank.description import *
+def get_offset(description, name, csr_data_width=8):
+ offset = 0
+ for c in description:
+ if c.name == name:
+ return offset
+ offset += (c.size + csr_data_width - 1)//csr_data_width
+ raise KeyError("CSR not found: "+name)
+
class Bank(Module):
def __init__(self, description, address=0, bus=None):
if bus is None:
View
24 migen/bank/description.py
@@ -84,13 +84,17 @@ def do_finalize(self, busword):
else:
self.sync += If(sc.re, self.storage_full[lo:hi].eq(sc.r))
-def csrprefix(prefix, csrs):
+def csrprefix(prefix, csrs, done):
for csr in csrs:
- csr.name = prefix + csr.name
+ if csr.huid not in done:
+ csr.name = prefix + csr.name
+ done.add(csr.huid)
-def memprefix(prefix, memories):
+def memprefix(prefix, memories, done):
for memory in memories:
- memory.name_override = prefix + memory.name_override
+ if memory.huid not in done:
+ memory.name_override = prefix + memory.name_override
+ done.add(memory.huid)
class AutoCSR:
def get_memories(self):
@@ -98,6 +102,10 @@ def get_memories(self):
exclude = self.autocsr_exclude
except AttributeError:
exclude = {}
+ try:
+ prefixed = self.__prefixed
+ except AttributeError:
+ prefixed = self.__prefixed = set()
r = []
for k, v in self.__dict__.items():
if k not in exclude:
@@ -105,7 +113,7 @@ def get_memories(self):
r.append(v)
elif hasattr(v, "get_memories") and callable(v.get_memories):
memories = v.get_memories()
- memprefix(k + "_", memories)
+ memprefix(k + "_", memories, prefixed)
r += memories
return sorted(r, key=lambda x: x.huid)
@@ -114,6 +122,10 @@ def get_csrs(self):
exclude = self.autocsr_exclude
except AttributeError:
exclude = {}
+ try:
+ prefixed = self.__prefixed
+ except AttributeError:
+ prefixed = self.__prefixed = set()
r = []
for k, v in self.__dict__.items():
if k not in exclude:
@@ -121,6 +133,6 @@ def get_csrs(self):
r.append(v)
elif hasattr(v, "get_csrs") and callable(v.get_csrs):
csrs = v.get_csrs()
- csrprefix(k + "_", csrs)
+ csrprefix(k + "_", csrs, prefixed)
r += csrs
return sorted(r, key=lambda x: x.huid)

No commit comments for this range

Something went wrong with that request. Please try again.