From 7117de0f1f4fe513f4b7a4d2484db9e23e28c1f1 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 24 Jun 2022 10:33:49 +0200 Subject: [PATCH] build/lattice/icestorm/trellis: Generate Yosys script in build_project. --- litex/build/lattice/icestorm.py | 8 +++----- litex/build/lattice/trellis.py | 12 +++++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/litex/build/lattice/icestorm.py b/litex/build/lattice/icestorm.py index 3287a4bca..1d72abca6 100644 --- a/litex/build/lattice/icestorm.py +++ b/litex/build/lattice/icestorm.py @@ -81,8 +81,6 @@ class LatticeIceStormToolchain(GenericToolchain): language, includes, filename)) return "\n".join(reads) - # Yosys/Nextpnr Helpers/Templates -------------------------------------------------------------- - _yosys_template = [ "verilog_defaults -push", "verilog_defaults -add -defer", @@ -92,7 +90,9 @@ class LatticeIceStormToolchain(GenericToolchain): "synth_ice40 {synth_opts} -json {build_name}.json -top {build_name} -dsp", ] - def _build_yosys(self): + # Project (.ys) -------------------------------------------------------------------------------- + + def build_project(self): ys = [] for l in self._yosys_template: ys.append(l.format( @@ -112,8 +112,6 @@ class LatticeIceStormToolchain(GenericToolchain): ] def build_script(self): - # Generate Yosys script - self._build_yosys() # Translate device to Nextpnr architecture/package (family, architecture, package) = self.parse_device() diff --git a/litex/build/lattice/trellis.py b/litex/build/lattice/trellis.py index 6f40742d1..4ee890e8d 100644 --- a/litex/build/lattice/trellis.py +++ b/litex/build/lattice/trellis.py @@ -87,7 +87,7 @@ class LatticeTrellisToolchain(GenericToolchain): lpf.append("\n\n".join(named_pc)) tools.write_to_file(self._build_name + ".lpf", "\n".join(lpf)) - # Yosys/Nextpnr Helpers/Templates -------------------------------------------------------------- + # Yosys Helpers/Templates ---------------------------------------------------------------------- _yosys_template = [ "verilog_defaults -push", @@ -111,7 +111,9 @@ class LatticeTrellisToolchain(GenericToolchain): language, includes, filename)) return "\n".join(reads) - def _build_yosys(self): + # Project (.ys) -------------------------------------------------------------------------------- + + def build_project(self): ys = [] for l in self._yosys_template: ys.append(l.format( @@ -122,6 +124,8 @@ class LatticeTrellisToolchain(GenericToolchain): )) tools.write_to_file(self._build_name + ".ys", "\n".join(ys)) + # NextPnr Helpers/Templates -------------------------------------------------------------------- + def nextpnr_ecp5_parse_device(self, device): device = device.lower() family = device.split("-")[0] @@ -167,8 +171,6 @@ class LatticeTrellisToolchain(GenericToolchain): ] def build_script(self): - # Generate Yosys script - self._build_yosys() # Translate device to Nextpnr architecture/package (family, size, speed_grade, package) = self.nextpnr_ecp5_parse_device(self.platform.device) architecture = self.nextpnr_ecp5_architectures[(family + "-" + size)] @@ -202,7 +204,7 @@ class LatticeTrellisToolchain(GenericToolchain): return script_file - def run_script(script): + def run_script(self, script): if sys.platform in ("win32", "cygwin"): shell = ["cmd", "/c"] else: