From 8faba46517d657b2d732b7d4bf3e10f75c09752b Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 14 Jan 2022 17:56:17 +0100 Subject: [PATCH] frontend/stream: Make ip_address filtering optional on LiteEthUDP2StreamRX. --- liteeth/frontend/stream.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/liteeth/frontend/stream.py b/liteeth/frontend/stream.py index fa6191a..1271ead 100644 --- a/liteeth/frontend/stream.py +++ b/liteeth/frontend/stream.py @@ -62,19 +62,24 @@ class LiteEthStream2UDPTX(Module): # UDP to Stream RX --------------------------------------------------------------------------------- class LiteEthUDP2StreamRX(Module): - def __init__(self, ip_address, udp_port, fifo_depth=None): + def __init__(self, ip_address=None, udp_port=None, fifo_depth=None): self.sink = sink = stream.Endpoint(eth_udp_user_description(8)) self.source = source = stream.Endpoint(eth_tty_description(8)) # # # - ip_address = convert_ip(ip_address) + valid = Signal(reset=1) - valid = Signal() - self.comb += valid.eq( - (sink.ip_address == ip_address) & - (sink.dst_port == udp_port) - ) + # Check UDP Port. + assert udp_port is not None + self.comb += If(sink.dst_port != udp_port, valid.eq(0)) + + # Check IP Address (Optional). + if ip_address is not None: + ip_address = convert_ip(ip_address) + self.comb += If(sink.ip_address != ip_address, valid.eq(0)) + + # Data-Path / Buffering (Optional). if fifo_depth is None: self.comb += [ sink.connect(source, keep={"last", "ready", "data"}),