From: Sergiusz Bazanski Date: Thu, 20 Jul 2017 12:21:10 +0000 (+0100) Subject: Add Diamond toolchain support for Linux. X-Git-Tag: 24jan2021_ls180~1813^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=503df5e93e3fe3fc3c115e4f8933e976ed4b23bd;p=litex.git Add Diamond toolchain support for Linux. This tries to replicate the same setup as in the Windows buildsystem. We also remove the Jedecgen step, as it doesn't seem to be supported nor necessary in newer versions of Diamond. --- diff --git a/litex/build/lattice/diamond.py b/litex/build/lattice/diamond.py index fad525f3..582d24bc 100644 --- a/litex/build/lattice/diamond.py +++ b/litex/build/lattice/diamond.py @@ -56,19 +56,31 @@ def _build_files(device, sources, vincpaths, build_name): tcl.append("prj_run Map -impl implementation") tcl.append("prj_run PAR -impl implementation") tcl.append("prj_run Export -impl implementation -task Bitgen") - tcl.append("prj_run Export -impl implementation -task Jedecgen") tools.write_to_file(build_name + ".tcl", "\n".join(tcl)) -def _run_diamond(build_name, source, ver=None): +def _run_diamond(build_name, toolchain_path, ver=None): if sys.platform == "win32" or sys.platform == "cygwin": build_script_contents = "REM Autogenerated by LiteX\n" - build_script_contents = "pnmainc " + build_name + ".tcl\n" + build_script_contents += "pnmainc " + build_name + ".tcl\n" build_script_file = "build_" + build_name + ".bat" tools.write_to_file(build_script_file, build_script_contents) r = subprocess.call([build_script_file]) shutil.copy(os.path.join("implementation", build_name + "_implementation.bit"), build_name + ".bit") shutil.copy(os.path.join("implementation", build_name + "_implementation.jed"), build_name + ".jed") + elif sys.platform == "linux": + bindir = os.path.join(toolchain_path, 'bin/lin64') + envfile = os.path.join(bindir, 'diamond_env') + build_script_contents = "# Autogenerated by LiteX\n" + build_script_contents += "set -e\n" + build_script_contents += "bindir='{}/'\n".format(bindir) + build_script_contents += "source {}\n".format(envfile) + build_script_contents += "diamondc {}.tcl | tee build.log\n".format(build_name) + build_script_file = "build_{}.sh".format(build_name) + + tools.write_to_file(build_script_file, build_script_contents) + r = subprocess.call(['/bin/sh', build_script_file]) + shutil.copy(os.path.join("implementation", build_name + "_implementation.bit"), build_name + ".bit") else: raise NotImplementedError diff --git a/litex/build/lattice/programmer.py b/litex/build/lattice/programmer.py index a34af86b..0923a65c 100644 --- a/litex/build/lattice/programmer.py +++ b/litex/build/lattice/programmer.py @@ -11,8 +11,12 @@ class LatticeProgrammer(GenericProgrammer): def __init__(self, xcf_template): self.xcf_template = xcf_template - def load_bitstream(self, bitstream_file): + def load_bitstream(self, bitstream_file, toolchain_path=''): xcf_file = bitstream_file.replace(".bit", ".xcf") xcf_content = self.xcf_template.format(bitstream_file=bitstream_file) tools.write_to_file(xcf_file, xcf_content) - subprocess.call(["pgrcmd", "-infile", xcf_file]) + if toolchain_path: + pgrcmd = os.path.join(toolchain_path, 'bin/lin64/pgrcmd') + else: + pgrcmr = 'pgrcmr' + subprocess.call([pgrcmd, "-infile", xcf_file])