build/generic_toolchain: Rename constraints methods to build_io_constraints/build_timing_constraints.
This commit is contained in:
parent
08cc384a0c
commit
1ecb9cec0a
|
@ -31,10 +31,9 @@ class AlteraQuartusToolchain(GenericToolchain):
|
||||||
self.cst = []
|
self.cst = []
|
||||||
|
|
||||||
def build(self, platform, fragment, **kwargs):
|
def build(self, platform, fragment, **kwargs):
|
||||||
|
|
||||||
return self._build(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):
|
def _format_constraint(self, c, signame, fmt_r):
|
||||||
# IO location constraints
|
# IO location constraints
|
||||||
|
@ -71,7 +70,7 @@ class AlteraQuartusToolchain(GenericToolchain):
|
||||||
"altera_reserved_tdo",
|
"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:
|
for sig, pins, others, resname in named_sc:
|
||||||
if len(pins) > 1:
|
if len(pins) > 1:
|
||||||
for i, p in enumerate(pins):
|
for i, p in enumerate(pins):
|
||||||
|
@ -85,9 +84,9 @@ class AlteraQuartusToolchain(GenericToolchain):
|
||||||
if named_pc:
|
if named_pc:
|
||||||
self.cst.append("\n\n".join(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 = []
|
sdc = []
|
||||||
|
|
||||||
# Clock constraints
|
# Clock constraints
|
||||||
|
@ -117,7 +116,7 @@ class AlteraQuartusToolchain(GenericToolchain):
|
||||||
# Generate .sdc
|
# Generate .sdc
|
||||||
tools.write_to_file("{}.sdc".format(self._build_name), "\n".join(sdc))
|
tools.write_to_file("{}.sdc".format(self._build_name), "\n".join(sdc))
|
||||||
|
|
||||||
# Project (.qsf) -----------------------------------------------------------------------------------
|
# Project (.qsf) -------------------------------------------------------------------------------
|
||||||
|
|
||||||
def build_project(self):
|
def build_project(self):
|
||||||
qsf = []
|
qsf = []
|
||||||
|
@ -164,7 +163,7 @@ class AlteraQuartusToolchain(GenericToolchain):
|
||||||
# Generate .qsf
|
# Generate .qsf
|
||||||
tools.write_to_file("{}.qsf".format(self._build_name), "\n".join(qsf))
|
tools.write_to_file("{}.qsf".format(self._build_name), "\n".join(qsf))
|
||||||
|
|
||||||
# Script -------------------------------------------------------------------------------------------
|
# Script ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
def build_script(self):
|
def build_script(self):
|
||||||
build_name = self._build_name
|
build_name = self._build_name
|
||||||
|
|
|
@ -22,10 +22,10 @@ class GenericToolchain:
|
||||||
self.named_pc = []
|
self.named_pc = []
|
||||||
self.named_sc = []
|
self.named_sc = []
|
||||||
|
|
||||||
def build_constr_file(self, named_sc, named_pc):
|
def build_io_constraints(self, named_sc, named_pc):
|
||||||
raise NotImplementedError("GenericToolchain.build_constr_file must be overloaded.")
|
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.
|
pass # Pass since optional.
|
||||||
|
|
||||||
def build_project(self):
|
def build_project(self):
|
||||||
|
@ -63,10 +63,10 @@ class GenericToolchain:
|
||||||
platform.add_source(v_file)
|
platform.add_source(v_file)
|
||||||
|
|
||||||
# Generate Design IO Constraints 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.
|
# 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.
|
# Generate project.
|
||||||
self.build_project()
|
self.build_project()
|
||||||
|
|
|
@ -25,7 +25,6 @@ class LatticeIceStormToolchain(GenericToolchain):
|
||||||
attr_translate = {
|
attr_translate = {
|
||||||
"keep": ("keep", "true"),
|
"keep": ("keep", "true"),
|
||||||
}
|
}
|
||||||
|
|
||||||
special_overrides = common.lattice_ice40_special_overrides
|
special_overrides = common.lattice_ice40_special_overrides
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -47,7 +46,7 @@ class LatticeIceStormToolchain(GenericToolchain):
|
||||||
|
|
||||||
# IO Constraints (.pcf) ------------------------------------------------------------------------
|
# IO Constraints (.pcf) ------------------------------------------------------------------------
|
||||||
|
|
||||||
def build_constr_file(self, named_sc, named_pc):
|
def build_io_constraints(self, named_sc, named_pc):
|
||||||
r = ""
|
r = ""
|
||||||
for sig, pins, others, resname in named_sc:
|
for sig, pins, others, resname in named_sc:
|
||||||
if len(pins) > 1:
|
if len(pins) > 1:
|
||||||
|
@ -59,15 +58,15 @@ class LatticeIceStormToolchain(GenericToolchain):
|
||||||
r += "\n" + "\n\n".join(named_pc)
|
r += "\n" + "\n\n".join(named_pc)
|
||||||
tools.write_to_file(self._build_name + ".pcf", r)
|
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 = ""
|
r = ""
|
||||||
for clk, period in clocks.items():
|
for clk, period in clocks.items():
|
||||||
r += """ctx.addClock("{}", {})\n""".format(vns.get_name(clk), 1e3/period)
|
r += """ctx.addClock("{}", {})\n""".format(vns.get_name(clk), 1e3/period)
|
||||||
tools.write_to_file(self._build_name + "_pre_pack.py", r)
|
tools.write_to_file(self._build_name + "_pre_pack.py", r)
|
||||||
|
|
||||||
# Yosys/Nextpnr Helpers/Templates ------------------------------------------------------------------
|
# Yosys/Nextpnr Helpers/Templates --------------------------------------------------------------
|
||||||
|
|
||||||
def _yosys_import_sources(self):
|
def _yosys_import_sources(self):
|
||||||
includes = ""
|
includes = ""
|
||||||
|
@ -82,7 +81,7 @@ class LatticeIceStormToolchain(GenericToolchain):
|
||||||
language, includes, filename))
|
language, includes, filename))
|
||||||
return "\n".join(reads)
|
return "\n".join(reads)
|
||||||
|
|
||||||
# Yosys/Nextpnr Helpers/Templates ------------------------------------------------------------------
|
# Yosys/Nextpnr Helpers/Templates --------------------------------------------------------------
|
||||||
|
|
||||||
_yosys_template = [
|
_yosys_template = [
|
||||||
"verilog_defaults -push",
|
"verilog_defaults -push",
|
||||||
|
@ -103,7 +102,7 @@ class LatticeIceStormToolchain(GenericToolchain):
|
||||||
))
|
))
|
||||||
tools.write_to_file(self._build_name + ".ys", "\n".join(ys))
|
tools.write_to_file(self._build_name + ".ys", "\n".join(ys))
|
||||||
|
|
||||||
# Script -------------------------------------------------------------------------------------------
|
# Script ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
_build_template = [
|
_build_template = [
|
||||||
"yosys -l {build_name}.rpt {build_name}.ys",
|
"yosys -l {build_name}.rpt {build_name}.ys",
|
||||||
|
|
|
@ -55,7 +55,7 @@ class LatticeTrellisToolchain(GenericToolchain):
|
||||||
|
|
||||||
return self._build(platform, fragment, **kwargs)
|
return self._build(platform, fragment, **kwargs)
|
||||||
|
|
||||||
# IO Constraints (.lpf) ----------------------------------------------------------------------------
|
# IO Constraints (.lpf) ------------------------------------------------------------------------
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _format_constraint(cls, c):
|
def _format_constraint(cls, c):
|
||||||
|
@ -73,7 +73,7 @@ class LatticeTrellisToolchain(GenericToolchain):
|
||||||
lpf.append(pre + "\"" + signame + "\"" + suf + ";")
|
lpf.append(pre + "\"" + signame + "\"" + suf + ";")
|
||||||
return "\n".join(lpf)
|
return "\n".join(lpf)
|
||||||
|
|
||||||
def build_constr_file(self, named_sc, named_pc):
|
def build_io_constraints(self, named_sc, named_pc):
|
||||||
lpf = []
|
lpf = []
|
||||||
lpf.append("BLOCK RESETPATHS;")
|
lpf.append("BLOCK RESETPATHS;")
|
||||||
lpf.append("BLOCK ASYNCPATHS;")
|
lpf.append("BLOCK ASYNCPATHS;")
|
||||||
|
@ -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/Nextpnr Helpers/Templates --------------------------------------------------------------
|
||||||
|
|
||||||
_yosys_template = [
|
_yosys_template = [
|
||||||
"verilog_defaults -push",
|
"verilog_defaults -push",
|
||||||
|
@ -157,7 +157,7 @@ class LatticeTrellisToolchain(GenericToolchain):
|
||||||
"lfe5um5g-85f": "um5g-85k",
|
"lfe5um5g-85f": "um5g-85k",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Script -------------------------------------------------------------------------------------------
|
# Script ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
_build_template = [
|
_build_template = [
|
||||||
"yosys -l {build_name}.rpt {build_name}.ys",
|
"yosys -l {build_name}.rpt {build_name}.ys",
|
||||||
|
|
Loading…
Reference in New Issue