from migen.fhdl.structure import *
-from migen.bus.csr import *
+from migen.bus import csr
from migen.bank.description import *
class Bank:
self.description = description
self.address = address
if interface is None:
- interface = Interface()
+ interface = csr.Interface()
self.interface = interface
def get_fragment(self):
sel = Signal()
comb.append(sel.eq(self.interface.adr[9:] == Constant(self.address, BV(5))))
- desc_exp = expand_description(self.description, 8)
+ desc_exp = expand_description(self.description, csr.data_width)
nbits = bits_for(len(desc_exp)-1)
# Bus writes
else:
raise TypeError
if brcases:
- sync.append(self.interface.dat_r.eq(Constant(0, BV(8))))
+ sync.append(self.interface.dat_r.eq(0))
sync.append(If(sel, Case(self.interface.adr[:nbits], *brcases)))
else:
- comb.append(self.interface.dat_r.eq(Constant(0, BV(8))))
+ comb.append(self.interface.dat_r.eq(0))
# Device access
for reg in self.description:
from migen.bus.transactions import *
from migen.sim.generic import PureSimulable
-_desc = Description(
- (M_TO_S, "adr", 14),
- (M_TO_S, "we", 1),
- (M_TO_S, "dat_w", 8),
- (S_TO_M, "dat_r", 8)
-)
+data_width = 8
class Interface(SimpleInterface):
def __init__(self):
- super().__init__(_desc)
+ super().__init__(Description(
+ (M_TO_S, "adr", 14),
+ (M_TO_S, "we", 1),
+ (M_TO_S, "dat_w", data_width),
+ (S_TO_M, "dat_r", data_width)))
class Interconnect(SimpleInterconnect):
pass
def get_fragment(self):
sync = [
self.csr.we.eq(0),
- self.csr.dat_w.eq(self.wishbone.dat_w[:8]),
+ self.csr.dat_w.eq(self.wishbone.dat_w[:csr.data_width]),
self.csr.adr.eq(self.wishbone.adr[:14]),
self.wishbone.dat_r.eq(self.csr.dat_r)
]