Add core CDC depth and buffered parameters.

This commit is contained in:
rowanG077 2023-02-16 22:05:07 +01:00
parent 97dccdb294
commit 641c5dbdc7
4 changed files with 72 additions and 17 deletions

View File

@ -2,6 +2,7 @@
# This file is part of LiteEth. # This file is part of LiteEth.
# #
# Copyright (c) 2015-2020 Florent Kermarrec <florent@enjoy-digital.fr> # Copyright (c) 2015-2020 Florent Kermarrec <florent@enjoy-digital.fr>
# Copyright (c) 2023 LumiGuide Fietsdetectie B.V. <goemansrowan@gmail.com>
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: BSD-2-Clause
from liteeth.common import * from liteeth.common import *
@ -17,7 +18,11 @@ class LiteEthIPCore(Module, AutoCSR):
def __init__(self, phy, mac_address, ip_address, clk_freq, dw=8, def __init__(self, phy, mac_address, ip_address, clk_freq, dw=8,
with_icmp = True, with_icmp = True,
with_ip_broadcast = True, with_ip_broadcast = True,
with_sys_datapath = False): with_sys_datapath = False,
tx_cdc_depth = 32,
tx_cdc_buffered = False,
rx_cdc_depth = 32,
rx_cdc_buffered = False):
# Parameters. # Parameters.
# ----------- # -----------
ip_address = convert_ip(ip_address) ip_address = convert_ip(ip_address)
@ -30,6 +35,10 @@ class LiteEthIPCore(Module, AutoCSR):
interface = "crossbar", interface = "crossbar",
with_preamble_crc = True, with_preamble_crc = True,
with_sys_datapath = with_sys_datapath, with_sys_datapath = with_sys_datapath,
tx_cdc_depth = tx_cdc_depth,
tx_cdc_buffered = tx_cdc_buffered,
rx_cdc_depth = rx_cdc_depth,
rx_cdc_buffered = rx_cdc_buffered
) )
# ARP. # ARP.
@ -67,7 +76,11 @@ class LiteEthUDPIPCore(LiteEthIPCore):
def __init__(self, phy, mac_address, ip_address, clk_freq, dw=8, def __init__(self, phy, mac_address, ip_address, clk_freq, dw=8,
with_icmp = True, with_icmp = True,
with_ip_broadcast = True, with_ip_broadcast = True,
with_sys_datapath = False): with_sys_datapath = False,
tx_cdc_depth = 32,
tx_cdc_buffered = False,
rx_cdc_depth = 32,
rx_cdc_buffered = False):
# Parameters. # Parameters.
# ----------- # -----------
ip_address = convert_ip(ip_address) ip_address = convert_ip(ip_address)
@ -83,6 +96,10 @@ class LiteEthUDPIPCore(LiteEthIPCore):
dw = dw, dw = dw,
with_ip_broadcast = with_ip_broadcast, with_ip_broadcast = with_ip_broadcast,
with_sys_datapath = with_sys_datapath, with_sys_datapath = with_sys_datapath,
tx_cdc_depth = tx_cdc_depth,
tx_cdc_buffered = tx_cdc_buffered,
rx_cdc_depth = rx_cdc_depth,
rx_cdc_buffered = rx_cdc_buffered
) )
# UDP. # UDP.
# ---- # ----

View File

@ -7,6 +7,7 @@
# Copyright (c) 2020 Xiretza <xiretza@xiretza.xyz> # Copyright (c) 2020 Xiretza <xiretza@xiretza.xyz>
# Copyright (c) 2020 Stefan Schrijvers <ximin@ximinity.net> # Copyright (c) 2020 Stefan Schrijvers <ximin@ximinity.net>
# Copyright (c) 2022 Victor Suarez Rovere <suarezvictor@gmail.com> # Copyright (c) 2022 Victor Suarez Rovere <suarezvictor@gmail.com>
# Copyright (c) 2023 LumiGuide Fietsdetectie B.V. <goemansrowan@gmail.com>
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: BSD-2-Clause
""" """
@ -233,9 +234,13 @@ class PHYCore(SoCMini):
class MACCore(PHYCore): class MACCore(PHYCore):
def __init__(self, platform, core_config): def __init__(self, platform, core_config):
# Parameters ------------------------------------------------------------------------------- # Parameters -------------------------------------------------------------------------------
nrxslots = core_config.get("nrxslots", 2) nrxslots = core_config.get("nrxslots", 2)
ntxslots = core_config.get("ntxslots", 2) ntxslots = core_config.get("ntxslots", 2)
bus_standard = core_config["core"] bus_standard = core_config["core"]
tx_cdc_depth = core_config.get("tx_cdc_depth", 32)
tx_cdc_buffered = core_config.get("tx_cdc_buffered", False)
rx_cdc_depth = core_config.get("rx_cdc_depth", 32)
rx_cdc_buffered = core_config.get("rx_cdc_buffered", False)
assert bus_standard in ["wishbone", "axi-lite"] assert bus_standard in ["wishbone", "axi-lite"]
# PHY -------------------------------------------------------------------------------------- # PHY --------------------------------------------------------------------------------------
@ -243,13 +248,18 @@ class MACCore(PHYCore):
# MAC -------------------------------------------------------------------------------------- # MAC --------------------------------------------------------------------------------------
self.submodules.ethmac = ethmac = LiteEthMAC( self.submodules.ethmac = ethmac = LiteEthMAC(
phy = self.ethphy, phy = self.ethphy,
dw = 32, dw = 32,
interface = "wishbone", interface = "wishbone",
endianness = core_config["endianness"], endianness = core_config["endianness"],
nrxslots = nrxslots, nrxslots = nrxslots,
ntxslots = ntxslots, ntxslots = ntxslots,
full_memory_we = core_config.get("full_memory_we", False)) full_memory_we = core_config.get("full_memory_we", False),
tx_cdc_depth = tx_cdc_depth
tx_cdc_buffered = tx_cdc_buffered
rx_cdc_depth = rx_cdc_depth
rx_cdc_buffered = rx_cdc_buffered
)
if bus_standard == "wishbone": if bus_standard == "wishbone":
# Wishbone Interface ----------------------------------------------------------------------- # Wishbone Interface -----------------------------------------------------------------------
@ -280,6 +290,10 @@ class UDPCore(PHYCore):
from liteeth.frontend.stream import LiteEthUDPStreamer from liteeth.frontend.stream import LiteEthUDPStreamer
# Config ----------------------------------------------------------------------------------- # Config -----------------------------------------------------------------------------------
tx_cdc_depth = core_config.get("tx_cdc_depth", 32)
tx_cdc_buffered = core_config.get("tx_cdc_buffered", False)
rx_cdc_depth = core_config.get("rx_cdc_depth", 32)
rx_cdc_buffered = core_config.get("rx_cdc_buffered", False)
# MAC Address. # MAC Address.
mac_address = core_config.get("mac_address", None) mac_address = core_config.get("mac_address", None)
@ -304,6 +318,11 @@ class UDPCore(PHYCore):
clk_freq = core_config["clk_freq"], clk_freq = core_config["clk_freq"],
dw = data_width, dw = data_width,
with_sys_datapath = (data_width == 32), with_sys_datapath = (data_width == 32),
tx_cdc_depth = tx_cdc_depth
tx_cdc_buffered = tx_cdc_buffered
rx_cdc_depth = rx_cdc_depth
rx_cdc_buffered = rx_cdc_buffered
) )
# UDP Ports -------------------------------------------------------------------------------- # UDP Ports --------------------------------------------------------------------------------

View File

@ -2,6 +2,7 @@
# This file is part of LiteEth. # This file is part of LiteEth.
# #
# Copyright (c) 2015-2020 Florent Kermarrec <florent@enjoy-digital.fr> # Copyright (c) 2015-2020 Florent Kermarrec <florent@enjoy-digital.fr>
# Copyright (c) 2023 LumiGuide Fietsdetectie B.V. <goemansrowan@gmail.com>
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: BSD-2-Clause
from liteeth.common import * from liteeth.common import *
@ -21,7 +22,11 @@ class LiteEthMAC(Module, AutoCSR):
hw_mac = None, hw_mac = None,
timestamp = None, timestamp = None,
full_memory_we = False, full_memory_we = False,
with_sys_datapath = False): with_sys_datapath = False,
tx_cdc_depth = 32,
tx_cdc_buffered = False,
rx_cdc_depth = 32,
rx_cdc_buffered = False):
assert dw%8 == 0 assert dw%8 == 0
assert interface in ["crossbar", "wishbone", "hybrid"] assert interface in ["crossbar", "wishbone", "hybrid"]
@ -31,7 +36,11 @@ class LiteEthMAC(Module, AutoCSR):
phy = phy, phy = phy,
dw = dw, dw = dw,
with_sys_datapath = with_sys_datapath, with_sys_datapath = with_sys_datapath,
with_preamble_crc = with_preamble_crc with_preamble_crc = with_preamble_crc,
tx_cdc_depth = tx_cdc_depth,
tx_cdc_buffered = tx_cdc_buffered,
rx_cdc_depth = rx_cdc_depth,
rx_cdc_buffered = rx_cdc_buffered
) )
self.csrs = [] self.csrs = []
if interface == "crossbar": if interface == "crossbar":

View File

@ -5,6 +5,7 @@
# Copyright (c) 2015-2017 Sebastien Bourdeauducq <sb@m-labs.hk> # Copyright (c) 2015-2017 Sebastien Bourdeauducq <sb@m-labs.hk>
# Copyright (c) 2021 David Sawatzke <d-git@sawatzke.dev> # Copyright (c) 2021 David Sawatzke <d-git@sawatzke.dev>
# Copyright (c) 2017-2018 whitequark <whitequark@whitequark.org> # Copyright (c) 2017-2018 whitequark <whitequark@whitequark.org>
# Copyright (c) 2023 LumiGuide Fietsdetectie B.V. <goemansrowan@gmail.com>
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: BSD-2-Clause
from liteeth.common import * from liteeth.common import *
@ -21,7 +22,12 @@ class LiteEthMACCore(Module, AutoCSR):
def __init__(self, phy, dw, def __init__(self, phy, dw,
with_sys_datapath = False, with_sys_datapath = False,
with_preamble_crc = True, with_preamble_crc = True,
with_padding = True): with_padding = True,
tx_cdc_depth = 32,
tx_cdc_buffered = False,
rx_cdc_depth = 32,
rx_cdc_buffered = False,
):
# Endpoints. # Endpoints.
self.sink = stream.Endpoint(eth_phy_description(dw)) self.sink = stream.Endpoint(eth_phy_description(dw))
@ -57,7 +63,9 @@ class LiteEthMACCore(Module, AutoCSR):
tx_cdc = stream.ClockDomainCrossing(eth_phy_description(core_dw), tx_cdc = stream.ClockDomainCrossing(eth_phy_description(core_dw),
cd_from = "sys", cd_from = "sys",
cd_to = "eth_tx", cd_to = "eth_tx",
depth = 32) depth = tx_cdc_depth,
buffered = tx_cdc_buffered
)
self.submodules += tx_cdc self.submodules += tx_cdc
self.pipeline.append(tx_cdc) self.pipeline.append(tx_cdc)
@ -186,7 +194,9 @@ class LiteEthMACCore(Module, AutoCSR):
rx_cdc = stream.ClockDomainCrossing(eth_phy_description(core_dw), rx_cdc = stream.ClockDomainCrossing(eth_phy_description(core_dw),
cd_from = "eth_rx", cd_from = "eth_rx",
cd_to = "sys", cd_to = "sys",
depth = 32) depth = rx_cdc_depth,
buffered = rx_cdc_buffered
)
self.submodules += rx_cdc self.submodules += rx_cdc
self.pipeline.append(rx_cdc) self.pipeline.append(rx_cdc)