targets/trellisboard: switch to SoCCore, use add_ethernet() method
Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
This commit is contained in:
parent
396b0383c8
commit
69a78c8c66
|
@ -13,6 +13,7 @@ from litex_boards.platforms import trellisboard
|
||||||
from litex.build.lattice.trellis import trellis_args, trellis_argdict
|
from litex.build.lattice.trellis import trellis_args, trellis_argdict
|
||||||
|
|
||||||
from litex.soc.cores.clock import *
|
from litex.soc.cores.clock import *
|
||||||
|
from litex.soc.integration.soc_core import *
|
||||||
from litex.soc.integration.soc_sdram import *
|
from litex.soc.integration.soc_sdram import *
|
||||||
from litex.soc.integration.builder import *
|
from litex.soc.integration.builder import *
|
||||||
|
|
||||||
|
@ -20,7 +21,6 @@ from litedram.modules import MT41J256M16
|
||||||
from litedram.phy import ECP5DDRPHY
|
from litedram.phy import ECP5DDRPHY
|
||||||
|
|
||||||
from liteeth.phy.ecp5rgmii import LiteEthPHYRGMII
|
from liteeth.phy.ecp5rgmii import LiteEthPHYRGMII
|
||||||
from liteeth.mac import LiteEthMAC
|
|
||||||
|
|
||||||
# CRG ----------------------------------------------------------------------------------------------
|
# CRG ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -78,8 +78,8 @@ class _CRG(Module):
|
||||||
|
|
||||||
# BaseSoC ------------------------------------------------------------------------------------------
|
# BaseSoC ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class BaseSoC(SoCSDRAM):
|
class BaseSoC(SoCCore):
|
||||||
def __init__(self, sys_clk_freq=int(75e6), toolchain="trellis", **kwargs):
|
def __init__(self, sys_clk_freq=int(75e6), toolchain="trellis", with_ethernet=False, **kwargs):
|
||||||
platform = trellisboard.Platform(toolchain=toolchain)
|
platform = trellisboard.Platform(toolchain=toolchain)
|
||||||
|
|
||||||
# SoCSDRAM ---------------------------------------------------------------------------------
|
# SoCSDRAM ---------------------------------------------------------------------------------
|
||||||
|
@ -89,48 +89,29 @@ class BaseSoC(SoCSDRAM):
|
||||||
self.submodules.crg = _CRG(platform, sys_clk_freq)
|
self.submodules.crg = _CRG(platform, sys_clk_freq)
|
||||||
|
|
||||||
# DDR3 SDRAM -------------------------------------------------------------------------------
|
# DDR3 SDRAM -------------------------------------------------------------------------------
|
||||||
|
if not self.integrated_main_ram_size:
|
||||||
self.submodules.ddrphy = ECP5DDRPHY(
|
self.submodules.ddrphy = ECP5DDRPHY(
|
||||||
platform.request("ddram"),
|
platform.request("ddram"),
|
||||||
sys_clk_freq=sys_clk_freq)
|
sys_clk_freq=sys_clk_freq)
|
||||||
self.add_csr("ddrphy")
|
self.add_csr("ddrphy")
|
||||||
self.add_constant("ECP5DDRPHY", None)
|
self.add_constant("ECP5DDRPHY", None)
|
||||||
self.comb += self.crg.stop.eq(self.ddrphy.init.stop)
|
self.add_sdram("sdram",
|
||||||
sdram_module = MT41J256M16(sys_clk_freq, "1:2")
|
phy = self.ddrphy,
|
||||||
self.register_sdram(self.ddrphy,
|
module = MT41J256M16(sys_clk_freq, "1:2"),
|
||||||
geom_settings = sdram_module.geom_settings,
|
origin = self.mem_map["main_ram"],
|
||||||
timing_settings = sdram_module.timing_settings)
|
size = kwargs.get("max_sdram_size", 0x40000000),
|
||||||
|
l2_cache_size = kwargs.get("l2_size", 8192),
|
||||||
# EthernetSoC --------------------------------------------------------------------------------------
|
l2_cache_min_data_width = kwargs.get("min_l2_data_width", 128),
|
||||||
|
l2_cache_reverse = True
|
||||||
class EthernetSoC(BaseSoC):
|
)
|
||||||
mem_map = {
|
|
||||||
"ethmac": 0xb0000000,
|
|
||||||
}
|
|
||||||
mem_map.update(BaseSoC.mem_map)
|
|
||||||
|
|
||||||
def __init__(self, toolchain="trellis", **kwargs):
|
|
||||||
BaseSoC.__init__(self, toolchain=toolchain, **kwargs)
|
|
||||||
|
|
||||||
# Ethernet ---------------------------------------------------------------------------------
|
# Ethernet ---------------------------------------------------------------------------------
|
||||||
# phy
|
if with_ethernet:
|
||||||
self.submodules.ethphy = LiteEthPHYRGMII(
|
self.submodules.ethphy = LiteEthPHYRGMII(
|
||||||
clock_pads = self.platform.request("eth_clocks"),
|
clock_pads = self.platform.request("eth_clocks"),
|
||||||
pads = self.platform.request("eth"))
|
pads = self.platform.request("eth"))
|
||||||
self.add_csr("ethphy")
|
self.add_csr("ethphy")
|
||||||
# mac
|
self.add_ethernet(phy=self.ethphy)
|
||||||
self.submodules.ethmac = LiteEthMAC(phy=self.ethphy, dw=32,
|
|
||||||
interface="wishbone", endianness=self.cpu.endianness)
|
|
||||||
self.add_memory_region("ethmac", self.mem_map["ethmac"], 0x2000, type="io")
|
|
||||||
self.add_wb_slave(self.mem_map["ethmac"], self.ethmac.bus, 0x2000)
|
|
||||||
self.add_csr("ethmac")
|
|
||||||
self.add_interrupt("ethmac")
|
|
||||||
# timing constraints
|
|
||||||
self.platform.add_period_constraint(self.ethphy.crg.cd_eth_rx.clk, 1e9/125e6)
|
|
||||||
self.platform.add_period_constraint(self.ethphy.crg.cd_eth_tx.clk, 1e9/125e6)
|
|
||||||
self.platform.add_false_path_constraints(
|
|
||||||
self.crg.cd_sys.clk,
|
|
||||||
self.ethphy.crg.cd_eth_rx.clk,
|
|
||||||
self.ethphy.crg.cd_eth_tx.clk)
|
|
||||||
|
|
||||||
# Build --------------------------------------------------------------------------------------------
|
# Build --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -147,8 +128,9 @@ def main():
|
||||||
help="enable Ethernet support")
|
help="enable Ethernet support")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
cls = EthernetSoC if args.with_ethernet else BaseSoC
|
soc = BaseSoC(sys_clk_freq=int(float(args.sys_clk_freq)),
|
||||||
soc = cls(toolchain=args.toolchain, sys_clk_freq=int(float(args.sys_clk_freq)), **soc_sdram_argdict(args))
|
with_ethernet=args.with_ethernet,
|
||||||
|
**soc_sdram_argdict(args))
|
||||||
builder = Builder(soc, **builder_argdict(args))
|
builder = Builder(soc, **builder_argdict(args))
|
||||||
builder_kargs = trellis_argdict(args) if args.toolchain == "trellis" else {}
|
builder_kargs = trellis_argdict(args) if args.toolchain == "trellis" else {}
|
||||||
builder.build(**builder_kargs)
|
builder.build(**builder_kargs)
|
||||||
|
|
Loading…
Reference in New Issue