From 8740aafdf3bf09164609f8b8ab7a4c473cc7e891 Mon Sep 17 00:00:00 2001 From: rowanG077 Date: Mon, 24 Jul 2023 15:31:11 +0200 Subject: [PATCH] gen.py: Add proper way to filter incoming packets in udpraw mode --- examples/udp_raw_ecp5rgmii.yml | 5 +++-- liteeth/gen.py | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/examples/udp_raw_ecp5rgmii.yml b/examples/udp_raw_ecp5rgmii.yml index 81c81a0..7a98389 100644 --- a/examples/udp_raw_ecp5rgmii.yml +++ b/examples/udp_raw_ecp5rgmii.yml @@ -33,12 +33,13 @@ rx_cdc_buffered: True udp_ports: raw: data_width: 32 + udp_port: 2000 mode: raw streamer1: data_width: 32 - port: 1337 + udp_port: 1337 mode: streamer streamer2: data_width: 32 - port: 6077 + udp_port: 6077 mode: streamer diff --git a/liteeth/gen.py b/liteeth/gen.py index 2a0570c..d2592a6 100755 --- a/liteeth/gen.py +++ b/liteeth/gen.py @@ -180,9 +180,13 @@ def get_udp_port_ios(name, data_width, dynamic_params=False): ), ] -def get_udp_raw_port_ios(name, data_width): +def get_udp_raw_port_ios(name, data_width, dynamic_params=False): return [ (f"{name}", 0, + # Parameters. + *([ + Subsignal("udp_listen_port", Pins(16)), + ] if dynamic_params else []), # Sink. Subsignal("sink_ip_address", Pins(32)), @@ -431,15 +435,26 @@ class UDPCore(PHYCore): # Use default Data-Width of 8-bit when not specified. data_width = port_cfg.get("data_width", 8) + # Used dynamic UDP-Port when not specified. + udp_listen_port = port_cfg.get("udp_port", None) + dynamic_params = udp_listen_port is None + + if dynamic_params: + udp_listen_port = port_ios.udp_listen_port + + if port_cfg.get("ip_address", None) is not None: + raise RuntimeWarning("\"ip_address\" config not supported on \"udpraw\" port") + # Create/Add IOs. # --------------- platform.add_extension(get_udp_raw_port_ios(name, data_width = data_width, + dynamic_params = dynamic_params )) port_ios = platform.request(name) - raw_port = self.core.udp.crossbar.get_port(port_ios.sink_dst_port, dw=data_width) + raw_port = self.core.udp.crossbar.get_port(udp_listen_port, dw=data_width) # Connect IOs. # ------------