diff --git a/.github/scripts/activate.sh b/.github/scripts/activate.sh index a15fb66..13782a1 100755 --- a/.github/scripts/activate.sh +++ b/.github/scripts/activate.sh @@ -18,14 +18,14 @@ set -e -F4PGA_FAM=${F4PGA_FAM:=xc7} +FPGA_FAM=${FPGA_FAM:=xc7} -case "$F4PGA_FAM" in +case "$FPGA_FAM" in xc7) F4PGA_DIR_ROOT='install';; eos-s3) F4PGA_DIR_ROOT='quicklogic-arch-defs';; esac -export PATH="$F4PGA_INSTALL_DIR/$F4PGA_FAM/$F4PGA_DIR_ROOT/bin:$PATH" -source "$F4PGA_INSTALL_DIR/$F4PGA_FAM/conda/etc/profile.d/conda.sh" +export PATH="$F4PGA_INSTALL_DIR/$FPGA_FAM/$F4PGA_DIR_ROOT/bin:$PATH" +source "$F4PGA_INSTALL_DIR/$FPGA_FAM/conda/etc/profile.d/conda.sh" -conda activate $F4PGA_FAM +conda activate $FPGA_FAM diff --git a/.github/scripts/prepare_environment.sh b/.github/scripts/prepare_environment.sh index 1fd78f8..1d26c3e 100755 --- a/.github/scripts/prepare_environment.sh +++ b/.github/scripts/prepare_environment.sh @@ -28,12 +28,12 @@ cd f4pga-examples echo '::endgroup::' -F4PGA_FAM=${F4PGA_FAM:=xc7} +FPGA_FAM=${FPGA_FAM:=xc7} echo '::group::Install Miniconda3' wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O conda_installer.sh -F4PGA_INSTALL_DIR_FAM="$F4PGA_INSTALL_DIR/$F4PGA_FAM" +F4PGA_INSTALL_DIR_FAM="$F4PGA_INSTALL_DIR/$FPGA_FAM" bash conda_installer.sh -u -b -p "$F4PGA_INSTALL_DIR_FAM"/conda source "$F4PGA_INSTALL_DIR_FAM"/conda/etc/profile.d/conda.sh @@ -41,19 +41,19 @@ echo '::endgroup::' echo '::group::Create environment' -conda env create -f "$F4PGA_FAM"/environment.yml +conda env create -f "$FPGA_FAM"/environment.yml echo '::endgroup::' echo '::group::Install arch-defs' -case "$F4PGA_FAM" in +case "$FPGA_FAM" in xc7) mkdir -p "$F4PGA_INSTALL_DIR_FAM"/install wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/535/20220128-000432/symbiflow-arch-defs-install-5fa5e715.tar.xz | tar -xJC $F4PGA_INSTALL_DIR/xc7/install wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/535/20220128-000432/symbiflow-arch-defs-xc7a50t_test-5fa5e715.tar.xz | tar -xJC $F4PGA_INSTALL_DIR/xc7/install ;; eos-s3) - wget -qO- https://storage.googleapis.com/symbiflow-arch-defs-install/quicklogic-arch-defs-63c3d8f9.tar.gz | tar -xz -C $F4PGA_INSTALL_DIR_FAM + wget -qO- https://storage.googleapis.com/symbiflow-arch-defs-install/quicklogic-arch-defs-qlf-fc5d8da.tar.gz | tar -xz -C $F4PGA_INSTALL_DIR_FAM ;; esac echo '::endgroup::' @@ -64,7 +64,7 @@ cd .. echo '::group::Add f4pga-env' -case "$F4PGA_FAM" in +case "$FPGA_FAM" in xc7) F4PGA_DIR_ROOT='install';; eos-s3) F4PGA_DIR_ROOT='quicklogic-arch-defs';; esac @@ -78,7 +78,7 @@ echo '::group::🗑️ Remove the wrappers (pre-packaged from arch-defs)' cd "$F4PGA_DIR_BIN" -case "$F4PGA_FAM" in +case "$FPGA_FAM" in xc7) rm -vrf \ env \ diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml index a3a3c86..e2c5ca0 100644 --- a/.github/workflows/Pipeline.yml +++ b/.github/workflows/Pipeline.yml @@ -88,7 +88,7 @@ jobs: name: '🚦 Example (deprecated sh) | ${{ matrix.fam }}' env: F4PGA_INSTALL_DIR: /opt/f4pga - F4PGA_FAM: ${{ matrix.fam }} + FPGA_FAM: ${{ matrix.fam }} steps: @@ -149,7 +149,7 @@ jobs: name: '🐍 Example | xc7' env: F4PGA_INSTALL_DIR: /opt/f4pga - F4PGA_FAM: xc7 + FPGA_FAM: xc7 steps: @@ -187,7 +187,7 @@ jobs: name: '🐍 PYTHONPATH' env: F4PGA_INSTALL_DIR: /opt/f4pga - F4PGA_FAM: xc7 + FPGA_FAM: xc7 steps: @@ -205,7 +205,7 @@ jobs: name: '🐍 Python wrappers' env: F4PGA_INSTALL_DIR: /opt/f4pga - F4PGA_FAM: xc7 + FPGA_FAM: xc7 steps: diff --git a/f4pga-env b/f4pga-env index 246bb24..40b5026 100755 --- a/f4pga-env +++ b/f4pga-env @@ -11,10 +11,7 @@ case "$1" in ;; share) ( - case "$F4PGA_FAM" in - xc7) cd $(dirname "$0")/../share/symbiflow;; - eos-s3) cd $(dirname "$0")/../share;; - esac + cd $(dirname "$0")/../share/symbiflow pwd ) ;; diff --git a/f4pga/setup.py b/f4pga/setup.py index 59c62d2..21d20d8 100644 --- a/f4pga/setup.py +++ b/f4pga/setup.py @@ -23,7 +23,7 @@ from typing import List from setuptools import setup as setuptools_setup from os import environ -F4PGA_FAM = environ.get('F4PGA_FAM', 'xc7') +FPGA_FAM = environ.get('FPGA_FAM', 'xc7') packagePath = Path(__file__).resolve().parent @@ -61,13 +61,23 @@ wrapper_entrypoints = [ f"{sf}_synth = {shwrappers}:synth", f"{sf}_write_bitstream = {shwrappers}:write_bitstream", f"{sf}_write_fasm = {shwrappers}:write_fasm", -] if F4PGA_FAM == 'xc7' else [ +] if FPGA_FAM == 'xc7' else [ + f"{sf}_synth = {shwrappers}:synth", f"{sf}_pack = {shwrappers}:pack", + f"{sf}_repack = {shwrappers}:repack", f"{sf}_place = {shwrappers}:place", f"{sf}_route = {shwrappers}:route", f"{sf}_write_fasm = {shwrappers}:write_fasm", + f"{sf}_generate_bitstream = {shwrappers}:generate_bitstream", + f"{sf}_generate_constraints = {shwrappers}:generate_constraints", + f"{sf}_analysis = {shwrappers}:analysis", + f"{sf}_fasm2bels = {shwrappers}:fasm2bels", + f"ql_{sf} = {shwrappers}:ql", + f"vpr_common = {shwrappers}:vpr_common", ] + + setuptools_setup( name=packagePath.name, version="0.0.0", diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index fc59c3e..63a0663 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -28,17 +28,17 @@ from subprocess import check_call f4pga_environ = environ.copy() ROOT = Path(__file__).resolve().parent -F4PGA_FAM = f4pga_environ.get('F4PGA_FAM', 'xc7') -isQuickLogic = F4PGA_FAM == 'eos-s3' -SH_SUBDIR = 'quicklogic' if isQuickLogic else F4PGA_FAM +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') if F4PGA_INSTALL_DIR is None: raise(Exception("Required environment variable F4PGA_INSTALL_DIR is undefined!")) F4PGA_INSTALL_DIR_PATH = Path(F4PGA_INSTALL_DIR) -f4pga_environ['F4PGA_ENV_BIN'] = f4pga_environ.get('F4PGA_ENV_BIN', str(F4PGA_INSTALL_DIR_PATH / F4PGA_FAM / 'conda/bin')) -f4pga_environ['F4PGA_ENV_SHARE'] = f4pga_environ.get('F4PGA_ENV_SHARE', str(F4PGA_INSTALL_DIR_PATH / F4PGA_FAM / ( +f4pga_environ['F4PGA_ENV_BIN'] = f4pga_environ.get('F4PGA_ENV_BIN', str(F4PGA_INSTALL_DIR_PATH / FPGA_FAM / 'conda/bin')) +f4pga_environ['F4PGA_ENV_SHARE'] = f4pga_environ.get('F4PGA_ENV_SHARE', str(F4PGA_INSTALL_DIR_PATH / FPGA_FAM / ( 'share' if isQuickLogic else 'install/share/symbiflow' ))) @@ -117,3 +117,8 @@ def generate_libfile(): def ql(): print("[F4PGA] Running (deprecated) ql") run_sh(ROOT / "quicklogic/ql.f4pga.sh") + + +def fasm2bels(): + print("[F4PGA] Running (deprecated) fasm2bels") + run_sh(ROOT / "quicklogic/fasm2bels.f4pga.sh") diff --git a/f4pga/wrappers/sh/quicklogic/analysis.f4pga.sh b/f4pga/wrappers/sh/quicklogic/analysis.f4pga.sh index 78ed5ba..136b1ab 100755 --- a/f4pga/wrappers/sh/quicklogic/analysis.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/analysis.f4pga.sh @@ -20,21 +20,14 @@ set -e if [ -z $VPRPATH ]; then export VPRPATH="$F4PGA_ENV_BIN" - export PYTHONPATH=${VPRPATH}/python:${VPRPATH}/python/prjxray:${PYTHONPATH} + export PYTHONPATH=${VPRPATH}/python:${PYTHONPATH} fi -source ${VPRPATH}/vpr_common +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 --verify_file_digests off +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 - -python3 "$F4PGA_ENV_BIN"/python/vpr_fixup_post_synth.py \ - --vlog-in ${TOP}_post_synthesis.v \ - --vlog-out ${TOP}_post_synthesis.v \ - --sdf-in ${TOP}_post_synthesis.sdf \ - --sdf-out ${TOP}_post_synthesis.sdf \ - --split-ports diff --git a/f4pga/wrappers/sh/quicklogic/conda_build_install_package.sh b/f4pga/wrappers/sh/quicklogic/conda_build_install_package.sh deleted file mode 100755 index 3a85c29..0000000 --- a/f4pga/wrappers/sh/quicklogic/conda_build_install_package.sh +++ /dev/null @@ -1,62 +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 - -echo -e "\e[1;34mInstallation starting for conda based symbiflow\e[0m" -echo -e "\e[1;34mQuickLogic Corporation\e[0m" - -if [ -z "$INSTALL_DIR" ] -then - echo -e "\e[1;31m\$INSTALL_DIR is not set, please set and then proceed!\e[0m" - echo -e "\e[1;31mExample: \"export INSTALL_DIR=/\". \e[0m" - exit 0 -elif [ -d "$INSTALL_DIR/conda" ]; then - echo -e "\e[1;32m $INSTALL_DIR/conda already exists, please clean up and re-install ! \e[0m" - exit 0 -else - echo -e "\e[1;32m\$INSTALL_DIR is set to $INSTALL_DIR ! \e[0m" -fi - -mkdir -p $INSTALL_DIR - -wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O conda_installer.sh -bash conda_installer.sh -b -p $INSTALL_DIR/conda && rm conda_installer.sh -source "$INSTALL_DIR/conda/etc/profile.d/conda.sh" -echo "include-system-site-packages=false" >> $INSTALL_DIR/conda/pyvenv.cfg -CONDA_FLAGS="-y --override-channels -c defaults -c conda-forge" -conda update $CONDA_FLAGS -q conda -curl $(curl https://storage.googleapis.com/symbiflow-arch-defs-install/latest-qlf) > arch.tar.gz -tar -C $INSTALL_DIR -xvf arch.tar.gz && rm arch.tar.gz -conda install $CONDA_FLAGS -c litex-hub/label/main yosys="0.9_5266_g0fb4224e 20210301_104249_py37" -conda install $CONDA_FLAGS -c litex-hub/label/main symbiflow-yosys-plugins="1.0.0_7_338_g93157fb=20210507_125510" -conda install $CONDA_FLAGS -c litex-hub/label/main vtr-optimized="8.0.0_3614_gb3b34e77a 20210507_125510" -conda install $CONDA_FLAGS -c litex-hub iverilog -conda install $CONDA_FLAGS -c tfors gtkwave -conda install $CONDA_FLAGS make lxml simplejson intervaltree git pip -conda activate -pip install python-constraint -pip install serial -pip install git+https://github.com/QuickLogic-Corp/ql_fasm@e5d0915 -conda deactivate -setup_file=$INSTALL_DIR/setup.sh -echo "export INSTALL_DIR=$INSTALL_DIR" >$setup_file -chmod 755 $setup_file - -# Adding symbiflow toolchain binaries to PATH -echo "export PATH=\"\$INSTALL_DIR/quicklogic-arch-defs/bin:\$INSTALL_DIR/quicklogic-arch-defs/bin/python:\$PATH\"" >>$setup_file -echo "source \"\$INSTALL_DIR/conda/etc/profile.d/conda.sh\"" >>$setup_file -echo "conda activate" >>$setup_file diff --git a/f4pga/wrappers/sh/quicklogic/fasm2bels.f4pga.sh b/f4pga/wrappers/sh/quicklogic/fasm2bels.f4pga.sh new file mode 100755 index 0000000..99bb16d --- /dev/null +++ b/f4pga/wrappers/sh/quicklogic/fasm2bels.f4pga.sh @@ -0,0 +1,93 @@ +#!/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_ENV_SHARE"} +BIN_DIR_PATH=${BIN_DIR_PATH:="$F4PGA_ENV_BIN"} + +OPTS=d:P:p:b: +LONGOPTS=device:,part:,pcf:,bit:, + +PARSED_OPTS=`getopt --options=${OPTS} --longoptions=${LONGOPTS} --name $0 -- "$@"` +eval set -- "${PARSED_OPTS}" + +DEVICE="" +PART="" +PCF="" +BIT="" + +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 + ;; + --) + 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 + + +# Run fasm2bels +if [[ "$DEVICE" =~ ^(ql-eos-s3|ql-pp3e)$ ]]; then + + VPR_DB=`readlink -f ${SHARE_DIR_PATH}/arch/${DEVICE}_wlcsp/db_phy.pickle` + FASM2BELS=`readlink -f ${BIN_DIR_PATH}/python/fasm2bels.py` + FASM2BELS_DEVICE=${DEVICE/ql-/} + VERILOG_FILE="${BIT}.v" + PCF_FILE="${BIT}.v.pcf" + QCF_FILE="${BIT}.v.qcf" + + if [ ! -z "{PCF}" ]; then + PCF_ARGS="--input-pcf ${PCF}" + else + PCF_ARGS="" + fi + + echo "Running fasm2bels" + `which python3` ${FASM2BELS} ${BIT} --phy-db ${VPR_DB} --device-name ${FASM2BELS_DEVICE} --package-name ${PART} --input-type bitstream --output-verilog ${VERILOG_FILE} ${PCF_ARGS} --output-pcf ${PCF_FILE} --output-qcf ${QCF_FILE} + +else + + echo "ERROR: Unsupported device '${DEVICE}' for fasm2bels" + exit -1 +fi diff --git a/f4pga/wrappers/sh/quicklogic/generate_bitstream.f4pga.sh b/f4pga/wrappers/sh/quicklogic/generate_bitstream.f4pga.sh index a899be9..2d1e56a 100755 --- a/f4pga/wrappers/sh/quicklogic/generate_bitstream.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/generate_bitstream.f4pga.sh @@ -18,8 +18,9 @@ set -e -OPTS=d:f:r:b: -LONGOPTS=device:,fasm:,format:,bit: +SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_ENV_SHARE"} +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}" @@ -28,6 +29,7 @@ DEVICE="" FASM="" BIT="" BIT_FORMAT="4byte" +PART="" while true; do case "$1" in @@ -35,6 +37,7 @@ while true; do -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 @@ -56,4 +59,14 @@ fi DB_ROOT="$F4PGA_ENV_SHARE"/fasm_database/${DEVICE} -`which qlf_fasm` --db-root ${DB_ROOT} --format ${BIT_FORMAT} --assemble $FASM $BIT +# qlf +if [[ "$DEVICE" =~ ^(qlf_k4n8.*)$ ]]; then + QLF_FASM=`which qlf_fasm` + DB_ROOT=`realpath ${SHARE_DIR_PATH}//fasm_database/${DEVICE}` + ${QLF_FASM} --db-root ${DB_ROOT} --format ${BIT_FORMAT} --assemble $FASM $BIT +elif [[ "$DEVICE" =~ ^(ql-eos-s3|ql-pp3e)$ ]]; then + qlfasm --dev-type ${DEVICE} ${FASM} ${BIT} +else + echo "ERROR: Unsupported device '${DEVICE}' for bitstream generation" + exit -1 +fi diff --git a/f4pga/wrappers/sh/quicklogic/generate_constraints.f4pga.sh b/f4pga/wrappers/sh/quicklogic/generate_constraints.f4pga.sh index 777acf7..a0dc823 100755 --- a/f4pga/wrappers/sh/quicklogic/generate_constraints.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/generate_constraints.f4pga.sh @@ -26,27 +26,74 @@ DEVICE=$5 ARCH_DEF=$6 CORNER=$7 -if [[ "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]];then - DEVICE_1="qlf_k4n8-qlf_k4n8_umc22_$CORNER" - PINMAPXML="pinmap_qlf_k4n8_umc22.xml" -elif [[ "$DEVICE" =~ ^(qlf_k6n10_qlf_k6n10)$ ]];then - DEVICE_1="qlf_k6n10-qlf_k6n10_gf12" - PINMAPXML="pinmap_qlf_k6n10_gf12.xml" -else - DEVICE_1=${DEVICE} -fi - -SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_ENV_SHARE"} - -PINMAP_XML=`realpath ${SHARE_DIR_PATH}/arch/${DEVICE_1}_${DEVICE_1}/${PINMAPXML}` - PROJECT=$(basename -- "$EBLIF") IOPLACE_FILE="${PROJECT%.*}_io.place" -python3 $(realpath "$F4PGA_ENV_BIN"/python/create_ioplace.py) \ - --pcf $PCF \ - --blif $EBLIF \ - --pinmap_xml $PINMAP_XML \ - --csv_file $PART \ - --net $NET \ - > ${IOPLACE_FILE} +BIN_DIR_PATH=${BIN_DIR_PATH:="$F4PGA_ENV_BIN"} +SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_ENV_SHARE"} + +PYTHON3=$(which python3) + +if [[ "$DEVICE" =~ ^(qlf_.*)$ ]]; then + if [[ "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]];then + DEVICE_1="qlf_k4n8-qlf_k4n8_umc22_$CORNER" + DEVICE_2=${DEVICE_1} + PINMAPXML="pinmap_qlf_k4n8_umc22.xml" + elif [[ "$DEVICE" =~ ^(qlf_k6n10_qlf_k6n10)$ ]];then + DEVICE_1="qlf_k6n10-qlf_k6n10_gf12" + DEVICE_2=${DEVICE_1} + PINMAPXML="pinmap_qlf_k6n10_gf12.xml" + else + echo "ERROR: Unknown qlf device '${DEVICE}'" + exit -1 + fi + + PINMAP_XML=`realpath ${SHARE_DIR_PATH}/arch/${DEVICE_1}_${DEVICE_1}/${PINMAPXML}` + IOGEN=`realpath ${BIN_DIR_PATH}/python/qlf_k4n8_create_ioplace.py` + + ${PYTHON3} ${IOGEN} --pcf $PCF --blif $EBLIF --pinmap_xml $PINMAP_XML --csv_file $PART --net $NET > ${IOPLACE_FILE} + +elif [[ "$DEVICE" =~ ^(ql-.*)$ ]]; then + DEVICE_1=${DEVICE} + DEVICE_2="wlcsp" + + 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" + + PINMAP=`realpath ${SHARE_DIR_PATH}/arch/${DEVICE_1}_${DEVICE_2}/${PINMAPCSV}` + CLKMAP=`realpath ${SHARE_DIR_PATH}/arch/${DEVICE_1}_${DEVICE_2}/${CLKMAPCSV}` + + IOGEN=`realpath ${BIN_DIR_PATH}/python/pp3_create_ioplace.py` + PLACEGEN=`realpath ${BIN_DIR_PATH}/python/pp3_create_place_constraints.py` + + PLACE_FILE="${PROJECT%.*}_constraints.place" + + ${PYTHON3} ${IOGEN} --pcf $PCF --blif $EBLIF --map $PINMAP --net $NET > ${IOPLACE_FILE} + ${PYTHON3} ${PLACEGEN} --blif $EBLIF --map $CLKMAP -i ${IOPLACE_FILE} > ${PLACE_FILE} + + # EOS-S3 IOMUX configuration + if [[ "$DEVICE" =~ ^(ql-eos-s3)$ ]]; then + + IOMUXGEN=`realpath ${BIN_DIR_PATH}/python/pp3_eos_s3_iomux_config.py` + + IOMUX_JLINK="${PROJECT%.*}_iomux.jlink" + IOMUX_OPENOCD="${PROJECT%.*}_iomux.openocd" + IOMUX_BINARY="${PROJECT%.*}_iomux.bin" + + ${PYTHON3} ${IOMUXGEN} --eblif $EBLIF --pcf $PCF --map $PINMAP --output-format=jlink > ${IOMUX_JLINK} + ${PYTHON3} ${IOMUXGEN} --eblif $EBLIF --pcf $PCF --map $PINMAP --output-format=openocd > ${IOMUX_OPENOCD} + ${PYTHON3} ${IOMUXGEN} --eblif $EBLIF --pcf $PCF --map $PINMAP --output-format=binary > ${IOMUX_BINARY} + fi + +else + echo "FIXME: Unsupported device '${DEVICE}'" + exit -1 +fi diff --git a/f4pga/wrappers/sh/quicklogic/generate_libfile.f4pga.sh b/f4pga/wrappers/sh/quicklogic/generate_libfile.f4pga.sh index a8a83e3..007455c 100755 --- a/f4pga/wrappers/sh/quicklogic/generate_libfile.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/generate_libfile.f4pga.sh @@ -34,7 +34,7 @@ fi ARCH_DIR="$F4PGA_ENV_SHARE"/arch/${DEVICE_1}_${DEVICE_1} PINMAP_XML=${ARCH_DIR}/${PINMAPXML} -python3 "$F4PGA_ENV_BIN"/python/create_lib.py \ +`which python3` "$F4PGA_ENV_BIN"/python/create_lib.py \ -n ${DEV}_0P72_SSM40 \ -m fpga_top \ -c $PART \ diff --git a/f4pga/wrappers/sh/quicklogic/pack.f4pga.sh b/f4pga/wrappers/sh/quicklogic/pack.f4pga.sh index a880122..eb44c03 100755 --- a/f4pga/wrappers/sh/quicklogic/pack.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/pack.f4pga.sh @@ -20,14 +20,14 @@ set -e if [ -z $VPRPATH ]; then export VPRPATH="$F4PGA_ENV_BIN" - export PYTHONPATH=${VPRPATH}/python:${VPRPATH}/python/prjxray:${PYTHONPATH} + export PYTHONPATH=${VPRPATH}/python:${PYTHONPATH} fi -source ${VPRPATH}/vpr_common +source $(dirname "$0")/vpr_common.f4pga.sh parse_args $@ export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_pack.log -run_vpr --pack +run_vpr --pack --write_block_usage block_usage.json mv vpr_stdout.log pack.log diff --git a/f4pga/wrappers/sh/quicklogic/place.f4pga.sh b/f4pga/wrappers/sh/quicklogic/place.f4pga.sh index 9b8d8dd..b4508fc 100755 --- a/f4pga/wrappers/sh/quicklogic/place.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/place.f4pga.sh @@ -20,10 +20,10 @@ set -e if [ -z $VPRPATH ]; then export VPRPATH="$F4PGA_ENV_BIN" - export PYTHONPATH=${VPRPATH}/python:${VPRPATH}/python/prjxray:${PYTHONPATH} + export PYTHONPATH=${VPRPATH}/python:${PYTHONPATH} fi -source ${VPRPATH}/vpr_common +source $(dirname "$0")/vpr_common.f4pga.sh parse_args $@ if [ -z $PCF ]; then diff --git a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh index 26328ae..24213ab 100755 --- a/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/ql.f4pga.sh @@ -18,15 +18,15 @@ set -e -BUILDDIR=build +SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_ENV_SHARE"} -source "$F4PGA_ENV_BIN"/vpr_common +source $(dirname "$0")/vpr_common.f4pga.sh VERSION="v2.0.1" if [ ! -n $1 ]; then echo "Please enter a valid command: Refer help ql_symbiflow --help" - exit 0 + exit 1 elif [[ $1 == "-synth" || $1 == "-compile" ]]; then echo -e "----------------- \n" elif [[ $1 == "-h" || $1 == "--help" ]];then @@ -35,13 +35,14 @@ elif [[ $1 == "-h" || $1 == "--help" ]];then \t>ql_symbiflow -synth -src -d -P -t -v -p \n\ To run synthesis, pack, place and route:\n\ \t>ql_symbiflow -compile -src -d -P -t -v -p -P -s \n\ -Device supported:qlf_k4n8" || exit +Devices supported: ql-eos-s3, qlf_k4n8 \n\ +Support temporarily disabled for: ql-pp3, qlf_k6n10" || exit elif [[ $1 == "-v" || $1 == "--version" ]];then echo "Symbiflow Tool Version : ${VERSION}" - exit + exit 0 else echo -e "Please provide a valid command : Refer -h/--help\n" - exit + exit 1 fi @@ -61,8 +62,11 @@ JSON="" PNR_CORNER="slow" ANALYSIS_CORNER="slow" COMPILE_EXTRA_ARGS=() - +BUILDDIR="build" +DEVICE_CHECK="INVALID" OPT="" +RUN_TILL="" + for arg in $@; do case $arg in -src|--source) OPT="src" ;; @@ -80,6 +84,7 @@ for arg in $@; do -synth|-compile) OPT="synth" ;; -y|+incdir+*|+libext+*|+define+*) OPT="compile_xtra" ;; -f) OPT="options_file" ;; + -build_dir) OPT="build_dir" ;; -h|--help) exit 0 ;; *) case $OPT in @@ -135,6 +140,10 @@ for arg in $@; do options_file) COMPILE_EXTRA_ARGS+=("-f \"`realpath $arg`\" ") ;; + build_dir) + BUILDDIR=$arg + OPT="" + ;; *) echo "Refer help for more details: ql_symbiflow -h " exit 1 @@ -151,10 +160,20 @@ 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}'" @@ -181,7 +200,7 @@ else if [ -f $SOURCE/v_list_tmp ];then rm -f $SOURCE/v_list_tmp fi - if [ $VERILOG_FILES == "*.v" ];then + if [ "$VERILOG_FILES" == "*.v" ];then VERILOG_FILES=`cd ${SOURCE};ls *.v` fi echo "$VERILOG_FILES" >${SOURCE}/v_list @@ -202,30 +221,21 @@ else fi if [[ $1 == "-compile" || $1 == "-post_verilog" ]]; then - # Allow no PCF/pinmap for some devices - if [[ ! "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]]; then - if [ -z "$PCF" ]; then - echo "PCF file option is missing. Refer -h/--help" - exit 1 - elif ! [ -f "$SOURCE/$PCF" ]; then - echo "The pcf file: $PCF is missing at: $SOURCE" - exit 1 - fi - fi if [ -z "$DEVICE" ]; then echo "DEVICE name is missing. Refer -h/--help" exit 1 - elif ! [[ "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]]; then - echo "Invalid Device name, supported qlf_k4n8" + elif ! [[ "$DEVICE_CHECK" =~ ^(VALID)$ ]]; then + echo "Invalid Device name, supported: ql-eos-s3, qlf_k4n8 \n\ + Support temporarily disabled for: qlf_k6n10" exit 1 fi if [ -z "$TOP" ]; then echo "TOP module name is missing. Refer -h/--help" exit 1 fi - if [[ "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]]; then + if [[ "$DEVICE_CHECK" =~ ^(VALID)$ ]]; then if [ -z "$PART" ]; then - if [ -n "$PCF" ];then + if [[ -n "$PCF" && $USE_PINMAP -ne 0 ]]; then echo "Error: pcf file cannot be used without declaring PINMAP CSV file" exit 1 fi @@ -272,12 +282,19 @@ if [ -f "$SOURCE/v_list_tmp" ]; then fi # FIXME: Some devices do not have fasm2bels yet +# FIXME: Some device do not support bitstream generation yet RUN_TILL="" if [[ "$DEVICE" =~ ^(qlf_k4n8.*)$ ]]; then HAVE_FASM2BELS=0 RUN_TILL="bit" -else +elif [[ "$DEVICE" =~ ^(qlf_k6n10.*)$ ]]; then + HAVE_FASM2BELS=0 + RUN_TILL="route" +elif [[ "$DEVICE" =~ ^(ql-eos-s3)$ ]]; then HAVE_FASM2BELS=1 + RUN_TILL="bit" +else + HAVE_FASM2BELS=0 RUN_TILL="route" fi @@ -290,7 +307,6 @@ fi export PCF_FILE=$PCF export JSON=$JSON -export TOP_F=$TOP export PINMAP_FILE=$PINMAPCSV export MAX_CRITICALITY=$MAX_CRITICALITY @@ -302,7 +318,7 @@ else CURR_DIR="${PWD}/${SOURCE}" fi -if [ -n "$PART" ]; then +if [[ -n "$PART" && $USE_PINMAP -ne 0 ]]; then if [[ -f $SOURCE/$PART ]];then CSV_PATH=`realpath $SOURCE/$PART` elif [[ -f $PART ]];then @@ -327,7 +343,11 @@ elif [[ -f $PCF ]];then PCF_PATH=`realpath $PCF` fi -export PART=${CSV_PATH} +if [[ $USE_PINMAP -ne 0 ]]; then + export PART=${CSV_PATH} +else + export PART=${PART} +fi export JSON=${JSON_PATH} export PCF_PATH=${PCF_PATH} @@ -337,8 +357,8 @@ LOG_FILE=${CURR_DIR}/${BUILDDIR}/${TOP}.log if [ -f "$SOURCE"/$PCF_FILE ];then PCF_MAKE="\${current_dir}/$PCF_FILE" else - touch ${CURR_DIR}/build/${TOP}_dummy.pcf - PCF_MAKE="\${current_dir}/build/${TOP}_dummy.pcf" + touch ${CURR_DIR}/${BUILDDIR}/${TOP}_dummy.pcf + PCF_MAKE="\${current_dir}/${BUILDDIR}/${TOP}_dummy.pcf" fi PROCESS_SDC=$(realpath "$F4PGA_ENV_BIN"/python/process_sdc_constraints.py) @@ -350,15 +370,15 @@ if ! [ -z "$SDC" ]; then SDC_MAKE="$SOURCE/$SDC" fi else - touch ${CURR_DIR}/build/${TOP}_dummy.sdc - SDC_MAKE="\${current_dir}/build/${TOP}_dummy.sdc" + touch ${CURR_DIR}/${BUILDDIR}/${TOP}_dummy.sdc + SDC_MAKE="\${current_dir}/${BUILDDIR}/${TOP}_dummy.sdc" fi if ! [ -z "$CSV_PATH" ]; then CSV_MAKE=$CSV_PATH else - touch ${CURR_DIR}/build/${TOP}_dummy.csv - CSV_MAKE="\${current_dir}/build/${TOP}_dummy.csv" + touch ${CURR_DIR}/${BUILDDIR}/${TOP}_dummy.csv + CSV_MAKE="\${current_dir}/${BUILDDIR}/${TOP}_dummy.csv" fi echo -e ".PHONY:\${BUILDDIR}\n @@ -375,7 +395,7 @@ PNR_CORNER := $ANALYSIS_CORNER\n\ PCF := $PCF_MAKE\n\ PINMAP_CSV := $CSV_MAKE\n\ SDC_IN := $SDC_MAKE\n\ -BUILDDIR := build\n\n\ +BUILDDIR := $BUILDDIR\n\n\ SDC := \${current_dir}/\${BUILDDIR}/\${TOP}.sdc all: \${BUILDDIR}/\${TOP}.${RUN_TILL}\n\ @@ -384,10 +404,11 @@ all: \${BUILDDIR}/\${TOP}.${RUN_TILL}\n\ ifneq (\"\$(wildcard \$(HEX_FILES))\",\"\")\n\ \$(shell cp \${current_dir}/*.hex \${BUILDDIR})\n\ endif\n\ - cd \${BUILDDIR} && symbiflow_synth -t \${TOP} -v \${VERILOG} -F \${FAMILY} -d \${DEVICE} -p \${PCF} ${COMPILE_EXTRA_ARGS[*]} > $LOG_FILE 2>&1\n\ + cd \${BUILDDIR} && symbiflow_synth -t \${TOP} -v \${VERILOG} -F \${FAMILY} -d \${DEVICE} -p \${PCF} -P \${PART} ${COMPILE_EXTRA_ARGS[*]} > $LOG_FILE 2>&1\n\ \n\ \${BUILDDIR}/\${TOP}.sdc: \${BUILDDIR}/\${TOP}.eblif\n\ python3 ${PROCESS_SDC} --sdc-in \${SDC_IN} --sdc-out \$@ --pcf \${PCF} --eblif \${BUILDDIR}/\${TOP}.eblif --pin-map \${PINMAP_CSV}\n\ +\n\ \${BUILDDIR}/\${TOP}.net: \${BUILDDIR}/\${TOP}.eblif \${BUILDDIR}/\${TOP}.sdc\n\ cd \${BUILDDIR} && symbiflow_pack -e \${TOP}.eblif -f \${FAMILY} -d \${DEVICE} -s \${SDC} -c \${PNR_CORNER} >> $LOG_FILE 2>&1\n\ \n\ @@ -418,7 +439,11 @@ fi \n\ \${BUILDDIR}/\${TOP}.fasm: \${BUILDDIR}/\${TOP_FINAL}.route\n\ cd \${BUILDDIR} && symbiflow_write_fasm -e \${TOP_FINAL}.eblif -f \${FAMILY} -d \${DEVICE} -s \${SDC} -c \${PNR_CORNER} >> $LOG_FILE 2>&1\n\ -\n\ + " >>$MAKE_FILE + +# Bitstream +if [ "$FAMILY" == "qlf_k4n8" ]; then + echo -e "\ \${BUILDDIR}/\${TOP}.bit: \${BUILDDIR}/\${TOP}.fasm\n\ cd \${BUILDDIR} && symbiflow_generate_bitstream -d \${FAMILY} -f \${TOP}.fasm -r 4byte -b \${TOP}.bit >> $LOG_FILE 2>&1\n\ cd \${BUILDDIR} && symbiflow_generate_bitstream -d \${FAMILY} -f \${TOP}.fasm -r txt -b \${TOP}.bin >> $LOG_FILE 2>&1\n\ @@ -427,16 +452,43 @@ fi cd \${BUILDDIR} && symbiflow_generate_libfile \${PARTNAME} \${DEVICE} \${PNR_CORNER} >> $LOG_FILE 2>&1\n\ " >>$MAKE_FILE +elif [ "$FAMILY" == "pp3" ]; then + echo -e "\ +\${BUILDDIR}/\${TOP}.bit: \${BUILDDIR}/\${TOP}.fasm\n\ + cd \${BUILDDIR} && symbiflow_generate_bitstream -d \${DEVICE} -f \${TOP}.fasm -P \${PARTNAME} -b \${TOP}.bit >> $LOG_FILE 2>&1\n\ + " >>$MAKE_FILE +fi + +# EOS-S3 specific targets +if [ "$DEVICE" == "ql-eos-s3" ]; then + echo -e "\ +\${BUILDDIR}/\${TOP}_bit.h: \${BUILDDIR}/\${TOP}.bit\n\ + symbiflow_write_bitheader \$^ \$@ >> $LOG_FILE 2>&1\n\ +\n\ +\${BUILDDIR}/\${TOP}.bin: \${BUILDDIR}/\${TOP}.bit\n\ + symbiflow_write_binary \$^ \$@ >> $LOG_FILE 2>&1\n\ +\n\ +\${BUILDDIR}/\${TOP}.jlink: \${BUILDDIR}/\${TOP}.bit\n\ + symbiflow_write_jlink \$^ \$@ >> $LOG_FILE 2>&1\n\ +\n\ +\${BUILDDIR}/\${TOP}.openocd: \${BUILDDIR}/\${TOP}.bit\n\ + symbiflow_write_openocd \$^ \$@ >> $LOG_FILE 2>&1\n\ +\n\ + " >>$MAKE_FILE +fi + +# fasm2bels if [ "$HAVE_FASM2BELS" != 0 ]; then echo -e "\ - cd \${BUILDDIR} && symbiflow_write_fasm2bels -e \${TOP}.eblif -d \${DEVICE} -p \${PCF} -n \${TOP}.net -P \${PARTNAME}\n\ +\${BUILDDIR}/\${TOP}.bit.v: \${BUILDDIR}/\${TOP}.bit\n\ + cd \${BUILDDIR} && symbiflow_fasm2bels -b \${TOP}.bit -d \${DEVICE} -p \${PCF} -P \${PARTNAME} >> $LOG_FILE 2>&1\n\ " >>$MAKE_FILE fi echo -e "\ clean:\n\ rm -rf \${BUILDDIR}\n\ -" >>$MAKE_FILE + " >>$MAKE_FILE ## Remove temporary files rm -f $SOURCE/f_list_temp $SOURCE/v_list_tmp $SOURCE/v_list @@ -444,14 +496,31 @@ rm -f $SOURCE/f_list_temp $SOURCE/v_list_tmp $SOURCE/v_list ## Make file Targets if [ $1 == "-synth" ]; then echo -e "Performing Synthesis " - cd $SOURCE;make -f Makefile.symbiflow ${BUILDDIR}/${TOP}.eblif || exit + cd $SOURCE;make -f Makefile.symbiflow ${BUILDDIR}/${TOP}.eblif || (cat $LOG_FILE && exit 1) elif [[ ! -z "$OUT" && $1 == "-compile" ]];then if [[ " ${OUT_ARR[@]} " =~ " post_verilog " ]];then - cd $SOURCE;make -f Makefile.symbiflow ${BUILDDIR}/${TOP}.post_v || exit + cd $SOURCE;make -f Makefile.symbiflow ${BUILDDIR}/${TOP}.post_v || (cat $LOG_FILE && exit 1) + fi + if [ "$DEVICE" == "ql-eos-s3" ]; then + if [[ " ${OUT_ARR[@]} " =~ " jlink " ]]; then + cd $SOURCE;make -f Makefile.symbiflow ${BUILDDIR}/${TOP}.jlink || (cat $LOG_FILE && exit 1) + fi + if [[ " ${OUT_ARR[@]} " =~ " openocd " ]]; then + cd $SOURCE;make -f Makefile.symbiflow ${BUILDDIR}/${TOP}.openocd || (cat $LOG_FILE && exit 1) + fi + if [[ " ${OUT_ARR[@]} " =~ " post_verilog " ]]; then + cd $SOURCE;make -f Makefile.symbiflow ${BUILDDIR}/${TOP}.bit.v || (cat $LOG_FILE && exit 1) + fi + if [[ " ${OUT_ARR[@]} " =~ " header " ]]; then + cd $SOURCE;make -f Makefile.symbiflow ${BUILDDIR}/${TOP}_bit.h || (cat $LOG_FILE && exit 1) + fi + if [[ " ${OUT_ARR[@]} " =~ " binary " ]]; then + cd $SOURCE;make -f Makefile.symbiflow ${BUILDDIR}/${TOP}.bin || (cat $LOG_FILE && exit 1) + fi fi else if [ $1 == "-compile" ]; then echo -e "Running Synth->Pack->Place->Route->FASM->bitstream" - cd $SOURCE;make -f Makefile.symbiflow ${BUILDDIR}/${TOP}.${RUN_TILL} || exit + cd $SOURCE;make -f Makefile.symbiflow ${BUILDDIR}/${TOP}.${RUN_TILL} || (cat $LOG_FILE && exit 1) fi fi diff --git a/f4pga/wrappers/sh/quicklogic/repack.f4pga.sh b/f4pga/wrappers/sh/quicklogic/repack.f4pga.sh index 60f145d..e424891 100755 --- a/f4pga/wrappers/sh/quicklogic/repack.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/repack.f4pga.sh @@ -20,10 +20,9 @@ set -e if [ -z $VPRPATH ]; then export VPRPATH="$F4PGA_ENV_BIN" - export PYTHONPATH=${VPRPATH}/python:${VPRPATH}/python/prjxray:${PYTHONPATH} fi -source ${VPRPATH}/vpr_common +source $(dirname "$0")/vpr_common.f4pga.sh parse_args $@ DESIGN=${EBLIF/.eblif/} @@ -31,7 +30,9 @@ DESIGN=${EBLIF/.eblif/} [ ! -z "${JSON}" ] && JSON_ARGS="--json-constraints ${JSON}" || JSON_ARGS= [ ! -z "${PCF_PATH}" ] && PCF_ARGS="--pcf-constraints ${PCF_PATH}" || PCF_ARGS= -python3 "$F4PGA_ENV_BIN"/python/repacker/repack.py \ +export PYTHONPATH=$F4PGA_ENV_BIN/python:$PYTHONPATH + +`which python3` "$F4PGA_ENV_BIN"/python/repacker/repack.py \ --vpr-arch ${ARCH_DEF} \ --repacking-rules ${ARCH_DIR}/${DEVICE_1}.repacking_rules.json \ $JSON_ARGS \ diff --git a/f4pga/wrappers/sh/quicklogic/route.f4pga.sh b/f4pga/wrappers/sh/quicklogic/route.f4pga.sh index 571ea61..5ed8717 100755 --- a/f4pga/wrappers/sh/quicklogic/route.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/route.f4pga.sh @@ -20,14 +20,14 @@ set -e if [ -z $VPRPATH ]; then export VPRPATH="$F4PGA_ENV_BIN" - export PYTHONPATH=${VPRPATH}/python:${VPRPATH}/python/prjxray:${PYTHONPATH} + export PYTHONPATH=${VPRPATH}/python:${PYTHONPATH} fi -source ${VPRPATH}/vpr_common +source $(dirname "$0")/vpr_common.f4pga.sh parse_args $@ export OUT_NOISY_WARNINGS=noisy_warnings-${DEVICE}_pack.log -run_vpr --route +run_vpr --route --write_timing_summary timing_summary.json mv vpr_stdout.log route.log diff --git a/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh b/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh index 9c0b98f..92f11f4 100755 --- a/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/synth.f4pga.sh @@ -134,9 +134,13 @@ export SYNTH_JSON=${TOP}_io.json 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=${VPRPATH}/python/ if [ -s $PCF ]; then export PCF_FILE=$PCF +else + export PCF_FILE="" fi DEVICE_PATH="${SHARE_DIR_PATH}/arch/${DEVICE}_${DEVICE}" @@ -174,6 +178,6 @@ if [ ! -z "${YOSYS_COMMANDS}" ]; then YOSYS_SCRIPT="$YOSYS_COMMANDS; $YOSYS_SCRIPT" fi -yosys -p "${YOSYS_SCRIPT}" -l $LOG -python3 ${SPLIT_INOUTS} -i ${OUT_JSON} -o ${SYNTH_JSON} -yosys -p "read_json $SYNTH_JSON; tcl ${CONV_TCL_PATH}" +`which yosys` -p "${YOSYS_SCRIPT}" -l $LOG +`which python3` ${SPLIT_INOUTS} -i ${OUT_JSON} -o ${SYNTH_JSON} +`which yosys` -p "read_json $SYNTH_JSON; tcl ${CONV_TCL_PATH}" diff --git a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh index 3addb97..60c9523 100755 --- a/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/vpr_common.f4pga.sh @@ -16,6 +16,18 @@ # # SPDX-License-Identifier: Apache-2.0 +SHARE_DIR_PATH=${SHARE_DIR_PATH:="$F4PGA_ENV_SHARE"} + +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 + " +fi + function parse_args { OPTS=d:f:e:p:n:P:j:s:t:c: @@ -109,40 +121,76 @@ function parse_args { 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 ${MYPATH}/../share/symbiflow/arch/${DEVICE_1}_${DEVICE_1}` - export ARCH_DEF=${ARCH_DIR}/arch_${DEVICE_1}_${DEVICE_1}.xml + 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 - export PLACE_DELAY=${ARCH_DIR}/rr_graph_${DEVICE_1}_${DEVICE_1}.place_delay.bin - export ROUTE_DELAY=${ARCH_DIR}/rr_graph_${DEVICE_1}_${DEVICE_1}.lookahead.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 VPR_CONFIG=`realpath ${MYPATH}/../share/symbiflow/scripts/${FAMILY}/vpr_config.sh` + if [[ "$DEVICE" == "qlf_k4n8_qlf_k4n8" ]]; then + VPR_OPTIONS="$VPR_OPTIONS + --route_chan_width 10 + --clock_modeling ideal + --place_delta_delay_matrix_calculation_method dijkstra + --place_delay_model delta_override + --router_lookahead extended_map + --allow_dangling_combinational_nodes on + --absorb_buffer_luts off" + else + VPR_OPTIONS="$VPR_OPTIONS + --route_chan_width 100 + --clock_modeling route + --place_delay_model delta_override + --router_lookahead extended_map + --check_route quick + --strict_checks off + --allow_dangling_combinational_nodes on + --disable_errors check_unbuffered_edges:check_route + --congested_routing_iteration_threshold 0.8 + --incremental_reroute_delay_ripup off + --base_cost_type delay_normalized_length_bounded + --bb_factor 10 + --initial_pres_fac 4.0 + --check_rr_graph off + --pack_high_fanout_threshold PB-LOGIC:18 + --suppress_warnings ${OUT_NOISY_WARNINGS},sum_pin_class:check_unbuffered_edges:load_rr_indexed_data_T_values:check_rr_node:trans_per_R:check_route:set_rr_graph_tool_comment" + fi } function run_vpr { set -e - source ${VPR_CONFIG} - SDC_OPTIONS="" if [ ! -z $SDC ] then SDC_OPTIONS="--sdc_file $SDC" fi - vpr ${ARCH_DEF} \ + `which vpr` ${ARCH_DEF} \ ${EBLIF} \ + --read_rr_graph ${RR_GRAPH} \ --device ${DEVICE_NAME} \ ${VPR_OPTIONS} \ - --read_rr_graph ${RR_GRAPH} \ - --read_placement_delay_lookup ${PLACE_DELAY} \ --read_router_lookahead ${ROUTE_DELAY} \ + --read_placement_delay_lookup ${PLACE_DELAY} \ ${SDC_OPTIONS} \ $@ @@ -152,9 +200,7 @@ function run_vpr { function run_genfasm { set -e - source ${VPR_CONFIG} - - genfasm ${ARCH_DEF} \ + `which genfasm` ${ARCH_DEF} \ ${EBLIF} \ --device ${DEVICE_NAME} \ ${VPR_OPTIONS} \ diff --git a/f4pga/wrappers/sh/quicklogic/write_binary.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_binary.f4pga.sh new file mode 100644 index 0000000..28bdfcf --- /dev/null +++ b/f4pga/wrappers/sh/quicklogic/write_binary.f4pga.sh @@ -0,0 +1,24 @@ +#!/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 + +source $(dirname "$(readlink -f "$BASH_SOURCE")")/env + +echo "Converting bitstream to flashable binary format" +`which python3` -m quicklogic_fasm.bitstream_to_binary $@ diff --git a/f4pga/wrappers/sh/quicklogic/vpr_config.sh b/f4pga/wrappers/sh/quicklogic/write_bitheader.f4pga.sh old mode 100755 new mode 100644 similarity index 78% rename from f4pga/wrappers/sh/quicklogic/vpr_config.sh rename to f4pga/wrappers/sh/quicklogic/write_bitheader.f4pga.sh index 5b8ca1a..2fa8a01 --- a/f4pga/wrappers/sh/quicklogic/vpr_config.sh +++ b/f4pga/wrappers/sh/quicklogic/write_bitheader.f4pga.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/bin/bash # # Copyright (C) 2020-2022 F4PGA Authors. # @@ -16,4 +16,9 @@ # # SPDX-License-Identifier: Apache-2.0 -VPR_OPTIONS="@VPR_ARGS@" +set -e + +source $(dirname "$(readlink -f "$BASH_SOURCE")")/env + +echo "Converting bitstream to C Header" +`which python3` -m quicklogic_fasm.bitstream_to_header $@ diff --git a/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh index 00e98e2..50c87c5 100755 --- a/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh @@ -20,10 +20,10 @@ set -e if [ -z $VPRPATH ]; then export VPRPATH="$F4PGA_ENV_BIN" - export PYTHONPATH=${VPRPATH}/python:${VPRPATH}/python/prjxray:${PYTHONPATH} + export PYTHONPATH=${VPRPATH}/python:${PYTHONPATH} fi -source ${VPRPATH}/vpr_common +source $(dirname "$0")/vpr_common.f4pga.sh parse_args "$@" TOP="${EBLIF%.*}" diff --git a/f4pga/wrappers/sh/quicklogic/write_jlink.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_jlink.f4pga.sh new file mode 100644 index 0000000..2e0c425 --- /dev/null +++ b/f4pga/wrappers/sh/quicklogic/write_jlink.f4pga.sh @@ -0,0 +1,24 @@ +#!/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 "$(readlink -f "$BASH_SOURCE")")/env + +echo "Converting bitstream to JLink script" +`which python3` -m quicklogic_fasm.bitstream_to_jlink $@ diff --git a/f4pga/wrappers/sh/quicklogic/write_openocd.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_openocd.f4pga.sh new file mode 100644 index 0000000..52bec54 --- /dev/null +++ b/f4pga/wrappers/sh/quicklogic/write_openocd.f4pga.sh @@ -0,0 +1,24 @@ +#!/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 "$(readlink -f "$BASH_SOURCE")")/env + +echo "Converting bitstream to OpenOCD script" +`which python3` -m quicklogic_fasm.bitstream_to_openocd $@