Skip to content

Commit

Permalink
frontend/stream/LiteEthStream2UDPTX: Latch ip_address/udp_port in Idl…
Browse files Browse the repository at this point in the history
…e state.

Useful when ip_address/udp_port are dynamic signals.
  • Loading branch information
enjoy-digital committed Jul 18, 2023
1 parent 64cceb2 commit eb63b77
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions liteeth/frontend/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ def __init__(self, ip_address, udp_port, data_width=8, fifo_depth=None):
level = Signal(max=fifo_depth+1)
counter = Signal(max=fifo_depth+1)

_ip_address = Signal(32)
_udp_port = Signal(16)

self.fifo = fifo = stream.SyncFIFO([("data", data_width)], fifo_depth, buffered=True)
self.comb += sink.connect(fifo.sink)

self.fsm = fsm = FSM(reset_state="IDLE")
fsm.act("IDLE",
NextValue(counter, 0),
NextValue(_ip_address, ip_address),
NextValue(_udp_port, udp_port),
# Send FIFO contenst when:
# - We have a full packet:
If(fifo.sink.valid & fifo.sink.ready & fifo.sink.last,
Expand All @@ -53,9 +58,9 @@ def __init__(self, ip_address, udp_port, data_width=8, fifo_depth=None):
fsm.act("SEND",
source.valid.eq(1),
source.last.eq(counter == (level - 1)),
source.src_port.eq(udp_port),
source.dst_port.eq(udp_port),
source.ip_address.eq(ip_address),
source.src_port.eq(_udp_port),
source.dst_port.eq(_udp_port),
source.ip_address.eq(_ip_address),
source.length.eq(level * (data_width//8)),
source.data.eq(fifo.source.data),
source.last_be.eq({
Expand Down

0 comments on commit eb63b77

Please sign in to comment.