From 77ea3b96ae48632f438e5ce3942eb090f3fb94bd Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 11 Aug 2022 00:31:49 +0200 Subject: [PATCH] f4pga/wrappers/sh: add vpr_run Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 24 +++++++++++++++--- .../sh/quicklogic/vpr_common.f4pga.sh | 25 +++---------------- f4pga/wrappers/sh/vpr_run.py | 23 +++++++++++++++++ f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh | 24 +----------------- 4 files changed, 47 insertions(+), 49 deletions(-) create mode 100644 f4pga/wrappers/sh/vpr_run.py diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 74974aa..42cf1d7 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -111,7 +111,7 @@ python3 "${SHARE_DIR_PATH}"/scripts/prjxray_create_place_constraints.py \ def pack(): print("[F4PGA] Running (deprecated) pack") extra_args = ['--write_block_usage', 'block_usage.json'] if isQuickLogic else [] - run_bash_cmds(vpr_common_cmds('pack')+f"run_vpr --pack {' '.join(extra_args)}") + run_bash_cmds(vpr_common_cmds('pack')+f"python3 -m f4pga.wrappers.sh.vpr_run --pack {' '.join(extra_args)}") Path('vpr_stdout.log').rename('pack.log') @@ -142,7 +142,7 @@ echo "Generating constrains ..." symbiflow_generate_constraints $EBLIF $NET $PART $DEVICE $ARCH_DEF $PCF VPR_PLACE_FILE='constraints.place' """ - place_cmds += 'run_vpr --fix_clusters "${VPR_PLACE_FILE}" --place' + place_cmds += 'python3 -m f4pga.wrappers.sh.vpr_run --fix_clusters "${VPR_PLACE_FILE}" --place' run_bash_cmds(vpr_common_cmds('place')+place_cmds) Path('vpr_stdout.log').rename('place.log') @@ -150,7 +150,7 @@ VPR_PLACE_FILE='constraints.place' def route(): print("[F4PGA] Running (deprecated) route") extra_args = ['--write_timing_summary', 'timing_summary.json'] if isQuickLogic else [] - run_bash_cmds(vpr_common_cmds('pack')+f"run_vpr --route {' '.join(extra_args)}") + run_bash_cmds(vpr_common_cmds('pack')+f"python3 -m f4pga.wrappers.sh.vpr_run --route {' '.join(extra_args)}") Path('vpr_stdout.log').rename('route.log') @@ -185,6 +185,22 @@ def vpr_common(): run_sh_script(ROOT / SH_SUBDIR / "vpr_common.f4pga.sh") +def vpr_run(): + print("[F4PGA] Running (deprecated) vpr run") + run_bash_cmds(f""" + set -e + SDC_OPTIONS="" + if [ ! -z $SDC ]; then SDC_OPTIONS="--sdc_file $SDC"; fi + '{which('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 \ +""" + f"{' '.join(sys_argv[1:])}") + + # Xilinx only def write_bitstream(): @@ -245,7 +261,7 @@ xcfasm \ def analysis(): print("[F4PGA] Running (deprecated) analysis") run_bash_cmds(vpr_common_cmds('analysis')+""" -run_vpr \ +python3 -m f4pga.wrappers.sh.vpr_run \ --analysis \ --gen_post_synthesis_netlist on \ --gen_post_implementation_merged_netlist on \ diff --git a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh index 7b864d1..07a9161 100755 --- a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh @@ -104,6 +104,8 @@ function parse_args { --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 + export VPR_OPTIONS="$VPR_OPTIONS" + if [[ "$DEVICE" == "qlf_k4n8_qlf_k4n8" ]]; then DEVICE_1="qlf_k4n8-qlf_k4n8_umc22_${CORNER}" DEVICE_2="$DEVICE_1" @@ -125,27 +127,6 @@ function parse_args { export RR_GRAPH="${ARCH_RR_PREFIX}".rr_graph.real.bin fi export PLACE_DELAY="${ARCH_RR_PREFIX}".place_delay.bin - export ROUTE_DELAY="${ARCH_RR_PREFIX}".lookahead.bin + export LOOKAHEAD="${ARCH_RR_PREFIX}".lookahead.bin export DEVICE_NAME="$DEVICE_1" } - -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 $? -} diff --git a/f4pga/wrappers/sh/vpr_run.py b/f4pga/wrappers/sh/vpr_run.py new file mode 100644 index 0000000..3647c2c --- /dev/null +++ b/f4pga/wrappers/sh/vpr_run.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# 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 + +from f4pga.wrappers.sh import vpr_run + +if __name__ == '__main__': + vpr_run() diff --git a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh index 9f7ae54..8214c63 100755 --- a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh @@ -94,31 +94,9 @@ function parse_args { export ARCH_DIR=`realpath ${SHARE_DIR_PATH}/arch/$DEVICE` export ARCH_DEF="${ARCH_DIR}"/arch.timing.xml ARCH_RR_PREFIX="${ARCH_DIR}/rr_graph_${DEVICE}" - export LOOKAHEAD="${ARCH_RR_PREFIX}".lookahead.bin 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'` } - -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 $? -}