Skip to content

Commit

Permalink
gen.py: Add proper way to filter incoming packets in udpraw mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanG077 committed Jul 24, 2023
1 parent 32de4f0 commit d03e33b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions examples/udp_raw_ecp5rgmii.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 12 additions & 1 deletion liteeth/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,26 @@ def add_raw_port(self, platform, name, port_cfg):
# 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.
# ------------
Expand Down

0 comments on commit d03e33b

Please sign in to comment.