Skip to content

Commit

Permalink
xilinx_zc706: Add Ethernet/Etherbone support through SFP/K7_1000BaseX…
Browse files Browse the repository at this point in the history
… (Untested on hardware).
  • Loading branch information
enjoy-digital committed Mar 26, 2024
1 parent a29532b commit 8a5b831
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions litex_boards/targets/xilinx_zc706.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from litex.soc.integration.builder import *
from litex.soc.cores.led import LedChaser

from liteeth.phy.k7_1000basex import K7_1000BASEX

from litepcie.phy.s7pciephy import S7PCIEPHY
from litepcie.software import generate_litepcie_software

Expand All @@ -39,6 +41,7 @@ class _CRG(LiteXModule):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.cd_sys = ClockDomain()
self.cd_eth = ClockDomain()

# # #

Expand All @@ -50,12 +53,21 @@ def __init__(self, platform, sys_clk_freq):
self.comb += pll.reset.eq(self.rst)
pll.register_clkin(clk200, 200e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_eth, 200e6)
platform.add_false_path_constraints(self.cd_sys.clk, pll.clkin) # Ignore sys_clk to pll.clkin path created by SoC's rst.

# BaseSoC ------------------------------------------------------------------------------------------

class BaseSoC(SoCCore):
def __init__(self, sys_clk_freq=100e6, with_led_chaser=True, with_pcie=False, **kwargs):
def __init__(self, sys_clk_freq=125e6,
with_ethernet = False,
with_etherbone = False,
eth_ip = "192.168.1.50",
remote_ip = None,
eth_dynamic_ip = False,
with_led_chaser = True,
with_pcie = False,
**kwargs):
platform = xilinx_zc706.Platform()
kwargs["uart_name"] = "crossover"
kwargs["with_jtagbone"] = True
Expand All @@ -66,6 +78,21 @@ def __init__(self, sys_clk_freq=100e6, with_led_chaser=True, with_pcie=False, **
# SoCCore ----------------------------------------------------------------------------------
SoCCore.__init__(self, platform, sys_clk_freq, ident="LiteX SoC on ZCU706", **kwargs)

# Ethernet / Etherbone ---------------------------------------------------------------------
if with_ethernet or with_etherbone:
self.ethphy = K7_1000BASEX(
refclk_or_clk_pads = self.crg.cd_eth.clk,
data_pads = self.platform.request("sfp", 0),
sys_clk_freq = self.clk_freq,
with_csr = False
)
self.comb += self.platform.request("sfp_tx_disable_n", 0).eq(1)
platform.add_platform_command("set_property SEVERITY {{Warning}} [get_drc_checks REQP-52]")
if with_etherbone:
self.add_etherbone(phy=self.ethphy, ip_address=eth_ip, with_ethmac=with_ethernet)
elif with_ethernet:
self.add_ethernet(phy=self.ethphy, dynamic_ip=eth_dynamic_ip, local_ip=eth_ip, remote_ip=remote_ip)

# PCIe -------------------------------------------------------------------------------------
if with_pcie:
self.pcie_phy = S7PCIEPHY(platform, platform.request("pcie_x4"),
Expand All @@ -84,14 +111,24 @@ def __init__(self, sys_clk_freq=100e6, with_led_chaser=True, with_pcie=False, **
def main():
from litex.build.parser import LiteXArgumentParser
parser = LiteXArgumentParser(platform=xilinx_zc706.Platform, description="LiteX SoC on ZC706.")
parser.add_target_argument("--sys-clk-freq", default=100e6, type=float, help="System clock frequency.")
parser.add_target_argument("--with-pcie", action="store_true", help="Enable PCIe support.")
parser.add_target_argument("--driver", action="store_true", help="Generate PCIe driver.")
parser.add_target_argument("--sys-clk-freq", default=125e6, type=float, help="System clock frequency.")
parser.add_target_argument("--with-ethernet", action="store_true", help="Enable Ethernet support.")
parser.add_target_argument("--with-etherbone", action="store_true", help="Enable Etherbone support.")
parser.add_target_argument("--eth-ip", default="192.168.1.50", help="Ethernet/Etherbone IP address.")
parser.add_target_argument("--remote-ip", default="192.168.1.100", help="Remote IP address of TFTP server.")
parser.add_target_argument("--eth-dynamic-ip", action="store_true", help="Enable dynamic Ethernet IP addresses setting.")
parser.add_target_argument("--with-pcie", action="store_true", help="Enable PCIe support.")
parser.add_target_argument("--driver", action="store_true", help="Generate PCIe driver.")
args = parser.parse_args()

soc = BaseSoC(
sys_clk_freq = args.sys_clk_freq,
with_pcie = args.with_pcie,
sys_clk_freq = args.sys_clk_freq,
with_ethernet = args.with_ethernet,
with_etherbone = args.with_etherbone,
eth_ip = args.eth_ip,
remote_ip = args.remote_ip,
eth_dynamic_ip = args.eth_dynamic_ip,
with_pcie = args.with_pcie,
**parser.soc_argdict
)
builder = Builder(soc, **parser.builder_argdict)
Expand Down

0 comments on commit 8a5b831

Please sign in to comment.