From ba7fec4bde7f27201fcae30edaf2ed1842e90b81 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 14:55:33 +0200 Subject: [PATCH 01/34] f4pga/wrappers: rm pack.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 10 ++++++- f4pga/wrappers/sh/quicklogic/pack.f4pga.sh | 31 ---------------------- f4pga/wrappers/sh/xc7/pack.f4pga.sh | 27 ------------------- 3 files changed, 9 insertions(+), 59 deletions(-) delete mode 100755 f4pga/wrappers/sh/quicklogic/pack.f4pga.sh delete mode 100755 f4pga/wrappers/sh/xc7/pack.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index e0325b0..9009741 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -60,7 +60,15 @@ def generate_constraints(): 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 [] + check_call(f""" +set -e +source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh +parse_args {' '.join(sys_argv[1:])} +export OUT_NOISY_WARNINGS=noisy_warnings-${{DEVICE}}_pack.log +run_vpr --pack {' '.join(extra_args)} +mv vpr_stdout.log pack.log +""", env=f4pga_environ, shell=True, executable='/bin/bash') def place(): 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/xc7/pack.f4pga.sh b/f4pga/wrappers/sh/xc7/pack.f4pga.sh deleted file mode 100755 index 48d0ecb..0000000 --- a/f4pga/wrappers/sh/xc7/pack.f4pga.sh +++ /dev/null @@ -1,27 +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 -mv vpr_stdout.log pack.log From ee80ab8dc673f802f698693bd888e1123e58219e Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 19:55:51 +0200 Subject: [PATCH 02/34] f4pga/wrappers/sh/xc7: cleanup Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh | 12 ------------ f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh | 6 +++++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh index cf40f84..7f12307 100755 --- a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh @@ -145,15 +145,3 @@ function run_genfasm { 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 $? -} diff --git a/f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh b/f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh index 2cf9aae..7b5f929 100755 --- a/f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh @@ -23,4 +23,8 @@ parse_args "$@" OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_place.log -run_vpr_xml_rr_graph --pack +vpr ${ARCH_DEF} \ + ${EBLIF} \ + --read_rr_graph ${RR_GRAPH} \ + --write_rr_graph ${RR_GRAPH_XML} \ + --pack From 20b64d95069e0fbe1f5faae3d0deabef32ecfeec Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 16:05:55 +0200 Subject: [PATCH 03/34] f4pga/wrappers/sh: add genfasm.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/setup.py | 1 + f4pga/wrappers/sh/genfasm.f4pga.sh | 23 +++++++++++++++++++ .../sh/quicklogic/vpr_common.f4pga.sh | 13 ----------- .../sh/quicklogic/write_fasm.f4pga.sh | 7 +++++- f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh | 13 ----------- f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh | 7 +++++- 6 files changed, 36 insertions(+), 28 deletions(-) create mode 100755 f4pga/wrappers/sh/genfasm.f4pga.sh diff --git a/f4pga/setup.py b/f4pga/setup.py index 50a65cf..286c0cf 100644 --- a/f4pga/setup.py +++ b/f4pga/setup.py @@ -92,6 +92,7 @@ setuptools_setup( 'platforms/*.json' ], 'f4pga.wrappers.sh': [ + '*.f4pga.sh', 'xc7/*.f4pga.sh', 'quicklogic/*.f4pga.sh' ] diff --git a/f4pga/wrappers/sh/genfasm.f4pga.sh b/f4pga/wrappers/sh/genfasm.f4pga.sh new file mode 100755 index 0000000..9767c89 --- /dev/null +++ b/f4pga/wrappers/sh/genfasm.f4pga.sh @@ -0,0 +1,23 @@ +#!/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 + +"`which genfasm`" ${ARCH_DEF} \ + ${EBLIF} --device ${DEVICE_NAME} ${VPR_OPTIONS} --read_rr_graph ${RR_GRAPH} \ + $@ diff --git a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh index f9b87c0..f4b26fa 100755 --- a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh @@ -163,16 +163,3 @@ function run_vpr { return $? } - -function run_genfasm { - set -e - - "`which genfasm`" ${ARCH_DEF} \ - ${EBLIF} \ - --device ${DEVICE_NAME} \ - ${VPR_OPTIONS} \ - --read_rr_graph ${RR_GRAPH} \ - $@ - - return $? -} diff --git a/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh index b7a503f..95e1d19 100755 --- a/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh @@ -26,7 +26,12 @@ FASM_EXTRA="${TOP}_fasm_extra.fasm" export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_fasm.log -run_genfasm +ARCH_DEF="$ARCH_DEF" \ +EBLIF="$EBLIF" \ +DEVICE_NAME="$DEVICE_NAME" \ +VPR_OPTIONS="$VPR_OPTIONS" \ +RR_GRAPH="$RR_GRAPH" \ + $(dirname "$0")/../genfasm.f4pga.sh echo "FASM extra: $FASM_EXTRA" if [ -f $FASM_EXTRA ]; then diff --git a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh index 7f12307..c751219 100755 --- a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh @@ -132,16 +132,3 @@ function run_vpr { return $? } - -function run_genfasm { - set -e - - genfasm ${ARCH_DEF} \ - ${EBLIF} \ - --device ${DEVICE_NAME} \ - ${VPR_OPTIONS} \ - --read_rr_graph ${RR_GRAPH} \ - $@ - - return $? -} diff --git a/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh b/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh index 5a89790..868e5f8 100755 --- a/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh @@ -26,7 +26,12 @@ FASM_EXTRA=${TOP}_fasm_extra.fasm export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_fasm.log -run_genfasm +ARCH_DEF="$ARCH_DEF" \ +EBLIF="$EBLIF" \ +DEVICE_NAME="$DEVICE_NAME" \ +VPR_OPTIONS="$VPR_OPTIONS" \ +RR_GRAPH="$RR_GRAPH" \ + $(dirname "$0")/../genfasm.f4pga.sh echo "FASM extra: $FASM_EXTRA" if [ -f $FASM_EXTRA ]; then From e6fa4ebf282448e08e50d33a812f663aa1228657 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 20:09:41 +0200 Subject: [PATCH 04/34] f4pga/wrappers/sh: convert genfasm.f4pga.sh into a Python function Signed-off-by: Unai Martinez-Corral --- f4pga/setup.py | 1 - f4pga/wrappers/sh/__init__.py | 8 +++ .../sh/{genfasm.f4pga.sh => genfasm.py} | 50 ++++++++++--------- .../sh/quicklogic/write_fasm.f4pga.sh | 2 +- f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh | 2 +- 5 files changed, 37 insertions(+), 26 deletions(-) rename f4pga/wrappers/sh/{genfasm.f4pga.sh => genfasm.py} (70%) mode change 100755 => 100644 diff --git a/f4pga/setup.py b/f4pga/setup.py index 286c0cf..50a65cf 100644 --- a/f4pga/setup.py +++ b/f4pga/setup.py @@ -92,7 +92,6 @@ setuptools_setup( 'platforms/*.json' ], 'f4pga.wrappers.sh': [ - '*.f4pga.sh', 'xc7/*.f4pga.sh', 'quicklogic/*.f4pga.sh' ] diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 9009741..19c0171 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -91,6 +91,14 @@ def write_bitstream(): run_sh(ROOT / SH_SUBDIR / "write_bitstream.f4pga.sh") +def genfasm(extra_args): + check_call(f""" +'{which('genfasm')}' ${{ARCH_DEF}} \ + ${{EBLIF}} --device ${{DEVICE_NAME}} ${{VPR_OPTIONS}} --read_rr_graph ${{RR_GRAPH}} \ + {' '.join(extra_args)} +""", env=f4pga_environ, shell=True, executable='/bin/bash') + + def write_fasm(): print("[F4PGA] Running (deprecated) write fasm") run_sh(ROOT / SH_SUBDIR / "write_fasm.f4pga.sh") diff --git a/f4pga/wrappers/sh/genfasm.f4pga.sh b/f4pga/wrappers/sh/genfasm.py old mode 100755 new mode 100644 similarity index 70% rename from f4pga/wrappers/sh/genfasm.f4pga.sh rename to f4pga/wrappers/sh/genfasm.py index 9767c89..70cab3f --- a/f4pga/wrappers/sh/genfasm.f4pga.sh +++ b/f4pga/wrappers/sh/genfasm.py @@ -1,23 +1,27 @@ -#!/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 - -"`which genfasm`" ${ARCH_DEF} \ - ${EBLIF} --device ${DEVICE_NAME} ${VPR_OPTIONS} --read_rr_graph ${RR_GRAPH} \ - $@ +#!/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 +# +# Python entrypoints to the shell wrappers moved from arch-defs + +from sys import argv as sys_argv + +from f4pga.wrappers.sh import genfasm + +if __name__ == '__main__': + genfasm(sys_argv[1:]) diff --git a/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh index 95e1d19..dd16153 100755 --- a/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh @@ -31,7 +31,7 @@ EBLIF="$EBLIF" \ DEVICE_NAME="$DEVICE_NAME" \ VPR_OPTIONS="$VPR_OPTIONS" \ RR_GRAPH="$RR_GRAPH" \ - $(dirname "$0")/../genfasm.f4pga.sh + python3 -m f4pga.wrappers.sh.genfasm echo "FASM extra: $FASM_EXTRA" if [ -f $FASM_EXTRA ]; then diff --git a/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh b/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh index 868e5f8..dc68e0c 100755 --- a/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh @@ -31,7 +31,7 @@ EBLIF="$EBLIF" \ DEVICE_NAME="$DEVICE_NAME" \ VPR_OPTIONS="$VPR_OPTIONS" \ RR_GRAPH="$RR_GRAPH" \ - $(dirname "$0")/../genfasm.f4pga.sh + python3 -m f4pga.wrappers.sh.genfasm echo "FASM extra: $FASM_EXTRA" if [ -f $FASM_EXTRA ]; then From 0e93d141c21f8254aeb541a2619feed34302f39a Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 20:21:32 +0200 Subject: [PATCH 05/34] f4pga/wrappers/sh/xc7/vpr_common: style Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh | 142 +++++++++++----------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh index c751219..843593a 100755 --- a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh @@ -19,33 +19,33 @@ SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} 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 - " + 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 { @@ -78,57 +78,57 @@ function parse_args { 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 $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 + 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 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'` + 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 + set -e - SDC_OPTIONS="" - if [ ! -z $SDC ] - then - SDC_OPTIONS="--sdc_file $SDC" - fi + 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} \ - $@ + 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 $? + return $? } From 5d01306eb16fbc1903a132aa138c764553924abc Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 20:27:42 +0200 Subject: [PATCH 06/34] f4pga/wrappers/sh/xc7: rm write_xml_rr_graph.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 12 +++++++- .../sh/xc7/write_xml_rr_graph.f4pga.sh | 30 ------------------- 2 files changed, 11 insertions(+), 31 deletions(-) delete mode 100755 f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 19c0171..e7322fd 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -106,7 +106,17 @@ def write_fasm(): def write_xml_rr_graph(): print("[F4PGA] Running (deprecated) write xlm rr graph") - run_sh(ROOT / SH_SUBDIR / "write_xml_rr_graph.f4pga.sh") + check_call(f""" +set -e +source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh +parse_args {' '.join(sys_argv[1:])} +export OUT_NOISY_WARNINGS=noisy_warnings-${{DEVICE}}_place.log +vpr ${{ARCH_DEF}} \ + ${{EBLIF}} \ + --read_rr_graph ${{RR_GRAPH}} \ + --write_rr_graph ${{RR_GRAPH_XML}} \ + --pack +""", env=f4pga_environ, shell=True, executable='/bin/bash') def vpr_common(): diff --git a/f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh b/f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh deleted file mode 100755 index 7b5f929..0000000 --- a/f4pga/wrappers/sh/xc7/write_xml_rr_graph.f4pga.sh +++ /dev/null @@ -1,30 +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 "$@" - -OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_place.log - -vpr ${ARCH_DEF} \ - ${EBLIF} \ - --read_rr_graph ${RR_GRAPH} \ - --write_rr_graph ${RR_GRAPH_XML} \ - --pack From 1d36340eeb2c2a76f849b5f1f0029604c600ed6a Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 20:36:26 +0200 Subject: [PATCH 07/34] f4pga/wrappers/sh: rm write_fasm.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 26 ++++++++++- .../sh/quicklogic/write_fasm.f4pga.sh | 43 ------------------- f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh | 43 ------------------- 3 files changed, 25 insertions(+), 87 deletions(-) delete mode 100755 f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh delete mode 100755 f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index e7322fd..1509012 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -101,7 +101,31 @@ def genfasm(extra_args): def write_fasm(): print("[F4PGA] Running (deprecated) write fasm") - run_sh(ROOT / SH_SUBDIR / "write_fasm.f4pga.sh") + check_call(f""" +set -e +source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh +parse_args {' '.join(sys_argv[1:])} +export OUT_NOISY_WARNINGS=noisy_warnings-${{DEVICE}}_fasm.log + +TOP="${{EBLIF%.*}}" +FASM_EXTRA="${{TOP}}_fasm_extra.fasm" + +ARCH_DEF="$ARCH_DEF" \ +EBLIF="$EBLIF" \ +DEVICE_NAME="$DEVICE_NAME" \ +VPR_OPTIONS="$VPR_OPTIONS" \ +RR_GRAPH="$RR_GRAPH" \ + python3 -m f4pga.wrappers.sh.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 +""", env=f4pga_environ, shell=True, executable='/bin/bash') def write_xml_rr_graph(): 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 dd16153..0000000 --- a/f4pga/wrappers/sh/quicklogic/write_fasm.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 "$@" - -TOP="${EBLIF%.*}" -FASM_EXTRA="${TOP}_fasm_extra.fasm" - -export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_fasm.log - -ARCH_DEF="$ARCH_DEF" \ -EBLIF="$EBLIF" \ -DEVICE_NAME="$DEVICE_NAME" \ -VPR_OPTIONS="$VPR_OPTIONS" \ -RR_GRAPH="$RR_GRAPH" \ - python3 -m f4pga.wrappers.sh.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/write_fasm.f4pga.sh b/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh deleted file mode 100755 index dc68e0c..0000000 --- a/f4pga/wrappers/sh/xc7/write_fasm.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 "$@" - -TOP="${EBLIF%.*}" -FASM_EXTRA=${TOP}_fasm_extra.fasm - -export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_fasm.log - -ARCH_DEF="$ARCH_DEF" \ -EBLIF="$EBLIF" \ -DEVICE_NAME="$DEVICE_NAME" \ -VPR_OPTIONS="$VPR_OPTIONS" \ -RR_GRAPH="$RR_GRAPH" \ - python3 -m f4pga.wrappers.sh.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 From 0b6432d0eb3d9ad878e0214d20bd0a9ca4fd3fd8 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 20:41:52 +0200 Subject: [PATCH 08/34] f4pga/wrappers/sh: add helper func 'run_bash_cmds' Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 46 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 1509012..4b537bd 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -41,11 +41,15 @@ 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): +def run_sh_script(script): stdout.flush() stderr.flush() check_call([str(script)]+sys_argv[1:], env=f4pga_environ) +def run_bash_cmds(cmds): + stdout.flush() + stderr.flush() + check_call(cmds, env=f4pga_environ, shell=True, executable='/bin/bash') def run_pym(module): stdout.flush() @@ -55,53 +59,53 @@ def run_pym(module): def generate_constraints(): print("[F4PGA] Running (deprecated) generate constraints") - run_sh(ROOT / SH_SUBDIR / "generate_constraints.f4pga.sh") + run_sh_script(ROOT / SH_SUBDIR / "generate_constraints.f4pga.sh") def pack(): print("[F4PGA] Running (deprecated) pack") extra_args = ['--write_block_usage', 'block_usage.json'] if isQuickLogic else [] - check_call(f""" + run_bash_cmds(f""" set -e source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh parse_args {' '.join(sys_argv[1:])} export OUT_NOISY_WARNINGS=noisy_warnings-${{DEVICE}}_pack.log run_vpr --pack {' '.join(extra_args)} mv vpr_stdout.log pack.log -""", env=f4pga_environ, shell=True, executable='/bin/bash') +""") def place(): print("[F4PGA] Running (deprecated) place") - run_sh(ROOT / SH_SUBDIR / "place.f4pga.sh") + run_sh_script(ROOT / SH_SUBDIR / "place.f4pga.sh") def route(): print("[F4PGA] Running (deprecated) route") - run_sh(ROOT / SH_SUBDIR / "route.f4pga.sh") + run_sh_script(ROOT / SH_SUBDIR / "route.f4pga.sh") def synth(): print("[F4PGA] Running (deprecated) synth") - run_sh(ROOT / SH_SUBDIR / "synth.f4pga.sh") + run_sh_script(ROOT / SH_SUBDIR / "synth.f4pga.sh") def write_bitstream(): print("[F4PGA] Running (deprecated) write bitstream") - run_sh(ROOT / SH_SUBDIR / "write_bitstream.f4pga.sh") + run_sh_script(ROOT / SH_SUBDIR / "write_bitstream.f4pga.sh") def genfasm(extra_args): - check_call(f""" + run_bash_cmds(f""" '{which('genfasm')}' ${{ARCH_DEF}} \ ${{EBLIF}} --device ${{DEVICE_NAME}} ${{VPR_OPTIONS}} --read_rr_graph ${{RR_GRAPH}} \ {' '.join(extra_args)} -""", env=f4pga_environ, shell=True, executable='/bin/bash') +""") def write_fasm(): print("[F4PGA] Running (deprecated) write fasm") - check_call(f""" + run_bash_cmds(f""" set -e source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh parse_args {' '.join(sys_argv[1:])} @@ -125,12 +129,12 @@ if [ -f $FASM_EXTRA ]; then fi mv vpr_stdout.log fasm.log -""", env=f4pga_environ, shell=True, executable='/bin/bash') +""") def write_xml_rr_graph(): print("[F4PGA] Running (deprecated) write xlm rr graph") - check_call(f""" + run_bash_cmds(f""" set -e source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh parse_args {' '.join(sys_argv[1:])} @@ -140,42 +144,42 @@ vpr ${{ARCH_DEF}} \ --read_rr_graph ${{RR_GRAPH}} \ --write_rr_graph ${{RR_GRAPH_XML}} \ --pack -""", env=f4pga_environ, shell=True, executable='/bin/bash') +""") def vpr_common(): print("[F4PGA] Running (deprecated) vpr common") - run_sh(ROOT / SH_SUBDIR / "vpr_common.f4pga.sh") + run_sh_script(ROOT / SH_SUBDIR / "vpr_common.f4pga.sh") def analysis(): print("[F4PGA] Running (deprecated) analysis") - run_sh(ROOT / "quicklogic/analysis.f4pga.sh") + run_sh_script(ROOT / "quicklogic/analysis.f4pga.sh") def repack(): print("[F4PGA] Running (deprecated) repack") - run_sh(ROOT / "quicklogic/repack.f4pga.sh") + run_sh_script(ROOT / "quicklogic/repack.f4pga.sh") def generate_bitstream(): print("[F4PGA] Running (deprecated) generate_bitstream") - run_sh(ROOT / "quicklogic/generate_bitstream.f4pga.sh") + run_sh_script(ROOT / "quicklogic/generate_bitstream.f4pga.sh") def generate_libfile(): print("[F4PGA] Running (deprecated) generate_libfile") - run_sh(ROOT / "quicklogic/generate_libfile.f4pga.sh") + run_sh_script(ROOT / "quicklogic/generate_libfile.f4pga.sh") def ql(): print("[F4PGA] Running (deprecated) ql") - run_sh(ROOT / "quicklogic/ql.f4pga.sh") + run_sh_script(ROOT / "quicklogic/ql.f4pga.sh") def fasm2bels(): print("[F4PGA] Running (deprecated) fasm2bels") - run_sh(ROOT / "quicklogic/fasm2bels.f4pga.sh") + run_sh_script(ROOT / "quicklogic/fasm2bels.f4pga.sh") def write_bitheader(): From 918e8a6c2debc66aaf38b5bd6965b4b7bab49395 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 20:46:33 +0200 Subject: [PATCH 09/34] f4pga/wrappers/sh: add helper func 'vpr_common_cmds' Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 4b537bd..0a03baa 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -41,6 +41,8 @@ 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')) +# Helper functions + def run_sh_script(script): stdout.flush() stderr.flush() @@ -56,6 +58,16 @@ def run_pym(module): stderr.flush() check_call([which('python3'), '-m' , module]+sys_argv[1:], env=f4pga_environ) +def vpr_common_cmds(log_suffix): + return f""" +set -e +source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh +parse_args {' '.join(sys_argv[1:])} +export OUT_NOISY_WARNINGS=noisy_warnings-${{DEVICE}}_{log_suffix}.log +""" + + +# Entrypoints def generate_constraints(): print("[F4PGA] Running (deprecated) generate constraints") @@ -65,11 +77,7 @@ def generate_constraints(): def pack(): print("[F4PGA] Running (deprecated) pack") extra_args = ['--write_block_usage', 'block_usage.json'] if isQuickLogic else [] - run_bash_cmds(f""" -set -e -source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh -parse_args {' '.join(sys_argv[1:])} -export OUT_NOISY_WARNINGS=noisy_warnings-${{DEVICE}}_pack.log + run_bash_cmds(vpr_common_cmds('pack')+f""" run_vpr --pack {' '.join(extra_args)} mv vpr_stdout.log pack.log """) @@ -105,12 +113,7 @@ def genfasm(extra_args): def write_fasm(): print("[F4PGA] Running (deprecated) write fasm") - run_bash_cmds(f""" -set -e -source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh -parse_args {' '.join(sys_argv[1:])} -export OUT_NOISY_WARNINGS=noisy_warnings-${{DEVICE}}_fasm.log - + run_bash_cmds(vpr_common_cmds('fasm')+f""" TOP="${{EBLIF%.*}}" FASM_EXTRA="${{TOP}}_fasm_extra.fasm" @@ -134,11 +137,7 @@ mv vpr_stdout.log fasm.log def write_xml_rr_graph(): print("[F4PGA] Running (deprecated) write xlm rr graph") - run_bash_cmds(f""" -set -e -source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh -parse_args {' '.join(sys_argv[1:])} -export OUT_NOISY_WARNINGS=noisy_warnings-${{DEVICE}}_place.log + run_bash_cmds(vpr_common_cmds('place')+f""" vpr ${{ARCH_DEF}} \ ${{EBLIF}} \ --read_rr_graph ${{RR_GRAPH}} \ From a74239fb35954c4597be9711338d41d7e9b06c00 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 20:56:51 +0200 Subject: [PATCH 10/34] f4pga/wrappers/sh/pack: use Path instead of bash's mv Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 0a03baa..2d6bbcb 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -77,10 +77,8 @@ def generate_constraints(): 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)} -mv vpr_stdout.log pack.log -""") + run_bash_cmds(vpr_common_cmds('pack')+f"run_vpr --pack {' '.join(extra_args)}") + Path('vpr_stdout.log').rename('pack.log') def place(): From 315ffd2df24837fce046dcec4e73bc63ab5661cc Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 21:00:50 +0200 Subject: [PATCH 11/34] f4pga/wrappers/sh: merge 'genfasm' into 'write_fasm' Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 20 +++++--------------- f4pga/wrappers/sh/genfasm.py | 27 --------------------------- 2 files changed, 5 insertions(+), 42 deletions(-) delete mode 100644 f4pga/wrappers/sh/genfasm.py diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 2d6bbcb..aaf19cb 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -101,26 +101,16 @@ def write_bitstream(): run_sh_script(ROOT / SH_SUBDIR / "write_bitstream.f4pga.sh") -def genfasm(extra_args): - run_bash_cmds(f""" -'{which('genfasm')}' ${{ARCH_DEF}} \ - ${{EBLIF}} --device ${{DEVICE_NAME}} ${{VPR_OPTIONS}} --read_rr_graph ${{RR_GRAPH}} \ - {' '.join(extra_args)} -""") - - -def write_fasm(): +def write_fasm(genfasm_extra_args = None): print("[F4PGA] Running (deprecated) write fasm") run_bash_cmds(vpr_common_cmds('fasm')+f""" TOP="${{EBLIF%.*}}" FASM_EXTRA="${{TOP}}_fasm_extra.fasm" -ARCH_DEF="$ARCH_DEF" \ -EBLIF="$EBLIF" \ -DEVICE_NAME="$DEVICE_NAME" \ -VPR_OPTIONS="$VPR_OPTIONS" \ -RR_GRAPH="$RR_GRAPH" \ - python3 -m f4pga.wrappers.sh.genfasm +'{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 ''} echo "FASM extra: $FASM_EXTRA" if [ -f $FASM_EXTRA ]; then diff --git a/f4pga/wrappers/sh/genfasm.py b/f4pga/wrappers/sh/genfasm.py deleted file mode 100644 index 70cab3f..0000000 --- a/f4pga/wrappers/sh/genfasm.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/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 -# -# Python entrypoints to the shell wrappers moved from arch-defs - -from sys import argv as sys_argv - -from f4pga.wrappers.sh import genfasm - -if __name__ == '__main__': - genfasm(sys_argv[1:]) From 20171e4d1eb4d6660ae48e04e3080e0bad11a08a Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 21:15:12 +0200 Subject: [PATCH 12/34] f4pga/wrappers/sh/fasm: use Path instead of bash's mv Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index aaf19cb..d3601b3 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -118,9 +118,8 @@ if [ -f $FASM_EXTRA ]; then cat ${{TOP}}.fasm $FASM_EXTRA > tmp.fasm mv tmp.fasm ${{TOP}}.fasm fi - -mv vpr_stdout.log fasm.log """) + Path('vpr_stdout.log').rename('fasm.log') def write_xml_rr_graph(): From de504b993040de3ed2af9fdc3b1a40aa4dd1f30e Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 21:19:45 +0200 Subject: [PATCH 13/34] f4pga/wrappers/sh/quicklogic: rm analysis.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 13 ++++++- .../wrappers/sh/quicklogic/analysis.f4pga.sh | 34 ------------------- 2 files changed, 12 insertions(+), 35 deletions(-) delete mode 100755 f4pga/wrappers/sh/quicklogic/analysis.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index d3601b3..237f1f7 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -138,9 +138,20 @@ def vpr_common(): run_sh_script(ROOT / SH_SUBDIR / "vpr_common.f4pga.sh") +# QuickLogic only + def analysis(): print("[F4PGA] Running (deprecated) analysis") - run_sh_script(ROOT / "quicklogic/analysis.f4pga.sh") + run_bash_cmds(vpr_common_cmds('analysis')+f""" +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 +""") + Path('vpr_stdout.log').rename('analysis.log') def repack(): 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 From 8720c4ff25bdeecf8a010271ba00339f7cdcc494 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 21:27:27 +0200 Subject: [PATCH 14/34] f4pga/wrappers/sh/quicklogic: rm generate_libfile.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 27 +++++++++++- .../sh/quicklogic/generate_libfile.f4pga.sh | 43 ------------------- 2 files changed, 26 insertions(+), 44 deletions(-) delete mode 100755 f4pga/wrappers/sh/quicklogic/generate_libfile.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 237f1f7..bdd8903 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -166,7 +166,32 @@ def generate_bitstream(): def generate_libfile(): print("[F4PGA] Running (deprecated) generate_libfile") - run_sh_script(ROOT / "quicklogic/generate_libfile.f4pga.sh") + run_bash_cmds(f""" +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" +""") def ql(): 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" From 45020ee7a640be99118d400637336205fb1b296e Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 21:36:10 +0200 Subject: [PATCH 15/34] f4pga/wrappers/sh/generate_libfile: cleanup Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index bdd8903..6af9e70 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -166,28 +166,23 @@ def generate_bitstream(): def generate_libfile(): print("[F4PGA] Running (deprecated) generate_libfile") + (part, device, corner) = sys_argv[1:4] run_bash_cmds(f""" set -e -PART=$1 -DEVICE=$2 -CORNER=$3 - -if [[ "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]];then - DEVICE_1="qlf_k4n8-qlf_k4n8_umc22_$CORNER" +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}} + 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}}" \ + -c '{part}' \ -x "${{ARCH_DIR}}/lib/${{INTERFACEXML}}" \ -l "${{DEV}}_0P72_SSM40.lib" \ -t "${{ARCH_DIR}}/lib" From dab5de2d1fbb771190aba1e839c091176c548ec8 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 21:40:16 +0200 Subject: [PATCH 16/34] f4pga/wrappers/sh/quicklogic: rm generate_bitstream.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 45 ++++++++++- .../sh/quicklogic/generate_bitstream.f4pga.sh | 81 ------------------- 2 files changed, 44 insertions(+), 82 deletions(-) delete mode 100755 f4pga/wrappers/sh/quicklogic/generate_bitstream.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 6af9e70..90545c9 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -161,7 +161,50 @@ def repack(): def generate_bitstream(): print("[F4PGA] Running (deprecated) generate_bitstream") - run_sh_script(ROOT / "quicklogic/generate_bitstream.f4pga.sh") + 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 +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 +""") def generate_libfile(): 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 From 5d0642249dd10d662a973e127f55840e7061ef2d Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 21:51:53 +0200 Subject: [PATCH 17/34] f4pga/wrappers/sh/quicklogic: rm fasm2bels.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 45 +++++++++- .../wrappers/sh/quicklogic/fasm2bels.f4pga.sh | 88 ------------------- 2 files changed, 44 insertions(+), 89 deletions(-) delete mode 100755 f4pga/wrappers/sh/quicklogic/fasm2bels.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 90545c9..9a620d5 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -239,7 +239,50 @@ def ql(): def fasm2bels(): print("[F4PGA] Running (deprecated) fasm2bels") - run_sh_script(ROOT / "quicklogic/fasm2bels.f4pga.sh") + run_bash_cmds(f""" +set -e +SHARE_DIR_PATH=${{SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"}} +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" +`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}}" +""") def write_bitheader(): 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}" From 52c27abd57841d0fcd5611ab3ad4dfa40736d3a4 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 22:12:44 +0200 Subject: [PATCH 18/34] f4pga/wrappers/sh/quicklogic: rm repack.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 29 ++++++++++--- f4pga/wrappers/sh/quicklogic/repack.f4pga.sh | 43 -------------------- 2 files changed, 24 insertions(+), 48 deletions(-) delete mode 100755 f4pga/wrappers/sh/quicklogic/repack.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 9a620d5..81422f2 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -58,13 +58,14 @@ def run_pym(module): stderr.flush() check_call([which('python3'), '-m' , module]+sys_argv[1:], env=f4pga_environ) -def vpr_common_cmds(log_suffix): +def vpr_common_cmds(log_suffix = None): return f""" set -e source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh parse_args {' '.join(sys_argv[1:])} +""" + (f""" export OUT_NOISY_WARNINGS=noisy_warnings-${{DEVICE}}_{log_suffix}.log -""" +""" if log_suffix is not None else '') # Entrypoints @@ -156,7 +157,25 @@ run_vpr \ def repack(): print("[F4PGA] Running (deprecated) repack") - run_sh_script(ROOT / "quicklogic/repack.f4pga.sh") + run_bash_cmds(vpr_common_cmds()+f""" +DESIGN=${{EBLIF/.eblif/}} +[ ! -z "${{JSON}}" ] && JSON_ARGS="--json-constraints ${{JSON}}" || JSON_ARGS= +[ ! -z "${{PCF_PATH}}" ] && PCF_ARGS="--pcf-constraints ${{PCF_PATH}}" || PCF_ARGS= +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 +""") def generate_bitstream(): @@ -188,7 +207,7 @@ 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` \ + '{which('qlf_fasm')}' \ --db-root "${{SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"}}/fasm_database/${{DEVICE}}" \ --format "$BIT_FORMAT" \ --assemble \ @@ -273,7 +292,7 @@ if [ -z $BIT ]; then echo "Please provide an input bistream file name"; exit 1; 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" -`which python3` "`readlink -f ${{SHARE_DIR_PATH}}/scripts/fasm2bels.py`" "${{BIT}}" \ +'{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" \ 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 From 7b597d43cf8735d1e1f86e7e2b7b7064bf8bf8fc Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 22:21:23 +0200 Subject: [PATCH 19/34] f4pga/wrappers/sh: rm route.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 4 ++- f4pga/wrappers/sh/quicklogic/route.f4pga.sh | 28 --------------------- f4pga/wrappers/sh/xc7/route.f4pga.sh | 28 --------------------- 3 files changed, 3 insertions(+), 57 deletions(-) delete mode 100755 f4pga/wrappers/sh/quicklogic/route.f4pga.sh delete mode 100755 f4pga/wrappers/sh/xc7/route.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 81422f2..f57646e 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -89,7 +89,9 @@ def place(): def route(): print("[F4PGA] Running (deprecated) route") - run_sh_script(ROOT / SH_SUBDIR / "route.f4pga.sh") + 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)}") + Path('vpr_stdout.log').rename('route.log') def synth(): 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/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 From 68139d14db431a1ce39c7450370d327b5c0de09d Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 22:31:36 +0200 Subject: [PATCH 20/34] f4pga/wrappers/sh/xc7: rm write_bitstream.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 58 ++++++++++- .../wrappers/sh/xc7/write_bitstream.f4pga.sh | 95 ------------------- 2 files changed, 53 insertions(+), 100 deletions(-) delete mode 100755 f4pga/wrappers/sh/xc7/write_bitstream.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index f57646e..b2dcc84 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -99,11 +99,6 @@ def synth(): run_sh_script(ROOT / SH_SUBDIR / "synth.f4pga.sh") -def write_bitstream(): - print("[F4PGA] Running (deprecated) write bitstream") - run_sh_script(ROOT / SH_SUBDIR / "write_bitstream.f4pga.sh") - - def write_fasm(genfasm_extra_args = None): print("[F4PGA] Running (deprecated) write fasm") run_bash_cmds(vpr_common_cmds('fasm')+f""" @@ -141,6 +136,59 @@ def vpr_common(): run_sh_script(ROOT / SH_SUBDIR / "vpr_common.f4pga.sh") +# Xilinx only + +def write_bitstream(): + print("[F4PGA] Running (deprecated) write bitstream") + run_bash_cmds(f""" +set -e +echo "Writing bitstream ..." +FRM2BIT="" +if [ ! -z ${{FRAMES2BIT}} ]; then FRM2BIT="--frm2bit ${{FRAMES2BIT}}"; fi +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}} +""") + + # QuickLogic only def analysis(): 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} From 30a2aa5b540dedcb4a5b2a71ec4350c681071e6e Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 22:39:59 +0200 Subject: [PATCH 21/34] f4pga/wrappers/sh: remove unused function Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 11 ----------- test/test_wrappers.py | 1 - 2 files changed, 12 deletions(-) diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index b2dcc84..c69a11f 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -120,17 +120,6 @@ fi Path('vpr_stdout.log').rename('fasm.log') -def write_xml_rr_graph(): - print("[F4PGA] Running (deprecated) write xlm rr graph") - run_bash_cmds(vpr_common_cmds('place')+f""" -vpr ${{ARCH_DEF}} \ - ${{EBLIF}} \ - --read_rr_graph ${{RR_GRAPH}} \ - --write_rr_graph ${{RR_GRAPH_XML}} \ - --pack -""") - - def vpr_common(): print("[F4PGA] Running (deprecated) vpr common") run_sh_script(ROOT / SH_SUBDIR / "vpr_common.f4pga.sh") diff --git a/test/test_wrappers.py b/test/test_wrappers.py index 418a5b3..cad69ef 100644 --- a/test/test_wrappers.py +++ b/test/test_wrappers.py @@ -32,7 +32,6 @@ wrappers = [ 'symbiflow_synth', 'symbiflow_write_bitstream', 'symbiflow_write_fasm', - 'symbiflow_write_xml_rr_graph', 'vpr_common', 'symbiflow_analysis', 'symbiflow_repack', From dd52188179495472711fa34264bf121fb676feff Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 22:49:14 +0200 Subject: [PATCH 22/34] f4pga/wrappers/sh: rm place.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 29 ++++++++++- f4pga/wrappers/sh/quicklogic/place.f4pga.sh | 55 --------------------- f4pga/wrappers/sh/xc7/place.f4pga.sh | 38 -------------- 3 files changed, 28 insertions(+), 94 deletions(-) delete mode 100755 f4pga/wrappers/sh/quicklogic/place.f4pga.sh delete mode 100755 f4pga/wrappers/sh/xc7/place.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index c69a11f..81033fd 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -84,7 +84,34 @@ def pack(): def place(): print("[F4PGA] Running (deprecated) place") - run_sh_script(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 ..." + symbiflow_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 += """ +PCF=${PCF:=} +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' + run_bash_cmds(vpr_common_cmds('place')+place_cmds) + Path('vpr_stdout.log').rename('place.log') def route(): 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/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 From 66d69b237a1f340e63e2ae1c583dbdeb0c76cd5d Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 23:04:38 +0200 Subject: [PATCH 23/34] f4pga/wrappers/sh/xc7: rm generate_constraints.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 35 ++++++++++++- .../sh/xc7/generate_constraints.f4pga.sh | 51 ------------------- 2 files changed, 34 insertions(+), 52 deletions(-) delete mode 100755 f4pga/wrappers/sh/xc7/generate_constraints.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 81033fd..9cdb19c 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -72,7 +72,40 @@ export OUT_NOISY_WARNINGS=noisy_warnings-${{DEVICE}}_{log_suffix}.log def generate_constraints(): print("[F4PGA] Running (deprecated) generate constraints") - run_sh_script(ROOT / SH_SUBDIR / "generate_constraints.f4pga.sh") + if isQuickLogic: + run_sh_script(ROOT / SH_SUBDIR / "generate_constraints.f4pga.sh") + else: + (eblif, net, part, device, arch_def) = sys_argv[1:6] + pcf_opts = f"PCF_OPTS='--pcf {sys_argv[6]}'" if len(sys_argv) > 6 else '' + run_bash_cmds(f""" +set -e +EBLIF='{eblif}' +NET='{net}' +PART='{part}' +DEVICE='{device}' +ARCH_DEF='{arch_def}' +{pcf_opts} +""" + """ +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 +""") def pack(): 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 From 8dc2c180382504b11e630ae755d7875332d7adf2 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 23:12:01 +0200 Subject: [PATCH 24/34] f4pga/wrappers/sh: cleanup Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 68 ++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 9cdb19c..74974aa 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -161,20 +161,20 @@ def synth(): def write_fasm(genfasm_extra_args = None): print("[F4PGA] Running (deprecated) write fasm") - run_bash_cmds(vpr_common_cmds('fasm')+f""" -TOP="${{EBLIF%.*}}" -FASM_EXTRA="${{TOP}}_fasm_extra.fasm" - + run_bash_cmds(vpr_common_cmds('fasm')+""" +TOP="${EBLIF%.*}" +FASM_EXTRA="${TOP}_fasm_extra.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 ''} - +""" + """ 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 + cat ${TOP}.fasm $FASM_EXTRA > tmp.fasm + mv tmp.fasm ${TOP}.fasm fi """) Path('vpr_stdout.log').rename('fasm.log') @@ -189,17 +189,19 @@ def vpr_common(): def write_bitstream(): print("[F4PGA] Running (deprecated) write bitstream") - run_bash_cmds(f""" + run_bash_cmds(""" set -e echo "Writing bitstream ..." FRM2BIT="" -if [ ! -z ${{FRAMES2BIT}} ]; then FRM2BIT="--frm2bit ${{FRAMES2BIT}}"; fi +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="" @@ -213,28 +215,28 @@ while true; do --) break ;; esac done -DATABASE_DIR=${{DATABASE_DIR:=$(prjxray-config)}} +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]}}")) + 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}}` +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 \ + --db-root ${DBROOT} \ + --part ${PART} \ + --part_file ${DBROOT}/${PART}/part.yaml \ --sparse \ --emit_pudc_b_pullup \ - --fn_in ${{FASM}} \ - --bit_out ${{BIT}} ${{FRM2BIT}} + --fn_in ${FASM} \ + --bit_out ${BIT} ${FRM2BIT} """) @@ -242,7 +244,7 @@ xcfasm \ def analysis(): print("[F4PGA] Running (deprecated) analysis") - run_bash_cmds(vpr_common_cmds('analysis')+f""" + run_bash_cmds(vpr_common_cmds('analysis')+""" run_vpr \ --analysis \ --gen_post_synthesis_netlist on \ @@ -256,10 +258,11 @@ run_vpr \ def repack(): print("[F4PGA] Running (deprecated) repack") - run_bash_cmds(vpr_common_cmds()+f""" -DESIGN=${{EBLIF/.eblif/}} -[ ! -z "${{JSON}}" ] && JSON_ARGS="--json-constraints ${{JSON}}" || JSON_ARGS= -[ ! -z "${{PCF_PATH}}" ] && PCF_ARGS="--pcf-constraints ${{PCF_PATH}}" || PCF_ARGS= + run_bash_cmds(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 \ '{which('python3')}' "$F4PGA_SHARE_DIR"/scripts/repacker/repack.py \ --vpr-arch ${{ARCH_DEF}} \ @@ -287,6 +290,7 @@ eval set -- "$( --longoptions=device:,fasm:,format:,bit:,part: \ --name $0 -- {' '.join(sys_argv[1:])} )" +""" + """ DEVICE="" FASM="" BIT_FORMAT="4byte" @@ -305,6 +309,7 @@ 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 "${{SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"}}/fasm_database/${{DEVICE}}" \ @@ -338,8 +343,10 @@ if [[ '{device}' =~ ^(qlf_k4n8_qlf_k4n8)$ ]];then else DEVICE_1={device} fi -ARCH_DIR="$F4PGA_SHARE_DIR"/arch/${{DEVICE_1}}_${{DEVICE_1}} -PINMAP_XML=${{ARCH_DIR}}/${{PINMAPXML}} +""" + """ +ARCH_DIR="$F4PGA_SHARE_DIR"/arch/${DEVICE_1}_${DEVICE_1} +PINMAP_XML=${ARCH_DIR}/${PINMAPXML} +""" + f""" '{which('python3')}' "$F4PGA_SHARE_DIR"/scripts/create_lib.py \ -n "${{DEV}}_0P72_SSM40" \ -m fpga_top \ @@ -357,15 +364,17 @@ def ql(): def fasm2bels(): print("[F4PGA] Running (deprecated) fasm2bels") - run_bash_cmds(f""" + run_bash_cmds(""" set -e SHARE_DIR_PATH=${{SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"}} +""" + f""" 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="" @@ -388,9 +397,10 @@ 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 +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""" '{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-/}}" \ From 1c94ac60a6eb42a479859473ac1d23a624b50616 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 11 Aug 2022 00:02:02 +0200 Subject: [PATCH 25/34] f4pga/wrappers/sh/vpr_common: style Signed-off-by: Unai Martinez-Corral --- .../sh/quicklogic/vpr_common.f4pga.sh | 116 ++++++++---------- f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh | 108 ++++++++-------- 2 files changed, 100 insertions(+), 124 deletions(-) diff --git a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh index f4b26fa..7b864d1 100755 --- a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh @@ -30,24 +30,22 @@ fi function parse_args { - OPTS=d:f:e:p:n:P:j:s:t:c: - LONGOPTS=device:,eblif:,pcf:,net:,part:,json:,sdc:,top:,corner: - - PARSED_OPTS=`getopt --options=${OPTS} --longoptions=${LONGOPTS} --name $0 -- $@` - eval set -- ${PARSED_OPTS} - + 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="" - DEVICE_NAME="" - PART="" EBLIF="" PCF="" NET="" - SDC="" + PART="" JSON="" + SDC="" TOP="top" CORNER="" - while true; do case "$1" in -d|--device) DEVICE=$2; shift 2 ;; @@ -63,55 +61,19 @@ function parse_args { --) 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 - 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} + 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 [[ "$DEVICE" == "qlf_k4n8_qlf_k4n8" ]]; then VPR_OPTIONS="$VPR_OPTIONS @@ -141,6 +103,30 @@ function parse_args { --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 + + 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 + + DEVICE_ARCH="${DEVICE_1}_${DEVICE_2}" + export ARCH_DIR=`realpath ${SHARE_DIR_PATH}/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 ROUTE_DELAY="${ARCH_RR_PREFIX}".lookahead.bin + export DEVICE_NAME="$DEVICE_1" } function run_vpr { @@ -151,14 +137,14 @@ function run_vpr { SDC_OPTIONS="--sdc_file $SDC" fi - "`which vpr`" ${ARCH_DEF} \ + "`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} \ + --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/xc7/vpr_common.f4pga.sh b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh index 843593a..9f7ae54 100755 --- a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh @@ -50,65 +50,55 @@ fi function parse_args { - 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 + 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 + 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 - 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 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'` + 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 DEVICE_NAME=`echo "$DEVICE" | sed -n 's/_/-/p'` } function run_vpr { @@ -120,15 +110,15 @@ function run_vpr { 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} \ + 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 $? + return $? } From 77ea3b96ae48632f438e5ce3942eb090f3fb94bd Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 11 Aug 2022 00:31:49 +0200 Subject: [PATCH 26/34] 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 $? -} From b33e80dbb670d23193b3ad64778e0759bd97affe Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 11 Aug 2022 01:38:55 +0200 Subject: [PATCH 27/34] f4pga/wrappers/sh/vpr_run: convert to Python only Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 127 +++++++++++++++++++++++----------- f4pga/wrappers/sh/vpr_run.py | 4 +- 2 files changed, 90 insertions(+), 41 deletions(-) diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 42cf1d7..e98ac83 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -43,22 +43,26 @@ f4pga_environ['F4PGA_SHARE_DIR'] = f4pga_environ.get('F4PGA_SHARE_DIR', str(F4PG # Helper functions -def run_sh_script(script): + +def p_run_sh_script(script): stdout.flush() stderr.flush() check_call([str(script)]+sys_argv[1:], env=f4pga_environ) -def run_bash_cmds(cmds): + +def p_run_bash_cmds(cmds): stdout.flush() stderr.flush() check_call(cmds, env=f4pga_environ, shell=True, executable='/bin/bash') -def run_pym(module): + +def p_run_pym(module): stdout.flush() stderr.flush() check_call([which('python3'), '-m' , module]+sys_argv[1:], env=f4pga_environ) -def vpr_common_cmds(log_suffix = None): + +def p_vpr_common_cmds(log_suffix = None): return f""" set -e source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh @@ -68,16 +72,75 @@ 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') + + 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") if isQuickLogic: - run_sh_script(ROOT / SH_SUBDIR / "generate_constraints.f4pga.sh") + p_run_sh_script(ROOT / SH_SUBDIR / "generate_constraints.f4pga.sh") else: (eblif, net, part, device, arch_def) = sys_argv[1:6] pcf_opts = f"PCF_OPTS='--pcf {sys_argv[6]}'" if len(sys_argv) > 6 else '' - run_bash_cmds(f""" + p_run_bash_cmds(f""" set -e EBLIF='{eblif}' NET='{net}' @@ -111,7 +174,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"python3 -m f4pga.wrappers.sh.vpr_run --pack {' '.join(extra_args)}") + 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') @@ -143,25 +206,25 @@ symbiflow_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' - run_bash_cmds(vpr_common_cmds('place')+place_cmds) + 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") extra_args = ['--write_timing_summary', 'timing_summary.json'] if isQuickLogic else [] - run_bash_cmds(vpr_common_cmds('pack')+f"python3 -m f4pga.wrappers.sh.vpr_run --route {' '.join(extra_args)}") + 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_script(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") - run_bash_cmds(vpr_common_cmds('fasm')+""" + p_run_bash_cmds(p_vpr_common_cmds('fasm')+""" TOP="${EBLIF%.*}" FASM_EXTRA="${TOP}_fasm_extra.fasm" """ + f""" @@ -182,30 +245,15 @@ fi def vpr_common(): print("[F4PGA] Running (deprecated) 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:])}") + p_run_sh_script(ROOT / SH_SUBDIR / "vpr_common.f4pga.sh") # Xilinx only + def write_bitstream(): print("[F4PGA] Running (deprecated) write bitstream") - run_bash_cmds(""" + p_run_bash_cmds(""" set -e echo "Writing bitstream ..." FRM2BIT="" @@ -258,9 +306,10 @@ xcfasm \ # QuickLogic only + def analysis(): print("[F4PGA] Running (deprecated) analysis") - run_bash_cmds(vpr_common_cmds('analysis')+""" + p_run_bash_cmds(p_vpr_common_cmds('analysis')+""" python3 -m f4pga.wrappers.sh.vpr_run \ --analysis \ --gen_post_synthesis_netlist on \ @@ -274,7 +323,7 @@ python3 -m f4pga.wrappers.sh.vpr_run \ def repack(): print("[F4PGA] Running (deprecated) repack") - run_bash_cmds(vpr_common_cmds()+""" + 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= @@ -298,7 +347,7 @@ PYTHONPATH=$F4PGA_SHARE_DIR/scripts:$PYTHONPATH \ def generate_bitstream(): print("[F4PGA] Running (deprecated) generate_bitstream") - run_bash_cmds(f""" + p_run_bash_cmds(f""" set -e eval set -- "$( getopt \ @@ -349,7 +398,7 @@ fi def generate_libfile(): print("[F4PGA] Running (deprecated) generate_libfile") (part, device, corner) = sys_argv[1:4] - run_bash_cmds(f""" + p_run_bash_cmds(f""" set -e if [[ '{device}' =~ ^(qlf_k4n8_qlf_k4n8)$ ]];then DEVICE_1="qlf_k4n8-qlf_k4n8_umc22_{corner}" @@ -375,12 +424,12 @@ PINMAP_XML=${ARCH_DIR}/${PINMAPXML} def ql(): print("[F4PGA] Running (deprecated) ql") - run_sh_script(ROOT / "quicklogic/ql.f4pga.sh") + p_run_sh_script(ROOT / "quicklogic/ql.f4pga.sh") def fasm2bels(): print("[F4PGA] Running (deprecated) fasm2bels") - run_bash_cmds(""" + p_run_bash_cmds(""" set -e SHARE_DIR_PATH=${{SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"}} """ + f""" @@ -432,19 +481,19 @@ echo "Running fasm2bels" 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/vpr_run.py b/f4pga/wrappers/sh/vpr_run.py index 3647c2c..0d325a8 100644 --- a/f4pga/wrappers/sh/vpr_run.py +++ b/f4pga/wrappers/sh/vpr_run.py @@ -17,7 +17,7 @@ # # SPDX-License-Identifier: Apache-2.0 -from f4pga.wrappers.sh import vpr_run +from f4pga.wrappers.sh import p_vpr_run if __name__ == '__main__': - vpr_run() + p_vpr_run() From 3ae5760017a595cf48d55be5b7dee1177dd602dc Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 11 Aug 2022 02:27:53 +0200 Subject: [PATCH 28/34] f4pga/wrappers/sh/generate_constraints: cleanup; rm symbiflow_generate_constraints Signed-off-by: Unai Martinez-Corral --- f4pga/setup.py | 1 - f4pga/wrappers/sh/__init__.py | 46 +++++++++-------------- f4pga/wrappers/sh/generate_constraints.py | 23 ++++++++++++ 3 files changed, 41 insertions(+), 29 deletions(-) create mode 100644 f4pga/wrappers/sh/generate_constraints.py diff --git a/f4pga/setup.py b/f4pga/setup.py index 50a65cf..50dad88 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", diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index e98ac83..a4a15d5 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -139,34 +139,24 @@ def generate_constraints(): p_run_sh_script(ROOT / SH_SUBDIR / "generate_constraints.f4pga.sh") else: (eblif, net, part, device, arch_def) = sys_argv[1:6] - pcf_opts = f"PCF_OPTS='--pcf {sys_argv[6]}'" if len(sys_argv) > 6 else '' + 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 -EBLIF='{eblif}' -NET='{net}' -PART='{part}' -DEVICE='{device}' -ARCH_DEF='{arch_def}' -{pcf_opts} -""" + """ -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" \ +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 """) @@ -191,7 +181,7 @@ PROJECT="${PROJECT%.*}" VPR_PLACE_FILE="${PROJECT}_constraints.place" if [ -s $PCF ]; then echo "Generating constraints ..." - symbiflow_generate_constraints $PCF $EBLIF $NET $PART $DEVICE $ARCH_DEF $CORNER + 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 @@ -202,7 +192,7 @@ fi place_cmds += """ PCF=${PCF:=} echo "Generating constrains ..." -symbiflow_generate_constraints $EBLIF $NET $PART $DEVICE $ARCH_DEF $PCF +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' diff --git a/f4pga/wrappers/sh/generate_constraints.py b/f4pga/wrappers/sh/generate_constraints.py new file mode 100644 index 0000000..58e6a90 --- /dev/null +++ b/f4pga/wrappers/sh/generate_constraints.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 generate_constraints + +if __name__ == '__main__': + generate_constraints() From a6f4fbd481f8c022914c2ffbffaf6e0c9a043518 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 11 Aug 2022 02:47:15 +0200 Subject: [PATCH 29/34] f4pga/wrappers/sh/quicklogic: rm generate_constraints.f4pga.sh Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 88 ++++++++++++++++- .../quicklogic/generate_constraints.f4pga.sh | 99 ------------------- 2 files changed, 83 insertions(+), 104 deletions(-) delete mode 100755 f4pga/wrappers/sh/quicklogic/generate_constraints.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index a4a15d5..a05bebb 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') @@ -59,7 +63,7 @@ def p_run_bash_cmds(cmds): def p_run_pym(module): stdout.flush() stderr.flush() - check_call([which('python3'), '-m' , module]+sys_argv[1:], env=f4pga_environ) + check_call([python3, '-m' , module]+sys_argv[1:], env=f4pga_environ) def p_vpr_common_cmds(log_suffix = None): @@ -136,7 +140,81 @@ def p_vpr_run(): def generate_constraints(): print("[F4PGA] Running (deprecated) generate constraints") if isQuickLogic: - p_run_sh_script(ROOT / SH_SUBDIR / "generate_constraints.f4pga.sh") + (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 '' @@ -319,7 +397,7 @@ DESIGN=${EBLIF/.eblif/} [ ! -z "${PCF_PATH}" ] && PCF_ARGS="--pcf-constraints ${PCF_PATH}" || PCF_ARGS= """ + f""" PYTHONPATH=$F4PGA_SHARE_DIR/scripts:$PYTHONPATH \ - '{which('python3')}' "$F4PGA_SHARE_DIR"/scripts/repacker/repack.py \ + '{python3}' "$F4PGA_SHARE_DIR"/scripts/repacker/repack.py \ --vpr-arch ${{ARCH_DEF}} \ --repacking-rules ${{ARCH_DIR}}/${{DEVICE_1}}.repacking_rules.json \ $JSON_ARGS \ @@ -402,7 +480,7 @@ fi ARCH_DIR="$F4PGA_SHARE_DIR"/arch/${DEVICE_1}_${DEVICE_1} PINMAP_XML=${ARCH_DIR}/${PINMAPXML} """ + f""" -'{which('python3')}' "$F4PGA_SHARE_DIR"/scripts/create_lib.py \ +'{python3}' "$F4PGA_SHARE_DIR"/scripts/create_lib.py \ -n "${{DEV}}_0P72_SSM40" \ -m fpga_top \ -c '{part}' \ @@ -456,7 +534,7 @@ if ! [[ "$DEVICE" =~ ^(ql-eos-s3|ql-pp3e)$ ]]; then echo "ERROR: Unsupported dev if [ -z "{PCF}" ]; then PCF_ARGS=""; else PCF_ARGS="--input-pcf ${PCF}"; fi echo "Running fasm2bels" """ + f""" -'{which('python3')}' "`readlink -f ${{SHARE_DIR_PATH}}/scripts/fasm2bels.py`" "${{BIT}}" \ +'{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" \ 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 From 9dc9d6cb987ed8a03359dde3f94713465858396f Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 11 Aug 2022 05:31:04 +0200 Subject: [PATCH 30/34] f4pga/wrappers/sh: cleanup Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 30 ++-- f4pga/wrappers/sh/quicklogic/ql.f4pga.sh | 159 ++++++------------ f4pga/wrappers/sh/quicklogic/synth.f4pga.sh | 2 +- .../sh/quicklogic/vpr_common.f4pga.sh | 2 +- f4pga/wrappers/sh/xc7/synth.f4pga.sh | 4 +- f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh | 2 +- 6 files changed, 67 insertions(+), 132 deletions(-) diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index a05bebb..862e7c3 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -234,7 +234,7 @@ python3 '{share_dir}'/scripts/prjxray_create_place_constraints.py \ --part '{part}' \ --vpr_grid_map '{share_dir}/arch/{device}/vpr_grid_map.csv' \ --input '{ioplace_file}' \ - --db_root "${{DATABASE_DIR:=$(prjxray-config)}}" \ + --db_root "${{DATABASE_DIR:-$(prjxray-config)}}" \ > constraints.place """) @@ -268,7 +268,6 @@ fi """ else: place_cmds += """ -PCF=${PCF:=} echo "Generating constrains ..." python3 -m f4pga.wrappers.sh.generate_constraints $EBLIF $NET $PART $DEVICE $ARCH_DEF $PCF VPR_PLACE_FILE='constraints.place' @@ -292,20 +291,17 @@ def synth(): def write_fasm(genfasm_extra_args = None): print("[F4PGA] Running (deprecated) write fasm") - p_run_bash_cmds(p_vpr_common_cmds('fasm')+""" -TOP="${EBLIF%.*}" -FASM_EXTRA="${TOP}_fasm_extra.fasm" -""" + f""" + 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 ''} """ + """ -echo "FASM extra: $FASM_EXTRA" +TOP="${EBLIF%.*}" +FASM_EXTRA="${TOP}_fasm_extra.fasm" if [ -f $FASM_EXTRA ]; then - echo "writing final fasm" - cat ${TOP}.fasm $FASM_EXTRA > tmp.fasm - mv tmp.fasm ${TOP}.fasm + echo "writing final fasm (extra: $FASM_EXTRA)" + cat $FASM_EXTRA >> ${TOP}.fasm fi """) Path('vpr_stdout.log').rename('fasm.log') @@ -347,7 +343,7 @@ while true; do --) break ;; esac done -DATABASE_DIR=${DATABASE_DIR:=$(prjxray-config)} +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}) @@ -445,7 +441,7 @@ if [ -z $BIT ]; then echo "Please provide an output bistream file name"; exit 1; """ + f""" if [[ "$DEVICE" =~ ^(qlf_k4n8.*)$ ]]; then '{which('qlf_fasm')}' \ - --db-root "${{SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"}}/fasm_database/${{DEVICE}}" \ + --db-root "${{F4PGA_SHARE_DIR}}/fasm_database/${{DEVICE}}" \ --format "$BIT_FORMAT" \ --assemble \ "$FASM" \ @@ -477,7 +473,7 @@ else DEVICE_1={device} fi """ + """ -ARCH_DIR="$F4PGA_SHARE_DIR"/arch/${DEVICE_1}_${DEVICE_1} +ARCH_DIR="${F4PGA_SHARE_DIR}/arch/${DEVICE_1}_${DEVICE_1}" PINMAP_XML=${ARCH_DIR}/${PINMAPXML} """ + f""" '{python3}' "$F4PGA_SHARE_DIR"/scripts/create_lib.py \ @@ -497,10 +493,8 @@ def ql(): def fasm2bels(): print("[F4PGA] Running (deprecated) fasm2bels") - p_run_bash_cmds(""" + p_run_bash_cmds(f""" set -e -SHARE_DIR_PATH=${{SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"}} -""" + f""" eval set -- "$( getopt \ --options=d:P:p:b:v:o:q \ @@ -534,8 +528,8 @@ if ! [[ "$DEVICE" =~ ^(ql-eos-s3|ql-pp3e)$ ]]; then echo "ERROR: Unsupported dev if [ -z "{PCF}" ]; then PCF_ARGS=""; else PCF_ARGS="--input-pcf ${PCF}"; fi echo "Running fasm2bels" """ + f""" -'{python3}' "`readlink -f ${{SHARE_DIR_PATH}}/scripts/fasm2bels.py`" "${{BIT}}" \ - --phy-db "`readlink -f ${{SHARE_DIR_PATH}}/arch/${{DEVICE}}_wlcsp/db_phy.pickle`" \ +'{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 \ diff --git a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh index d008f31..b453032 100755 --- a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh @@ -18,7 +18,7 @@ set -e -SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} +SHARE_DIR_PATH=${SHARE_DIR_PATH:-"$F4PGA_SHARE_DIR"} source $(dirname "$0")/vpr_common.f4pga.sh @@ -88,62 +88,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 +120,47 @@ 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" +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 + if [[ $1 != "-h" || $1 != "--help" ]];then + echo "Please provide at least one Verilog file" 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 +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 + if [[ $1 == "-compile" || $1 == "-post_verilog" ]]; then if [ -z "$DEVICE" ]; then echo "DEVICE name is missing. Refer -h/--help" @@ -344,9 +285,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} diff --git a/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh b/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh index b872413..1d19fd8 100755 --- a/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh @@ -18,7 +18,7 @@ set -e -export SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} +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` diff --git a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh index 07a9161..4c0a59a 100755 --- a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh @@ -16,7 +16,7 @@ # # SPDX-License-Identifier: Apache-2.0 -SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} +SHARE_DIR_PATH=${SHARE_DIR_PATH:-"$F4PGA_SHARE_DIR"} if [ -z $VPR_OPTIONS ]; then echo "Using default VPR options." diff --git a/f4pga/wrappers/sh/xc7/synth.f4pga.sh b/f4pga/wrappers/sh/xc7/synth.f4pga.sh index 9ba3709..37a5440 100755 --- a/f4pga/wrappers/sh/xc7/synth.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/synth.f4pga.sh @@ -118,7 +118,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 +130,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 8214c63..fa81a13 100755 --- a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh @@ -16,7 +16,7 @@ # # SPDX-License-Identifier: Apache-2.0 -SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_SHARE_DIR"} +SHARE_DIR_PATH=${SHARE_DIR_PATH:-"$F4PGA_SHARE_DIR"} if [ -z $VPR_OPTIONS ]; then echo "Using default VPR options." From 6dc738fd3da3be2ff2e2b950c14c17b8cc327bc0 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 11 Aug 2022 06:14:51 +0200 Subject: [PATCH 31/34] f4pga/setup: rm vpr_common Signed-off-by: Unai Martinez-Corral --- f4pga/setup.py | 1 - f4pga/wrappers/sh/__init__.py | 5 ----- test/test_wrappers.py | 1 - 3 files changed, 7 deletions(-) diff --git a/f4pga/setup.py b/f4pga/setup.py index 50dad88..99dd82c 100644 --- a/f4pga/setup.py +++ b/f4pga/setup.py @@ -120,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 862e7c3..1642806 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -307,11 +307,6 @@ fi Path('vpr_stdout.log').rename('fasm.log') -def vpr_common(): - print("[F4PGA] Running (deprecated) vpr common") - p_run_sh_script(ROOT / SH_SUBDIR / "vpr_common.f4pga.sh") - - # Xilinx only diff --git a/test/test_wrappers.py b/test/test_wrappers.py index cad69ef..d0d2ec7 100644 --- a/test/test_wrappers.py +++ b/test/test_wrappers.py @@ -32,7 +32,6 @@ wrappers = [ 'symbiflow_synth', 'symbiflow_write_bitstream', 'symbiflow_write_fasm', - 'vpr_common', 'symbiflow_analysis', 'symbiflow_repack', 'symbiflow_generate_bitstream', From 453fffea4ef08cbc4232343a7e0be78662146019 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 11 Aug 2022 06:03:21 +0200 Subject: [PATCH 32/34] f4pga/wrappers/sh: cleanup Signed-off-by: Unai Martinez-Corral --- f4pga/platforms/ql-eos-s3.json | 1 - f4pga/wrappers/sh/__init__.py | 4 +++- f4pga/wrappers/sh/quicklogic/ql.f4pga.sh | 10 +++------- f4pga/wrappers/sh/quicklogic/synth.f4pga.sh | 17 ++++++++--------- .../wrappers/sh/quicklogic/vpr_common.f4pga.sh | 4 +--- f4pga/wrappers/sh/xc7/synth.f4pga.sh | 5 ++--- f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh | 14 ++++++-------- 7 files changed, 23 insertions(+), 32 deletions(-) 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/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 1642806..e80ea51 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -70,7 +70,7 @@ def p_vpr_common_cmds(log_suffix = None): return f""" set -e source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh -parse_args {' '.join(sys_argv[1:])} +parse_args {' '.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 '') @@ -112,6 +112,8 @@ def p_vpr_run(): raise(Exception('[F4PGA] vpr run: envvar PLACE_DELAY cannot be unset/empty!')) sdc = f4pga_environ.get('SDC') + if sdc == '': + sdc = None check_call( [ diff --git a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh index b453032..e7c8d30 100755 --- a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh @@ -18,8 +18,6 @@ set -e -SHARE_DIR_PATH=${SHARE_DIR_PATH:-"$F4PGA_SHARE_DIR"} - source $(dirname "$0")/vpr_common.f4pga.sh VERSION="v2.0.1" @@ -196,10 +194,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 @@ -302,7 +298,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/synth.f4pga.sh b/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh index 1d19fd8..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 4c0a59a..7b792a6 100755 --- a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh @@ -16,8 +16,6 @@ # # SPDX-License-Identifier: Apache-2.0 -SHARE_DIR_PATH=${SHARE_DIR_PATH:-"$F4PGA_SHARE_DIR"} - if [ -z $VPR_OPTIONS ]; then echo "Using default VPR options." VPR_OPTIONS=" @@ -118,7 +116,7 @@ function parse_args { fi DEVICE_ARCH="${DEVICE_1}_${DEVICE_2}" - export ARCH_DIR=`realpath ${SHARE_DIR_PATH}/arch/${DEVICE_ARCH}` + 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. diff --git a/f4pga/wrappers/sh/xc7/synth.f4pga.sh b/f4pga/wrappers/sh/xc7/synth.f4pga.sh index 37a5440..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=() diff --git a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh index fa81a13..3646ed1 100755 --- a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh @@ -16,9 +16,7 @@ # # SPDX-License-Identifier: Apache-2.0 -SHARE_DIR_PATH=${SHARE_DIR_PATH:-"$F4PGA_SHARE_DIR"} - -if [ -z $VPR_OPTIONS ]; then +if [ -z "$VPR_OPTIONS" ]; then echo "Using default VPR options." VPR_OPTIONS=" --max_router_iterations 500 @@ -76,13 +74,13 @@ function parse_args { esac done - if [ -z $DEVICE ] && [ -n $PART ]; then + 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}) + 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 + 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" @@ -91,7 +89,7 @@ function parse_args { export SDC="$SDC" export VPR_OPTIONS="$VPR_OPTIONS $ADDITIONAL_VPR_OPTIONS" - export ARCH_DIR=`realpath ${SHARE_DIR_PATH}/arch/$DEVICE` + 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 From cb7f555511c44ff5f61d32a3f99caebb027f01a1 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 11 Aug 2022 15:06:43 +0200 Subject: [PATCH 33/34] f4pga/wrappers/sh/quicklogic/ql: remove redundant condition Co-Authored-By: Pawel Czarnecki Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/quicklogic/ql.f4pga.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh index e7c8d30..f30f915 100755 --- a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh @@ -147,17 +147,15 @@ echo "$VERILOG_FILES" >${SOURCE}/v_list ## 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` + 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 From e0ffd4e0942817a62713b13ba8812ff4b8eb0fba Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Sat, 13 Aug 2022 19:27:03 +0200 Subject: [PATCH 34/34] f4pga/wrappers/sh/vpr_common: remove function parse_args Signed-off-by: Unai Martinez-Corral --- f4pga/wrappers/sh/__init__.py | 3 +- f4pga/wrappers/sh/quicklogic/ql.f4pga.sh | 2 - .../sh/quicklogic/vpr_common.f4pga.sh | 192 +++++++++--------- f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh | 100 +++++---- 4 files changed, 144 insertions(+), 153 deletions(-) diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index e80ea51..8ed200d 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -69,8 +69,7 @@ def p_run_pym(module): def p_vpr_common_cmds(log_suffix = None): return f""" set -e -source {ROOT / SH_SUBDIR}/vpr_common.f4pga.sh -parse_args {' '.join([f"'{arg}'" for arg in sys_argv[1:]])} +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 '') diff --git a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh index f30f915..cbbcb8b 100755 --- a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh @@ -18,8 +18,6 @@ set -e -source $(dirname "$0")/vpr_common.f4pga.sh - VERSION="v2.0.1" if [ ! -n $1 ]; then diff --git a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh index 7b792a6..4e06f2d 100755 --- a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh @@ -16,6 +16,51 @@ # # SPDX-License-Identifier: Apache-2.0 +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." VPR_OPTIONS=" @@ -26,105 +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" - 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 +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 - 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" +export VPR_OPTIONS="$VPR_OPTIONS" - 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 +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 VPR_OPTIONS="$VPR_OPTIONS" - - 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 - - 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" -} +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/xc7/vpr_common.f4pga.sh b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh index 3646ed1..2382a7f 100755 --- a/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/vpr_common.f4pga.sh @@ -16,6 +16,46 @@ # # SPDX-License-Identifier: Apache-2.0 +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=(${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=" @@ -46,55 +86,13 @@ if [ -z "$VPR_OPTIONS" ]; then " 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=(${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" - export VPR_OPTIONS="$VPR_OPTIONS $ADDITIONAL_VPR_OPTIONS" - - 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'` -} +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'`