build/lattice/icestorm/trellis: Generate Yosys script in build_project.

This commit is contained in:
Florent Kermarrec 2022-06-24 10:33:49 +02:00
parent 4c978bf463
commit 7117de0f1f
2 changed files with 10 additions and 10 deletions

View File

@ -81,8 +81,6 @@ class LatticeIceStormToolchain(GenericToolchain):
language, includes, filename)) language, includes, filename))
return "\n".join(reads) return "\n".join(reads)
# Yosys/Nextpnr Helpers/Templates --------------------------------------------------------------
_yosys_template = [ _yosys_template = [
"verilog_defaults -push", "verilog_defaults -push",
"verilog_defaults -add -defer", "verilog_defaults -add -defer",
@ -92,7 +90,9 @@ class LatticeIceStormToolchain(GenericToolchain):
"synth_ice40 {synth_opts} -json {build_name}.json -top {build_name} -dsp", "synth_ice40 {synth_opts} -json {build_name}.json -top {build_name} -dsp",
] ]
def _build_yosys(self): # Project (.ys) --------------------------------------------------------------------------------
def build_project(self):
ys = [] ys = []
for l in self._yosys_template: for l in self._yosys_template:
ys.append(l.format( ys.append(l.format(
@ -112,8 +112,6 @@ class LatticeIceStormToolchain(GenericToolchain):
] ]
def build_script(self): def build_script(self):
# Generate Yosys script
self._build_yosys()
# Translate device to Nextpnr architecture/package # Translate device to Nextpnr architecture/package
(family, architecture, package) = self.parse_device() (family, architecture, package) = self.parse_device()

View File

@ -87,7 +87,7 @@ class LatticeTrellisToolchain(GenericToolchain):
lpf.append("\n\n".join(named_pc)) lpf.append("\n\n".join(named_pc))
tools.write_to_file(self._build_name + ".lpf", "\n".join(lpf)) tools.write_to_file(self._build_name + ".lpf", "\n".join(lpf))
# Yosys/Nextpnr Helpers/Templates -------------------------------------------------------------- # Yosys Helpers/Templates ----------------------------------------------------------------------
_yosys_template = [ _yosys_template = [
"verilog_defaults -push", "verilog_defaults -push",
@ -111,7 +111,9 @@ class LatticeTrellisToolchain(GenericToolchain):
language, includes, filename)) language, includes, filename))
return "\n".join(reads) return "\n".join(reads)
def _build_yosys(self): # Project (.ys) --------------------------------------------------------------------------------
def build_project(self):
ys = [] ys = []
for l in self._yosys_template: for l in self._yosys_template:
ys.append(l.format( ys.append(l.format(
@ -122,6 +124,8 @@ class LatticeTrellisToolchain(GenericToolchain):
)) ))
tools.write_to_file(self._build_name + ".ys", "\n".join(ys)) tools.write_to_file(self._build_name + ".ys", "\n".join(ys))
# NextPnr Helpers/Templates --------------------------------------------------------------------
def nextpnr_ecp5_parse_device(self, device): def nextpnr_ecp5_parse_device(self, device):
device = device.lower() device = device.lower()
family = device.split("-")[0] family = device.split("-")[0]
@ -167,8 +171,6 @@ class LatticeTrellisToolchain(GenericToolchain):
] ]
def build_script(self): def build_script(self):
# Generate Yosys script
self._build_yosys()
# Translate device to Nextpnr architecture/package # Translate device to Nextpnr architecture/package
(family, size, speed_grade, package) = self.nextpnr_ecp5_parse_device(self.platform.device) (family, size, speed_grade, package) = self.nextpnr_ecp5_parse_device(self.platform.device)
architecture = self.nextpnr_ecp5_architectures[(family + "-" + size)] architecture = self.nextpnr_ecp5_architectures[(family + "-" + size)]
@ -202,7 +204,7 @@ class LatticeTrellisToolchain(GenericToolchain):
return script_file return script_file
def run_script(script): def run_script(self, script):
if sys.platform in ("win32", "cygwin"): if sys.platform in ("win32", "cygwin"):
shell = ["cmd", "/c"] shell = ["cmd", "/c"]
else: else: