From 426ab676e84bf42f4111ceba50aa0da9885d6191 Mon Sep 17 00:00:00 2001 From: Konrad Beckmann Date: Tue, 7 Jan 2020 23:15:13 +0100 Subject: [PATCH] trellis: Pass speed grade argument to nextpnr --- litex/build/lattice/trellis.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/litex/build/lattice/trellis.py b/litex/build/lattice/trellis.py index 770c336ce..dcc2e38de 100644 --- a/litex/build/lattice/trellis.py +++ b/litex/build/lattice/trellis.py @@ -99,16 +99,19 @@ def nextpnr_ecp5_package(package): return "CABGA756" raise ValueError("Unknown package {}".format(package)) +def nextpnr_ecp5_speed_grade(package): + return package[0] if package[0] in ["6", "7", "8"] else "6" + # Script ------------------------------------------------------------------------------------------- _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} --package {package} {timefailarg}", + --{architecture} --package {package} --speed {speed_grade} {timefailarg}", "ecppack {build_name}.config --svf {build_name}.svf --bit {build_name}.bit" ] -def _build_script(source, build_template, build_name, architecture, package, timingstrict): +def _build_script(source, build_template, build_name, architecture, package, speed_grade, timingstrict): if sys.platform in ("win32", "cygwin"): script_ext = ".bat" script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n\n" @@ -124,6 +127,7 @@ def _build_script(source, build_template, build_name, architecture, package, tim build_name = build_name, architecture = architecture, package = package, + speed_grade = speed_grade, timefailarg = "--timing-allow-fail" if not timingstrict else "", fail_stmt = fail_stmt) @@ -202,11 +206,12 @@ class LatticeTrellisToolchain: # Translate device to Nextpnr architecture/package (family, size, package) = platform.device.split("-") architecture = nextpnr_ecp5_architectures[(family + "-" + size).lower()] + speed_grade = nextpnr_ecp5_speed_grade(package) package = nextpnr_ecp5_package(package) # Generate build script script = _build_script(False, self.build_template, build_name, architecture, package, - timingstrict) + speed_grade, timingstrict) # Run if run: