From 5d0642249dd10d662a973e127f55840e7061ef2d Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 21:51:53 +0200 Subject: [PATCH] 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}"