diff --git a/f4pga/platforms/ql-eos-s3.json b/f4pga/platforms/ql-eos-s3.json index 78deaf1..f55f5b4 100644 --- a/f4pga/platforms/ql-eos-s3.json +++ b/f4pga/platforms/ql-eos-s3.json @@ -464,7 +464,6 @@ "$F4PGA_INSTALL_DIR": "${shareDir}/../../../../", "$FPGA_FAM": "eos-s3", "$PATH": "${shareDir}/../../../conda/envs/eos-s3/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", - "$SHARE_DIR_PATH": "${shareDir}", "$BIN_DIR_PATH": "${binDir}" } } diff --git a/f4pga/setup.py b/f4pga/setup.py index 50a65cf..99dd82c 100644 --- a/f4pga/setup.py +++ b/f4pga/setup.py @@ -102,7 +102,6 @@ setuptools_setup( entry_points={ "console_scripts": [ "f4pga = f4pga.__init__:main", - f"{sf}_generate_constraints = {shwrappers}:generate_constraints", f"{sf}_pack = {shwrappers}:pack", f"{sf}_place = {shwrappers}:place", f"{sf}_route = {shwrappers}:route", @@ -121,7 +120,6 @@ setuptools_setup( f"{sf}_write_jlink = {shwrappers}:write_jlink", f"{sf}_write_openocd = {shwrappers}:write_openocd", f"ql_{sf} = {shwrappers}:ql", - f"vpr_common = {shwrappers}:vpr_common" ] ) }, diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index e0325b0..8ed200d 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -26,11 +26,15 @@ from shutil import which from subprocess import check_call +python3 = which('python3') + f4pga_environ = environ.copy() ROOT = Path(__file__).resolve().parent + FPGA_FAM = f4pga_environ.get('FPGA_FAM', 'xc7') isQuickLogic = FPGA_FAM == 'eos-s3' + SH_SUBDIR = 'quicklogic' if isQuickLogic else FPGA_FAM F4PGA_INSTALL_DIR = f4pga_environ.get('F4PGA_INSTALL_DIR') @@ -41,109 +45,513 @@ F4PGA_INSTALL_DIR_PATH = Path(F4PGA_INSTALL_DIR) f4pga_environ['F4PGA_SHARE_DIR'] = f4pga_environ.get('F4PGA_SHARE_DIR', str(F4PGA_INSTALL_DIR_PATH / FPGA_FAM / 'share/f4pga')) -def run_sh(script): +# Helper functions + + +def p_run_sh_script(script): stdout.flush() stderr.flush() check_call([str(script)]+sys_argv[1:], env=f4pga_environ) -def run_pym(module): +def p_run_bash_cmds(cmds): stdout.flush() stderr.flush() - check_call([which('python3'), '-m' , module]+sys_argv[1:], env=f4pga_environ) + check_call(cmds, env=f4pga_environ, shell=True, executable='/bin/bash') + + +def p_run_pym(module): + stdout.flush() + stderr.flush() + check_call([python3, '-m' , module]+sys_argv[1:], env=f4pga_environ) + + +def p_vpr_common_cmds(log_suffix = None): + return f""" +set -e +source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh {' '.join([f"'{arg}'" for arg in sys_argv[1:]])} +""" + (f""" +export OUT_NOISY_WARNINGS=noisy_warnings-${{DEVICE}}_{log_suffix}.log +""" if log_suffix is not None else '') + + +def p_args_str2list(args): + return [arg for arg in args.strip().split() if arg != ''] + + +def p_vpr_run(): + print("[F4PGA] Running (deprecated) vpr run") + + arg_arch_def = f4pga_environ.get('ARCH_DEF') + if arg_arch_def is None: + raise(Exception('[F4PGA] vpr run: envvar ARCH_DEF cannot be unset/empty!')) + + arg_eblif = f4pga_environ.get('EBLIF') + if arg_eblif is None: + raise(Exception('[F4PGA] vpr run: envvar EBLIF cannot be unset/empty!')) + + arg_vpr_options = f4pga_environ.get('VPR_OPTIONS') + if arg_vpr_options is None: + raise(Exception('[F4PGA] vpr run: envvar VPR_OPTIONS cannot be unset/empty!')) + + arg_device_name = f4pga_environ.get('DEVICE_NAME') + if arg_device_name is None: + raise(Exception('[F4PGA] vpr run: envvar DEVICE_NAME cannot be unset/empty!')) + + arg_rr_graph = f4pga_environ.get('RR_GRAPH') + if arg_rr_graph is None: + raise(Exception('[F4PGA] vpr run: envvar RR_GRAPH cannot be unset/empty!')) + + arg_lookahead = f4pga_environ.get('LOOKAHEAD') + if arg_lookahead is None: + raise(Exception('[F4PGA] vpr run: envvar LOOKAHEAD cannot be unset/empty!')) + + arg_place_delay = f4pga_environ.get('PLACE_DELAY') + if arg_place_delay is None: + raise(Exception('[F4PGA] vpr run: envvar PLACE_DELAY cannot be unset/empty!')) + + sdc = f4pga_environ.get('SDC') + if sdc == '': + sdc = None + + check_call( + [ + which('vpr'), + arg_arch_def, + arg_eblif + ] + p_args_str2list(arg_vpr_options) + [ + '--device', + arg_device_name, + '--read_rr_graph', + arg_rr_graph, + '--read_router_lookahead', + arg_lookahead, + '--read_placement_delay_lookup', + arg_place_delay + ] + ( + ['--sdc_file', sdc] if sdc is not None else [] + ) + sys_argv[1:], + env=f4pga_environ + ) + + +# Entrypoints def generate_constraints(): print("[F4PGA] Running (deprecated) generate constraints") - run_sh(ROOT / SH_SUBDIR / "generate_constraints.f4pga.sh") + if isQuickLogic: + (pcf, eblif, net, part, device, arch_def, corner) = sys_argv[1:8] + place_file_prefix = Path(eblif).stem + share_dir = Path(f4pga_environ['F4PGA_SHARE_DIR']) + scripts_dir = share_dir / 'scripts' + archs_dir = share_dir / 'arch' + p_run_bash_cmds(f""" +set -e + +if [[ '{device}' =~ ^(qlf_.*)$ ]]; then + + if [[ '{device}' =~ ^(qlf_k4n8_qlf_k4n8)$ ]];then + DEVICE_PATH='qlf_k4n8-qlf_k4n8_umc22_{corner}' + PINMAPXML="pinmap_qlf_k4n8_umc22.xml" + elif [[ '{device}' =~ ^(qlf_k6n10_qlf_k6n10)$ ]];then + DEVICE_PATH="qlf_k6n10-qlf_k6n10_gf12" + PINMAPXML="pinmap_qlf_k6n10_gf12.xml" + else + echo "ERROR: Unknown qlf device '{device}'" + exit -1 + fi + + '{python3}' '{scripts_dir}/qlf_k4n8_create_ioplace.py' \ + --pcf '{pcf}' \ + --blif '{eblif}' \ + --pinmap_xml '{archs_dir}'/"${{DEVICE_PATH}}_${{DEVICE_PATH}}/${{PINMAPXML}}" \ + --csv_file '{part}' \ + --net '{net}' \ + > '{place_file_prefix}_io.place' + +elif [[ '{device}' =~ ^(ql-.*)$ ]]; then + + if ! [[ '{part}' =~ ^(PU64|WR42|PD64|WD30)$ ]]; then + PINMAPCSV="pinmap_PD64.csv" + CLKMAPCSV="clkmap_PD64.csv" + else + PINMAPCSV='pinmap_{part}.csv' + CLKMAPCSV='clkmap_{part}.csv' + fi + + echo "PINMAP FILE : $PINMAPCSV" + echo "CLKMAP FILE : $CLKMAPCSV" + + DEVICE_PATH='{device}_wlcsp' + PINMAP='{archs_dir}'/"${{DEVICE_PATH}}/${{PINMAPCSV}}" + + '{python3}' '{scripts_dir}/pp3_create_ioplace.py' \ + --pcf '{pcf}' \ + --blif '{eblif}' \ + --map "$PINMAP" \ + --net '{net}' \ + > '{place_file_prefix}_io.place' + + '{python3}' '{scripts_dir}/pp3_create_place_constraints.py' \ + --blif '{eblif}' \ + --map '{archs_dir}'/"${{DEVICE_PATH}}/${{CLKMAPCSV}}" \ + -i '{place_file_prefix}_io.place' \ + > '{place_file_prefix}_constraints.place' + + # EOS-S3 IOMUX configuration + if [[ '{device}' =~ ^(ql-eos-s3)$ ]]; then +""" + '\n'.join([f""" + '{python3}' '{scripts_dir}/pp3_eos_s3_iomux_config.py' \ + --eblif '{eblif}' \ + --pcf '{pcf}' \ + --map "$PINMAP" \ + --output-format={fmt[0]} \ + > '{place_file_prefix}_iomux.{fmt[1]}' +""" for fmt in [['jlink', 'jlink'], ['openocd', 'openocd'], ['binary', 'bin']]]) + f""" + fi + +else + echo "FIXME: Unsupported device '{device}'" + exit -1 +fi +""") + else: + (eblif, net, part, device, arch_def) = sys_argv[1:6] + pcf_opts = f"'--pcf' '{sys_argv[6]}'" if len(sys_argv) > 6 else '' + ioplace_file = f'{Path(eblif).stem}.ioplace' + share_dir = f4pga_environ['F4PGA_SHARE_DIR'] + p_run_bash_cmds(f""" +set -e +python3 '{share_dir}/scripts/prjxray_create_ioplace.py' \ + --blif '{eblif}' \ + --net '{net}' {pcf_opts} \ + --map '{share_dir}/arch/{device}/{part}/pinmap.csv' \ + > '{ioplace_file}' +python3 '{share_dir}'/scripts/prjxray_create_place_constraints.py \ + --blif '{eblif}' \ + --net '{net}' \ + --arch '{arch_def}' \ + --part '{part}' \ + --vpr_grid_map '{share_dir}/arch/{device}/vpr_grid_map.csv' \ + --input '{ioplace_file}' \ + --db_root "${{DATABASE_DIR:-$(prjxray-config)}}" \ + > constraints.place +""") def pack(): print("[F4PGA] Running (deprecated) pack") - run_sh(ROOT / SH_SUBDIR / "pack.f4pga.sh") + extra_args = ['--write_block_usage', 'block_usage.json'] if isQuickLogic else [] + p_run_bash_cmds(p_vpr_common_cmds('pack')+f"python3 -m f4pga.wrappers.sh.vpr_run --pack {' '.join(extra_args)}") + Path('vpr_stdout.log').rename('pack.log') def place(): print("[F4PGA] Running (deprecated) place") - run_sh(ROOT / SH_SUBDIR / "place.f4pga.sh") + place_cmds = """ +if [ -z $NET ]; then echo "Please provide net file name"; exit 1; fi +""" + if isQuickLogic: + place_cmds += """ +if [ -z $PCF ]; then echo "Please provide pcf file name"; exit 1; fi +PROJECT=$(basename -- "$EBLIF") +PROJECT="${PROJECT%.*}" +VPR_PLACE_FILE="${PROJECT}_constraints.place" +if [ -s $PCF ]; then + echo "Generating constraints ..." + python3 -m f4pga.wrappers.sh.generate_constraints $PCF $EBLIF $NET $PART $DEVICE $ARCH_DEF $CORNER + if [ ! -f ${VPR_PLACE_FILE} ]; then VPR_PLACE_FILE="${PROJECT}_io.place"; fi +else + # Make a dummy empty constraint file + touch ${VPR_PLACE_FILE} +fi +""" + else: + place_cmds += """ +echo "Generating constrains ..." +python3 -m f4pga.wrappers.sh.generate_constraints $EBLIF $NET $PART $DEVICE $ARCH_DEF $PCF +VPR_PLACE_FILE='constraints.place' +""" + place_cmds += 'python3 -m f4pga.wrappers.sh.vpr_run --fix_clusters "${VPR_PLACE_FILE}" --place' + p_run_bash_cmds(p_vpr_common_cmds('place')+place_cmds) + Path('vpr_stdout.log').rename('place.log') def route(): print("[F4PGA] Running (deprecated) route") - run_sh(ROOT / SH_SUBDIR / "route.f4pga.sh") + extra_args = ['--write_timing_summary', 'timing_summary.json'] if isQuickLogic else [] + p_run_bash_cmds(p_vpr_common_cmds('pack')+f"python3 -m f4pga.wrappers.sh.vpr_run --route {' '.join(extra_args)}") + Path('vpr_stdout.log').rename('route.log') def synth(): print("[F4PGA] Running (deprecated) synth") - run_sh(ROOT / SH_SUBDIR / "synth.f4pga.sh") + p_run_sh_script(ROOT / SH_SUBDIR / "synth.f4pga.sh") + + +def write_fasm(genfasm_extra_args = None): + print("[F4PGA] Running (deprecated) write fasm") + p_run_bash_cmds(p_vpr_common_cmds('fasm')+f""" +'{which('genfasm')}' \ + ${{ARCH_DEF}} ${{EBLIF}} --device ${{DEVICE_NAME}} \ + ${{VPR_OPTIONS}} \ + --read_rr_graph ${{RR_GRAPH}} {' '.join(genfasm_extra_args) if genfasm_extra_args is not None else ''} +""" + """ +TOP="${EBLIF%.*}" +FASM_EXTRA="${TOP}_fasm_extra.fasm" +if [ -f $FASM_EXTRA ]; then + echo "writing final fasm (extra: $FASM_EXTRA)" + cat $FASM_EXTRA >> ${TOP}.fasm +fi +""") + Path('vpr_stdout.log').rename('fasm.log') + + +# Xilinx only def write_bitstream(): print("[F4PGA] Running (deprecated) write bitstream") - run_sh(ROOT / SH_SUBDIR / "write_bitstream.f4pga.sh") + p_run_bash_cmds(""" +set -e +echo "Writing bitstream ..." +FRM2BIT="" +if [ ! -z ${FRAMES2BIT} ]; then FRM2BIT="--frm2bit ${FRAMES2BIT}"; fi +""" + f""" +eval set -- $( + getopt \ + --options=d:f:b:p: \ + --longoptions=device:,fasm:,bit:,part: \ + --name $0 -- {' '.join(sys_argv[1:])} +) +""" + """ +DEVICE="" +FASM="" +BIT="" +PART=xc7a35tcpg236-1 +while true; do + case "$1" in + -d|--device) DEVICE=$2; shift 2; ;; + -p|--part) PART=$2; shift 2; ;; + -f|--fasm) FASM=$2; shift 2; ;; + -b|--bit) BIT=$2; shift 2; ;; + --) break ;; + esac +done +DATABASE_DIR=${DATABASE_DIR:-$(prjxray-config)} +if [ -z $DEVICE ]; then + # Try to find device name. Accept only when exactly one is found + PART_DIRS=(${DATABASE_DIR}/*/${PART}) + if [ ${#PART_DIRS[@]} -eq 1 ]; then + DEVICE=$(basename $(dirname "${PART_DIRS[0]}")) + else + echo "Please provide device name" + exit 1 + fi +fi +DBROOT=`realpath ${DATABASE_DIR}/${DEVICE}` +if [ -z $FASM ]; then echo "Please provide fasm file name"; exit 1; fi +if [ -z $BIT ]; then echo "Please provide bit file name"; exit 1; fi +xcfasm \ + --db-root ${DBROOT} \ + --part ${PART} \ + --part_file ${DBROOT}/${PART}/part.yaml \ + --sparse \ + --emit_pudc_b_pullup \ + --fn_in ${FASM} \ + --bit_out ${BIT} ${FRM2BIT} +""") -def write_fasm(): - print("[F4PGA] Running (deprecated) write fasm") - run_sh(ROOT / SH_SUBDIR / "write_fasm.f4pga.sh") - - -def write_xml_rr_graph(): - print("[F4PGA] Running (deprecated) write xlm rr graph") - run_sh(ROOT / SH_SUBDIR / "write_xml_rr_graph.f4pga.sh") - - -def vpr_common(): - print("[F4PGA] Running (deprecated) vpr common") - run_sh(ROOT / SH_SUBDIR / "vpr_common.f4pga.sh") +# QuickLogic only def analysis(): print("[F4PGA] Running (deprecated) analysis") - run_sh(ROOT / "quicklogic/analysis.f4pga.sh") + p_run_bash_cmds(p_vpr_common_cmds('analysis')+""" +python3 -m f4pga.wrappers.sh.vpr_run \ + --analysis \ + --gen_post_synthesis_netlist on \ + --gen_post_implementation_merged_netlist on \ + --post_synth_netlist_unconn_inputs nets \ + --post_synth_netlist_unconn_outputs nets \ + --verify_file_digests off +""") + Path('vpr_stdout.log').rename('analysis.log') def repack(): print("[F4PGA] Running (deprecated) repack") - run_sh(ROOT / "quicklogic/repack.f4pga.sh") + p_run_bash_cmds(p_vpr_common_cmds()+""" +DESIGN=${EBLIF/.eblif/} +[ ! -z "${JSON}" ] && JSON_ARGS="--json-constraints ${JSON}" || JSON_ARGS= +[ ! -z "${PCF_PATH}" ] && PCF_ARGS="--pcf-constraints ${PCF_PATH}" || PCF_ARGS= +""" + f""" +PYTHONPATH=$F4PGA_SHARE_DIR/scripts:$PYTHONPATH \ + '{python3}' "$F4PGA_SHARE_DIR"/scripts/repacker/repack.py \ + --vpr-arch ${{ARCH_DEF}} \ + --repacking-rules ${{ARCH_DIR}}/${{DEVICE_1}}.repacking_rules.json \ + $JSON_ARGS \ + $PCF_ARGS \ + --eblif-in ${{DESIGN}}.eblif \ + --net-in ${{DESIGN}}.net \ + --place-in ${{DESIGN}}.place \ + --eblif-out ${{DESIGN}}.repacked.eblif \ + --net-out ${{DESIGN}}.repacked.net \ + --place-out ${{DESIGN}}.repacked.place \ + --absorb_buffer_luts on \ + > repack.log 2>&1 +""") def generate_bitstream(): print("[F4PGA] Running (deprecated) generate_bitstream") - run_sh(ROOT / "quicklogic/generate_bitstream.f4pga.sh") + p_run_bash_cmds(f""" +set -e +eval set -- "$( + getopt \ + --options=d:f:r:b:P: \ + --longoptions=device:,fasm:,format:,bit:,part: \ + --name $0 -- {' '.join(sys_argv[1:])} +)" +""" + """ +DEVICE="" +FASM="" +BIT_FORMAT="4byte" +BIT="" +PART="" +while true; do + case "$1" in + -d|--device) DEVICE=$2; shift 2;; + -f|--fasm) FASM=$2; shift 2;; + -r|--format) BIT_FORMAT=$2; shift 2;; + -b|--bit) BIT=$2; shift 2;; + -P|--part) PART=$2; shift 2;; + --) break;; + esac +done +if [ -z $DEVICE ]; then echo "Please provide device name"; exit 1; fi +if [ -z $FASM ]; then echo "Please provide an input FASM file name"; exit 1; fi +if [ -z $BIT ]; then echo "Please provide an output bistream file name"; exit 1; fi +""" + f""" +if [[ "$DEVICE" =~ ^(qlf_k4n8.*)$ ]]; then + '{which('qlf_fasm')}' \ + --db-root "${{F4PGA_SHARE_DIR}}/fasm_database/${{DEVICE}}" \ + --format "$BIT_FORMAT" \ + --assemble \ + "$FASM" \ + "$BIT" +elif [[ "$DEVICE" =~ ^(ql-eos-s3|ql-pp3e)$ ]]; then + qlfasm \ + --dev-type \ + "$DEVICE" \ + "$FASM" \ + "$BIT" +else + echo "ERROR: Unsupported device '${{DEVICE}}' for bitstream generation" + exit -1 +fi +""") def generate_libfile(): print("[F4PGA] Running (deprecated) generate_libfile") - run_sh(ROOT / "quicklogic/generate_libfile.f4pga.sh") + (part, device, corner) = sys_argv[1:4] + p_run_bash_cmds(f""" +set -e +if [[ '{device}' =~ ^(qlf_k4n8_qlf_k4n8)$ ]];then + DEVICE_1="qlf_k4n8-qlf_k4n8_umc22_{corner}" + PINMAPXML="pinmap_qlf_k4n8_umc22.xml" + INTERFACEXML="interface-mapping_24x24.xml" + DEV="qlf_k4n8_umc22" +else + DEVICE_1={device} +fi +""" + """ +ARCH_DIR="${F4PGA_SHARE_DIR}/arch/${DEVICE_1}_${DEVICE_1}" +PINMAP_XML=${ARCH_DIR}/${PINMAPXML} +""" + f""" +'{python3}' "$F4PGA_SHARE_DIR"/scripts/create_lib.py \ + -n "${{DEV}}_0P72_SSM40" \ + -m fpga_top \ + -c '{part}' \ + -x "${{ARCH_DIR}}/lib/${{INTERFACEXML}}" \ + -l "${{DEV}}_0P72_SSM40.lib" \ + -t "${{ARCH_DIR}}/lib" +""") def ql(): print("[F4PGA] Running (deprecated) ql") - run_sh(ROOT / "quicklogic/ql.f4pga.sh") + p_run_sh_script(ROOT / "quicklogic/ql.f4pga.sh") def fasm2bels(): print("[F4PGA] Running (deprecated) fasm2bels") - run_sh(ROOT / "quicklogic/fasm2bels.f4pga.sh") + p_run_bash_cmds(f""" +set -e +eval set -- "$( + getopt \ + --options=d:P:p:b:v:o:q \ + --longoptions=device:,part:,pcf:,bit:,out-verilog:,out-pcf:,out-qcf:, \ + --name $0 -- {' '.join(sys_argv[1:])} +)" +""" + """ +DEVICE="" +PART="" +PCF="" +BIT="" +OUT_VERILOG="" +OUT_PCF="" +OUT_QCF="" +while true; do + case "$1" in + -d|--device) DEVICE=$2; shift 2 ;; + -P|--part) PART=$2; shift 2 ;; + -p|--pcf) PCF=$2; shift 2 ;; + -b|--bit) BIT=$2; shift 2 ;; + -v|--out-verilog) OUT_VERILOG=$2; shift 2 ;; + -o|--out-pcf) OUT_PCF=$2; shift 2 ;; + -q|--out-qcf) OUT_QCF=$2; shift 2 ;; + --) break ;; + esac +done +if [ -z $DEVICE ]; then echo "Please provide device name"; exit 1; fi +if [ -z $BIT ]; then echo "Please provide an input bistream file name"; exit 1; fi +# $DEVICE is not ql-eos-s3 or ql-pp3e +if ! [[ "$DEVICE" =~ ^(ql-eos-s3|ql-pp3e)$ ]]; then echo "ERROR: Unsupported device '${DEVICE}' for fasm2bels"; exit -1; fi +if [ -z "{PCF}" ]; then PCF_ARGS=""; else PCF_ARGS="--input-pcf ${PCF}"; fi +echo "Running fasm2bels" +""" + f""" +'{python3}' "${{F4PGA_SHARE_DIR}}"/scripts/fasm2bels.py "${{BIT}}" \ + --phy-db "${{F4PGA_SHARE_DIR}}/arch/${{DEVICE}}_wlcsp/db_phy.pickle" \ + --device-name "${{DEVICE/ql-/}}" \ + --package-name "$PART" \ + --input-type bitstream \ + --output-verilog "${{OUT_VERILOG:-$BIT.v}}" \ + ${{PCF_ARGS}} \ + --output-pcf "${{OUT_PCF:-$BIT.v.pcf}}" \ + --output-qcf "${{OUT_QCF:-$BIT.v.qcf}}" +""") def write_bitheader(): print("[F4PGA] Running (deprecated) write bitheader") print("Converting bitstream to C Header") - run_pym('quicklogic_fasm.bitstream_to_header') + p_run_pym('quicklogic_fasm.bitstream_to_header') def write_binary(): print("[F4PGA] Running (deprecated) write binary") print("Converting bitstream to flashable binary format") - run_pym('quicklogic_fasm.bitstream_to_binary') + p_run_pym('quicklogic_fasm.bitstream_to_binary') def write_jlink(): print("[F4PGA] Running (deprecated) write jlink") print("Converting bitstream to JLink script") - run_pym('quicklogic_fasm.bitstream_to_jlink') + p_run_pym('quicklogic_fasm.bitstream_to_jlink') def write_openocd(): print("[F4PGA] Running (deprecated) write openocd") print("Converting bitstream to OpenOCD script") - run_pym('quicklogic_fasm.bitstream_to_openocd') + p_run_pym('quicklogic_fasm.bitstream_to_openocd') diff --git a/f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh b/f4pga/wrappers/sh/generate_constraints.py old mode 100755 new mode 100644 similarity index 78% rename from f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh rename to f4pga/wrappers/sh/generate_constraints.py index 2cf9aae..58e6a90 --- a/f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh +++ b/f4pga/wrappers/sh/generate_constraints.py @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- # # Copyright (C) 2020-2022 F4PGA Authors. # @@ -16,11 +17,7 @@ # # SPDX-License-Identifier: Apache-2.0 -set -e +from f4pga.wrappers.sh import generate_constraints -source $(dirname "$0")/vpr_common.f4pga.sh -parse_args "$@" - -OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_place.log - -run_vpr_xml_rr_graph --pack +if __name__ == '__main__': + generate_constraints() diff --git a/f4pga/wrappers/sh/quicklogic/analysis.f4pga.sh b/f4pga/wrappers/sh/quicklogic/analysis.f4pga.sh deleted file mode 100755 index 81adca8..0000000 --- a/f4pga/wrappers/sh/quicklogic/analysis.f4pga.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -source $(dirname "$0")/vpr_common.f4pga.sh -parse_args $@ - -export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_analysis.log - -run_vpr \ - --analysis \ - --gen_post_synthesis_netlist on \ - --gen_post_implementation_merged_netlist on \ - --post_synth_netlist_unconn_inputs nets \ - --post_synth_netlist_unconn_outputs nets \ - --verify_file_digests off - -mv vpr_stdout.log analysis.log diff --git a/f4pga/wrappers/sh/quicklogic/fasm2bels.f4pga.sh b/f4pga/wrappers/sh/quicklogic/fasm2bels.f4pga.sh deleted file mode 100755 index 69c502c..0000000 --- a/f4pga/wrappers/sh/quicklogic/fasm2bels.f4pga.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} - -OPTS=d:P:p:b:v:o:q -LONGOPTS=device:,part:,pcf:,bit:,out-verilog:,out-pcf:,out-qcf:, - -PARSED_OPTS=`getopt --options=${OPTS} --longoptions=${LONGOPTS} --name $0 -- "$@"` -eval set -- "${PARSED_OPTS}" - -DEVICE="" -PART="" -PCF="" -BIT="" -OUT_VERILOG="" -OUT_PCF="" -OUT_QCF="" - -while true; do - case "$1" in - -d|--device) DEVICE=$2; shift 2 ;; - -P|--part) PART=$2; shift 2 ;; - -p|--pcf) PCF=$2; shift 2 ;; - -b|--bit) BIT=$2; shift 2 ;; - -v|--out-verilog) OUT_VERILOG=$2; shift 2 ;; - -o|--out-pcf) OUT_PCF=$2; shift 2 ;; - -q|--out-qcf) OUT_QCF=$2; shift 2 ;; - --) break ;; - esac -done - -if [ -z $DEVICE ]; then - echo "Please provide device name" - exit 1 -fi - -if [ -z $BIT ]; then - echo "Please provide an input bistream file name" - exit 1 -fi - -if ! [[ "$DEVICE" =~ ^(ql-eos-s3|ql-pp3e)$ ]]; then - echo "ERROR: Unsupported device '${DEVICE}' for fasm2bels" - exit -1 -fi - -# $DEVICE is not ql-eos-s3 or ql-pp3e -if ! [[ "$DEVICE" =~ ^(ql-eos-s3|ql-pp3e)$ ]]; then - echo "ERROR: Unsupported device '${DEVICE}' for fasm2bels" - exit -1 -fi - -if [ ! -z "{PCF}" ]; then - PCF_ARGS="--input-pcf ${PCF}" -else - PCF_ARGS="" -fi - -echo "Running fasm2bels" - -echo "Running fasm2bels" -`which python3` "`readlink -f ${SHARE_DIR_PATH}/scripts/fasm2bels.py`" "${BIT}" \ - --phy-db "`readlink -f ${SHARE_DIR_PATH}/arch/${DEVICE}_wlcsp/db_phy.pickle`" \ - --device-name "${DEVICE/ql-/}" \ - --package-name "$PART" \ - --input-type bitstream \ - --output-verilog "${OUT_VERILOG:-$BIT.v}" \ - ${PCF_ARGS} \ - --output-pcf "${OUT_PCF:-$BIT.v.pcf}" \ - --output-qcf "${OUT_QCF:-$BIT.v.qcf}" diff --git a/f4pga/wrappers/sh/quicklogic/generate_bitstream.f4pga.sh b/f4pga/wrappers/sh/quicklogic/generate_bitstream.f4pga.sh deleted file mode 100755 index da41954..0000000 --- a/f4pga/wrappers/sh/quicklogic/generate_bitstream.f4pga.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -OPTS=d:f:r:b:P: -LONGOPTS=device:,fasm:,format:,bit:,part: - -PARSED_OPTS=`getopt --options=${OPTS} --longoptions=${LONGOPTS} --name $0 -- "$@"` -eval set -- "${PARSED_OPTS}" - -DEVICE="" -FASM="" -BIT="" -BIT_FORMAT="4byte" -PART="" - -while true; do - case "$1" in - -d|--device) DEVICE=$2; shift 2;; - -f|--fasm) FASM=$2; shift 2;; - -r|--format) BIT_FORMAT=$2; shift 2;; - -b|--bit) BIT=$2; shift 2;; - -P|--part) PART=$2; shift 2;; - --) break;; - esac -done - -if [ -z $DEVICE ]; then - echo "Please provide device name" - exit 1 -fi - -if [ -z $FASM ]; then - echo "Please provide an input FASM file name" - exit 1 -fi - -if [ -z $BIT ]; then - echo "Please provide an output bistream file name" - exit 1 -fi - -if [[ "$DEVICE" =~ ^(qlf_k4n8.*)$ ]]; then - - `which qlf_fasm` \ - --db-root "${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"}/fasm_database/${DEVICE}" \ - --format "$BIT_FORMAT" \ - --assemble \ - "$FASM" \ - "$BIT" - -elif [[ "$DEVICE" =~ ^(ql-eos-s3|ql-pp3e)$ ]]; then - - qlfasm \ - --dev-type \ - "$DEVICE" \ - "$FASM" \ - "$BIT" - -else - - echo "ERROR: Unsupported device '${DEVICE}' for bitstream generation" - exit -1 - -fi diff --git a/f4pga/wrappers/sh/quicklogic/generate_constraints.f4pga.sh b/f4pga/wrappers/sh/quicklogic/generate_constraints.f4pga.sh deleted file mode 100755 index 90c6b62..0000000 --- a/f4pga/wrappers/sh/quicklogic/generate_constraints.f4pga.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -PCF=$1 -EBLIF=$2 -NET=$3 -PART=$4 -DEVICE=$5 -ARCH_DEF=$6 -CORNER=$7 - -PROJECT=$(basename -- "$EBLIF") -IOPLACE_FILE="${PROJECT%.*}_io.place" - -SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} - -PYTHON3=$(which python3) - -if [[ "$DEVICE" =~ ^(qlf_.*)$ ]]; then - - if [[ "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]];then - DEVICE_PATH="qlf_k4n8-qlf_k4n8_umc22_$CORNER" - PINMAPXML="pinmap_qlf_k4n8_umc22.xml" - elif [[ "$DEVICE" =~ ^(qlf_k6n10_qlf_k6n10)$ ]];then - DEVICE_PATH="qlf_k6n10-qlf_k6n10_gf12" - PINMAPXML="pinmap_qlf_k6n10_gf12.xml" - else - echo "ERROR: Unknown qlf device '${DEVICE}'" - exit -1 - fi - - "${PYTHON3}" "`realpath ${SHARE_DIR_PATH}/scripts/qlf_k4n8_create_ioplace.py`" \ - --pcf "$PCF" \ - --blif "$EBLIF" \ - --pinmap_xml "`realpath ${SHARE_DIR_PATH}/arch/${DEVICE_PATH}_${DEVICE_PATH}/${PINMAPXML}`" \ - --csv_file "$PART" \ - --net "$NET" \ - > "${IOPLACE_FILE}" - -elif [[ "$DEVICE" =~ ^(ql-.*)$ ]]; then - - if ! [[ "$PART" =~ ^(PU64|WR42|PD64|WD30)$ ]]; then - PINMAPCSV="pinmap_PD64.csv" - CLKMAPCSV="clkmap_PD64.csv" - else - PINMAPCSV="pinmap_${PART}.csv" - CLKMAPCSV="clkmap_${PART}.csv" - fi - - echo "PINMAP FILE : $PINMAPCSV" - echo "CLKMAP FILE : $CLKMAPCSV" - - DEVICE_PATH="${DEVICE}_wlcsp" - PINMAP=`realpath ${SHARE_DIR_PATH}/arch/${DEVICE_PATH}/${PINMAPCSV}` - - "${PYTHON3}" `realpath ${SHARE_DIR_PATH}/scripts/pp3_create_ioplace.py` \ - --pcf "$PCF" \ - --blif "$EBLIF" \ - --map "$PINMAP" \ - --net "$NET" \ - > ${IOPLACE_FILE} - - "${PYTHON3}" `realpath ${SHARE_DIR_PATH}/scripts/pp3_create_place_constraints.py` \ - --blif "$EBLIF" \ - --map "`realpath ${SHARE_DIR_PATH}/arch/${DEVICE_PATH}/${CLKMAPCSV}`" \ - -i "$IOPLACE_FILE" \ - > "${PROJECT%.*}_constraints.place" - - # EOS-S3 IOMUX configuration - if [[ "$DEVICE" =~ ^(ql-eos-s3)$ ]]; then - IOMUXGEN=`realpath ${SHARE_DIR_PATH}/scripts/pp3_eos_s3_iomux_config.py` - "${PYTHON3}" "${IOMUXGEN}" --eblif "$EBLIF" --pcf "$PCF" --map "$PINMAP" --output-format=jlink > "${PROJECT%.*}_iomux.jlink" - "${PYTHON3}" "${IOMUXGEN}" --eblif "$EBLIF" --pcf "$PCF" --map "$PINMAP" --output-format=openocd > "${PROJECT%.*}_iomux.openocd" - "${PYTHON3}" "${IOMUXGEN}" --eblif "$EBLIF" --pcf "$PCF" --map "$PINMAP" --output-format=binary > "${PROJECT%.*}_iomux.bin" - fi - -else - - echo "FIXME: Unsupported device '${DEVICE}'" - exit -1 - -fi diff --git a/f4pga/wrappers/sh/quicklogic/generate_libfile.f4pga.sh b/f4pga/wrappers/sh/quicklogic/generate_libfile.f4pga.sh deleted file mode 100755 index 865cc60..0000000 --- a/f4pga/wrappers/sh/quicklogic/generate_libfile.f4pga.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -PART=$1 -DEVICE=$2 -CORNER=$3 - -if [[ "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]];then - DEVICE_1="qlf_k4n8-qlf_k4n8_umc22_$CORNER" - PINMAPXML="pinmap_qlf_k4n8_umc22.xml" - INTERFACEXML="interface-mapping_24x24.xml" - DEV="qlf_k4n8_umc22" -else - DEVICE_1=${DEVICE} -fi - -ARCH_DIR="$F4PGA_SHARE_DIR"/arch/${DEVICE_1}_${DEVICE_1} -PINMAP_XML=${ARCH_DIR}/${PINMAPXML} - -`which python3` "$F4PGA_SHARE_DIR"/scripts/create_lib.py \ - -n "${DEV}_0P72_SSM40" \ - -m fpga_top \ - -c "$PART" \ - -x "${ARCH_DIR}/lib/${INTERFACEXML}" \ - -l "${DEV}_0P72_SSM40.lib" \ - -t "${ARCH_DIR}/lib" diff --git a/f4pga/wrappers/sh/quicklogic/pack.f4pga.sh b/f4pga/wrappers/sh/quicklogic/pack.f4pga.sh deleted file mode 100755 index 705a5ce..0000000 --- a/f4pga/wrappers/sh/quicklogic/pack.f4pga.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -source $(dirname "$0")/vpr_common.f4pga.sh -parse_args $@ - -export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_pack.log - -run_vpr \ - --pack \ - --write_block_usage \ - block_usage.json - -mv vpr_stdout.log pack.log diff --git a/f4pga/wrappers/sh/quicklogic/place.f4pga.sh b/f4pga/wrappers/sh/quicklogic/place.f4pga.sh deleted file mode 100755 index f136d43..0000000 --- a/f4pga/wrappers/sh/quicklogic/place.f4pga.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -source $(dirname "$0")/vpr_common.f4pga.sh -parse_args $@ - -if [ -z $PCF ]; then - echo "Please provide pcf file name" - exit 1 -fi - -if [ -z $NET ]; then - echo "Please provide net file name" - exit 1 -fi - -OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_place.log -PROJECT=$(basename -- "$EBLIF") -PLACE_FILE="${PROJECT%.*}_constraints.place" - -if [ -s $PCF ]; then - # Generate IO constraints - echo "Generating constraints ..." - symbiflow_generate_constraints $PCF $EBLIF $NET $PART $DEVICE $ARCH_DEF $CORNER - if [ -f ${PLACE_FILE} ]; then - VPR_PLACE_FILE=${PLACE_FILE} - else - VPR_PLACE_FILE="${PROJECT%.*}_io.place" - fi -else - # Make a dummy empty constraint file - touch ${PLACE_FILE} - VPR_PLACE_FILE=${PLACE_FILE} -fi - -run_vpr --fix_clusters ${VPR_PLACE_FILE} --place - -mv vpr_stdout.log place.log diff --git a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh index d008f31..cbbcb8b 100755 --- a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh @@ -18,10 +18,6 @@ set -e -SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} - -source $(dirname "$0")/vpr_common.f4pga.sh - VERSION="v2.0.1" if [ ! -n $1 ]; then @@ -88,62 +84,25 @@ for arg in $@; do -h|--help) exit 0 ;; *) case $OPT in - src) - SOURCE=$arg - OPT="" - ;; - top) - TOP=$arg - OPT="" - ;; - vlog) - VERILOG_FILES+="$arg " - ;; - dev) - DEVICE=$arg - OPT="" - ;; - pcf) - PCF=$arg - OPT="" - ;; - part) - PART=$arg - OPT="" - ;; - json) - JSON=$arg - OPT="" - ;; - sdc) - SDC=$arg - OPT="" - ;; + src) SOURCE=$arg; OPT="" ;; + top) TOP=$arg; OPT="" ;; + dev) DEVICE=$arg; OPT="" ;; + pcf) PCF=$arg; OPT="" ;; + part) PART=$arg; OPT="" ;; + json) JSON=$arg; OPT="" ;; + sdc) SDC=$arg; OPT="" ;; + pnr_corner) PNR_CORNER=$arg; OPT="" ;; + analysis_corner) ANALYSIS_CORNER=$arg; OPT="" ;; + build_dir) BUILDDIR=$arg OPT="" ;; route) ROUTE_FLAG0="$arg" ROUTE_FLAG0="${ROUTE_FLAG0,,}" OPT="" ;; - pnr_corner) - PNR_CORNER=$arg - OPT="" - ;; - analysis_corner) - ANALYSIS_CORNER=$arg - OPT="" - ;; - dump) - OUT+="$arg " - ;; - compile_xtra) - ;; - options_file) - COMPILE_EXTRA_ARGS+=("-f \"`realpath $arg`\" ") - ;; - build_dir) - BUILDDIR=$arg - OPT="" - ;; + vlog) VERILOG_FILES+="$arg " ;; + dump) OUT+="$arg " ;; + compile_xtra) ;; + options_file) COMPILE_EXTRA_ARGS+=("-f \"`realpath $arg`\" ") ;; *) echo "Refer help for more details: ql_symbiflow -h " exit 1 @@ -157,69 +116,45 @@ for arg in $@; do done case ${DEVICE} in - qlf_k4n8) - DEVICE="${DEVICE}_${DEVICE}" - FAMILY="qlf_k4n8" - DEVICE_CHECK="VALID" - USE_PINMAP=1 - ;; - qlf_k6n10) - DEVICE="${DEVICE}_${DEVICE}" - FAMILY="qlf_k6n10" - DEVICE_CHECK="VALID" - USE_PINMAP=1 - ;; - ql-eos-s3) - DEVICE="${DEVICE}" - FAMILY="pp3" - DEVICE_CHECK="VALID" - USE_PINMAP=0 - ;; - *) - echo "Unsupported device '${DEVICE}'" - exit 1 - ;; + qlf_k4n8) DEVICE="${DEVICE}_${DEVICE}"; FAMILY="qlf_k4n8"; DEVICE_CHECK="VALID"; USE_PINMAP=1 ;; + qlf_k6n10) DEVICE="${DEVICE}_${DEVICE}"; FAMILY="qlf_k6n10"; DEVICE_CHECK="VALID"; USE_PINMAP=1 ;; + ql-eos-s3) DEVICE="${DEVICE}"; FAMILY="pp3"; DEVICE_CHECK="VALID"; USE_PINMAP=0 ;; + *) echo "Unsupported device '${DEVICE}'"; exit 1 ;; esac -## Check if the source directory exists if [[ $1 == "-h" || $1 == "--help" ]];then exit 1 -else - if [ -z "$SOURCE" ];then - SOURCE=$PWD - elif [ $SOURCE == "." ];then - SOURCE=$PWD - elif [ ! -d "$SOURCE" ];then - echo "Directory path $SOURCE DOES NOT exists. Please add absolute path" - exit 1 - fi - - if [[ $1 == "-h" || $1 == "--help" ]];then - exit 0 - else - if [ -f $SOURCE/v_list_tmp ];then - rm -f $SOURCE/v_list_tmp - fi - if [ "$VERILOG_FILES" == "*.v" ];then - VERILOG_FILES=`cd ${SOURCE};ls *.v` - fi - echo "$VERILOG_FILES" >${SOURCE}/v_list - fi - - ## Validate the verlog source files - if [ ${#VERILOG_FILES[@]} -eq 0 ]; then - if [[ $1 != "-h" || $1 != "--help" ]];then - echo "Please provide at least one Verilog file" - exit 1 - fi - else - echo "verilog files: $VERILOG_FILES" - echo $VERILOG_FILES >${SOURCE}/v_list - sed '/^$/d' $SOURCE/v_list > $SOURCE/f_list_temp - VERILOG_FILES=`cat $SOURCE/f_list_temp` - fi fi +## Check if the source directory exists +SOURCE=${SOURCE:-$PWD} +if [ $SOURCE == "." ];then + SOURCE=$PWD +elif [ ! -d "$SOURCE" ];then + echo "Directory path $SOURCE DOES NOT exists. Please add absolute path" + exit 1 +fi + +if [ -f $SOURCE/v_list_tmp ];then + rm -f $SOURCE/v_list_tmp +fi +if [ "$VERILOG_FILES" == "*.v" ];then + VERILOG_FILES=`cd ${SOURCE};ls *.v` +fi +echo "$VERILOG_FILES" >${SOURCE}/v_list + +## Validate the verlog source files +if [ ${#VERILOG_FILES[@]} -eq 0 ]; then + echo "Please provide at least one Verilog file" + exit 1 +fi + +echo "verilog files: $VERILOG_FILES" +echo $VERILOG_FILES >${SOURCE}/v_list +sed '/^$/d' $SOURCE/v_list > $SOURCE/f_list_temp +VERILOG_FILES=`cat $SOURCE/f_list_temp` + + if [[ $1 == "-compile" || $1 == "-post_verilog" ]]; then if [ -z "$DEVICE" ]; then echo "DEVICE name is missing. Refer -h/--help" @@ -255,10 +190,8 @@ if [[ $1 == "-compile" || $1 == "-post_verilog" ]]; then fi fi -if [ ! -z "$SOURCE" ]; then - if [ ! -d $SOURCE/$BUILDDIR ]; then - mkdir -p $SOURCE/$BUILDDIR - fi +if [ ! -z "$SOURCE" ] && [ ! -d $SOURCE/$BUILDDIR ]; then + mkdir -p $SOURCE/$BUILDDIR fi if [ ! -z "$OUT" ]; then @@ -344,9 +277,9 @@ elif [[ -f $PCF ]];then fi if [[ $USE_PINMAP -ne 0 ]]; then - export PART=${CSV_PATH} + export PART=${CSV_PATH} else - export PART=${PART} + export PART=${PART} fi export JSON=${JSON_PATH} export PCF_PATH=${PCF_PATH} @@ -361,7 +294,7 @@ else PCF_MAKE="\${current_dir}/${BUILDDIR}/${TOP}_dummy.pcf" fi -PROCESS_SDC=$(realpath "$F4PGA_SHARE_DIR"/scripts/process_sdc_constraints.py) +PROCESS_SDC="$F4PGA_SHARE_DIR"/scripts/process_sdc_constraints.py if ! [ -z "$SDC" ]; then if ! [ -f "$SOURCE"/$SDC ];then echo "The sdc file: $SDC is missing at: $SOURCE" diff --git a/f4pga/wrappers/sh/quicklogic/repack.f4pga.sh b/f4pga/wrappers/sh/quicklogic/repack.f4pga.sh deleted file mode 100755 index 29a16c4..0000000 --- a/f4pga/wrappers/sh/quicklogic/repack.f4pga.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -source $(dirname "$0")/vpr_common.f4pga.sh -parse_args $@ - -DESIGN=${EBLIF/.eblif/} - -[ ! -z "${JSON}" ] && JSON_ARGS="--json-constraints ${JSON}" || JSON_ARGS= -[ ! -z "${PCF_PATH}" ] && PCF_ARGS="--pcf-constraints ${PCF_PATH}" || PCF_ARGS= - -export PYTHONPATH=$F4PGA_SHARE_DIR/scripts:$PYTHONPATH - -`which python3` "$F4PGA_SHARE_DIR"/scripts/repacker/repack.py \ - --vpr-arch ${ARCH_DEF} \ - --repacking-rules ${ARCH_DIR}/${DEVICE_1}.repacking_rules.json \ - $JSON_ARGS \ - $PCF_ARGS \ - --eblif-in ${DESIGN}.eblif \ - --net-in ${DESIGN}.net \ - --place-in ${DESIGN}.place \ - --eblif-out ${DESIGN}.repacked.eblif \ - --net-out ${DESIGN}.repacked.net \ - --place-out ${DESIGN}.repacked.place \ - --absorb_buffer_luts on \ - >repack.log 2>&1 diff --git a/f4pga/wrappers/sh/quicklogic/route.f4pga.sh b/f4pga/wrappers/sh/quicklogic/route.f4pga.sh deleted file mode 100755 index 6e832e7..0000000 --- a/f4pga/wrappers/sh/quicklogic/route.f4pga.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -source $(dirname "$0")/vpr_common.f4pga.sh -parse_args $@ - -export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_pack.log - -run_vpr --route --write_timing_summary timing_summary.json - -mv vpr_stdout.log route.log diff --git a/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh b/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh index b872413..575ac32 100755 --- a/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh @@ -18,9 +18,8 @@ set -e -export SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} -SPLIT_INOUTS=`realpath ${SHARE_DIR_PATH}/scripts/split_inouts.py` -CONVERT_OPTS=`realpath ${SHARE_DIR_PATH}/scripts/convert_compile_opts.py` +SPLIT_INOUTS="${F4PGA_SHARE_DIR}"/scripts/split_inouts.py +CONVERT_OPTS="${F4PGA_SHARE_DIR}"/scripts/convert_compile_opts.py print_usage () { echo "Usage: symbiflow_synth -v|--verilog " @@ -122,10 +121,10 @@ fi PINMAPCSV="pinmap_${PART}.csv" -export TECHMAP_PATH="${SHARE_DIR_PATH}/techmaps/${FAMILY}" +export TECHMAP_PATH="${F4PGA_SHARE_DIR}/techmaps/${FAMILY}" -SYNTH_TCL_PATH="${SHARE_DIR_PATH}/scripts/${FAMILY}/synth.tcl" -CONV_TCL_PATH="${SHARE_DIR_PATH}/scripts/${FAMILY}/conv.tcl" +SYNTH_TCL_PATH="${F4PGA_SHARE_DIR}/scripts/${FAMILY}/synth.tcl" +CONV_TCL_PATH="${F4PGA_SHARE_DIR}/scripts/${FAMILY}/conv.tcl" export USE_ROI="FALSE" export OUT_JSON=$TOP.json @@ -134,7 +133,7 @@ export OUT_SYNTH_V=${TOP}_synth.v export OUT_EBLIF=${TOP}.eblif export OUT_FASM_EXTRA=${TOP}_fasm_extra.fasm export PYTHON3=$(which python3) -export UTILS_PATH=${SHARE_DIR_PATH}/scripts +export UTILS_PATH="${F4PGA_SHARE_DIR}"/scripts if [ -s $PCF ]; then export PCF_FILE=$PCF @@ -142,7 +141,7 @@ else export PCF_FILE="" fi -DEVICE_PATH="${SHARE_DIR_PATH}/arch/${DEVICE}_${DEVICE}" +DEVICE_PATH="${F4PGA_SHARE_DIR}/arch/${DEVICE}_${DEVICE}" export PINMAP_FILE=${DEVICE_PATH}/${PINMAPCSV} if [ -d "${DEVICE_PATH}/cells" ]; then export DEVICE_CELLS_SIM=`find ${DEVICE_PATH}/cells -name "*_sim.v"` @@ -151,7 +150,7 @@ else # pp3 family has different directory naming scheme # the are named as ${DEVICE}_${PACKAGE} # ${PACKAGE} is not known because it is not passed down in add_binary_toolchain_test - DEVICE_PATH=$(find $(realpath ${SHARE_DIR_PATH}/arch/) -type d -name "${DEVICE}*") + DEVICE_PATH=$(find "${F4PGA_SHARE_DIR}"/arch/ -type d -name "${DEVICE}*") export PINMAP_FILE=${DEVICE_PATH}/${PINMAPCSV} if [ -d "${DEVICE_PATH}/cells" ]; then export DEVICE_CELLS_SIM=`find ${DEVICE_PATH}/cells -name "*_sim.v"` diff --git a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh index f9b87c0..4e06f2d 100755 --- a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh @@ -16,7 +16,50 @@ # # SPDX-License-Identifier: Apache-2.0 -SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} +eval set -- $( + getopt \ + --options=d:f:e:p:n:P:j:s:t:c: \ + --longoptions=device:,eblif:,pcf:,net:,part:,json:,sdc:,top:,corner: \ + --name $0 -- $@ +) +DEVICE="" +FAMILY="" +EBLIF="" +PCF="" +NET="" +PART="" +JSON="" +SDC="" +TOP="top" +CORNER="" +while true; do + case "$1" in + -d|--device) DEVICE=$2; shift 2 ;; + -f|--family) FAMILY=$2; shift 2 ;; + -e|--eblif) EBLIF=$2; shift 2 ;; + -p|--pcf) PCF=$2; shift 2 ;; + -n|--net) NET=$2; shift 2 ;; + -P|--part) PART=$2; shift 2 ;; + -j|--json) JSON=$2; shift 2 ;; + -s|--sdc) SDC=$2; shift 2 ;; + -t|--top) TOP=$2; shift 2 ;; + -c|--corner) CORNER=$2; shift 2 ;; + --) break ;; + esac +done +if [ -z $DEVICE ]; then echo "Please provide device name"; exit 1; fi +if [ -z $FAMILY ]; then echo "Please provide device family name"; exit 1; fi +if [ -z $EBLIF ]; then echo "Please provide blif file name"; exit 1; fi + +export DEVICE="$DEVICE" +export FAMILY="$FAMILY" +export EBLIF="$EBLIF" +export PCF="$PCF" +export NET="$NET" +export JSON="$JSON" +export SDC="$SDC" +export TOP="$TOP" +export CORNER="$CORNER" if [ -z $VPR_OPTIONS ]; then echo "Using default VPR options." @@ -28,151 +71,56 @@ if [ -z $VPR_OPTIONS ]; then " fi -function parse_args { +VPR_OPTIONS="$VPR_OPTIONS + --place_delay_model delta_override + --router_lookahead extended_map + --allow_dangling_combinational_nodes on" - OPTS=d:f:e:p:n:P:j:s:t:c: - LONGOPTS=device:,eblif:,pcf:,net:,part:,json:,sdc:,top:,corner: +if [[ "$DEVICE" == "qlf_k4n8_qlf_k4n8" ]]; then + VPR_OPTIONS="$VPR_OPTIONS + --route_chan_width 10 + --clock_modeling ideal + --place_delta_delay_matrix_calculation_method dijkstra + --absorb_buffer_luts off" +else + VPR_OPTIONS="$VPR_OPTIONS + --route_chan_width 100 + --clock_modeling route + --check_route quick + --strict_checks off + --disable_errors check_unbuffered_edges:check_route + --congested_routing_iteration_threshold 0.8 + --incremental_reroute_delay_ripup off + --base_cost_type delay_normalized_length_bounded + --bb_factor 10 + --initial_pres_fac 4.0 + --check_rr_graph off + --pack_high_fanout_threshold PB-LOGIC:18 + --suppress_warnings ${OUT_NOISY_WARNINGS},sum_pin_class:check_unbuffered_edges:load_rr_indexed_data_T_values:check_rr_node:trans_per_R:check_route:set_rr_graph_tool_comment" +fi - PARSED_OPTS=`getopt --options=${OPTS} --longoptions=${LONGOPTS} --name $0 -- $@` - eval set -- ${PARSED_OPTS} +export VPR_OPTIONS="$VPR_OPTIONS" - DEVICE="" - FAMILY="" - DEVICE_NAME="" - PART="" - EBLIF="" - PCF="" - NET="" - SDC="" - JSON="" - TOP="top" - CORNER="" +if [[ "$DEVICE" == "qlf_k4n8_qlf_k4n8" ]]; then + DEVICE_1="qlf_k4n8-qlf_k4n8_umc22_${CORNER}" + DEVICE_2="$DEVICE_1" +elif [[ "$DEVICE" == "qlf_k6n10_qlf_k6n10" ]];then + DEVICE_1="qlf_k6n10-qlf_k6n10_gf12" + DEVICE_2="$DEVICE_1" +else + DEVICE_1="$DEVICE" + DEVICE_2="wlcsp" +fi - while true; do - case "$1" in - -d|--device) DEVICE=$2; shift 2 ;; - -f|--family) FAMILY=$2; shift 2 ;; - -e|--eblif) EBLIF=$2; shift 2 ;; - -p|--pcf) PCF=$2; shift 2 ;; - -n|--net) NET=$2; shift 2 ;; - -P|--part) PART=$2; shift 2 ;; - -j|--json) JSON=$2; shift 2 ;; - -s|--sdc) SDC=$2; shift 2 ;; - -t|--top) TOP=$2; shift 2 ;; - -c|--corner) CORNER=$2; shift 2 ;; - --) break ;; - esac - done - - if [ -z $DEVICE ]; then - echo "Please provide device name" - exit 1 - fi - - if [ -z $FAMILY ]; then - echo "Please provide device family name" - exit 1 - fi - - if [ -z $EBLIF ]; then - echo "Please provide blif file name" - exit 1 - fi - - export DEVICE=$DEVICE - export FAMILY=$FAMILY - export EBLIF=$EBLIF - export PCF=$PCF - export NET=$NET - export SDC=$SDC - export JSON=$JSON - export CORNER=$CORNER - if [[ "$DEVICE" == "qlf_k4n8_qlf_k4n8" ]]; then - DEVICE_1="qlf_k4n8-qlf_k4n8_umc22_${CORNER}" - DEVICE_2=${DEVICE_1} - elif [[ "$DEVICE" == "qlf_k6n10_qlf_k6n10" ]];then - DEVICE_1="qlf_k6n10-qlf_k6n10_gf12" - DEVICE_2=${DEVICE_1} - else - DEVICE_1=${DEVICE} - DEVICE_2="wlcsp" - fi - export TOP=$TOP - - export ARCH_DIR=`realpath ${SHARE_DIR_PATH}/arch/${DEVICE_1}_${DEVICE_2}` - export ARCH_DEF=${ARCH_DIR}/arch_${DEVICE_1}_${DEVICE_2}.xml - - # qlf* devices use different naming scheme than pp3* ones. - export RR_GRAPH=${ARCH_DIR}/${DEVICE_1}.rr_graph.bin - if [ ! -f ${RR_GRAPH} ]; then - export RR_GRAPH=${ARCH_DIR}/rr_graph_${DEVICE_1}_${DEVICE_2}.rr_graph.real.bin - fi - - export PLACE_DELAY=${ARCH_DIR}/rr_graph_${DEVICE_1}_${DEVICE_2}.place_delay.bin - export ROUTE_DELAY=${ARCH_DIR}/rr_graph_${DEVICE_1}_${DEVICE_2}.lookahead.bin - - export DEVICE_NAME=${DEVICE_1} - - if [[ "$DEVICE" == "qlf_k4n8_qlf_k4n8" ]]; then - VPR_OPTIONS="$VPR_OPTIONS - --route_chan_width 10 - --clock_modeling ideal - --place_delta_delay_matrix_calculation_method dijkstra - --place_delay_model delta_override - --router_lookahead extended_map - --allow_dangling_combinational_nodes on - --absorb_buffer_luts off" - else - VPR_OPTIONS="$VPR_OPTIONS - --route_chan_width 100 - --clock_modeling route - --place_delay_model delta_override - --router_lookahead extended_map - --check_route quick - --strict_checks off - --allow_dangling_combinational_nodes on - --disable_errors check_unbuffered_edges:check_route - --congested_routing_iteration_threshold 0.8 - --incremental_reroute_delay_ripup off - --base_cost_type delay_normalized_length_bounded - --bb_factor 10 - --initial_pres_fac 4.0 - --check_rr_graph off - --pack_high_fanout_threshold PB-LOGIC:18 - --suppress_warnings ${OUT_NOISY_WARNINGS},sum_pin_class:check_unbuffered_edges:load_rr_indexed_data_T_values:check_rr_node:trans_per_R:check_route:set_rr_graph_tool_comment" - fi -} - -function run_vpr { - set -e - - SDC_OPTIONS="" - if [ ! -z $SDC ]; then - SDC_OPTIONS="--sdc_file $SDC" - fi - - "`which vpr`" ${ARCH_DEF} \ - ${EBLIF} \ - --read_rr_graph ${RR_GRAPH} \ - --device ${DEVICE_NAME} \ - ${VPR_OPTIONS} \ - --read_router_lookahead ${ROUTE_DELAY} \ - --read_placement_delay_lookup ${PLACE_DELAY} \ - ${SDC_OPTIONS} \ - $@ - - return $? -} - -function run_genfasm { - set -e - - "`which genfasm`" ${ARCH_DEF} \ - ${EBLIF} \ - --device ${DEVICE_NAME} \ - ${VPR_OPTIONS} \ - --read_rr_graph ${RR_GRAPH} \ - $@ - - return $? -} +DEVICE_ARCH="${DEVICE_1}_${DEVICE_2}" +export ARCH_DIR="${F4PGA_SHARE_DIR}/arch/${DEVICE_ARCH}" +export ARCH_DEF="${ARCH_DIR}/arch_${DEVICE_ARCH}".xml +ARCH_RR_PREFIX="${ARCH_DIR}/rr_graph_${DEVICE_ARCH}" +# qlf* devices use different naming scheme than pp3* ones. +export RR_GRAPH="${ARCH_DIR}/${DEVICE_1}".rr_graph.bin +if [ ! -f "${RR_GRAPH}" ]; then + export RR_GRAPH="${ARCH_RR_PREFIX}".rr_graph.real.bin +fi +export PLACE_DELAY="${ARCH_RR_PREFIX}".place_delay.bin +export LOOKAHEAD="${ARCH_RR_PREFIX}".lookahead.bin +export DEVICE_NAME="$DEVICE_1" diff --git a/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh deleted file mode 100755 index b7a503f..0000000 --- a/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -source $(dirname "$0")/vpr_common.f4pga.sh -parse_args "$@" - -TOP="${EBLIF%.*}" -FASM_EXTRA="${TOP}_fasm_extra.fasm" - -export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_fasm.log - -run_genfasm - -echo "FASM extra: $FASM_EXTRA" -if [ -f $FASM_EXTRA ]; then - echo "writing final fasm" - cat ${TOP}.fasm $FASM_EXTRA > tmp.fasm - mv tmp.fasm ${TOP}.fasm -fi - -mv vpr_stdout.log fasm.log diff --git a/f4pga/wrappers/sh/xc7/pack.f4pga.sh b/f4pga/wrappers/sh/vpr_run.py old mode 100755 new mode 100644 similarity index 76% rename from f4pga/wrappers/sh/xc7/pack.f4pga.sh rename to f4pga/wrappers/sh/vpr_run.py index 48d0ecb..0d325a8 --- a/f4pga/wrappers/sh/xc7/pack.f4pga.sh +++ b/f4pga/wrappers/sh/vpr_run.py @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- # # Copyright (C) 2020-2022 F4PGA Authors. # @@ -16,12 +17,7 @@ # # SPDX-License-Identifier: Apache-2.0 -set -e +from f4pga.wrappers.sh import p_vpr_run -source $(dirname "$0")/vpr_common.f4pga.sh -parse_args "$@" - -export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_pack.log - -run_vpr --pack -mv vpr_stdout.log pack.log +if __name__ == '__main__': + p_vpr_run() diff --git a/f4pga/wrappers/sh/xc7/generate_constraints.f4pga.sh b/f4pga/wrappers/sh/xc7/generate_constraints.f4pga.sh deleted file mode 100755 index 2bbd2f8..0000000 --- a/f4pga/wrappers/sh/xc7/generate_constraints.f4pga.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -EBLIF=$1 -NET=$2 -PART=$3 -DEVICE=$4 -ARCH_DEF=$5 -PCF=$6 - -if [ ! -z $PCF ]; then - PCF_OPTS="--pcf $PCF" -fi - -SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} - -PROJECT=$(basename -- "$EBLIF") -IOPLACE_FILE="${PROJECT%.*}.ioplace" - -python3 ${SHARE_DIR_PATH}/scripts/prjxray_create_ioplace.py \ - --blif $EBLIF \ - --map ${SHARE_DIR_PATH}/arch/${DEVICE}/${PART}/pinmap.csv \ - --net $NET $PCF_OPTS \ - > ${IOPLACE_FILE} - -python3 ${SHARE_DIR_PATH}/scripts/prjxray_create_place_constraints.py \ - --net $NET \ - --arch ${ARCH_DEF} \ - --blif $EBLIF \ - --vpr_grid_map ${SHARE_DIR_PATH}/arch/${DEVICE}/vpr_grid_map.csv \ - --input ${IOPLACE_FILE} \ - --db_root ${DATABASE_DIR:=$(prjxray-config)} \ - --part $PART \ - > constraints.place diff --git a/f4pga/wrappers/sh/xc7/place.f4pga.sh b/f4pga/wrappers/sh/xc7/place.f4pga.sh deleted file mode 100755 index be52a92..0000000 --- a/f4pga/wrappers/sh/xc7/place.f4pga.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -source $(dirname "$0")/vpr_common.f4pga.sh -parse_args "$@" - -PCF=${PCF:=} - -if [ -z $NET ]; then - echo "Please provide net file name" - exit 1 -fi - -export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_place.log - -echo "Generating coinstrains ..." -symbiflow_generate_constraints $EBLIF $NET $PART $DEVICE $ARCH_DEF $PCF - -run_vpr --fix_clusters constraints.place --place - -mv vpr_stdout.log place.log diff --git a/f4pga/wrappers/sh/xc7/route.f4pga.sh b/f4pga/wrappers/sh/xc7/route.f4pga.sh deleted file mode 100755 index 34dbe23..0000000 --- a/f4pga/wrappers/sh/xc7/route.f4pga.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -source $(dirname "$0")/vpr_common.f4pga.sh -parse_args "$@" - -export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_pack.log - -run_vpr --route - -mv vpr_stdout.log route.log diff --git a/f4pga/wrappers/sh/xc7/synth.f4pga.sh b/f4pga/wrappers/sh/xc7/synth.f4pga.sh index 9ba3709..c1e87b8 100755 --- a/f4pga/wrappers/sh/xc7/synth.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/synth.f4pga.sh @@ -18,10 +18,9 @@ set -e -export SHARE_DIR_PATH="$F4PGA_SHARE_DIR" -export TECHMAP_PATH=${SHARE_DIR_PATH}/techmaps/xc7_vpr/techmap +export TECHMAP_PATH="${F4PGA_SHARE_DIR}"/techmaps/xc7_vpr/techmap -export UTILS_PATH=${SHARE_DIR_PATH}/scripts +export UTILS_PATH="${F4PGA_SHARE_DIR}"/scripts SYNTH_TCL_PATH=${UTILS_PATH}/xc7/synth.tcl VERILOG_FILES=() @@ -118,7 +117,7 @@ if [ ${#VERILOG_FILES[@]} -eq 0 ]; then exit 1 fi -DATABASE_DIR=${DATABASE_DIR:=$(prjxray-config)} +DATABASE_DIR=${DATABASE_DIR:-$(prjxray-config)} export TOP=${TOP} export USE_ROI="FALSE" @@ -130,7 +129,7 @@ export OUT_SYNTH_V=${TOP}_synth.v export OUT_EBLIF=${TOP}.eblif export PART_JSON=`realpath ${DATABASE_DIR}/$DEVICE/$PART/part.json` export OUT_FASM_EXTRA=${TOP}_fasm_extra.fasm -export PYTHON3=${PYTHON3:=$(which python3)} +export PYTHON3=${PYTHON3:-$(which python3)} LOG=${TOP}_synth.log diff --git a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh index cf40f84..2382a7f 100755 --- a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh @@ -16,144 +16,83 @@ # # SPDX-License-Identifier: Apache-2.0 -SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} +eval set -- "$( + getopt \ + --options=d:e:p:n:P:s: \ + --longoptions=device:,eblif:,pcf:,net:,part:,sdc: \ + --name $0 -- "$@" +)" +DEVICE='' +DEVICE_NAME='' +PART='' +EBLIF='' +PCF='' +NET='' +SDC='' +ADDITIONAL_VPR_OPTIONS='' +while true; do + case "$1" in + -d|--device) DEVICE=$2; shift 2 ;; + -e|--eblif) EBLIF=$2; shift 2 ;; + -p|--pcf) PCF=$2; shift 2 ;; + -n|--net) NET=$2; shift 2 ;; + -P|--part) PART=$2; shift 2 ;; + -s|--sdc) SDC=$2; shift 2 ;; + --) shift; ADDITIONAL_VPR_OPTIONS="$@"; break ;; + esac +done -if [ -z $VPR_OPTIONS ]; then - echo "Using default VPR options." - VPR_OPTIONS=" - --max_router_iterations 500 - --routing_failure_predictor off - --router_high_fanout_threshold -1 - --constant_net_method route - --route_chan_width 500 - --router_heap bucket - --clock_modeling route - --place_delta_delay_matrix_calculation_method dijkstra - --place_delay_model delta - --router_lookahead extended_map - --check_route quick - --strict_checks off - --allow_dangling_combinational_nodes on - --disable_errors check_unbuffered_edges:check_route - --congested_routing_iteration_threshold 0.8 - --incremental_reroute_delay_ripup off - --base_cost_type delay_normalized_length_bounded - --bb_factor 10 - --acc_fac 0.7 - --astar_fac 1.8 - --initial_pres_fac 2.828 - --pres_fac_mult 1.2 - --check_rr_graph off - --suppress_warnings ${OUT_NOISY_WARNINGS},sum_pin_class:check_unbuffered_edges:load_rr_indexed_data_T_values:check_rr_node:trans_per_R:check_route:set_rr_graph_tool_comment:calculate_average_switch - " +if [ -z "$DEVICE" ] && [ -n "$PART" ]; then + # Try to find device name. Accept only when exactly one is found + PART_DIRS=(${F4PGA_SHARE_DIR}/arch/*/${PART}) + if [ ${#PART_DIRS[@]} -eq 1 ]; then DEVICE=$(basename $(dirname "${PART_DIRS[0]}")); fi +fi +if [ -z "$DEVICE" ]; then echo "Please provide device name"; exit 1; fi +if [ -z "$EBLIF" ]; then echo "Please provide blif file name"; exit 1; fi + +export DEVICE="$DEVICE" +export EBLIF="$EBLIF" +export PCF="$PCF" +export NET="$NET" +export SDC="$SDC" + +if [ -z "$VPR_OPTIONS" ]; then + echo "Using default VPR options." + VPR_OPTIONS=" + --max_router_iterations 500 + --routing_failure_predictor off + --router_high_fanout_threshold -1 + --constant_net_method route + --route_chan_width 500 + --router_heap bucket + --clock_modeling route + --place_delta_delay_matrix_calculation_method dijkstra + --place_delay_model delta + --router_lookahead extended_map + --check_route quick + --strict_checks off + --allow_dangling_combinational_nodes on + --disable_errors check_unbuffered_edges:check_route + --congested_routing_iteration_threshold 0.8 + --incremental_reroute_delay_ripup off + --base_cost_type delay_normalized_length_bounded + --bb_factor 10 + --acc_fac 0.7 + --astar_fac 1.8 + --initial_pres_fac 2.828 + --pres_fac_mult 1.2 + --check_rr_graph off + --suppress_warnings ${OUT_NOISY_WARNINGS},sum_pin_class:check_unbuffered_edges:load_rr_indexed_data_T_values:check_rr_node:trans_per_R:check_route:set_rr_graph_tool_comment:calculate_average_switch + " fi -function parse_args { +export VPR_OPTIONS="$VPR_OPTIONS $ADDITIONAL_VPR_OPTIONS" - eval set -- "$( - getopt \ - --options=d:e:p:n:P:s: \ - --longoptions=device:,eblif:,pcf:,net:,part:,sdc: \ - --name $0 -- "$@" - )" - - DEVICE='' - DEVICE_NAME='' - PART='' - EBLIF='' - PCF='' - NET='' - SDC='' - ADDITIONAL_VPR_OPTIONS='' - - while true; do - case "$1" in - -d|--device) DEVICE=$2; shift 2 ;; - -e|--eblif) EBLIF=$2; shift 2 ;; - -p|--pcf) PCF=$2; shift 2 ;; - -n|--net) NET=$2; shift 2 ;; - -P|--part) PART=$2; shift 2 ;; - -s|--sdc) SDC=$2; shift 2 ;; - --) shift; ADDITIONAL_VPR_OPTIONS="$@"; break ;; - esac - done - - if [ -z $DEVICE ] && [ -n $PART ]; then - # Try to find device name. Accept only when exactly one is found - PART_DIRS=(${SHARE_DIR_PATH}/arch/*/${PART}) - if [ ${#PART_DIRS[@]} -eq 1 ]; then - DEVICE=$(basename $(dirname "${PART_DIRS[0]}")) - fi - fi - if [ -z $DEVICE ]; then - echo "Please provide device name" - exit 1 - fi - - if [ -z $EBLIF ]; then - echo "Please provide blif file name" - exit 1 - fi - - export DEVICE=$DEVICE - export EBLIF=$EBLIF - export PCF=$PCF - export NET=$NET - export SDC=$SDC - export VPR_OPTIONS="$VPR_OPTIONS $ADDITIONAL_VPR_OPTIONS" - - export ARCH_DIR=`realpath ${SHARE_DIR_PATH}/arch/$DEVICE` - export ARCH_DEF=${ARCH_DIR}/arch.timing.xml - export LOOKAHEAD=${ARCH_DIR}/rr_graph_${DEVICE}.lookahead.bin - export RR_GRAPH=${ARCH_DIR}/rr_graph_${DEVICE}.rr_graph.real.bin - export RR_GRAPH_XML=${ARCH_DIR}/rr_graph_${DEVICE}.rr_graph.real.xml - export PLACE_DELAY=${ARCH_DIR}/rr_graph_${DEVICE}.place_delay.bin - export DEVICE_NAME=`echo $DEVICE | sed -n 's/_/-/p'` -} - -function run_vpr { - set -e - - SDC_OPTIONS="" - if [ ! -z $SDC ] - then - SDC_OPTIONS="--sdc_file $SDC" - fi - - vpr ${ARCH_DEF} \ - ${EBLIF} \ - --device ${DEVICE_NAME} \ - ${VPR_OPTIONS} \ - --read_rr_graph ${RR_GRAPH} \ - --read_router_lookahead ${LOOKAHEAD} \ - --read_placement_delay_lookup ${PLACE_DELAY} \ - ${SDC_OPTIONS} \ - $@ - - return $? -} - -function run_genfasm { - set -e - - genfasm ${ARCH_DEF} \ - ${EBLIF} \ - --device ${DEVICE_NAME} \ - ${VPR_OPTIONS} \ - --read_rr_graph ${RR_GRAPH} \ - $@ - - return $? -} - -function run_vpr_xml_rr_graph { - set -e - - vpr ${ARCH_DEF} \ - ${EBLIF} \ - --read_rr_graph ${RR_GRAPH} - --write_rr_graph ${RR_GRAPH_XML} - $@ - - return $? -} +export ARCH_DIR="${F4PGA_SHARE_DIR}/arch/$DEVICE" +export ARCH_DEF="${ARCH_DIR}"/arch.timing.xml +ARCH_RR_PREFIX="${ARCH_DIR}/rr_graph_${DEVICE}" +export RR_GRAPH="${ARCH_RR_PREFIX}".rr_graph.real.bin +export RR_GRAPH_XML="${ARCH_RR_PREFIX}".rr_graph.real.xml +export PLACE_DELAY="${ARCH_RR_PREFIX}".place_delay.bin +export LOOKAHEAD="${ARCH_RR_PREFIX}".lookahead.bin +export DEVICE_NAME=`echo "$DEVICE" | sed -n 's/_/-/p'` diff --git a/f4pga/wrappers/sh/xc7/write_bitstream.f4pga.sh b/f4pga/wrappers/sh/xc7/write_bitstream.f4pga.sh deleted file mode 100755 index 8e1db81..0000000 --- a/f4pga/wrappers/sh/xc7/write_bitstream.f4pga.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -echo "Writing bitstream ..." - -FRM2BIT="" -if [ ! -z ${FRAMES2BIT} ]; then - FRM2BIT="--frm2bit ${FRAMES2BIT}" -fi - -OPTS=d:f:b:p: -LONGOPTS=device:,fasm:,bit:,part: - -PARSED_OPTS=`getopt --options=${OPTS} --longoptions=${LONGOPTS} --name $0 -- $@` -eval set -- ${PARSED_OPTS} - -DEVICE="" -FASM="" -BIT="" -PART=xc7a35tcpg236-1 - -while true; do - case "$1" in - -d|--device) - DEVICE=$2 - shift 2 - ;; - -p|--part) - PART=$2 - shift 2 - ;; - -f|--fasm) - FASM=$2 - shift 2 - ;; - -b|--bit) - BIT=$2 - shift 2 - ;; - --) - break - ;; - esac -done - -DATABASE_DIR=${DATABASE_DIR:=$(prjxray-config)} - -if [ -z $DEVICE ]; then - # Try to find device name. Accept only when exactly one is found - PART_DIRS=(${DATABASE_DIR}/*/${PART}) - if [ ${#PART_DIRS[@]} -eq 1 ]; then - DEVICE=$(basename $(dirname "${PART_DIRS[0]}")) - else - echo "Please provide device name" - exit 1 - fi -fi - -DBROOT=`realpath ${DATABASE_DIR}/${DEVICE}` - -if [ -z $FASM ]; then - echo "Please provide fasm file name" - exit 1 -fi - -if [ -z $BIT ]; then - echo "Please provide bit file name" - exit 1 -fi - -xcfasm \ - --db-root ${DBROOT} \ - --part ${PART} \ - --part_file ${DBROOT}/${PART}/part.yaml \ - --sparse \ - --emit_pudc_b_pullup \ - --fn_in ${FASM} \ - --bit_out ${BIT} ${FRM2BIT} diff --git a/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh b/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh deleted file mode 100755 index 5a89790..0000000 --- a/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -source $(dirname "$0")/vpr_common.f4pga.sh -parse_args "$@" - -TOP="${EBLIF%.*}" -FASM_EXTRA=${TOP}_fasm_extra.fasm - -export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_fasm.log - -run_genfasm - -echo "FASM extra: $FASM_EXTRA" -if [ -f $FASM_EXTRA ]; then - echo "writing final fasm" - cat ${TOP}.fasm $FASM_EXTRA > tmp.fasm - mv tmp.fasm ${TOP}.fasm -fi - -mv vpr_stdout.log fasm.log diff --git a/test/test_wrappers.py b/test/test_wrappers.py index 418a5b3..d0d2ec7 100644 --- a/test/test_wrappers.py +++ b/test/test_wrappers.py @@ -32,8 +32,6 @@ wrappers = [ 'symbiflow_synth', 'symbiflow_write_bitstream', 'symbiflow_write_fasm', - 'symbiflow_write_xml_rr_graph', - 'vpr_common', 'symbiflow_analysis', 'symbiflow_repack', 'symbiflow_generate_bitstream',