Merge pull request #2006 from trabucayre/update_altera_build

Update altera build
This commit is contained in:
enjoy-digital 2024-07-04 13:04:15 +02:00 committed by GitHub
commit d838a9ca73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 4 deletions

View File

@ -62,3 +62,11 @@ class AlteraPlatform(GenericPlatform):
for pad in common.altera_reserved_jtag_pads: for pad in common.altera_reserved_jtag_pads:
r[pad] = self.request(pad) r[pad] = self.request(pad)
return r return r
@classmethod
def fill_args(cls, toolchain, parser):
quartus.fill_args(parser)
@classmethod
def get_argdict(cls, toolchain, args):
return quartus.get_argdict(args)

View File

@ -28,10 +28,19 @@ class AlteraQuartusToolchain(GenericToolchain):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self._synth_tool = "quartus_map"
self.additional_sdc_commands = [] self.additional_sdc_commands = []
self.additional_qsf_commands = [] self.additional_qsf_commands = []
self.cst = [] self.cst = []
def build(self, platform, fragment,
synth_tool = "quartus_map",
**kwargs):
self._synth_tool = synth_tool
return GenericToolchain.build(self, 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):
@ -143,7 +152,8 @@ class AlteraQuartusToolchain(GenericToolchain):
# Add IPs # Add IPs
for filename in self.platform.ips: for filename in self.platform.ips:
qsf.append("set_global_assignment -name QSYS_FILE " + filename.replace("\\", "/")) file_ext = os.path.splitext(filename)[1][1:].upper()
qsf.append(f"set_global_assignment -name {file_ext}_FILE " + filename.replace("\\", "/"))
# Add include paths # Add include paths
for path in self.platform.verilog_include_paths: for path in self.platform.verilog_include_paths:
@ -178,7 +188,7 @@ class AlteraQuartusToolchain(GenericToolchain):
script_contents += "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n" script_contents += "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n"
script_contents += "set -e -u -x -o pipefail\n" script_contents += "set -e -u -x -o pipefail\n"
script_contents += """ script_contents += """
quartus_map --read_settings_files=on --write_settings_files=off {build_name} -c {build_name} {synth_tool} --read_settings_files=on --write_settings_files=off {build_name} -c {build_name}
quartus_fit --read_settings_files=off --write_settings_files=off {build_name} -c {build_name} quartus_fit --read_settings_files=off --write_settings_files=off {build_name} -c {build_name}
quartus_asm --read_settings_files=off --write_settings_files=off {build_name} -c {build_name} quartus_asm --read_settings_files=off --write_settings_files=off {build_name} -c {build_name}
quartus_sta {build_name} -c {build_name}""" quartus_sta {build_name} -c {build_name}"""
@ -196,7 +206,7 @@ then
quartus_cpf -c {build_name}.sof {build_name}.rbf quartus_cpf -c {build_name}.sof {build_name}.rbf
fi fi
""" """
script_contents = script_contents.format(build_name=build_name) script_contents = script_contents.format(build_name=build_name, synth_tool=self._synth_tool)
tools.write_to_file(script_file, script_contents, force_unix=True) tools.write_to_file(script_file, script_contents, force_unix=True)
return script_file return script_file
@ -207,10 +217,19 @@ fi
else: else:
shell = ["bash"] shell = ["bash"]
if which("quartus_map") is None: if which(self._synth_tool) is None:
msg = "Unable to find Quartus toolchain, please:\n" msg = "Unable to find Quartus toolchain, please:\n"
msg += "- Add Quartus toolchain to your $PATH." msg += "- Add Quartus toolchain to your $PATH."
raise OSError(msg) raise OSError(msg)
if subprocess.call(shell + [script]) != 0: if subprocess.call(shell + [script]) != 0:
raise OSError("Error occured during Quartus's script execution.") raise OSError("Error occured during Quartus's script execution.")
def fill_args(parser):
toolchain_group = parser.add_argument_group(title="Quartus toolchain options")
toolchain_group.add_argument("--synth-tool", default="quartus_map", help="Synthesis mode (quartus_map or quartus_syn).")
def get_argdict(args):
return {
"synth_tool" : args.synth_tool,
}