litex_gen/wishbone: simplify the way the bus is exposed as ios and connected to pads.
This commit is contained in:
parent
18c57a64a3
commit
d86db6f12b
|
@ -70,58 +70,30 @@ class Interface(Record):
|
||||||
yield from self._do_transaction()
|
yield from self._do_transaction()
|
||||||
return (yield self.dat_r)
|
return (yield self.dat_r)
|
||||||
|
|
||||||
def _signals_in_channels(self, channels):
|
def get_ios(self, bus_name="wb"):
|
||||||
for channel_name in channels:
|
subsignals = []
|
||||||
s = getattr(self, channel_name)
|
for name, width, direction in self.layout:
|
||||||
for l in _layout:
|
subsignals.append(Subsignal(name, Pins(width)))
|
||||||
if l[0] == channel_name:
|
ios = [(bus_name , 0) + tuple(subsignals)]
|
||||||
yield channel_name, s.nbits, l[2]
|
return ios
|
||||||
|
|
||||||
def to_pads(self, bus_name='wb'):
|
def connect_to_pads(self, pads, mode="master"):
|
||||||
wb_bus = {}
|
assert mode in ["slave", "master"]
|
||||||
for name, width, direction in self._signals_in_channels(['adr', 'dat_w', 'dat_r',
|
r = []
|
||||||
'sel', 'cyc', 'stb', 'ack',
|
for name, width, direction in self.layout:
|
||||||
'we', 'cti', 'bte', 'err']):
|
sig = getattr(self, name)
|
||||||
signal_name = name
|
pad = getattr(pads, name)
|
||||||
wb_bus[signal_name] = width
|
if mode == "master":
|
||||||
|
|
||||||
signals = []
|
|
||||||
for pad in wb_bus:
|
|
||||||
signals.append(Subsignal(pad, Pins(wb_bus[pad])))
|
|
||||||
|
|
||||||
pads = [
|
|
||||||
(bus_name , 0) + tuple(signals)
|
|
||||||
]
|
|
||||||
print(pads)
|
|
||||||
return pads
|
|
||||||
|
|
||||||
def connect_to_pads(self, module, platform, bus_name, mode='master'):
|
|
||||||
|
|
||||||
def _get_signals(pads, name):
|
|
||||||
signal_name = name
|
|
||||||
wb_signal = getattr(self, signal_name)
|
|
||||||
pads_signal = getattr(pads, signal_name)
|
|
||||||
return pads_signal, wb_signal
|
|
||||||
|
|
||||||
wb_pads = self.to_pads(bus_name)
|
|
||||||
platform.add_extension(wb_pads)
|
|
||||||
pads = platform.request(bus_name)
|
|
||||||
|
|
||||||
for name, width, direction in self._signals_in_channels(['adr', 'dat_w', 'dat_r',
|
|
||||||
'sel', 'cyc', 'stb', 'ack',
|
|
||||||
'we', 'cti', 'bte', 'err']):
|
|
||||||
pads_signal, wb_signal = _get_signals(pads, name)
|
|
||||||
|
|
||||||
if mode == 'master':
|
|
||||||
if direction == DIR_M_TO_S:
|
if direction == DIR_M_TO_S:
|
||||||
module.comb += pads_signal.eq(wb_signal)
|
r.append(pad.eq(sig))
|
||||||
else:
|
else:
|
||||||
module.comb += wb_signal.eq(pads_signal)
|
r.append(sig.eq(pad))
|
||||||
else:
|
else:
|
||||||
if direction == DIR_S_TO_M:
|
if direction == DIR_S_TO_M:
|
||||||
module.comb += pads_signal.eq(wb_signal)
|
r.append(pad.eq(sig))
|
||||||
else:
|
else:
|
||||||
module.comb += wb_signal.eq(pads_signal)
|
r.append(sig.eq(pad))
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
class InterconnectPointToPoint(Module):
|
class InterconnectPointToPoint(Module):
|
||||||
|
|
Loading…
Reference in New Issue