From 96a406b2eb08c77b0a33fcc6eb9e472ef17ea594 Mon Sep 17 00:00:00 2001 From: Joppe Blondel Date: Mon, 5 Sep 2022 12:38:21 +0200 Subject: [PATCH] Full bit and timing log generation Signed-off-by: Joppe Blondel --- examples/spartan6/project.cfg | 3 ++ remotesyn/toolchains/ISE.py | 16 +++++++++++ remotesyn/toolchains/util_ISE/bitgen.py | 37 +++++++++++++++++++++++++ remotesyn/toolchains/util_ISE/trce.py | 32 +++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 remotesyn/toolchains/util_ISE/bitgen.py create mode 100644 remotesyn/toolchains/util_ISE/trce.py diff --git a/examples/spartan6/project.cfg b/examples/spartan6/project.cfg index 1fb52fa..0b3e34b 100644 --- a/examples/spartan6/project.cfg +++ b/examples/spartan6/project.cfg @@ -23,6 +23,9 @@ toplevel = toplevel #ngdbuild_opts = #map_opts = #par_opts = +#netgen_opts = +#bitgen_opts = +#trce_opts = # Fileset files_vhdl = RTL/toplevel.vhd diff --git a/remotesyn/toolchains/ISE.py b/remotesyn/toolchains/ISE.py index 462236d..ef6fdc0 100644 --- a/remotesyn/toolchains/ISE.py +++ b/remotesyn/toolchains/ISE.py @@ -3,6 +3,8 @@ from .util_ISE.ngdbuild import ngdbuild from .util_ISE.map import map from .util_ISE.par import par from .util_ISE.netgen import netgen +from .util_ISE.bitgen import bitgen +from .util_ISE.trce import trce def do(config, target, log, subprocesses, prefix='.'): log("Syntesize:") @@ -29,7 +31,21 @@ def do(config, target, log, subprocesses, prefix='.'): print("ERROR: par returned with", res) return res + log("Generate output files") + res = netgen(config, target, log, subprocesses, prefix) if res != 0: print("ERROR: netgen returned with", res) + return res + + res = bitgen(config, target, log, subprocesses, prefix) + if res != 0: + print("ERROR: bitgen returned with", res) + return res + + log("Analyze design") + + res = trce(config, target, log, subprocesses, prefix) + if res != 0: + print("ERROR: trce returned with", res) return res \ No newline at end of file diff --git a/remotesyn/toolchains/util_ISE/bitgen.py b/remotesyn/toolchains/util_ISE/bitgen.py new file mode 100644 index 0000000..e03144b --- /dev/null +++ b/remotesyn/toolchains/util_ISE/bitgen.py @@ -0,0 +1,37 @@ +import shutil +import os +import time +import subprocess + +def bitgen(config, target, log, subprocesses, prefix='.') -> int: + log(" - parsing options") + bitgen_opts = config.get(f'target.{target}', 'bitgen_opts', fallback='') + build_dir = config.get(f'project', 'build_dir', fallback='build') + out_dir = config.get(f'project', 'out_dir', fallback='out') + + prefix = f'{os.getcwd()}/{prefix}' + build_dir = f'{prefix}/{build_dir}' + out_dir = f'{prefix}/{out_dir}/{target}' + + log(" - creating output directories") + os.makedirs(build_dir, exist_ok=True) + os.makedirs(out_dir, exist_ok=True) + + log(" - run bitgen") + p = subprocess.Popen(f"bitgen -intstyle xflow {bitgen_opts} -g Binary:Yes -w {out_dir}/{target}.ncd {target}.bit {out_dir}/{target}.pcf 2> bitgen.log", + shell=True, cwd=build_dir, + stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocesses.append(p) + while p.poll() is None: + time.sleep(1) + res = p.returncode + + log(" - copy logs") + shutil.copy(f'{build_dir}/bitgen.log', f'{out_dir}/bitgen.log') + + if res==0: + log(" - copy output files") + shutil.copy(f'{build_dir}/{target}.bit', f'{out_dir}/{target}.bit') + shutil.copy(f'{build_dir}/{target}.bin', f'{out_dir}/{target}.bin') + + return res \ No newline at end of file diff --git a/remotesyn/toolchains/util_ISE/trce.py b/remotesyn/toolchains/util_ISE/trce.py new file mode 100644 index 0000000..c251c60 --- /dev/null +++ b/remotesyn/toolchains/util_ISE/trce.py @@ -0,0 +1,32 @@ +import shutil +import os +import time +import subprocess + +def trce(config, target, log, subprocesses, prefix='.') -> int: + log(" - parsing options") + trce_opts = config.get(f'target.{target}', 'trce_opts', fallback='') + build_dir = config.get(f'project', 'build_dir', fallback='build') + out_dir = config.get(f'project', 'out_dir', fallback='out') + + prefix = f'{os.getcwd()}/{prefix}' + build_dir = f'{prefix}/{build_dir}' + out_dir = f'{prefix}/{out_dir}/{target}' + + log(" - creating output directories") + os.makedirs(build_dir, exist_ok=True) + os.makedirs(out_dir, exist_ok=True) + + log(" - run trce") + p = subprocess.Popen(f"trce -intstyle xflow {trce_opts} -v 3 -s 2 -n 3 -fastpaths {out_dir}/{target}.ncd {out_dir}/{target}.pcf", + shell=True, cwd=build_dir, + stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocesses.append(p) + while p.poll() is None: + time.sleep(1) + res = p.returncode + + log(" - copy logs") + shutil.copy(f'{build_dir}/{target}.twr', f'{out_dir}/timing.log') + + return res \ No newline at end of file