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. # ------------