Add patched liteeth.core module to allow hybrid mode

https://github.com/enjoy-digital/liteeth/pull/116
This commit is contained in:
Xiretza 2022-07-14 16:04:40 +02:00
parent a13569c2eb
commit c44e94da5d
2 changed files with 97 additions and 1 deletions

View file

@ -27,7 +27,7 @@ from liteeth.common import *
from liteeth import phy as liteeth_phys
from liteeth.mac import LiteEthMAC
from liteeth.core import LiteEthUDPIPCore
from liteeth_cores import LiteEthUDPIPCore
from liteeth.core.udp import LiteEthUDP
# IOs ----------------------------------------------------------------------------------------------

96
liteeth_cores.py Normal file
View file

@ -0,0 +1,96 @@
#
# This file is part of LiteEth.
#
# Copyright (c) 2015-2020 Florent Kermarrec <florent@enjoy-digital.fr>
# SPDX-License-Identifier: BSD-2-Clause
from liteeth.common import *
from liteeth.mac import LiteEthMAC
from liteeth.core.arp import LiteEthARP
from liteeth.core.ip import LiteEthIP
from liteeth.core.udp import LiteEthUDP
from liteeth.core.icmp import LiteEthICMP
# IP Core ------------------------------------------------------------------------------------------
class LiteEthIPCore(Module, AutoCSR):
def __init__(self, phy, mac_address, ip_address, clk_freq, dw=8,
hybrid = False,
with_icmp = True,
with_ip_broadcast = True,
with_sys_datapath = False):
# Parameters.
# -----------
ip_address = convert_ip(ip_address)
# MAC.
# ----
self.submodules.mac = LiteEthMAC(
phy = phy,
dw = dw,
interface = "hybrid" if hybrid else "crossbar",
with_preamble_crc = True,
with_sys_datapath = with_sys_datapath,
)
# 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,
with_broadcast = with_ip_broadcast,
dw = dw,
)
# ICMP (Optional).
# ----------------
if with_icmp:
self.submodules.icmp = LiteEthICMP(
ip = self.ip,
ip_address = ip_address,
dw = dw,
)
# UDP IP Core --------------------------------------------------------------------------------------
class LiteEthUDPIPCore(LiteEthIPCore):
def __init__(self, phy, mac_address, ip_address, clk_freq, dw=8,
hybrid=False,
with_icmp = True,
with_ip_broadcast = True,
with_sys_datapath = False):
# Parameters.
# -----------
ip_address = convert_ip(ip_address)
# Core: MAC + ARP + IP + (ICMP).
# ------------------------------
LiteEthIPCore.__init__(self,
phy = phy,
mac_address = mac_address,
ip_address = ip_address,
clk_freq = clk_freq,
hybrid = hybrid,
with_icmp = with_icmp,
dw = dw,
with_ip_broadcast = with_ip_broadcast,
with_sys_datapath = with_sys_datapath,
)
# UDP.
# ----
self.submodules.udp = LiteEthUDP(
ip = self.ip,
ip_address = ip_address,
dw = dw,
)