frontend/stream: Make ip_address filtering optional on LiteEthUDP2StreamRX.

This commit is contained in:
Florent Kermarrec 2022-01-14 17:56:17 +01:00
parent c3e3dee0e9
commit 8faba46517
1 changed files with 12 additions and 7 deletions

View File

@ -62,19 +62,24 @@ class LiteEthStream2UDPTX(Module):
# UDP to Stream RX --------------------------------------------------------------------------------- # UDP to Stream RX ---------------------------------------------------------------------------------
class LiteEthUDP2StreamRX(Module): 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.sink = sink = stream.Endpoint(eth_udp_user_description(8))
self.source = source = stream.Endpoint(eth_tty_description(8)) self.source = source = stream.Endpoint(eth_tty_description(8))
# # # # # #
ip_address = convert_ip(ip_address) valid = Signal(reset=1)
valid = Signal() # Check UDP Port.
self.comb += valid.eq( assert udp_port is not None
(sink.ip_address == ip_address) & self.comb += If(sink.dst_port != udp_port, valid.eq(0))
(sink.dst_port == udp_port)
) # 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: if fifo_depth is None:
self.comb += [ self.comb += [
sink.connect(source, keep={"last", "ready", "data"}), sink.connect(source, keep={"last", "ready", "data"}),