def _run_vivado(build_name, vivado_path, source, ver=None): if sys.platform == "win32" or sys.platform == "cygwin": build_script_contents = "REM Autogenerated by LiteX\n" build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n" build_script_file = "build_" + build_name + ".bat" tools.write_to_file(build_script_file, build_script_contents) command = build_script_file else: build_script_contents = "# Autogenerated by LiteX\nset -e\n" # For backwards compatibility with ISE paths, also # look for a version in a subdirectory named "Vivado" # under the current directory. paths_to_try = [vivado_path, os.path.join(vivado_path, "Vivado")] for p in paths_to_try: try: settings = common.settings(p, ver) except OSError: continue break else: raise OSError("Unable to locate Vivado directory or settings.") build_script_contents += "source " + settings + "\n" build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n" build_script_file = "build_" + build_name + ".sh" tools.write_to_file(build_script_file, build_script_contents) command = ["bash", build_script_file] r = tools.subprocess_call_filtered(command, common.colors) if r != 0: raise OSError("Subprocess failed")
def run_script(self, script): if self._mode == "yosys": self._run_yosys() if self._mode == "edif": # Generate edif e_output = self.platform.get_edif(self._fragment) self._vns = e_output.ns self.named_sc, self.named_pc = self.platform.resolve_signals( self._vns) e_file = build_name + ".edif" e_output.write(e_file) self.build_io_constraints() if sys.platform == "win32" or sys.platform == "cygwin": shell = ["cmd", "/c"] else: shell = ["bash"] command = shell + [script] if which("ise") is None and os.getenv("LITEX_ENV_ISE", False) == False: msg = "Unable to find or source ISE toolchain, please either:\n" msg += "- Source ISE's settings manually.\n" msg += "- Or set LITEX_ENV_ISE environment variant to ISE's settings path.\n" msg += "- Or add ISE toolchain to your $PATH." raise OSError(msg) if tools.subprocess_call_filtered(command, common.colors) != 0: raise OSError("Error occured during ISE's script execution.")
def _run_vivado(build_name, vivado_path, source, ver=None): if sys.platform == "win32" or sys.platform == "cygwin": build_script_contents = "REM Autogenerated by Migen\n" build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n" build_script_file = "build_" + build_name + ".bat" tools.write_to_file(build_script_file, build_script_contents) command = build_script_file else: build_script_contents = "# Autogenerated by Migen\nset -e\n" # For backwards compatibility with ISE paths, also # look for a version in a subdirectory named "Vivado" # under the current directory. paths_to_try = [vivado_path, os.path.join(vivado_path, "Vivado")] for p in paths_to_try: try: settings = common.settings(p, ver) except OSError: continue break else: raise OSError("Unable to locate Vivado directory or settings.") build_script_contents += "source " + settings + "\n" build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n" build_script_file = "build_" + build_name + ".sh" tools.write_to_file(build_script_file, build_script_contents) command = ["bash", build_script_file] r = tools.subprocess_call_filtered(command, common.colors) if r != 0: raise OSError("Subprocess failed")
def _run_script(script): if sys.platform in ["win32", "cygwin"]: shell = ["cmd", "/c"] else: shell = ["bash"] if tools.subprocess_call_filtered(shell + [script], common.colors) != 0: raise OSError("Subprocess failed")
def _run_make(): if which("symbiflow_synth") is None: msg = "Unable to find Symbiflow toolchain, please:\n" msg += "- Add Symbiflow toolchain to your $PATH." raise OSError(msg) if tools.subprocess_call_filtered(shell + [script], common.colors) != 0: raise OSError("Error occured during Symbiflow's script execution.")
def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt, toolchain, platform, ver=None): if sys.platform == "win32" or sys.platform == "cygwin": source_cmd = "call " script_ext = ".bat" shell = ["cmd", "/c"] build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n" fail_stmt = " || exit /b" else: source_cmd = "source " script_ext = ".sh" shell = ["bash"] build_script_contents = "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\nset -e\n" fail_stmt = "" if source: settings = common.settings(ise_path, ver, "ISE_DS") build_script_contents += source_cmd + tools.cygpath(settings) + "\n" if mode == "edif": ext = "edif" else: ext = "ngc" build_script_contents += """ xst -ifn {build_name}.xst{fail_stmt} """ # This generates a .v file for post synthesis simulation build_script_contents += """ netgen -ofmt verilog -w -sim {build_name}.{ext} {build_name}_synth.v """ build_script_contents += """ ngdbuild {ngdbuild_opt} -uc {build_name}.ucf {build_name}.{ext} {build_name}.ngd{fail_stmt} """ if mode == "cpld": build_script_contents += """ cpldfit -ofmt verilog {par_opt} -p {device} {build_name}.ngd{fail_stmt} taengine -f {build_name}.vm6 -detail -iopath -l {build_name}.tim{fail_stmt} hprep6 -s IEEE1532 -i {build_name}.vm6{fail_stmt} """ else: build_script_contents += """ map {map_opt} -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf{fail_stmt} par {par_opt} {build_name}_map.ncd {build_name}.ncd {build_name}.pcf{fail_stmt} bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit{fail_stmt} """ build_script_contents = build_script_contents.format(build_name=build_name, ngdbuild_opt=ngdbuild_opt, bitgen_opt=toolchain.bitgen_opt, ext=ext, par_opt=toolchain.par_opt, map_opt=toolchain.map_opt, device=platform.device, fail_stmt=fail_stmt) build_script_contents += toolchain.ise_commands.format(build_name=build_name) build_script_file = "build_" + build_name + script_ext tools.write_to_file(build_script_file, build_script_contents, force_unix=False) command = shell + [build_script_file] r = tools.subprocess_call_filtered(command, common.colors) if r != 0: raise OSError("Subprocess failed")
def _run_make(): make_cmd = ["make", "-j1"] if which("nextpnr-xilinx") is None: msg = "Unable to find Yosys+Nextpnr toolchain, please:\n" msg += "- Add Yosys and Nextpnr tools to your $PATH." raise OSError(msg) if tools.subprocess_call_filtered(make_cmd, common.colors) != 0: raise OSError("Error occured during yosys or nextpnr script execution.")
def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt, bitgen_opt, ise_commands, map_opt, par_opt, ver=None): if sys.platform == "win32" or sys.platform == "cygwin": source_cmd = "call " script_ext = ".bat" shell = ["cmd", "/c"] build_script_contents = "@echo off\nrem Autogenerated by LiteX\n" fail_stmt = " || exit /b" else: source_cmd = "source " script_ext = ".sh" shell = ["bash"] build_script_contents = "# Autogenerated by LiteX\nset -e\n" fail_stmt = "" if source: settings = common.settings(ise_path, ver, "ISE_DS") build_script_contents += source_cmd + settings + "\n" ext = "ngc" build_script_contents += """ xst -ifn {build_name}.xst{fail_stmt} """ build_script_contents += """ ngdbuild {ngdbuild_opt} -uc {build_name}.ucf {build_name}.{ext} {build_name}.ngd{fail_stmt} map {map_opt} -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf{fail_stmt} par {par_opt} {build_name}_map.ncd {build_name}.ncd {build_name}.pcf{fail_stmt} bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit{fail_stmt} """ build_script_contents = build_script_contents.format( build_name=build_name, ngdbuild_opt=ngdbuild_opt, bitgen_opt=bitgen_opt, ext=ext, par_opt=par_opt, map_opt=map_opt, fail_stmt=fail_stmt) build_script_contents += ise_commands.format(build_name=build_name) build_script_file = "build_" + build_name + script_ext tools.write_to_file(build_script_file, build_script_contents, force_unix=False) command = shell + [build_script_file] r = tools.subprocess_call_filtered(command, common.colors) if r != 0: raise OSError("Subprocess failed")
def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt, toolchain, platform, ver=None): if sys.platform == "win32" or sys.platform == "cygwin": source_cmd = "call " script_ext = ".bat" shell = ["cmd", "/c"] build_script_contents = "@echo off\nrem Autogenerated by Migen\n" fail_stmt = " || exit /b" else: source_cmd = "source " script_ext = ".sh" shell = ["bash"] build_script_contents = "# Autogenerated by Migen\nset -e\n" fail_stmt = "" if source: settings = common.settings(ise_path, ver, "ISE_DS") build_script_contents += source_cmd + tools.cygpath(settings) + "\n" if mode == "edif": ext = "edif" else: ext = "ngc" build_script_contents += """ xst -ifn {build_name}.xst{fail_stmt} """ build_script_contents += """ ngdbuild {ngdbuild_opt} -uc {build_name}.ucf {build_name}.{ext} {build_name}.ngd{fail_stmt} """ if mode == "cpld": build_script_contents += """ cpldfit -ofmt verilog {par_opt} -p {device} {build_name}.ngd{fail_stmt} taengine -f {build_name}.vm6 -detail -iopath -l {build_name}.tim{fail_stmt} hprep6 -s IEEE1532 -i {build_name}.vm6{fail_stmt} """ else: build_script_contents += """ map {map_opt} -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf{fail_stmt} par {par_opt} {build_name}_map.ncd {build_name}.ncd {build_name}.pcf{fail_stmt} bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit{fail_stmt} """ build_script_contents = build_script_contents.format(build_name=build_name, ngdbuild_opt=ngdbuild_opt, bitgen_opt=toolchain.bitgen_opt, ext=ext, par_opt=toolchain.par_opt, map_opt=toolchain.map_opt, device=platform.device, fail_stmt=fail_stmt) build_script_contents += toolchain.ise_commands.format(build_name=build_name) build_script_file = "build_" + build_name + script_ext tools.write_to_file(build_script_file, build_script_contents, force_unix=False) command = shell + [build_script_file] r = tools.subprocess_call_filtered(command, common.colors) if r != 0: raise OSError("Subprocess failed")
def _run_script(script): if sys.platform in ["win32", "cygwin"]: shell = ["cmd", "/c"] else: shell = ["bash"] if which("vivado") is None and os.getenv("LITEX_ENV_VIVADO", False) == False: msg = "Unable to find or source Vivado toolchain, please either:\n" msg += "- Source Vivado's settings manually.\n" msg += "- Or set LITEX_ENV_VIVADO environment variant to Vivado's settings path.\n" msg += "- Or add Vivado toolchain to your $PATH." raise OSError(msg) if tools.subprocess_call_filtered(shell + [script], common.colors) != 0: raise OSError("Error occured during Vivado's script execution.")
def _run_vivado(build_name, vivado_path, source, ver=None): if sys.platform == "win32" or sys.platform == "cygwin": build_script_contents = "REM Autogenerated by LiteX\n" build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n" build_script_file = "build_" + build_name + ".bat" tools.write_to_file(build_script_file, build_script_contents) command = build_script_file else: build_script_contents = "# Autogenerated by LiteX\nset -e\n" settings = common.settings(vivado_path, "Vivado", ver, first="name") build_script_contents += "source " + settings + "\n" build_script_contents += "vivado -mode batch -source " + build_name + ".tcl\n" build_script_file = "build_" + build_name + ".sh" tools.write_to_file(build_script_file, build_script_contents) command = ["bash", build_script_file] r = tools.subprocess_call_filtered(command, common.colors) if r != 0: raise OSError("Subprocess failed")
def _run_script(script): if sys.platform in ["win32", "cygwin"]: shell = ["cmd", "/c"] elif sys.platform == "darwin": root = str(Path(os.path.abspath(os.getcwd())).parent.parent.parent) shell = ["docker","run", "--rm", "-v", root + ":" + root, "-w", os.getcwd(), "xilinx", "bash"] else: shell = ["bash"] if sys.platform != "darwin" and which("vivado") is None and os.getenv("LITEX_ENV_VIVADO", False) == False: msg = "Unable to find or source Vivado toolchain, please either:\n" msg += "- Source Vivado's settings manually.\n" msg += "- Or set LITEX_ENV_VIVADO environment variant to Vivado's settings path.\n" msg += "- Or add Vivado toolchain to your $PATH." raise OSError(msg) if tools.subprocess_call_filtered(shell + [script], common.colors) != 0: raise OSError("Error occured during Vivado's script execution.")
def _run_make(): if tools.subprocess_call_filtered("make", []) != 0: raise OSError("Subprocess failed")
def _run_ise(build_name, mode, ngdbuild_opt, toolchain, platform): if sys.platform == "win32" or sys.platform == "cygwin": script_ext = ".bat" shell = ["cmd", "/c"] build_script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision( ) + "\n" fail_stmt = " || exit /b" else: script_ext = ".sh" shell = ["bash"] build_script_contents = "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision( ) + "\nset -e\n" if os.getenv("LITEX_ENV_ISE", False): build_script_contents += "source " + os.path.join( os.getenv("LITEX_ENV_ISE"), "settings64.sh\n") fail_stmt = "" if mode == "edif": ext = "ngo" build_script_contents += """ edif2ngd {build_name}.edif {build_name}.{ext}{fail_stmt} """ else: ext = "ngc" build_script_contents += """ xst -ifn {build_name}.xst{fail_stmt} """ # This generates a .v file for post synthesis simulation build_script_contents += """ netgen -ofmt verilog -w -sim {build_name}.{ext} {build_name}_synth.v """ build_script_contents += """ ngdbuild {ngdbuild_opt} -uc {build_name}.ucf {build_name}.{ext} {build_name}.ngd{fail_stmt} """ if mode == "cpld": build_script_contents += """ cpldfit -ofmt verilog {par_opt} -p {device} {build_name}.ngd{fail_stmt} taengine -f {build_name}.vm6 -detail -iopath -l {build_name}.tim{fail_stmt} hprep6 -s IEEE1532 -i {build_name}.vm6{fail_stmt} """ else: build_script_contents += """ map {map_opt} -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf{fail_stmt} par {par_opt} {build_name}_map.ncd {build_name}.ncd {build_name}.pcf{fail_stmt} bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit{fail_stmt} """ build_script_contents = build_script_contents.format( build_name=build_name, ngdbuild_opt=ngdbuild_opt, bitgen_opt=toolchain.bitgen_opt, ext=ext, par_opt=toolchain.par_opt, map_opt=toolchain.map_opt, device=platform.device, fail_stmt=fail_stmt) build_script_contents += toolchain.ise_commands.format( build_name=build_name) build_script_file = "build_" + build_name + script_ext tools.write_to_file(build_script_file, build_script_contents, force_unix=False) command = shell + [build_script_file] if which("ise") is None and os.getenv("LITEX_ENV_ISE", False) == False: msg = "Unable to find or source ISE toolchain, please either:\n" msg += "- Source ISE's settings manually.\n" msg += "- Or set LITEX_ENV_ISE environment variant to ISE's settings path.\n" msg += "- Or add ISE toolchain to your $PATH." raise OSError(msg) if tools.subprocess_call_filtered(command, common.colors) != 0: raise OSError("Error occured during ISE's script execution.")