From 1ecb9cec0a41d59c626708608b7afd2361bb5b06 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 24 Jun 2022 10:12:36 +0200 Subject: [PATCH] build/generic_toolchain: Rename constraints methods to build_io_constraints/build_timing_constraints. --- litex/build/altera/quartus.py | 13 ++++++------- litex/build/generic_toolchain.py | 10 +++++----- litex/build/lattice/icestorm.py | 13 ++++++------- litex/build/lattice/trellis.py | 8 ++++---- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/litex/build/altera/quartus.py b/litex/build/altera/quartus.py index 08388f348..f014ef598 100644 --- a/litex/build/altera/quartus.py +++ b/litex/build/altera/quartus.py @@ -31,10 +31,9 @@ class AlteraQuartusToolchain(GenericToolchain): self.cst = [] def build(self, platform, fragment, **kwargs): - return self._build(platform, fragment, **kwargs) - # IO/Placement Constraints (.qsf) ------------------------------------------------------------------ + # IO/Placement Constraints (.qsf) -------------------------------------------------------------- def _format_constraint(self, c, signame, fmt_r): # IO location constraints @@ -71,7 +70,7 @@ class AlteraQuartusToolchain(GenericToolchain): "altera_reserved_tdo", ) - def build_constr_file(self, named_sc, named_pc): + def build_io_constraints(self, named_sc, named_pc): for sig, pins, others, resname in named_sc: if len(pins) > 1: for i, p in enumerate(pins): @@ -85,9 +84,9 @@ class AlteraQuartusToolchain(GenericToolchain): if named_pc: self.cst.append("\n\n".join(named_pc)) - # Timing Constraints (.sdc) ------------------------------------------------------------------------ + # Timing Constraints (.sdc) -------------------------------------------------------------------- - def build_timing_constr(self, vns, clocks): + def build_timing_constraints(self, vns, clocks): sdc = [] # Clock constraints @@ -117,7 +116,7 @@ class AlteraQuartusToolchain(GenericToolchain): # Generate .sdc tools.write_to_file("{}.sdc".format(self._build_name), "\n".join(sdc)) - # Project (.qsf) ----------------------------------------------------------------------------------- + # Project (.qsf) ------------------------------------------------------------------------------- def build_project(self): qsf = [] @@ -164,7 +163,7 @@ class AlteraQuartusToolchain(GenericToolchain): # Generate .qsf tools.write_to_file("{}.qsf".format(self._build_name), "\n".join(qsf)) - # Script ------------------------------------------------------------------------------------------- + # Script --------------------------------------------------------------------------------------- def build_script(self): build_name = self._build_name diff --git a/litex/build/generic_toolchain.py b/litex/build/generic_toolchain.py index 7537b3cf7..c4bea285b 100644 --- a/litex/build/generic_toolchain.py +++ b/litex/build/generic_toolchain.py @@ -22,10 +22,10 @@ class GenericToolchain: self.named_pc = [] self.named_sc = [] - def build_constr_file(self, named_sc, named_pc): - raise NotImplementedError("GenericToolchain.build_constr_file must be overloaded.") + def build_io_constraints(self, named_sc, named_pc): + raise NotImplementedError("GenericToolchain.build_io_constraints must be overloaded.") - def build_timing_constr(self, vns, clocks): + def build_timing_constraints(self, vns, clocks): pass # Pass since optional. def build_project(self): @@ -63,10 +63,10 @@ class GenericToolchain: platform.add_source(v_file) # Generate Design IO Constraints File. - self.build_constr_file(self.named_sc, self.named_pc) + self.build_io_constraints(self.named_sc, self.named_pc) # Generate Design Timing Constraints File. - self.build_timing_constr(v_output.ns, self.clocks) + self.build_timing_constraints(v_output.ns, self.clocks) # Generate project. self.build_project() diff --git a/litex/build/lattice/icestorm.py b/litex/build/lattice/icestorm.py index 7b110cf05..3287a4bca 100644 --- a/litex/build/lattice/icestorm.py +++ b/litex/build/lattice/icestorm.py @@ -25,7 +25,6 @@ class LatticeIceStormToolchain(GenericToolchain): attr_translate = { "keep": ("keep", "true"), } - special_overrides = common.lattice_ice40_special_overrides def __init__(self): @@ -47,7 +46,7 @@ class LatticeIceStormToolchain(GenericToolchain): # IO Constraints (.pcf) ------------------------------------------------------------------------ - def build_constr_file(self, named_sc, named_pc): + def build_io_constraints(self, named_sc, named_pc): r = "" for sig, pins, others, resname in named_sc: if len(pins) > 1: @@ -59,15 +58,15 @@ class LatticeIceStormToolchain(GenericToolchain): r += "\n" + "\n\n".join(named_pc) tools.write_to_file(self._build_name + ".pcf", r) - # Timing Constraints (in pre_pack file) ------------------------------------------------------------ + # Timing Constraints (in pre_pack file) -------------------------------------------------------- - def build_timing_constr(self, vns, clocks): + def build_timing_constraints(self, vns, clocks): r = "" for clk, period in clocks.items(): r += """ctx.addClock("{}", {})\n""".format(vns.get_name(clk), 1e3/period) tools.write_to_file(self._build_name + "_pre_pack.py", r) - # Yosys/Nextpnr Helpers/Templates ------------------------------------------------------------------ + # Yosys/Nextpnr Helpers/Templates -------------------------------------------------------------- def _yosys_import_sources(self): includes = "" @@ -82,7 +81,7 @@ class LatticeIceStormToolchain(GenericToolchain): language, includes, filename)) return "\n".join(reads) - # Yosys/Nextpnr Helpers/Templates ------------------------------------------------------------------ + # Yosys/Nextpnr Helpers/Templates -------------------------------------------------------------- _yosys_template = [ "verilog_defaults -push", @@ -103,7 +102,7 @@ class LatticeIceStormToolchain(GenericToolchain): )) tools.write_to_file(self._build_name + ".ys", "\n".join(ys)) - # Script ------------------------------------------------------------------------------------------- + # Script --------------------------------------------------------------------------------------- _build_template = [ "yosys -l {build_name}.rpt {build_name}.ys", diff --git a/litex/build/lattice/trellis.py b/litex/build/lattice/trellis.py index 48452d35c..03334b1b7 100644 --- a/litex/build/lattice/trellis.py +++ b/litex/build/lattice/trellis.py @@ -55,7 +55,7 @@ class LatticeTrellisToolchain(GenericToolchain): return self._build(platform, fragment, **kwargs) - # IO Constraints (.lpf) ---------------------------------------------------------------------------- + # IO Constraints (.lpf) ------------------------------------------------------------------------ @classmethod def _format_constraint(cls, c): @@ -73,7 +73,7 @@ class LatticeTrellisToolchain(GenericToolchain): lpf.append(pre + "\"" + signame + "\"" + suf + ";") return "\n".join(lpf) - def build_constr_file(self, named_sc, named_pc): + def build_io_constraints(self, named_sc, named_pc): lpf = [] lpf.append("BLOCK RESETPATHS;") lpf.append("BLOCK ASYNCPATHS;") @@ -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/Nextpnr Helpers/Templates -------------------------------------------------------------- _yosys_template = [ "verilog_defaults -push", @@ -157,7 +157,7 @@ class LatticeTrellisToolchain(GenericToolchain): "lfe5um5g-85f": "um5g-85k", } - # Script ------------------------------------------------------------------------------------------- + # Script --------------------------------------------------------------------------------------- _build_template = [ "yosys -l {build_name}.rpt {build_name}.ys",