projects
/
litex.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2a296ac
)
bank/csrgen: add get_offset function to pre-calculate register addresses
author
Sebastien Bourdeauducq
<sebastien@milkymist.org>
Fri, 2 Aug 2013 21:05:54 +0000
(23:05 +0200)
committer
Sebastien Bourdeauducq
<sebastien@milkymist.org>
Fri, 2 Aug 2013 21:05:54 +0000
(23:05 +0200)
migen/bank/csrgen.py
patch
|
blob
|
history
diff --git
a/migen/bank/csrgen.py
b/migen/bank/csrgen.py
index 3624d90d3b9fee3be7b074ea2e150c058ccbadd3..320b3ec0c1e7f8ee8042f804dcc40865340252d4 100644
(file)
--- a/
migen/bank/csrgen.py
+++ b/
migen/bank/csrgen.py
@@
-4,6
+4,14
@@
from migen.fhdl.std import *
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: