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.
This commit is contained in:
Sergiusz Bazanski 2017-07-20 13:21:10 +01:00
parent 1885e50d54
commit 503df5e93e
2 changed files with 21 additions and 5 deletions

View File

@ -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

View File

@ -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])