soc/interconnect/stream: use valid/ready/last signals instead of stb/ack/eop (similar to AXI)

This commit is contained in:
Florent Kermarrec 2016-03-16 20:06:05 +01:00
parent 9032665750
commit 71a719be44
6 changed files with 127 additions and 127 deletions

View file

@ -22,7 +22,7 @@ class RS232PHYRX(Module):
rx_reg = Signal(8) rx_reg = Signal(8)
rx_bitcount = Signal(4) rx_bitcount = Signal(4)
rx_busy = Signal() rx_busy = Signal()
rx_done = self.source.stb rx_done = self.source.valid
rx_data = self.source.data rx_data = self.source.data
self.sync += [ self.sync += [
rx_done.eq(0), rx_done.eq(0),
@ -74,8 +74,8 @@ class RS232PHYTX(Module):
tx_bitcount = Signal(4) tx_bitcount = Signal(4)
tx_busy = Signal() tx_busy = Signal()
self.sync += [ self.sync += [
self.sink.ack.eq(0), self.sink.ready.eq(0),
If(self.sink.stb & ~tx_busy & ~self.sink.ack, If(self.sink.valid & ~tx_busy & ~self.sink.ready,
tx_reg.eq(self.sink.data), tx_reg.eq(self.sink.data),
tx_bitcount.eq(0), tx_bitcount.eq(0),
tx_busy.eq(1), tx_busy.eq(1),
@ -87,7 +87,7 @@ class RS232PHYTX(Module):
).Elif(tx_bitcount == 9, ).Elif(tx_bitcount == 9,
pads.tx.eq(1), pads.tx.eq(1),
tx_busy.eq(0), tx_busy.eq(0),
self.sink.ack.eq(1), self.sink.ready.eq(1),
).Else( ).Else(
pads.tx.eq(tx_reg[0]), pads.tx.eq(tx_reg[0]),
tx_reg.eq(Cat(tx_reg[1:], 0)) tx_reg.eq(Cat(tx_reg[1:], 0))
@ -117,13 +117,13 @@ class RS232PHYModel(Module):
self.source = stream.Endpoint([("data", 8)]) self.source = stream.Endpoint([("data", 8)])
self.comb += [ self.comb += [
pads.source_stb.eq(self.sink.stb), pads.source_stb.eq(self.sink.valid),
pads.source_data.eq(self.sink.data), pads.source_data.eq(self.sink.data),
self.sink.ack.eq(pads.source_ack), self.sink.ready.eq(pads.source_ack),
self.source.stb.eq(pads.sink_stb), self.source.valid.eq(pads.sink_stb),
self.source.data.eq(pads.sink_data), self.source.data.eq(pads.sink_data),
pads.sink_ack.eq(self.source.ack) pads.sink_ack.eq(self.source.ready)
] ]
@ -156,12 +156,12 @@ class UART(Module, AutoCSR):
self.submodules += tx_fifo self.submodules += tx_fifo
self.comb += [ self.comb += [
tx_fifo.sink.stb.eq(self._rxtx.re), tx_fifo.sink.valid.eq(self._rxtx.re),
tx_fifo.sink.data.eq(self._rxtx.r), tx_fifo.sink.data.eq(self._rxtx.r),
self._txfull.status.eq(~tx_fifo.sink.ack), self._txfull.status.eq(~tx_fifo.sink.ready),
tx_fifo.source.connect(phy.sink), tx_fifo.source.connect(phy.sink),
# Generate TX IRQ when tx_fifo becomes non-full # Generate TX IRQ when tx_fifo becomes non-full
self.ev.tx.trigger.eq(~tx_fifo.sink.ack) self.ev.tx.trigger.eq(~tx_fifo.sink.ready)
] ]
# RX # RX
@ -170,9 +170,9 @@ class UART(Module, AutoCSR):
self.comb += [ self.comb += [
phy.source.connect(rx_fifo.sink), phy.source.connect(rx_fifo.sink),
self._rxempty.status.eq(~rx_fifo.source.stb), self._rxempty.status.eq(~rx_fifo.source.valid),
self._rxtx.w.eq(rx_fifo.source.data), self._rxtx.w.eq(rx_fifo.source.data),
rx_fifo.source.ack.eq(self.ev.rx.clear), rx_fifo.source.ready.eq(self.ev.rx.clear),
# Generate RX IRQ when tx_fifo becomes non-empty # Generate RX IRQ when tx_fifo becomes non-empty
self.ev.rx.trigger.eq(~rx_fifo.source.stb) self.ev.rx.trigger.eq(~rx_fifo.source.valid)
] ]

View file

@ -20,9 +20,9 @@ class Reader(Module):
self.comb += [ self.comb += [
lasmim.we.eq(0), lasmim.we.eq(0),
lasmim.stb.eq(self.address.stb & request_enable), lasmim.stb.eq(self.address.valid & request_enable),
lasmim.adr.eq(self.address.a), lasmim.adr.eq(self.address.a),
self.address.ack.eq(lasmim.req_ack & request_enable), self.address.ready.eq(lasmim.req_ack & request_enable),
request_issued.eq(lasmim.stb & lasmim.req_ack) request_issued.eq(lasmim.stb & lasmim.req_ack)
] ]
@ -51,10 +51,10 @@ class Reader(Module):
fifo.din.eq(lasmim.dat_r), fifo.din.eq(lasmim.dat_r),
fifo.we.eq(lasmim.dat_r_ack), fifo.we.eq(lasmim.dat_r_ack),
self.data.stb.eq(fifo.readable), self.data.valid.eq(fifo.readable),
fifo.re.eq(self.data.ack), fifo.re.eq(self.data.ready),
self.data.d.eq(fifo.dout), self.data.d.eq(fifo.dout),
data_dequeued.eq(self.data.stb & self.data.ack) data_dequeued.eq(self.data.valid & self.data.ready)
] ]
@ -73,10 +73,10 @@ class Writer(Module):
self.comb += [ self.comb += [
lasmim.we.eq(1), lasmim.we.eq(1),
lasmim.stb.eq(fifo.writable & self.address_data.stb), lasmim.stb.eq(fifo.writable & self.address_data.valid),
lasmim.adr.eq(self.address_data.a), lasmim.adr.eq(self.address_data.a),
self.address_data.ack.eq(fifo.writable & lasmim.req_ack), self.address_data.ready.eq(fifo.writable & lasmim.req_ack),
fifo.we.eq(self.address_data.stb & lasmim.req_ack), fifo.we.eq(self.address_data.valid & lasmim.req_ack),
fifo.din.eq(self.address_data.d) fifo.din.eq(self.address_data.d)
] ]

View file

@ -20,7 +20,7 @@ class EndpointDescription:
self.param_layout = param_layout self.param_layout = param_layout
def get_full_layout(self): def get_full_layout(self):
reserved = {"stb", "ack", "payload", "param", "eop", "description"} reserved = {"valid", "ready", "payload", "param", "last", "description"}
attributed = set() attributed = set()
for f in self.payload_layout + self.param_layout: for f in self.payload_layout + self.param_layout:
if f[0] in attributed: if f[0] in attributed:
@ -30,9 +30,9 @@ class EndpointDescription:
attributed.add(f[0]) attributed.add(f[0])
full_layout = [ full_layout = [
("stb", 1, DIR_M_TO_S), ("valid", 1, DIR_M_TO_S),
("ack", 1, DIR_S_TO_M), ("ready", 1, DIR_S_TO_M),
("eop", 1, DIR_M_TO_S), ("last", 1, DIR_M_TO_S),
("payload", _make_m2s(self.payload_layout)), ("payload", _make_m2s(self.payload_layout)),
("param", _make_m2s(self.param_layout)) ("param", _make_m2s(self.param_layout))
] ]
@ -64,7 +64,7 @@ class _FIFOWrapper(Module):
description = self.sink.description description = self.sink.description
fifo_layout = [("payload", description.payload_layout), fifo_layout = [("payload", description.payload_layout),
("param", description.param_layout), ("param", description.param_layout),
("eop", 1)] ("last", 1)]
self.submodules.fifo = fifo_class(layout_len(fifo_layout), depth) self.submodules.fifo = fifo_class(layout_len(fifo_layout), depth)
fifo_in = Record(fifo_layout) fifo_in = Record(fifo_layout)
@ -75,17 +75,17 @@ class _FIFOWrapper(Module):
] ]
self.comb += [ self.comb += [
self.sink.ack.eq(self.fifo.writable), self.sink.ready.eq(self.fifo.writable),
self.fifo.we.eq(self.sink.stb), self.fifo.we.eq(self.sink.valid),
fifo_in.eop.eq(self.sink.eop), fifo_in.last.eq(self.sink.last),
fifo_in.payload.eq(self.sink.payload), fifo_in.payload.eq(self.sink.payload),
fifo_in.param.eq(self.sink.param), fifo_in.param.eq(self.sink.param),
self.source.stb.eq(self.fifo.readable), self.source.valid.eq(self.fifo.readable),
self.source.eop.eq(fifo_out.eop), self.source.last.eq(fifo_out.last),
self.source.payload.eq(fifo_out.payload), self.source.payload.eq(fifo_out.payload),
self.source.param.eq(fifo_out.param), self.source.param.eq(fifo_out.param),
self.fifo.re.eq(self.source.ack) self.fifo.re.eq(self.source.ready)
] ]
@ -153,15 +153,15 @@ class _UpConverter(Module):
load_part = Signal() load_part = Signal()
strobe_all = Signal() strobe_all = Signal()
self.comb += [ self.comb += [
sink.ack.eq(~strobe_all | source.ack), sink.ready.eq(~strobe_all | source.ready),
source.stb.eq(strobe_all), source.valid.eq(strobe_all),
load_part.eq(sink.stb & sink.ack) load_part.eq(sink.valid & sink.ready)
] ]
demux_last = ((demux == (ratio - 1)) | sink.eop) demux_last = ((demux == (ratio - 1)) | sink.last)
self.sync += [ self.sync += [
If(source.ack, strobe_all.eq(0)), If(source.ready, strobe_all.eq(0)),
If(load_part, If(load_part,
If(demux_last, If(demux_last,
demux.eq(0), demux.eq(0),
@ -170,10 +170,10 @@ class _UpConverter(Module):
demux.eq(demux + 1) demux.eq(demux + 1)
) )
), ),
If(source.stb & source.ack, If(source.valid & source.ready,
source.eop.eq(sink.eop), source.last.eq(sink.last),
).Elif(sink.stb & sink.ack, ).Elif(sink.valid & sink.ready,
source.eop.eq(sink.eop | source.eop) source.last.eq(sink.last | source.last)
) )
] ]
@ -202,12 +202,12 @@ class _DownConverter(Module):
last = Signal() last = Signal()
self.comb += [ self.comb += [
last.eq(mux == (ratio-1)), last.eq(mux == (ratio-1)),
source.stb.eq(sink.stb), source.valid.eq(sink.valid),
source.eop.eq(sink.eop & last), source.last.eq(sink.last & last),
sink.ack.eq(last & source.ack) sink.ready.eq(last & source.ready)
] ]
self.sync += \ self.sync += \
If(source.stb & source.ack, If(source.valid & source.ready,
If(last, If(last,
mux.eq(0) mux.eq(0)
).Else( ).Else(
@ -294,9 +294,9 @@ class StrideConverter(Module):
# cast sink to converter.sink (user fields --> raw bits) # cast sink to converter.sink (user fields --> raw bits)
self.comb += [ self.comb += [
converter.sink.stb.eq(sink.stb), converter.sink.valid.eq(sink.valid),
converter.sink.eop.eq(sink.eop), converter.sink.last.eq(sink.last),
sink.ack.eq(converter.sink.ack) sink.ready.eq(converter.sink.ready)
] ]
if converter.cls == _DownConverter: if converter.cls == _DownConverter:
ratio = converter.ratio ratio = converter.ratio
@ -313,9 +313,9 @@ class StrideConverter(Module):
# cast converter.source to source (raw bits --> user fields) # cast converter.source to source (raw bits --> user fields)
self.comb += [ self.comb += [
source.stb.eq(converter.source.stb), source.valid.eq(converter.source.valid),
source.eop.eq(converter.source.eop), source.last.eq(converter.source.last),
converter.source.ack.eq(source.ack) converter.source.ready.eq(source.ready)
] ]
if converter.cls == _UpConverter: if converter.cls == _UpConverter:
ratio = converter.ratio ratio = converter.ratio
@ -380,9 +380,9 @@ class BinaryActor(Module):
class CombinatorialActor(BinaryActor): class CombinatorialActor(BinaryActor):
def build_binary_control(self, sink, source): def build_binary_control(self, sink, source):
self.comb += [ self.comb += [
source.stb.eq(sink.stb), source.valid.eq(sink.valid),
source.eop.eq(sink.eop), source.last.eq(sink.last),
sink.ack.eq(source.ack), sink.ready.eq(source.ready),
] ]
@ -392,26 +392,26 @@ class PipelinedActor(BinaryActor):
BinaryActor.__init__(self, latency) BinaryActor.__init__(self, latency)
def build_binary_control(self, sink, source, latency): def build_binary_control(self, sink, source, latency):
valid = sink.stb valid = sink.valid
for i in range(latency): for i in range(latency):
valid_n = Signal() valid_n = Signal()
self.sync += If(self.pipe_ce, valid_n.eq(valid)) self.sync += If(self.pipe_ce, valid_n.eq(valid))
valid = valid_n valid = valid_n
self.comb += [ self.comb += [
self.pipe_ce.eq(source.ack | ~valid), self.pipe_ce.eq(source.ready | ~valid),
sink.ack.eq(self.pipe_ce), sink.ready.eq(self.pipe_ce),
source.stb.eq(valid) source.valid.eq(valid)
] ]
eop = sink.stb & sink.eop last = sink.valid & sink.last
for i in range(latency): for i in range(latency):
eop_n = Signal() last_n = Signal()
self.sync += \ self.sync += \
If(self.pipe_ce, If(self.pipe_ce,
eop_n.eq(eop) last_n.eq(last)
) )
eop = eop_n last = last_n
self.comb += source.eop.eq(eop) self.comb += source.last.eq(last)
class Buffer(PipelinedActor): class Buffer(PipelinedActor):
@ -458,11 +458,11 @@ class Unpack(Module):
last = Signal() last = Signal()
self.comb += [ self.comb += [
last.eq(mux == (n-1)), last.eq(mux == (n-1)),
source.stb.eq(sink.stb), source.valid.eq(sink.valid),
sink.ack.eq(last & source.ack) sink.ready.eq(last & source.ready)
] ]
self.sync += [ self.sync += [
If(source.stb & source.ack, If(source.valid & source.ready,
If(last, If(last,
mux.eq(0) mux.eq(0)
).Else( ).Else(
@ -481,7 +481,7 @@ class Unpack(Module):
dst = getattr(self.source, f[0]) dst = getattr(self.source, f[0])
self.comb += dst.eq(src) self.comb += dst.eq(src)
self.comb += source.eop.eq(sink.eop & last) self.comb += source.last.eq(sink.last & last)
class Pack(Module): class Pack(Module):
@ -502,9 +502,9 @@ class Pack(Module):
chunk = n-i-1 if reverse else i chunk = n-i-1 if reverse else i
cases[i] = [getattr(source.payload, "chunk"+str(chunk)).raw_bits().eq(sink.payload.raw_bits())] cases[i] = [getattr(source.payload, "chunk"+str(chunk)).raw_bits().eq(sink.payload.raw_bits())]
self.comb += [ self.comb += [
sink.ack.eq(~strobe_all | source.ack), sink.ready.eq(~strobe_all | source.ready),
source.stb.eq(strobe_all), source.valid.eq(strobe_all),
load_part.eq(sink.stb & sink.ack) load_part.eq(sink.valid & sink.ready)
] ]
for f in description_to.param_layout: for f in description_to.param_layout:
@ -512,10 +512,10 @@ class Pack(Module):
dst = getattr(self.source, f[0]) dst = getattr(self.source, f[0])
self.sync += If(load_part, dst.eq(src)) self.sync += If(load_part, dst.eq(src))
demux_last = ((demux == (n - 1)) | sink.eop) demux_last = ((demux == (n - 1)) | sink.last)
self.sync += [ self.sync += [
If(source.ack, strobe_all.eq(0)), If(source.ready, strobe_all.eq(0)),
If(load_part, If(load_part,
Case(demux, cases), Case(demux, cases),
If(demux_last, If(demux_last,
@ -525,10 +525,10 @@ class Pack(Module):
demux.eq(demux + 1) demux.eq(demux + 1)
) )
), ),
If(source.stb & source.ack, If(source.valid & source.ready,
source.eop.eq(sink.eop), source.last.eq(sink.last),
).Elif(sink.stb & sink.ack, ).Elif(sink.valid & sink.ready,
source.eop.eq(sink.eop | source.eop) source.last.eq(sink.last | source.last)
) )
] ]

View file

@ -19,21 +19,21 @@ def reverse_bytes(signal):
class Status(Module): class Status(Module):
def __init__(self, endpoint): def __init__(self, endpoint):
self.first = first = Signal(reset=1) self.first = first = Signal(reset=1)
self.eop = eop = Signal() self.last = last = Signal()
self.ongoing = Signal() self.ongoing = Signal()
ongoing = Signal() ongoing = Signal()
self.comb += \ self.comb += \
If(endpoint.stb, If(endpoint.valid,
eop.eq(endpoint.eop & endpoint.ack) last.eq(endpoint.last & endpoint.ready)
) )
self.sync += ongoing.eq((endpoint.stb | ongoing) & ~eop) self.sync += ongoing.eq((endpoint.valid | ongoing) & ~last)
self.comb += self.ongoing.eq((endpoint.stb | ongoing) & ~eop) self.comb += self.ongoing.eq((endpoint.valid | ongoing) & ~last)
self.sync += [ self.sync += [
If(eop, If(last,
first.eq(1) first.eq(1)
).Elif(endpoint.stb & endpoint.ack, ).Elif(endpoint.valid & endpoint.ready,
first.eq(0) first.eq(0)
) )
] ]
@ -95,7 +95,7 @@ class Dispatcher(Module):
else: else:
idx = i idx = i
cases[idx] = [master.connect(slave)] cases[idx] = [master.connect(slave)]
cases["default"] = [master.ack.eq(1)] cases["default"] = [master.ready.eq(1)]
self.comb += Case(sel, cases) self.comb += Case(sel, cases)
@ -202,14 +202,14 @@ class Packetizer(Module):
idle_next_state = "SEND_HEADER" idle_next_state = "SEND_HEADER"
fsm.act("IDLE", fsm.act("IDLE",
sink.ack.eq(1), sink.ready.eq(1),
counter_reset.eq(1), counter_reset.eq(1),
If(sink.stb, If(sink.valid,
sink.ack.eq(0), sink.ready.eq(0),
source.stb.eq(1), source.valid.eq(1),
source.eop.eq(0), source.last.eq(0),
source.data.eq(self.header[:dw]), source.data.eq(self.header[:dw]),
If(source.stb & source.ack, If(source.valid & source.ready,
load.eq(1), load.eq(1),
NextState(idle_next_state) NextState(idle_next_state)
) )
@ -217,10 +217,10 @@ class Packetizer(Module):
) )
if header_words != 1: if header_words != 1:
fsm.act("SEND_HEADER", fsm.act("SEND_HEADER",
source.stb.eq(1), source.valid.eq(1),
source.eop.eq(0), source.last.eq(0),
source.data.eq(header_reg[dw:2*dw]), source.data.eq(header_reg[dw:2*dw]),
If(source.stb & source.ack, If(source.valid & source.ready,
shift.eq(1), shift.eq(1),
counter_ce.eq(1), counter_ce.eq(1),
If(counter == header_words-2, If(counter == header_words-2,
@ -229,13 +229,13 @@ class Packetizer(Module):
) )
) )
fsm.act("COPY", fsm.act("COPY",
source.stb.eq(sink.stb), source.valid.eq(sink.valid),
source.eop.eq(sink.eop), source.last.eq(sink.last),
source.data.eq(sink.data), source.data.eq(sink.data),
source.error.eq(sink.error), source.error.eq(sink.error),
If(source.stb & source.ack, If(source.valid & source.ready,
sink.ack.eq(1), sink.ready.eq(1),
If(source.eop, If(source.last,
NextState("IDLE") NextState("IDLE")
) )
) )
@ -285,17 +285,17 @@ class Depacketizer(Module):
idle_next_state = "RECEIVE_HEADER" idle_next_state = "RECEIVE_HEADER"
fsm.act("IDLE", fsm.act("IDLE",
sink.ack.eq(1), sink.ready.eq(1),
counter_reset.eq(1), counter_reset.eq(1),
If(sink.stb, If(sink.valid,
shift.eq(1), shift.eq(1),
NextState(idle_next_state) NextState(idle_next_state)
) )
) )
if header_words != 1: if header_words != 1:
fsm.act("RECEIVE_HEADER", fsm.act("RECEIVE_HEADER",
sink.ack.eq(1), sink.ready.eq(1),
If(sink.stb, If(sink.valid,
counter_ce.eq(1), counter_ce.eq(1),
shift.eq(1), shift.eq(1),
If(counter == header_words-2, If(counter == header_words-2,
@ -306,20 +306,20 @@ class Depacketizer(Module):
no_payload = Signal() no_payload = Signal()
self.sync += \ self.sync += \
If(fsm.before_entering("COPY"), If(fsm.before_entering("COPY"),
no_payload.eq(sink.eop) no_payload.eq(sink.last)
) )
if hasattr(sink, "error"): if hasattr(sink, "error"):
self.comb += source.error.eq(sink.error) self.comb += source.error.eq(sink.error)
self.comb += [ self.comb += [
source.eop.eq(sink.eop | no_payload), source.last.eq(sink.last | no_payload),
source.data.eq(sink.data), source.data.eq(sink.data),
header.decode(self.header, source) header.decode(self.header, source)
] ]
fsm.act("COPY", fsm.act("COPY",
sink.ack.eq(source.ack), sink.ready.eq(source.ready),
source.stb.eq(sink.stb | no_payload), source.valid.eq(sink.valid | no_payload),
If(source.stb & source.ack & source.eop, If(source.valid & source.ready & source.last,
NextState("IDLE") NextState("IDLE")
) )
) )

View file

@ -119,24 +119,24 @@ class PacketStreamer(Module):
if len(self.packets) and self.packet.done: if len(self.packets) and self.packet.done:
self.packet = self.packets.pop(0) self.packet = self.packets.pop(0)
if not self.packet.ongoing and not self.packet.done: if not self.packet.ongoing and not self.packet.done:
selfp.source.stb = 1 selfp.source.valid = 1
selfp.source.data = self.packet.pop(0) selfp.source.data = self.packet.pop(0)
self.packet.ongoing = True self.packet.ongoing = True
elif selfp.source.stb == 1 and selfp.source.ack == 1: elif selfp.source.valid == 1 and selfp.source.ready == 1:
if len(self.packet) == 1: if len(self.packet) == 1:
selfp.source.eop = 1 selfp.source.last = 1
if self.last_be is not None: if self.last_be is not None:
selfp.source.last_be = self.last_be selfp.source.last_be = self.last_be
else: else:
selfp.source.eop = 0 selfp.source.last = 0
if self.last_be is not None: if self.last_be is not None:
selfp.source.last_be = 0 selfp.source.last_be = 0
if len(self.packet) > 0: if len(self.packet) > 0:
selfp.source.stb = 1 selfp.source.valid = 1
selfp.source.data = self.packet.pop(0) selfp.source.data = self.packet.pop(0)
else: else:
self.packet.done = True self.packet.done = True
selfp.source.stb = 0 selfp.source.valid = 0
class PacketLogger(Module): class PacketLogger(Module):
@ -154,15 +154,15 @@ class PacketLogger(Module):
yield yield
def do_simulation(self, selfp): def do_simulation(self, selfp):
selfp.sink.ack = 1 selfp.sink.ready = 1
if selfp.sink.stb: if selfp.sink.valid:
if self.first: if self.first:
self.packet = Packet() self.packet = Packet()
self.packet.append(selfp.sink.data) self.packet.append(selfp.sink.data)
self.first = False self.first = False
else: else:
self.packet.append(selfp.sink.data) self.packet.append(selfp.sink.data)
if selfp.sink.eop: if selfp.sink.last:
self.packet.done = True self.packet.done = True
self.first = True self.first = True
@ -180,8 +180,8 @@ class AckRandomizer(Module):
If(self.run, If(self.run,
self.sink.connect(self.source) self.sink.connect(self.source)
).Else( ).Else(
self.source.stb.eq(0), self.source.valid.eq(0),
self.sink.ack.eq(0), self.sink.ready.eq(0),
) )
def do_simulation(self, selfp): def do_simulation(self, selfp):

View file

@ -68,10 +68,10 @@ class WishboneStreamingBridge(Module):
self.submodules += fsm, timer self.submodules += fsm, timer
self.comb += [ self.comb += [
fsm.reset.eq(timer.done), fsm.reset.eq(timer.done),
phy.source.ack.eq(1) phy.source.ready.eq(1)
] ]
fsm.act("IDLE", fsm.act("IDLE",
If(phy.source.stb, If(phy.source.valid,
cmd_ce.eq(1), cmd_ce.eq(1),
If((phy.source.data == self.cmds["write"]) | If((phy.source.data == self.cmds["write"]) |
(phy.source.data == self.cmds["read"]), (phy.source.data == self.cmds["read"]),
@ -82,13 +82,13 @@ class WishboneStreamingBridge(Module):
) )
) )
fsm.act("RECEIVE_LENGTH", fsm.act("RECEIVE_LENGTH",
If(phy.source.stb, If(phy.source.valid,
length_ce.eq(1), length_ce.eq(1),
NextState("RECEIVE_ADDRESS") NextState("RECEIVE_ADDRESS")
) )
) )
fsm.act("RECEIVE_ADDRESS", fsm.act("RECEIVE_ADDRESS",
If(phy.source.stb, If(phy.source.valid,
address_ce.eq(1), address_ce.eq(1),
byte_counter_ce.eq(1), byte_counter_ce.eq(1),
If(byte_counter == 3, If(byte_counter == 3,
@ -102,7 +102,7 @@ class WishboneStreamingBridge(Module):
) )
) )
fsm.act("RECEIVE_DATA", fsm.act("RECEIVE_DATA",
If(phy.source.stb, If(phy.source.valid,
rx_data_ce.eq(1), rx_data_ce.eq(1),
byte_counter_ce.eq(1), byte_counter_ce.eq(1),
If(byte_counter == 3, If(byte_counter == 3,
@ -141,8 +141,8 @@ class WishboneStreamingBridge(Module):
self.comb += \ self.comb += \
chooser(data, byte_counter, phy.sink.data, n=4, reverse=True) chooser(data, byte_counter, phy.sink.data, n=4, reverse=True)
fsm.act("SEND_DATA", fsm.act("SEND_DATA",
phy.sink.stb.eq(1), phy.sink.valid.eq(1),
If(phy.sink.ack, If(phy.sink.ready,
byte_counter_ce.eq(1), byte_counter_ce.eq(1),
If(byte_counter == 3, If(byte_counter == 3,
word_counter_ce.eq(1), word_counter_ce.eq(1),
@ -158,7 +158,7 @@ class WishboneStreamingBridge(Module):
self.comb += timer.wait.eq(~fsm.ongoing("IDLE")) self.comb += timer.wait.eq(~fsm.ongoing("IDLE"))
self.comb += phy.sink.eop.eq((byte_counter == 3) & (word_counter == length - 1)) self.comb += phy.sink.last.eq((byte_counter == 3) & (word_counter == length - 1))
if hasattr(phy.sink, "length"): if hasattr(phy.sink, "length"):
self.comb += phy.sink.length.eq(4*length) self.comb += phy.sink.length.eq(4*length)