From 5ef28bdf75a57735312a37d444919a371b69daae Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 1 Mar 2019 15:20:02 +0100 Subject: [PATCH] build/lattice/trellis: add package support --- litex/build/lattice/trellis.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/litex/build/lattice/trellis.py b/litex/build/lattice/trellis.py index b804df7a2..f4c7c05cf 100644 --- a/litex/build/lattice/trellis.py +++ b/litex/build/lattice/trellis.py @@ -28,6 +28,18 @@ nextpnr_ecp5_architectures = { } +def nextpnr_ecp5_package(package): + if "285" in package: + return "CSFBGA285" + elif "381" in package: + return "CABGA381" + elif "554" in package: + return "CABGA554" + elif "756" in package: + return "CABGA756" + raise ValueError("Unknown package") + + def _format_constraint(c): if isinstance(c, Pins): return ("LOCATE COMP ", " SITE " + "\"" + c.identifiers[0] + "\"") @@ -60,7 +72,7 @@ def _build_lpf(named_sc, named_pc): def _build_script(source, build_template, build_name, architecture, - freq_constraint): + package, freq_constraint): if sys.platform in ("win32", "cygwin"): script_ext = ".bat" build_script_contents = "@echo off\nrem Autogenerated by Migen\n\n" @@ -74,6 +86,7 @@ def _build_script(source, build_template, build_name, architecture, s_fail = s + "{fail_stmt}\n" # Required so Windows scripts fail early. build_script_contents += s_fail.format(build_name=build_name, architecture=architecture, + package=package, freq_constraint=freq_constraint, fail_stmt=fail_stmt) @@ -129,7 +142,7 @@ class LatticeTrellisToolchain: self.build_template = [ "yosys -q -l {build_name}.rpt {build_name}.ys", - "nextpnr-ecp5 --json {build_name}.json --lpf {build_name}.lpf --textcfg {build_name}.config --{architecture} --freq {freq_constraint}", + "nextpnr-ecp5 --json {build_name}.json --lpf {build_name}.lpf --textcfg {build_name}.config --{architecture} --package {package} --freq {freq_constraint}", "ecppack {build_name}.config {build_name}.bit" ] @@ -168,11 +181,12 @@ class LatticeTrellisToolchain: # transform platform.device to nextpnr's architecture (family, size, package) = platform.device.split("-") architecture = nextpnr_ecp5_architectures[(family + "-" + size).lower()] + package = nextpnr_ecp5_package(package) freq_constraint = str(max(self.freq_constraints.values(), default=0.0)) script = _build_script(False, self.build_template, build_name, - architecture, freq_constraint) + architecture, package, freq_constraint) # run scripts if run: