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_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 _build_script(build_name, vivado_path, source, ver=None): if sys.platform in ["win32", "cygwin"]: script_contents = "REM Autogenerated by LiteX / git: " + tools.get_litex_git_revision( ) + "\n" script_contents += "vivado -mode batch -source " + build_name + ".tcl\n" script_file = "build_" + build_name + ".bat" tools.write_to_file(script_file, script_contents) else: script_contents = "# Autogenerated by LiteX / git: " + tools.get_litex_git_revision( ) + "\nset -e\n" # Only source Vivado settings if not already in our $PATH if not find_executable("vivado"): # 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.") script_contents += "source " + settings + "\n" script_contents += "vivado -mode batch -source " + build_name + ".tcl\n" script_file = "build_" + build_name + ".sh" tools.write_to_file(script_file, script_contents) return script_file
def _run_vivado(path, ver, cmds): if sys.platform == "win32" or sys.platform == "cygwin": vivado_cmd = "vivado -mode tcl" else: settings = common.settings(path, ver) vivado_cmd = "bash -c \"source " + settings + "&& vivado -mode tcl\"" with subprocess.Popen(vivado_cmd, stdin=subprocess.PIPE, shell=True) as process: process.stdin.write(cmds.encode("ASCII")) process.communicate()
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_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_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_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) r = subprocess.call([build_script_file]) else: build_script_contents = "# Autogenerated by LiteX\nset -e\n" settings = common.settings(vivado_path, ver) 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) r = subprocess.call(["bash", build_script_file]) if r != 0: raise OSError("Subprocess failed")
def _run_vivado(path, ver, cmds): if sys.platform == "win32" or sys.platform == "cygwin": vivado_cmd = "vivado -mode tcl" else: # For backwards compatibility with ISE paths, also # look for a version in a subdirectory named "Vivado" # under the current directory. paths_to_try = [path, os.path.join(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.") vivado_cmd = "bash -c \"source " + settings + "&& vivado -mode tcl\"" with subprocess.Popen(vivado_cmd, stdin=subprocess.PIPE, shell=True) as process: process.stdin.write(cmds.encode("ASCII")) process.communicate()
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) r = subprocess.call([build_script_file]) else: build_script_contents = "# Autogenerated by LiteX\nset -e\n" if vivado_path is None: vivado_path = "/opt/Xilinx/Vivado" settings = common.settings(vivado_path, ver) 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) r = subprocess.call(["bash", build_script_file]) if r != 0: raise OSError("Subprocess failed")
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" else: source_cmd = "source " script_ext = ".sh" shell = ["bash"] build_script_contents = "# Autogenerated by LiteX\nset -e\n" 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 """ build_script_contents += """ ngdbuild {ngdbuild_opt} -uc {build_name}.ucf {build_name}.{ext} {build_name}.ngd map {map_opt} -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf par {par_opt} {build_name}_map.ncd {build_name}.ncd {build_name}.pcf bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit """ 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) 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 = subprocess.call(command) if r != 0: raise OSError("Subprocess failed")