From dab5de2d1fbb771190aba1e839c091176c548ec8 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 21:40:16 +0200 Subject: [PATCH] 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