From 2291026181192b604e5eb44b29113c47b055f118 Mon Sep 17 00:00:00 2001 From: Krzysztof Boronski Date: Fri, 6 May 2022 06:00:12 -0500 Subject: [PATCH] f4pga: Remove irrelevant old prototype code Signed-off-by: Krzysztof Boronski --- f4pga/wrappers/__init__.py | 28 ------- f4pga/wrappers/xc7/__init__.py | 113 ---------------------------- f4pga/wrappers/xc7/synth.py | 126 ------------------------------- f4pga/wrappers/xc7/vpr.py | 133 --------------------------------- 4 files changed, 400 deletions(-) delete mode 100644 f4pga/wrappers/__init__.py delete mode 100644 f4pga/wrappers/xc7/__init__.py delete mode 100755 f4pga/wrappers/xc7/synth.py delete mode 100644 f4pga/wrappers/xc7/vpr.py diff --git a/f4pga/wrappers/__init__.py b/f4pga/wrappers/__init__.py deleted file mode 100644 index 7c627bc..0000000 --- a/f4pga/wrappers/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -from pathlib import Path -from os import environ -from sys import argv as sys_argv -from subprocess import run as subprocess_run - - -def run(*args): - """ - Execute subroutine - """ - out = subprocess_run(args, capture_output=True) - if out.returncode != 0: - raise(Exception(out.returncode)) - return out.stdout - - -def noisy_warnings(device): - """ - Emit some noisy warnings - """ - environ['OUR_NOISY_WARNINGS'] = f'noisy_warnings-{device}_pack.log' - - -def my_path(): - """ - Get current PWD - """ - return str(Path(sys_argv[0]).resolve().parent) diff --git a/f4pga/wrappers/xc7/__init__.py b/f4pga/wrappers/xc7/__init__.py deleted file mode 100644 index 7a9cf14..0000000 --- a/f4pga/wrappers/xc7/__init__.py +++ /dev/null @@ -1,113 +0,0 @@ -from pathlib import Path -from re import search as re_search - -from f4pga.wrappers import ( - my_path, - noisy_warnings, - run -) - -from f4pga.wrappers.xc7.vpr import ( - save_vpr_log, - setup_vpr_arg_parser, - VprArgs, - vpr -) - - -def place(): - parser = setup_vpr_arg_parser() - parser.add_argument( - '-n', - '--net', - nargs='+', - metavar='', - type=str, - help='NET filename' - ) - args = parser.parse_args() - - vprargs = VprArgs(my_path(), args) + [ - '--fix_clusters', - 'constraints.place', - '--place' - ] - vprargs.export() - - if not args.net: - print('Please provide NET filename') - exit(1) - - noisy_warnings() - - print('Generating constraints...\n') - - run( - 'symbiflow_generate_constraints', - args.eblif, - args.net, - args.part, - vprargs.arch_def, - args.pcf - ) - - vpr(vprargs) - - save_vpr_log('place.log') - - -def route(): - args = setup_vpr_arg_parser().parse_args() - - vprargs = VprArgs(my_path(), args) - vprargs.export() - - noisy_warnings(args.device) - - vprargs.optional += '--route' - - print('Routing...') - vpr(vprargs) - - save_vpr_log('route.log') - - -def write_fasm(): - vprargs = VprArgs( - my_path(), - setup_vpr_arg_parser().parse_args() - ) - - if vprargs.eblif is None: - raise(Exception("Argument EBLIF is required!")) - - top_ext_match = re_search('.*\\.[^.]*', vprargs.eblif) - top = top[:top_ext_match.pos] if top_ext_match else vprargs.eblif - - fasm_extra = top + '_fasm_extra.fasm' - - noisy_warnings() - - run( - 'genfasm', - vprargs.arch_def, - vprargs.eblif, - '--device', vprargs.device_name, - vprargs.vpr_options, - '--read_rr_graph', vprargs.rr_graph - ) - - print(f'FASM extra: {fasm_extra}\n') - - # Concatenate top.fasm with extra.fasm if necessary - if Path(fasm_extra).is_file(): - print('writing final fasm') - with open(top + '.fasm', 'r+<') as top_file, open(fasm_extra) as extra_file: - cat = top_file.read() - cat += '\n' - cat += extra_file.read() - top_file.seek(0) - top_file.write(cat) - top_file.truncate() - - save_vpr_log('fasm.log') diff --git a/f4pga/wrappers/xc7/synth.py b/f4pga/wrappers/xc7/synth.py deleted file mode 100755 index f209c24..0000000 --- a/f4pga/wrappers/xc7/synth.py +++ /dev/null @@ -1,126 +0,0 @@ -from pathlib import Path -from sys import argv as sys_argv -from os import environ -from argparse import ArgumentParser -from f4pga.wrappers import run - - -def arg_parser(): - parser = ArgumentParser(description="Parse flags") - - parser.add_argument( - '-t', - '--top', - nargs=1, - metavar='', - type=str, - help='Top module name' - ) - - parser.add_argument( - '-v', - '--verilog', - nargs='+', - metavar='', - type=str, - help='Verilog file list' - ) - - parser.add_argument( - '-x', - '--xdc', - nargs='+', - metavar='', - type=str, - help='XDC file list' - ) - - parser.add_argument( - '-d', - '--device', - nargs=1, - metavar='', - type=str, - help='Device type (e.g. artix7)' - ) - - parser.add_argument( - '-p', - '--part', - nargs=1, - metavar='', - type=str, - help='Part name' - ) - - return parser.parse_args() - - -def main(): - share_dir_path = (Path(sys_argv[0]).resolve().parent / '../share/symbiflow').resolve() - utils_path = share_dir_path / 'scripts' - - environ['SHARE_DIR_PATH'] = str(share_dir_path) - environ['TECHMAP_PATH'] = str(share_dir_path / 'techmaps/xc7_vpr/techmap') - environ['UTILS_PATH'] = str(utils_path) - - args = arg_parser() - - database_dir = environ.get('DATABASE_DIR', str(run('prjxray-config'))) - environ['DATABASE_DIR'] = database_dir - - # TODO: is this crossplatform??? - if 'PYTHON3' not in environ: - environ['PYTHON3'] = run(['which', 'python3']) - - if not args.verilog: - raise(Exception('Please provide at least one Verilog file\n')) - - if not args.top: - raise(Exception('Top module must be specified\n')) - - if not args.device: - raise(Exception('Device parameter required\n')) - - if not args.part: - raise(Exception('Part parameter required\n')) - - out_json = f"{args.top}.json" - synth_json = f"{args.top}_io.json" - log = f"{args.top}_synth.log" - - environ['TOP'] = args.top - environ['OUT_JSON'] = out_json - environ['OUT_SDC'] = f"{args.top}.sdc" - environ['SYNTH_JSON'] = synth_json - environ['OUT_SYNTH_V'] = f"{args.top}_synth.v" - environ['OUT_EBLIF'] = f"{args.top}.eblif" - environ['PART_JSON'] = str(Path(database_dir) / f"{args.device}/{args.part}/part.json") - environ['OUT_FASM_EXTRA'] = args.top + '_fasm_extra.fasm' - - if args.xdc: - environ['INPUT_XDC_FILES'] = ' '.join(args.xdc) - - run( - 'yosys', - '-p', - f'\"tcl {(utils_path / "xc7/synth.tcl")!s}\"', - '-l', - 'log', - ' '.join(args.verilog) - ) - - run( - 'python3', - str(utils_path / 'split_inouts.py'), - '-i', - out_json, - '-o', - synth_json - ) - - run( - 'yosys', - '-p', - f'\"read_json {synth_json}; tcl {(utils_path / "xc7/conv.tcl")!s}\"' - ) diff --git a/f4pga/wrappers/xc7/vpr.py b/f4pga/wrappers/xc7/vpr.py deleted file mode 100644 index 7a54e1b..0000000 --- a/f4pga/wrappers/xc7/vpr.py +++ /dev/null @@ -1,133 +0,0 @@ -from typing import List -from pathlib import Path -from argparse import ArgumentParser -from os import environ -from shutil import move as sh_mv - -from f4pga.wrappers import run - -class VprArgs: - arch_dir: Path - arch_def: Path - lookahead: Path - rr_graph: Path - rr_graph_xml: Path - place_delay: Path - device_name: Path - eblif: str - vpr_options: str - optional: List[str] - - def __init__(self, mypath, args): - self.arch_dir = (Path(mypath) / '../share/symbiflow/arch' / args.device).resolve() - self.arch_def = self.arch_dir / 'arch.timing.xml' - filename = f'rr_graph_{args.device}' - self.lookahead = self.arch_dir / f'{filename}.lookahead.bin' - self.rr_graph = self.arch_dir / f'{filename}.rr_graph.real.bin' - self.rr_graph_xml = self.arch_dir / f'{filename}.rr_graph.real.xml' - self.place_delay = self.arch_dir / f'{filename}.place_delay.bin' - self.device_name = args.device.replace('_', '-') - self.eblif = args.eblif - self.vpr_options = args.vpr_options - self.optional = ['--sdc_file', args.sdc] if args.sdc else [] - - def export(self): - environ['ARCH_DIR'] = str(self.arch_dir) - environ['ARCH_DEF'] = str(self.arch_def) - environ['LOOKAHEAD'] = str(self.lookahead) - environ['RR_GRAPH'] = str(self.rr_graph) - environ['RR_GRAPH_XML'] = str(self.rr_graph_xml) - environ['PLACE_DELAY'] = str(self.place_delay) - environ['DEVICE_NAME'] = str(self.device_name) - - -def setup_vpr_arg_parser(): - parser = ArgumentParser(description="Parse flags") - - parser.add_argument( - '-d', - '--device', - nargs=1, - metavar='', - type=str, - help='Device type (e.g. artix7)', - default='artix7' - ) - - parser.add_argument( - '-e', - '--eblif', - nargs=1, - metavar='', - type=str, - help='EBLIF filename' - ) - - parser.add_argument( - '-p', - '--pcf', - nargs=1, - metavar='', - type=str, - help='PCF filename' - ) - - parser.add_argument( - '-P', - '--part', - nargs=1, - metavar='', - type=str, - help='Part name' - ) - - parser.add_argument( - '-s', - '--sdc', - nargs=1, - metavar='', - type=str, - help='SDC file' - ) - - parser.add_argument( - '-a', - '--vpr_options', - metavar='', - type=str, - help='Additional VPR options' - ) - - parser.add_argument( - 'additional_vpr_args', - nargs='*', - metavar='', - type=str, - help='Additional arguments for vpr command' - ) - - return parser - - -def vpr(vprargs: VprArgs): - """ - Execute `vpr` - """ - return run( - 'vpr', - vprargs.arch_def, - vprargs.eblif, - '--device', vprargs.device_name, - vprargs.vpr_options, - '--read_rr_graph', vprargs.rr_graph, - '--read_router_lookahead', vprargs.lookahead, - 'read_placement_delay_lookup', vprargs.place_delay, - *vprargs.optional - ) - - -def save_vpr_log(filename): - """ - Save VPR log. - """ - sh_mv('vpr_stdout.log', filename)