From a6298975bdce5abfea00bc0da0a6e2cbdd574e75 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 22 Sep 2021 16:54:41 +0200 Subject: [PATCH] core/udp: Simplify LiteEthUDPTX. --- liteeth/core/udp.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/liteeth/core/udp.py b/liteeth/core/udp.py index e085c21..2f9b587 100644 --- a/liteeth/core/udp.py +++ b/liteeth/core/udp.py @@ -107,24 +107,27 @@ class LiteEthUDPTX(Module): # # # + # Packetizer. self.submodules.packetizer = packetizer = LiteEthUDPPacketizer(dw=dw) + + # Data-Path. self.comb += [ - packetizer.sink.valid.eq(sink.valid), - packetizer.sink.last.eq(sink.last), - packetizer.sink.last_be.eq(sink.last_be), - sink.ready.eq(packetizer.sink.ready), - packetizer.sink.src_port.eq(sink.src_port), - packetizer.sink.dst_port.eq(sink.dst_port), + sink.connect(packetizer.sink, keep={ + "valid", + "ready", + "last", + "last_be", + "src_port", + "dst_port", + "data"}), packetizer.sink.length.eq(sink.length + udp_header.length), - packetizer.sink.checksum.eq(0), # Disabled (MAC CRC is enough) - packetizer.sink.data.eq(sink.data) + packetizer.sink.checksum.eq(0), # UDP Checksum is not used, we only rely on MAC CRC. ] + # Control-Path (FSM). self.submodules.fsm = fsm = FSM(reset_state="IDLE") fsm.act("IDLE", - packetizer.source.ready.eq(1), If(packetizer.source.valid, - packetizer.source.ready.eq(0), NextState("SEND") ) ) @@ -133,8 +136,10 @@ class LiteEthUDPTX(Module): source.length.eq(packetizer.sink.length), source.protocol.eq(udp_protocol), source.ip_address.eq(sink.ip_address), - If(source.valid & source.last & source.ready, - NextState("IDLE") + If(source.valid & source.ready, + If(source.last, + NextState("IDLE") + ) ) )