rx_reg = Signal(8)
rx_bitcount = Signal(4)
rx_busy = Signal()
- rx_done = self.source.stb
+ rx_done = self.source.valid
rx_data = self.source.data
self.sync += [
rx_done.eq(0),
tx_bitcount = Signal(4)
tx_busy = Signal()
self.sync += [
- self.sink.ack.eq(0),
- If(self.sink.stb & ~tx_busy & ~self.sink.ack,
+ self.sink.ready.eq(0),
+ If(self.sink.valid & ~tx_busy & ~self.sink.ready,
tx_reg.eq(self.sink.data),
tx_bitcount.eq(0),
tx_busy.eq(1),
).Elif(tx_bitcount == 9,
pads.tx.eq(1),
tx_busy.eq(0),
- self.sink.ack.eq(1),
+ self.sink.ready.eq(1),
).Else(
pads.tx.eq(tx_reg[0]),
tx_reg.eq(Cat(tx_reg[1:], 0))
self.source = stream.Endpoint([("data", 8)])
self.comb += [
- pads.source_stb.eq(self.sink.stb),
+ pads.source_stb.eq(self.sink.valid),
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),
- pads.sink_ack.eq(self.source.ack)
+ pads.sink_ack.eq(self.source.ready)
]
self.submodules += tx_fifo
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),
- self._txfull.status.eq(~tx_fifo.sink.ack),
+ self._txfull.status.eq(~tx_fifo.sink.ready),
tx_fifo.source.connect(phy.sink),
# 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
self.comb += [
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),
- 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
- self.ev.rx.trigger.eq(~rx_fifo.source.stb)
+ self.ev.rx.trigger.eq(~rx_fifo.source.valid)
]
self.param_layout = param_layout
def get_full_layout(self):
- reserved = {"stb", "ack", "payload", "param", "eop", "description"}
+ reserved = {"valid", "ready", "payload", "param", "last", "description"}
attributed = set()
for f in self.payload_layout + self.param_layout:
if f[0] in attributed:
attributed.add(f[0])
full_layout = [
- ("stb", 1, DIR_M_TO_S),
- ("ack", 1, DIR_S_TO_M),
- ("eop", 1, DIR_M_TO_S),
+ ("valid", 1, DIR_M_TO_S),
+ ("ready", 1, DIR_S_TO_M),
+ ("last", 1, DIR_M_TO_S),
("payload", _make_m2s(self.payload_layout)),
("param", _make_m2s(self.param_layout))
]
description = self.sink.description
fifo_layout = [("payload", description.payload_layout),
("param", description.param_layout),
- ("eop", 1)]
+ ("last", 1)]
self.submodules.fifo = fifo_class(layout_len(fifo_layout), depth)
fifo_in = Record(fifo_layout)
]
self.comb += [
- self.sink.ack.eq(self.fifo.writable),
- self.fifo.we.eq(self.sink.stb),
- fifo_in.eop.eq(self.sink.eop),
+ self.sink.ready.eq(self.fifo.writable),
+ self.fifo.we.eq(self.sink.valid),
+ fifo_in.last.eq(self.sink.last),
fifo_in.payload.eq(self.sink.payload),
fifo_in.param.eq(self.sink.param),
- self.source.stb.eq(self.fifo.readable),
- self.source.eop.eq(fifo_out.eop),
+ self.source.valid.eq(self.fifo.readable),
+ self.source.last.eq(fifo_out.last),
self.source.payload.eq(fifo_out.payload),
self.source.param.eq(fifo_out.param),
- self.fifo.re.eq(self.source.ack)
+ self.fifo.re.eq(self.source.ready)
]
load_part = Signal()
strobe_all = Signal()
self.comb += [
- sink.ack.eq(~strobe_all | source.ack),
- source.stb.eq(strobe_all),
- load_part.eq(sink.stb & sink.ack)
+ sink.ready.eq(~strobe_all | source.ready),
+ source.valid.eq(strobe_all),
+ load_part.eq(sink.valid & sink.ready)
]
- demux_last = ((demux == (ratio - 1)) | sink.eop)
+ demux_last = ((demux == (ratio - 1)) | sink.last)
self.sync += [
- If(source.ack, strobe_all.eq(0)),
+ If(source.ready, strobe_all.eq(0)),
If(load_part,
If(demux_last,
demux.eq(0),
demux.eq(demux + 1)
)
),
- If(source.stb & source.ack,
- source.eop.eq(sink.eop),
- ).Elif(sink.stb & sink.ack,
- source.eop.eq(sink.eop | source.eop)
+ If(source.valid & source.ready,
+ source.last.eq(sink.last),
+ ).Elif(sink.valid & sink.ready,
+ source.last.eq(sink.last | source.last)
)
]
last = Signal()
self.comb += [
last.eq(mux == (ratio-1)),
- source.stb.eq(sink.stb),
- source.eop.eq(sink.eop & last),
- sink.ack.eq(last & source.ack)
+ source.valid.eq(sink.valid),
+ source.last.eq(sink.last & last),
+ sink.ready.eq(last & source.ready)
]
self.sync += \
- If(source.stb & source.ack,
+ If(source.valid & source.ready,
If(last,
mux.eq(0)
).Else(
# cast sink to converter.sink (user fields --> raw bits)
self.comb += [
- converter.sink.stb.eq(sink.stb),
- converter.sink.eop.eq(sink.eop),
- sink.ack.eq(converter.sink.ack)
+ converter.sink.valid.eq(sink.valid),
+ converter.sink.last.eq(sink.last),
+ sink.ready.eq(converter.sink.ready)
]
if converter.cls == _DownConverter:
ratio = converter.ratio
# cast converter.source to source (raw bits --> user fields)
self.comb += [
- source.stb.eq(converter.source.stb),
- source.eop.eq(converter.source.eop),
- converter.source.ack.eq(source.ack)
+ source.valid.eq(converter.source.valid),
+ source.last.eq(converter.source.last),
+ converter.source.ready.eq(source.ready)
]
if converter.cls == _UpConverter:
ratio = converter.ratio
class CombinatorialActor(BinaryActor):
def build_binary_control(self, sink, source):
self.comb += [
- source.stb.eq(sink.stb),
- source.eop.eq(sink.eop),
- sink.ack.eq(source.ack),
+ source.valid.eq(sink.valid),
+ source.last.eq(sink.last),
+ sink.ready.eq(source.ready),
]
BinaryActor.__init__(self, latency)
def build_binary_control(self, sink, source, latency):
- valid = sink.stb
+ valid = sink.valid
for i in range(latency):
valid_n = Signal()
self.sync += If(self.pipe_ce, valid_n.eq(valid))
valid = valid_n
self.comb += [
- self.pipe_ce.eq(source.ack | ~valid),
- sink.ack.eq(self.pipe_ce),
- source.stb.eq(valid)
+ self.pipe_ce.eq(source.ready | ~valid),
+ sink.ready.eq(self.pipe_ce),
+ source.valid.eq(valid)
]
- eop = sink.stb & sink.eop
+ last = sink.valid & sink.last
for i in range(latency):
- eop_n = Signal()
+ last_n = Signal()
self.sync += \
If(self.pipe_ce,
- eop_n.eq(eop)
+ last_n.eq(last)
)
- eop = eop_n
- self.comb += source.eop.eq(eop)
+ last = last_n
+ self.comb += source.last.eq(last)
class Buffer(PipelinedActor):
last = Signal()
self.comb += [
last.eq(mux == (n-1)),
- source.stb.eq(sink.stb),
- sink.ack.eq(last & source.ack)
+ source.valid.eq(sink.valid),
+ sink.ready.eq(last & source.ready)
]
self.sync += [
- If(source.stb & source.ack,
+ If(source.valid & source.ready,
If(last,
mux.eq(0)
).Else(
dst = getattr(self.source, f[0])
self.comb += dst.eq(src)
- self.comb += source.eop.eq(sink.eop & last)
+ self.comb += source.last.eq(sink.last & last)
class Pack(Module):
chunk = n-i-1 if reverse else i
cases[i] = [getattr(source.payload, "chunk"+str(chunk)).raw_bits().eq(sink.payload.raw_bits())]
self.comb += [
- sink.ack.eq(~strobe_all | source.ack),
- source.stb.eq(strobe_all),
- load_part.eq(sink.stb & sink.ack)
+ sink.ready.eq(~strobe_all | source.ready),
+ source.valid.eq(strobe_all),
+ load_part.eq(sink.valid & sink.ready)
]
for f in description_to.param_layout:
dst = getattr(self.source, f[0])
self.sync += If(load_part, dst.eq(src))
- demux_last = ((demux == (n - 1)) | sink.eop)
+ demux_last = ((demux == (n - 1)) | sink.last)
self.sync += [
- If(source.ack, strobe_all.eq(0)),
+ If(source.ready, strobe_all.eq(0)),
If(load_part,
Case(demux, cases),
If(demux_last,
demux.eq(demux + 1)
)
),
- If(source.stb & source.ack,
- source.eop.eq(sink.eop),
- ).Elif(sink.stb & sink.ack,
- source.eop.eq(sink.eop | source.eop)
+ If(source.valid & source.ready,
+ source.last.eq(sink.last),
+ ).Elif(sink.valid & sink.ready,
+ source.last.eq(sink.last | source.last)
)
]
class Status(Module):
def __init__(self, endpoint):
self.first = first = Signal(reset=1)
- self.eop = eop = Signal()
+ self.last = last = Signal()
self.ongoing = Signal()
ongoing = Signal()
self.comb += \
- If(endpoint.stb,
- eop.eq(endpoint.eop & endpoint.ack)
+ If(endpoint.valid,
+ last.eq(endpoint.last & endpoint.ready)
)
- self.sync += ongoing.eq((endpoint.stb | ongoing) & ~eop)
- self.comb += self.ongoing.eq((endpoint.stb | ongoing) & ~eop)
+ self.sync += ongoing.eq((endpoint.valid | ongoing) & ~last)
+ self.comb += self.ongoing.eq((endpoint.valid | ongoing) & ~last)
self.sync += [
- If(eop,
+ If(last,
first.eq(1)
- ).Elif(endpoint.stb & endpoint.ack,
+ ).Elif(endpoint.valid & endpoint.ready,
first.eq(0)
)
]
else:
idx = i
cases[idx] = [master.connect(slave)]
- cases["default"] = [master.ack.eq(1)]
+ cases["default"] = [master.ready.eq(1)]
self.comb += Case(sel, cases)
idle_next_state = "SEND_HEADER"
fsm.act("IDLE",
- sink.ack.eq(1),
+ sink.ready.eq(1),
counter_reset.eq(1),
- If(sink.stb,
- sink.ack.eq(0),
- source.stb.eq(1),
- source.eop.eq(0),
+ If(sink.valid,
+ sink.ready.eq(0),
+ source.valid.eq(1),
+ source.last.eq(0),
source.data.eq(self.header[:dw]),
- If(source.stb & source.ack,
+ If(source.valid & source.ready,
load.eq(1),
NextState(idle_next_state)
)
)
if header_words != 1:
fsm.act("SEND_HEADER",
- source.stb.eq(1),
- source.eop.eq(0),
+ source.valid.eq(1),
+ source.last.eq(0),
source.data.eq(header_reg[dw:2*dw]),
- If(source.stb & source.ack,
+ If(source.valid & source.ready,
shift.eq(1),
counter_ce.eq(1),
If(counter == header_words-2,
)
)
fsm.act("COPY",
- source.stb.eq(sink.stb),
- source.eop.eq(sink.eop),
+ source.valid.eq(sink.valid),
+ source.last.eq(sink.last),
source.data.eq(sink.data),
source.error.eq(sink.error),
- If(source.stb & source.ack,
- sink.ack.eq(1),
- If(source.eop,
+ If(source.valid & source.ready,
+ sink.ready.eq(1),
+ If(source.last,
NextState("IDLE")
)
)
idle_next_state = "RECEIVE_HEADER"
fsm.act("IDLE",
- sink.ack.eq(1),
+ sink.ready.eq(1),
counter_reset.eq(1),
- If(sink.stb,
+ If(sink.valid,
shift.eq(1),
NextState(idle_next_state)
)
)
if header_words != 1:
fsm.act("RECEIVE_HEADER",
- sink.ack.eq(1),
- If(sink.stb,
+ sink.ready.eq(1),
+ If(sink.valid,
counter_ce.eq(1),
shift.eq(1),
If(counter == header_words-2,
no_payload = Signal()
self.sync += \
If(fsm.before_entering("COPY"),
- no_payload.eq(sink.eop)
+ no_payload.eq(sink.last)
)
if hasattr(sink, "error"):
self.comb += source.error.eq(sink.error)
self.comb += [
- source.eop.eq(sink.eop | no_payload),
+ source.last.eq(sink.last | no_payload),
source.data.eq(sink.data),
header.decode(self.header, source)
]
fsm.act("COPY",
- sink.ack.eq(source.ack),
- source.stb.eq(sink.stb | no_payload),
- If(source.stb & source.ack & source.eop,
+ sink.ready.eq(source.ready),
+ source.valid.eq(sink.valid | no_payload),
+ If(source.valid & source.ready & source.last,
NextState("IDLE")
)
)