liteeth_gen/udp: Directly integrate UDPStreamer to simplify use and just expose a LiteX-Stream/AXI-ST interface.

This commit is contained in:
Florent Kermarrec 2022-01-26 11:18:48 +01:00
parent 2beec096b4
commit 680806997d
2 changed files with 34 additions and 63 deletions

View file

@ -13,4 +13,4 @@ clk_freq: 125e6
core: udp core: udp
mac_address: 0x10e2d5000000 mac_address: 0x10e2d5000000
ip_address: 192.168.1.50 ip_address: 192.168.1.50
port: 6000 udp_port: 6000

View file

@ -130,34 +130,19 @@ _io = [
# UDP # UDP
("udp_port", 0, Pins(16)), ("udp_port", 0, Pins(16)),
("udp_ip_address", 0, Pins(32)),
("udp_sink", 0, ("udp_sink", 0,
# Control
Subsignal("valid", Pins(1)), Subsignal("valid", Pins(1)),
Subsignal("last", Pins(1)), Subsignal("last", Pins(1)),
Subsignal("ready", Pins(1)), Subsignal("ready", Pins(1)),
# Param Subsignal("data", Pins(32))
Subsignal("src_port", Pins(16)),
Subsignal("dst_port", Pins(16)),
Subsignal("ip_address", Pins(32)),
Subsignal("length", Pins(16)),
# Payload
Subsignal("data", Pins(32)),
Subsignal("error", Pins(4))
), ),
("udp_source", 0, ("udp_source", 0,
# Control
Subsignal("valid", Pins(1)), Subsignal("valid", Pins(1)),
Subsignal("last", Pins(1)), Subsignal("last", Pins(1)),
Subsignal("ready", Pins(1)), Subsignal("ready", Pins(1)),
# Param
Subsignal("src_port", Pins(16)),
Subsignal("dst_port", Pins(16)),
Subsignal("ip_address", Pins(32)),
Subsignal("length", Pins(16)),
# Payload
Subsignal("data", Pins(32)), Subsignal("data", Pins(32)),
Subsignal("error", Pins(4))
), ),
] ]
@ -261,6 +246,8 @@ class MACCore(PHYCore):
class UDPCore(PHYCore): class UDPCore(PHYCore):
def __init__(self, platform, core_config): def __init__(self, platform, core_config):
from liteeth.frontend.stream import LiteEthUDPStreamer
# Config ----------------------------------------------------------------------------------- # Config -----------------------------------------------------------------------------------
# MAC Address. # MAC Address.
@ -276,11 +263,10 @@ class UDPCore(PHYCore):
ip_address = platform.request("ip_address") ip_address = platform.request("ip_address")
# UDP Port. # UDP Port.
port = core_config.get("port", None) udp_port = core_config.get("udp_port", None)
# Get UDP Port from IOs when not specified. # Get UDP Port from IOs when not specified.
if port is None: if udp_port is None:
port = Signal() udp_port = platform.request("udp_port")
port = platform.request("udp_port")
# PHY -------------------------------------------------------------------------------------- # PHY --------------------------------------------------------------------------------------
PHYCore.__init__(self, platform, core_config) PHYCore.__init__(self, platform, core_config)
@ -293,44 +279,29 @@ class UDPCore(PHYCore):
) )
# UDP -------------------------------------------------------------------------------------- # UDP --------------------------------------------------------------------------------------
udp_port = self.core.udp.crossbar.get_port(port, 8)
# Connect UDP Sink IOs to UDP Port.
udp_sink = self.platform.request("udp_sink") udp_sink = self.platform.request("udp_sink")
udp_source = self.platform.request("udp_source")
udp_streamer = LiteEthUDPStreamer(self.core.udp,
ip_address = platform.request("udp_ip_address"),
udp_port = udp_port,
data_width = 32
)
self.submodules += udp_streamer
# Connect UDP Sink IOs to UDP Steamer.
self.comb += [ self.comb += [
# Control udp_streamer.sink.valid.eq(udp_sink.valid),
udp_port.sink.valid.eq(udp_sink.valid), udp_streamer.sink.last.eq(udp_sink.last),
udp_port.sink.last.eq(udp_sink.last), udp_sink.ready.eq(udp_streamer.sink.ready),
udp_sink.ready.eq(udp_port.sink.ready), udp_streamer.sink.data.eq(udp_sink.data)
# Param
udp_port.sink.src_port.eq(udp_sink.src_port),
udp_port.sink.dst_port.eq(udp_sink.dst_port),
udp_port.sink.ip_address.eq(udp_sink.ip_address),
udp_port.sink.length.eq(udp_sink.length),
# Payload
udp_port.sink.data.eq(udp_sink.data),
udp_port.sink.error.eq(udp_sink.error)
] ]
# Connect UDP Port to UDP Source IOs. # Connect UDP Streamer to UDP Source IOs.
udp_source = self.platform.request("udp_source")
self.comb += [ self.comb += [
# Control udp_source.valid.eq(udp_streamer.source.valid),
udp_source.valid.eq(udp_port.source.valid), udp_source.last.eq(udp_streamer.source.last),
udp_source.last.eq(udp_port.source.last), udp_streamer.source.ready.eq(udp_source.ready),
udp_port.source.ready.eq(udp_source.ready), udp_source.data.eq(udp_streamer.source.data)
# Param
udp_source.src_port.eq(udp_port.source.src_port),
udp_source.dst_port.eq(udp_port.source.dst_port),
udp_source.ip_address.eq(udp_port.source.ip_address),
udp_source.length.eq(udp_port.source.length),
# Payload
udp_source.data.eq(udp_port.source.data),
udp_source.error.eq(udp_port.source.error)
] ]
# Build -------------------------------------------------------------------------------------------- # Build --------------------------------------------------------------------------------------------