targets/litex_acorn_baseboard_mini: Make it similar to other targets and keep SoC + UART + DRAM + Ethernet.

This commit is contained in:
Florent Kermarrec 2024-02-26 17:29:09 +01:00
parent aa34acc426
commit 7bc03e5fbc

View file

@ -6,13 +6,12 @@
# Copyright (c) 2021-2024 Florent Kermarrec <florent@enjoy-digital.fr> # Copyright (c) 2021-2024 Florent Kermarrec <florent@enjoy-digital.fr>
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: BSD-2-Clause
# Build/Use ----------------------------------------------------------------------------------------
import os
from migen import * from migen import *
from litex.gen import LiteXModule from litex.gen import *
from litex.build.io import DifferentialInput
from litex.build.openocd import OpenOCD
from litex_boards.platforms import sqrl_acorn from litex_boards.platforms import sqrl_acorn
@ -23,104 +22,126 @@ from litex.soc.integration.builder import *
from litex.soc.cores.clock import * from litex.soc.cores.clock import *
from litex.soc.cores.led import LedChaser from litex.soc.cores.led import LedChaser
from litex.build.generic_platform import Subsignal, Pins from litex.build.generic_platform import IOStandard, Subsignal, Pins
from litedram.modules import MT41K512M16
from litedram.phy import s7ddrphy
from liteeth.phy.a7_gtp import QPLLSettings, QPLL from liteeth.phy.a7_gtp import QPLLSettings, QPLL
from liteeth.phy.a7_1000basex import A7_1000BASEX from liteeth.phy.a7_1000basex import A7_1000BASEX
# Platform -----------------------------------------------------------------------------------------
class Platform(sqrl_acorn.Platform):
def create_programmer(self, name="openocd"):
return OpenOCD("openocd_xc7_ft2232.cfg", "bscan_spi_xc7a200t.bit")
_serial_io = [
("serial", 0,
Subsignal("tx", Pins("G1"), IOStandard("LVCMOS33")), # CLK_REQ
Subsignal("rx", Pins("Y13"), IOStandard("LVCMOS18")), # SMB_ALERT_N
),
]
# CRG ---------------------------------------------------------------------------------------------- # CRG ----------------------------------------------------------------------------------------------
class CRG(Module): class CRG(LiteXModule):
def __init__(self, platform, sys_clk_freq): def __init__(self, platform, sys_clk_freq):
self.rst = Signal() self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain() self.cd_sys = ClockDomain()
self.clock_domains.cd_idelay = ClockDomain() self.cd_sys4x = ClockDomain()
self.cd_sys4x_dqs = ClockDomain()
self.cd_idelay = ClockDomain()
# Clk/Rst # Clk/Rst.
clk200 = platform.request("clk200") clk200 = platform.request("clk200")
clk200_se = Signal()
self.specials += DifferentialInput(clk200.p, clk200.n, clk200_se)
# PLL # PLL.
self.submodules.pll = pll = S7PLL() self.pll = pll = S7PLL()
self.comb += pll.reset.eq(self.rst) self.comb += pll.reset.eq(self.rst)
pll.register_clkin(clk200, 200e6) pll.register_clkin(clk200_se, 200e6)
pll.create_clkout(self.cd_sys, sys_clk_freq, margin=0) pll.create_clkout(self.cd_sys, sys_clk_freq)
# Ignore sys_clk to pll.clkin path created by SoC's rst. pll.create_clkout(self.cd_sys4x, 4*sys_clk_freq)
platform.add_false_path_constraints(self.cd_sys.clk, pll.clkin) pll.create_clkout(self.cd_sys4x_dqs, 4*sys_clk_freq, phase=90)
platform.add_false_path_constraints(self.cd_sys.clk, pll.clkin) # Ignore sys_clk to pll.clkin path created by SoC's rst.
# IDelayCtrl.
self.comb += self.cd_idelay.clk.eq(clk200_se)
self.idelayctrl = S7IDELAYCTRL(self.cd_idelay)
# BaseSoC ----------------------------------------------------------------------------------------- # BaseSoC -----------------------------------------------------------------------------------------
class BaseSoC(SoCMini): class BaseSoC(SoCCore):
def __init__(self, variant="cle-215+", sys_clk_freq=156.25e6, with_led_chaser=True, **kwargs): def __init__(self, variant="cle-215+", sys_clk_freq=156.25e6,
platform = sqrl_acorn.Platform(variant=variant) with_ethernet = False,
assert sys_clk_freq == 156.25e6 with_etherbone = False,
eth_ip = "192.168.1.50",
# SoCCore ---------------------------------------------------------------------------------- remote_ip = None,
SoCMini.__init__(self, platform, sys_clk_freq, ident="LiteX SoC on Acorn CLE-101/215(+)") eth_dynamic_ip = False,
with_led_chaser = True,
**kwargs):
platform = Platform(variant=variant)
platform.add_extension(_serial_io, prepend=True)
# CRG -------------------------------------------------------------------------------------- # CRG --------------------------------------------------------------------------------------
self.submodules.crg = CRG(platform, sys_clk_freq) self.crg = CRG(platform, sys_clk_freq)
# Etherbone -------------------------------------------------------------------------------- # SoCCore ----------------------------------------------------------------------------------
SoCCore.__init__(self, platform, sys_clk_freq, ident="LiteX SoC on Acorn CLE-101/215(+)", **kwargs)
_eth_io = [ # DDR3 SDRAM -------------------------------------------------------------------------------
("sfp", 0, if not self.integrated_main_ram_size:
Subsignal("txp", Pins("D5")), self.ddrphy = s7ddrphy.A7DDRPHY(platform.request("ddram"),
Subsignal("txn", Pins("C5")), memtype = "DDR3",
Subsignal("rxp", Pins("D11")), nphases = 4,
Subsignal("rxn", Pins("C11")), sys_clk_freq = sys_clk_freq)
), self.add_sdram("sdram",
("sfp", 1, phy = self.ddrphy,
Subsignal("txp", Pins("B4")), module = MT41K512M16(sys_clk_freq, "1:4"),
Subsignal("txn", Pins("A4")), l2_cache_size = kwargs.get("l2_size", 8192)
Subsignal("rxp", Pins("B8")), )
Subsignal("rxn", Pins("A8")),
),
]
platform.add_extension(_eth_io)
# phy # Ethernet / Etherbone ---------------------------------------------------------------------
qpll_settings = QPLLSettings( if with_ethernet or with_etherbone:
refclksel = 0b001, _eth_io = [
fbdiv = 4, ("sfp", 0,
fbdiv_45 = 4, Subsignal("txp", Pins("D5")),
refclk_div = 1 Subsignal("txn", Pins("C5")),
) Subsignal("rxp", Pins("D11")),
qpll = QPLL(ClockSignal("sys"), qpll_settings) Subsignal("rxn", Pins("C11")),
print(qpll) ),
self.submodules += qpll ]
platform.add_extension(_eth_io)
self.ethphy0 = A7_1000BASEX( qpll_settings = QPLLSettings(
qpll_channel = qpll.channels[0], refclksel = 0b001,
data_pads = self.platform.request("sfp", 0), fbdiv = 4,
sys_clk_freq = self.clk_freq, fbdiv_45 = 4,
rx_polarity = 1, # Inverted on Acorn refclk_div = 1
tx_polarity = 0 # Inverted on Acorn and on baseboard. )
) qpll = QPLL(ClockSignal("sys"), qpll_settings)
platform.add_platform_command("set_property SEVERITY {{Warning}} [get_drc_checks REQP-49]") print(qpll)
self.add_etherbone(name="etherbone0", self.submodules += qpll
phy = self.ethphy0,
phy_cd = "ethphy0_eth",
mac_address = 0x10e2d5000000,
ip_address = "192.168.1.50"
)
self.ethphy1 = A7_1000BASEX( self.ethphy = A7_1000BASEX(
qpll_channel = qpll.channels[0], qpll_channel = qpll.channels[0],
data_pads = self.platform.request("sfp", 1), data_pads = self.platform.request("sfp"),
sys_clk_freq = self.clk_freq, sys_clk_freq = self.clk_freq,
rx_polarity = 1, # Inverted on Acorn rx_polarity = 1, # Inverted on Acorn.
tx_polarity = 0 # Inverted on Acorn and on baseboard. tx_polarity = 0 # Inverted on Acorn and on baseboard.
) )
platform.add_platform_command("set_property SEVERITY {{Warning}} [get_drc_checks REQP-49]") platform.add_platform_command("set_property SEVERITY {{Warning}} [get_drc_checks REQP-49]")
self.add_etherbone(name="etherbone1",
phy = self.ethphy1, if with_etherbone:
phy_cd = "ethphy1_eth", self.add_etherbone(phy=self.ethphy, ip_address=eth_ip, with_ethmac=with_ethernet)
mac_address = 0x10e2d5000001, elif with_ethernet:
ip_address = "192.168.1.51" self.add_ethernet(phy=self.ethphy, dynamic_ip=eth_dynamic_ip, local_ip=eth_ip, remote_ip=remote_ip)
)
# Leds ------------------------------------------------------------------------------------- # Leds -------------------------------------------------------------------------------------
if with_led_chaser: if with_led_chaser:
self.submodules.leds = LedChaser( self.leds = LedChaser(
pads = platform.request_all("user_led"), pads = platform.request_all("user_led"),
sys_clk_freq = sys_clk_freq) sys_clk_freq = sys_clk_freq)
@ -129,16 +150,28 @@ class BaseSoC(SoCMini):
def main(): def main():
from litex.build.parser import LiteXArgumentParser from litex.build.parser import LiteXArgumentParser
parser = LiteXArgumentParser(platform=sqrl_acorn.Platform, description="LiteX SoC on Acorn CLE-101/215(+).") parser = LiteXArgumentParser(platform=sqrl_acorn.Platform, description="LiteX SoC on Acorn CLE-101/215(+).")
parser.add_target_argument("--flash", action="store_true", help="Flash bitstream.") parser.add_target_argument("--flash", action="store_true", help="Flash bitstream.")
parser.add_target_argument("--variant", default="cle-215+", help="Board variant (cle-215+, cle-215 or cle-101).") parser.add_target_argument("--variant", default="cle-215+", help="Board variant (cle-215+, cle-215 or cle-101).")
parser.add_target_argument("--sys-clk-freq", default=156.25e6, 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.")
args = parser.parse_args() args = parser.parse_args()
soc = BaseSoC( soc = BaseSoC(
variant = args.variant, variant = args.variant,
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,
**parser.soc_argdict **parser.soc_argdict
) )
builder = Builder(soc, **parser.builder_argdict) builder = Builder(soc, **parser.builder_argdict)
if args.build: if args.build:
builder.build(**parser.toolchain_argdict) builder.build(**parser.toolchain_argdict)