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

Hybrid Etherbone simplification #1838

Merged
merged 2 commits into from
Nov 13, 2023
Merged
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
21 changes: 16 additions & 5 deletions litex/soc/integration/soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1781,8 +1781,7 @@ def add_etherbone(self, name="etherbone", phy=None, phy_cd="eth", data_width=8,
buffer_depth = 16,
with_ip_broadcast = True,
with_timing_constraints = True,
interface = "crossbar",
endianness = "big"):
ethernet = False):
# Imports
from liteeth.core import LiteEthUDPIPCore
from liteeth.frontend.etherbone import LiteEthEtherbone
Expand All @@ -1801,10 +1800,10 @@ def add_etherbone(self, name="etherbone", phy=None, phy_cd="eth", data_width=8,
dw = data_width,
with_ip_broadcast = with_ip_broadcast,
with_sys_datapath = with_sys_datapath,
interface = interface,
endianness = endianness,
interface = "hybrid" if ethernet else "crossbar",
endianness = self.cpu.endianness if ethernet else "big",
)
if interface == "hybrid":
if ethernet:
ethcore.autocsr_exclude = {"mac"} # Exclude MAC here since added externally.
if not with_sys_datapath:
# Use PHY's eth_tx/eth_rx clock domains.
Expand Down Expand Up @@ -1840,6 +1839,18 @@ def add_etherbone(self, name="etherbone", phy=None, phy_cd="eth", data_width=8,
else:
self.platform.add_false_path_constraints(self.crg.cd_sys.clk, eth_rx_clk)

if ethernet:
# Software Interface.
self.ethmac = ethmac = ethcore.mac
ethmac_region_size = (ethmac.rx_slots.constant + ethmac.tx_slots.constant)*ethmac.slot_size.constant
ethmac_region = SoCRegion(origin=self.mem_map.get("ethmac", None), size=ethmac_region_size, cached=False)
self.bus.add_slave(name="ethmac", slave=ethmac.bus, region=ethmac_region)
# Add IRQs (if enabled).
if self.irq.enabled:
self.irq.add("ethmac", use_loc_if_exists=True)

self.add_constant("ETH_PHY_NO_RESET") # Disable reset from BIOS to avoid disabling Hardware Interface.

# Add SPI Flash --------------------------------------------------------------------------------
def add_spi_flash(self, name="spiflash", mode="4x", clk_freq=None, module=None, phy=None, rate="1:1", software_debug=False, **kwargs):
# Imports.
Expand Down
29 changes: 4 additions & 25 deletions litex/tools/litex_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,29 +233,16 @@ def __init__(self,
else:
raise ValueError("Unknown Ethernet PHY model:", ethernet_phy_model)

# Ethernet and Etherbone -------------------------------------------------------------------
if with_ethernet and with_etherbone:
# Etherbone.
# Etherbone with optional Ethernet ---------------------------------------------------------
if with_etherbone:
self.add_etherbone(
phy = self.ethphy,
ip_address = etherbone_ip_address,
mac_address = etherbone_mac_address,
data_width = 8,
interface = "hybrid",
endianness = self.cpu.endianness
ethernet = with_ethernet,
)

# Software Interface.
self.ethmac = ethmac = self.get_module("ethcore_etherbone").mac
ethmac_region_size = (ethmac.rx_slots.constant + ethmac.tx_slots.constant)*ethmac.slot_size.constant
ethmac_region = SoCRegion(origin=self.mem_map.get("ethmac", None), size=ethmac_region_size, cached=False)
self.bus.add_slave(name="ethmac", slave=ethmac.bus, region=ethmac_region)

# Add IRQs (if enabled).
if self.irq.enabled:
self.irq.add("ethmac", use_loc_if_exists=True)

# Ethernet ---------------------------------------------------------------------------------
# Ethernet only ----------------------------------------------------------------------------
elif with_ethernet:
# Ethernet MAC
self.ethmac = ethmac = LiteEthMAC(
Expand All @@ -272,14 +259,6 @@ def __init__(self,
if self.irq.enabled:
self.irq.add("ethmac", use_loc_if_exists=True)

# Etherbone --------------------------------------------------------------------------------
elif with_etherbone:
self.add_etherbone(
phy = self.ethphy,
ip_address = etherbone_ip_address,
mac_address = etherbone_mac_address
)

# I2C --------------------------------------------------------------------------------------
if with_i2c:
pads = platform.request("i2c", 0)
Expand Down