Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix gen.py: Add proper way to filter incoming packets in udpraw mode #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 17 additions & 2 deletions liteeth/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down Expand Up @@ -431,15 +435,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