From 0c003c8ee7e167d925c5c9a25f52c693e90b9ccb Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 10 Feb 2021 19:18:55 +0100 Subject: [PATCH] liteeth/core: handle last_be. --- liteeth/core/arp.py | 7 +++++-- liteeth/core/icmp.py | 6 ++++-- liteeth/core/ip.py | 4 +++- liteeth/core/udp.py | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/liteeth/core/arp.py b/liteeth/core/arp.py index 5c9e15f..c272718 100644 --- a/liteeth/core/arp.py +++ b/liteeth/core/arp.py @@ -36,7 +36,9 @@ class LiteEthARPTX(Module): # # # - counter = Signal(max=max(arp_header.length, eth_min_len), reset_less=True) + packet_length = max(arp_header.length, eth_min_len) + packet_words = packet_length//(dw//8) + counter = Signal(max=packet_words, reset_less=True) self.submodules.packetizer = packetizer = LiteEthARPPacketizer(dw) @@ -50,7 +52,8 @@ class LiteEthARPTX(Module): ) ) self.comb += [ - packetizer.sink.last.eq(counter == max(arp_header.length, eth_min_len)-1), + packetizer.sink.last.eq(counter == (packet_words - 1)), + packetizer.sink.last_be.eq(1 if len(packetizer.sink.last_be) == 1 else 2**(packet_length%(dw//8)-1)), packetizer.sink.hwtype.eq(arp_hwtype_ethernet), packetizer.sink.proto.eq(arp_proto_ip), packetizer.sink.hwsize.eq(6), diff --git a/liteeth/core/icmp.py b/liteeth/core/icmp.py index 41f20f3..06aaaec 100644 --- a/liteeth/core/icmp.py +++ b/liteeth/core/icmp.py @@ -34,7 +34,8 @@ class LiteEthICMPTX(Module): packetizer.sink.code.eq(sink.code), packetizer.sink.checksum.eq(sink.checksum), packetizer.sink.quench.eq(sink.quench), - packetizer.sink.data.eq(sink.data) + packetizer.sink.data.eq(sink.data), + packetizer.sink.last_be.eq(sink.last_be) ] self.submodules.fsm = fsm = FSM(reset_state="IDLE") @@ -104,7 +105,8 @@ class LiteEthICMPRX(Module): source.ip_address.eq(sink.ip_address), source.length.eq(sink.length - icmp_header.length), source.data.eq(depacketizer.source.data), - source.error.eq(depacketizer.source.error) + source.error.eq(depacketizer.source.error), + source.last_be.eq(depacketizer.source.last_be) ] fsm.act("PRESENT", source.valid.eq(depacketizer.source.valid), diff --git a/liteeth/core/ip.py b/liteeth/core/ip.py index 89c3b30..1144e1b 100644 --- a/liteeth/core/ip.py +++ b/liteeth/core/ip.py @@ -106,6 +106,7 @@ class LiteEthIPTX(Module): self.comb += [ packetizer.sink.valid.eq(sink.valid & checksum.done), packetizer.sink.last.eq(sink.last), + packetizer.sink.last_be.eq(sink.last_be), sink.ready.eq(packetizer.sink.ready & checksum.done), packetizer.sink.target_ip.eq(sink.ip_address), packetizer.sink.protocol.eq(sink.protocol), @@ -231,7 +232,8 @@ class LiteEthIPRX(Module): source.protocol.eq(depacketizer.source.protocol), source.ip_address.eq(depacketizer.source.sender_ip), source.data.eq(depacketizer.source.data), - source.error.eq(depacketizer.source.error) + source.error.eq(depacketizer.source.error), + source.last_be.eq(depacketizer.source.last_be) ] fsm.act("PRESENT", source.valid.eq(depacketizer.source.valid), diff --git a/liteeth/core/udp.py b/liteeth/core/udp.py index 771d77f..b00f26c 100644 --- a/liteeth/core/udp.py +++ b/liteeth/core/udp.py @@ -102,6 +102,7 @@ class LiteEthUDPTX(Module): 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),