core/LiteEthIPCore/LiteEthUDPIPCore: Improve code readability.

This commit is contained in:
Florent Kermarrec 2022-04-25 17:33:32 +02:00
parent 2f6ac9a216
commit 28c8871624
1 changed files with 59 additions and 7 deletions

View File

@ -15,18 +15,70 @@ from liteeth.core.icmp import LiteEthICMP
class LiteEthIPCore(Module, AutoCSR): class LiteEthIPCore(Module, AutoCSR):
def __init__(self, phy, mac_address, ip_address, clk_freq, with_icmp=True, dw=8): def __init__(self, phy, mac_address, ip_address, clk_freq, with_icmp=True, dw=8):
# Parameters.
# -----------
ip_address = convert_ip(ip_address) ip_address = convert_ip(ip_address)
self.submodules.mac = LiteEthMAC(phy, dw, interface="crossbar", with_preamble_crc=True)
self.submodules.arp = LiteEthARP(self.mac, mac_address, ip_address, clk_freq, dw=dw) # MAC.
self.submodules.ip = LiteEthIP(self.mac, mac_address, ip_address, self.arp.table, dw=dw) # ----
self.submodules.mac = LiteEthMAC(
phy = phy,
dw = dw,
interface = "crossbar",
with_preamble_crc = True,
with_sys_datapath = False,
)
# ARP.
# ----
self.submodules.arp = LiteEthARP(
mac = self.mac,
mac_address = mac_address,
ip_address = ip_address,
clk_freq = clk_freq,
dw = dw,
)
# IP.
# ---
self.submodules.ip = LiteEthIP(
mac = self.mac,
mac_address = mac_address,
ip_address = ip_address,
arp_table = self.arp.table,
dw = dw,
)
# ICMP (Optional).
# ----------------
if with_icmp: if with_icmp:
self.submodules.icmp = LiteEthICMP(self.ip, ip_address, dw=dw) self.submodules.icmp = LiteEthICMP(
ip = self.ip,
ip_address = ip_address,
dw = dw,
)
# UDP IP Core -------------------------------------------------------------------------------------- # UDP IP Core --------------------------------------------------------------------------------------
class LiteEthUDPIPCore(LiteEthIPCore): class LiteEthUDPIPCore(LiteEthIPCore):
def __init__(self, phy, mac_address, ip_address, clk_freq, with_icmp=True, dw=8): def __init__(self, phy, mac_address, ip_address, clk_freq, with_icmp=True, dw=8):
# Parameters.
# -----------
ip_address = convert_ip(ip_address) ip_address = convert_ip(ip_address)
LiteEthIPCore.__init__(self, phy, mac_address, ip_address, clk_freq, dw=dw,
with_icmp=with_icmp) # Core: MAC + ARP + IP + (ICMP).
self.submodules.udp = LiteEthUDP(self.ip, ip_address, dw=dw) # ------------------------------
LiteEthIPCore.__init__(self,
phy = phy,
mac_address = mac_address,
ip_address = ip_address,
clk_freq = clk_freq,
dw = dw,
with_icmp = with_icmp
)
# UDP.
# ----
self.submodules.udp = LiteEthUDP(
ip = self.ip,
ip_address = ip_address,
dw = dw,
)