diff --git a/tools/hdltool_readme.txt b/tools/hdltool_readme.txt index 361a5be7f22b4498f2f4ef3ff4e57b8b49388466..dea146bf34d7de4e4cc01854e348f11b2b18f863 100644 --- a/tools/hdltool_readme.txt +++ b/tools/hdltool_readme.txt @@ -55,7 +55,7 @@ using Python scripts. In the old style UNB environment the tool project files ne a) ~/.bashrc -To setup the RadioHDL environment and the old style UniBoard environment add this to the .bashrc: +To setup the RadioHDL environment add this to the .bashrc: # Python PATH=${PATH}:/usr/local/anaconda/bin @@ -75,11 +75,12 @@ To setup the RadioHDL environment and the old style UniBoard environment add thi # Setup RadioHDL environment for UniBoard2 and new UniBoard1 applications . ${SVN}/RadioHDL/trunk/tools/setup_radiohdl.sh +In case of running the non-RadioHDL UniBoard environment: UNB, AARTFAAC or PAASAR add this to ~/.bashrc as well: + # Support old UniBoard environment (including Aartfaac and Paasar) . ${SVN}/RadioHDL/trunk/tools/setup_unb.sh -Different tool versions need to be stored in a sub directory in the tool root directory. - + b) Python environment setup @@ -94,7 +95,7 @@ UniBoard and RadioHDL python files that we use. c) Tool environment setup scripts The settings for the RadioHDL environment and the old style UniBoard development are kept in environment setup scripts that -gets sourced in the .bashrc: +gets sourced in the ~/.bashrc: - $RADIOHDL/tools/setup_radiohdl.sh # always needed to source in .bashrc (see 2a) - $RADIOHDL/tools/setup_unb.sh # only needed to source in .bashrc if old style UniBoard 1 development in $UNB, $PAASAR and $AARTFAAC is required (see 2a) @@ -142,8 +143,6 @@ f) How to start Modelsim for RadioHDL To start Modelsim for RadioHDL do: - > run_modelsim & - or > run_modelsim unb1 & This starts Modelsim 6.6c using Quartus 11.1 libraries for Stratix IV and with extra commands from ${RADIOHDL}/tools/modelsim/commands.do @@ -156,6 +155,9 @@ To make the tool version dependent settings the run_modelsim script calls: $RADIOHDL/tools/quartus/quartus_version.sh # for path to the FPGA technology HDL simulation libraries $RADIOHDL/tools/modelsim/modelsim_version.sh # for path to the vsim simulator +To enable other Modelsimtool versions, edit the script $RADIOHDL/tools/modelsim/set_modelsim +Now only the toolsets 'unb1' and 'unb2' are defined + The commands.do defines the following extra commands that can be used at the Modelsim prompt: . lp <name> : load HDL library <name>.mpf project @@ -168,8 +170,6 @@ g) How to start Quartus for RadioHDL To start Quartus for RadioHDL do: - > run_quartus & - or > run_quartus unb1 & This starts Quartus 11.1 for Stratix IV. To start Quartus 13.1a10 for Arria10 as needed for UniBoard2 do: @@ -180,20 +180,33 @@ To make the tool version dependent settings and the generic settings the run_qua $RADIOHDL/tools/quartus/quartus_version.sh # for path to the quartus sythesis tool $RADIOHDL/tools/quartus/quartus_generic.sh # version independent paths and settings for Quartus, SOPC, Nios + +To enable other Quartus tool versions, edit the script $RADIOHDL/tools/quartus/set_quartus +Now only the toolsets 'unb1' and 'unb2' are defined The Quartus unb_* bash commands for $UNB have also been ported to $RADIOHDL. They use quartus 11.1 so they only support Stratix IV and UniBoard1. -For Arria10 and UniBoard2 these commands will have to be ported to an equivalent in Python. The following Quartus unb2_* bash commands are kept in -$UNB/Firmware/software/build. For now these unb2_* bash commands can be used in $RADIOHDL. The unb2_* bash commands assume that the design library +For Arria10 and UniBoard2 these commands will have to be ported to an equivalent in Python. The following Quartus run_* bash commands are kept in +$RADIOHDL/tools/quartus. These run_* bash commands can be used in $RADIOHDL. The run_* bash commands assume that the design library projects are in the central $HDL_BUILD_DIR = $RADIOHDL/build/quartus: - > unb2_sopc unb1_minimal - > unb2_app unb1_minimal app=unb_osy # calls: unb2_bsp, unb2_reg, unb2_mif - > unb2_app_clean unb1_minimal - > unb2_qcomp unb1_minimal - > unb2_all unb1_minimal app=unb_osy # = unb2_sopc + unb2_app + unb2_qcomp - > unb2_rbf unb1_minimal - > unb2_sof unb1_minimal 0 + > run_sopc unb1 unb1_minimal + > run_app unb1 unb1_minimal # calls: run_bsp, run_reg, run_mif + > run_app_clean unb1 unb1_minimal + > run_qcomp unb1 unb1_minimal + > run_all_sopc unb1 unb1_minimal # sequentially running: run_sopc + run_app + run_qcomp + > run_rbf unb1 unb1_minimal + > run_sof unb1 unb1_minimal 0 +For building a QSYS system use: + + > run_qsys unb1 unb1_minimal + > run_app unb1 unb1_minimal use=qsys + > run_qcomp unb1 unb1_minimal + > run_all_qsys unb1 unb1_minimal # sequentially running: run_qsys + run_app + run_qcomp + > run_rbf unb1 unb1_minimal + > run_sof unb1 unb1_minimal 0 + + h) How to start Modelsim for UNB GUI: @@ -212,7 +225,7 @@ GUI: or - > run_quartus & # Makes the UNB settings again and calls the 11.1 executable + > run_quartus unb1 & # Makes the UNB settings again and calls the 11.1 executable For command line scripts use the unb_* scripts. See ASTRON_RP_1354_unb_minimal.pdf for more description. @@ -564,4 +577,4 @@ c) Link RadioHDL developments with the OneClick MyHDL developments. may not exist as a file and but only as the dictionary in the script. The various methods in modelsim_config.py and quartus_config.py can also be reused in a OneClick flow. - \ No newline at end of file + diff --git a/tools/modelsim/run_modelsim b/tools/modelsim/run_modelsim index 79966e7889d674f13d30509b9e355bb871ebfec7..a53eb70736789aff6b046968ff369220f1a3c741 100755 --- a/tools/modelsim/run_modelsim +++ b/tools/modelsim/run_modelsim @@ -23,7 +23,7 @@ # General tool and project settings # - use '. <script>.sh' to have the settings apply in this shell, otherwise they get lost when <script>.sh returns -# Tool settings for selected target "", "unb1", or "unb2" (where "" defaults to target "unb1") +# Tool settings for selected target "unb1", or "unb2" . ${RADIOHDL}/tools/modelsim/set_modelsim ${1:-} # Start the Modelsim GUI diff --git a/tools/modelsim/set_modelsim b/tools/modelsim/set_modelsim index ec18cb850481e9df2598993ca5fe399eb4467c4d..6e2ac657a9c1d3277f85874ec466eeb4aa28128e 100755 --- a/tools/modelsim/set_modelsim +++ b/tools/modelsim/set_modelsim @@ -22,32 +22,26 @@ # Purpose: Map command line argument to a tool version # Description: -# By using command line arguments like "", "unb1", "unb2" to select the tool +# By using command line arguments like "unb1" or "unb2" to select the tool # version it is easier to manage combinations of tool versions. # General tool and project settings # - use '. <script>.sh' to have the settings apply in this shell, otherwise they get lost when <script>.sh returns # Select target -TARGET=${1:-} -if [ "${TARGET}" = "" ]; then - TARGET="default" -fi -echo "Make Modelsim and Altera library simulation settings for RadioHDL with target: ${TARGET}" +TOOLSET=${1:-} +echo "Make Modelsim and Altera library simulation settings for RadioHDL with tool setting: ${TOOLSET}" # Select tool version -if [ "${TARGET}" = "default" ]; then - . ${RADIOHDL}/tools/quartus/quartus_version.sh 11.1 - . ${RADIOHDL}/tools/modelsim/modelsim_version.sh 6.6c -elif [ "${TARGET}" = "unb1" ]; then +if [ "${TOOLSET}" = "unb1" ]; then . ${RADIOHDL}/tools/quartus/quartus_version.sh 11.1 . ${RADIOHDL}/tools/modelsim/modelsim_version.sh 10.2c -elif [ "${TARGET}" = "unb2" ]; then +elif [ "${TOOLSET}" = "unb2" ]; then #. ${RADIOHDL}/tools/quartus/quartus_version.sh 13.1 . ${RADIOHDL}/tools/quartus/quartus_version.sh 14.0a10 . ${RADIOHDL}/tools/modelsim/modelsim_version.sh 10.2c else - echo "error: unknown target" + echo "error: unknown tool setting: ${TOOLSET} (choose 'unb1' or 'unb2')" exit 1 fi diff --git a/tools/quartus/run_all b/tools/quartus/run_all new file mode 100755 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tools/quartus/run_all_qsys b/tools/quartus/run_all_qsys new file mode 100755 index 0000000000000000000000000000000000000000..f4e4d8851b1d357c8a058780f9b03d6330fad864 --- /dev/null +++ b/tools/quartus/run_all_qsys @@ -0,0 +1,91 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# +# Copyright (C) 2010 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# -------------------------------------------------------------------------- # + + +# Run this tool with at least the commandline arguments: +# run_all_qsys toolset design_name +# example: +# run_all_qsys unb2 unb2_minimal + + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + + +# treat unset variables as an error - better fail loudly. +# implication is that "$1" and "$2" etc cannot be used in tests +# as they may be quite unset, eg when the user did not enter +# them on the commandline. +# now you get to parse the commandline and explicitly extract +# the info you want or fill in with defaults +# bonus: extragratis failure if, for some reason, the ${UNB} +# directory is not set. +set -u + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ... ($0 is untouched) + +project= + +# parse cmdline +for arg ; do + case ${arg} in + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + ;; + * ) + # only accept one non-option argument, the project name + if [ -n "${project}" ]; then + unb_error $0 "You cannot pass more than one project names" + fi + project=${arg} + ;; + esac +done + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +# run the commands we're supposed to run +unb_exec $0 run_qsys ${toolset} $* +unb_exec $0 run_app ${toolset} $* use=qsys +unb_exec $0 run_qcomp ${toolset} $* + +unb_info $0 "All operations completed successfully" diff --git a/tools/quartus/run_all_sopc b/tools/quartus/run_all_sopc new file mode 100755 index 0000000000000000000000000000000000000000..c1f22de4c73940c55fb8e6466652820e5ea1b60b --- /dev/null +++ b/tools/quartus/run_all_sopc @@ -0,0 +1,92 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# +# Copyright (C) 2010 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# -------------------------------------------------------------------------- # + + +# Run this tool with at least the commandline arguments: +# run_all_sopc toolset design_name +# example: +# run_all_sopc unb1 unb1_minimal + + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + + + +# treat unset variables as an error - better fail loudly. +# implication is that "$1" and "$2" etc cannot be used in tests +# as they may be quite unset, eg when the user did not enter +# them on the commandline. +# now you get to parse the commandline and explicitly extract +# the info you want or fill in with defaults +# bonus: extragratis failure if, for some reason, the ${UNB} +# directory is not set. +set -u + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ... ($0 is untouched) + +project= + +# parse cmdline +for arg ; do + case ${arg} in + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + ;; + * ) + # only accept one non-option argument, the project name + if [ -n "${project}" ]; then + unb_error $0 "You cannot pass more than one project names" + fi + project=${arg} + ;; + esac +done + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +# run the commands we're supposed to run +unb_exec $0 run_sopc ${toolset} $* +unb_exec $0 run_app ${toolset} $* +unb_exec $0 run_qcomp ${toolset} $* + +unb_info $0 "All operations completed successfully" diff --git a/tools/quartus/run_app b/tools/quartus/run_app new file mode 100755 index 0000000000000000000000000000000000000000..8b4f72d891d8716af8c06f251b3e4369ee17dd3b --- /dev/null +++ b/tools/quartus/run_app @@ -0,0 +1,270 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# +# Copyright (C) 2010 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# -------------------------------------------------------------------------- # +# +# +# This script calls the unb_create_bsp script, +# generates the HAL and +# compiles all files included in the [app].src file. +# default [app] == [project] but can override via +# "app=<appname>" commandline option +# + +# Run this tool with at least the commandline arguments: +# run_app toolset design_name +# example: +# run_app unb2 unb2_minimal +# + + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + + +set -u + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ... ($0 is untouched) + + +# First, check to see if $SOPC_KIT_NIOS2 environmental variable is set. +# This variable is required for the command line tools to execute correctly. +if [ -z "${SOPC_KIT_NIOS2}" ]; then + unb_error $0 "SOPC_KIT_NIOS2 environment variable is not set!!" +fi + +project= +app="unb_osy" +skip_make= +nolib= +hexname= +userflags="-DCOMPILE_FOR_SOPC" + +# parse cmdline +for arg ; do + case ${arg} in + --no-make) + skip_make="skip_make" + ;; + --nolib) + nolib="nolib" + ;; + --hexname=*) + # if app not already set, set it now + if [ -n "${hexname}" ]; then + unb_error $0 "Do not pass more than one hex file name!" + fi + hexname=`echo ${arg} | sed 's/^--hexname=//'` + ;; + + --*) # some other option we don't care about + ;; + + app=*) + # if app not already set, set it now + if [ -n "${app}" ]; then + unb_error $0 "Do not pass more than one app name!" + fi + app=`echo ${arg} | sed 's/^app=//'` + ;; + use=qsys) + userflags="-DCOMPILE_FOR_QSYS" + ;; + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + ;; + * ) + # only accept one non-option argument, the project name + if [ -n "${project}" ]; then + unb_error $0 "You cannot pass more than one project name" + fi + project=${arg} + ;; + esac +done + +unb_info $0 "app=${app}" +unb_info $0 "Adding compiler option: ${userflags}" + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +# if no app given, default to [project] and inform user +if [ -z "${app}" ]; then + app=${project} + unb_info $0 "SELECTING DEFAULT APP '${app}'" +fi + +# Generate the paths we need +quartusdir="${PRJ}/build/quartus/${project}" +builddir="${quartusdir}/software" +bspdstdir="${builddir}/bsp" +unbsrcdir="${UNB}/Firmware/software/modules/src" +unbdstdir="${builddir}/unb_lib" +appsrcdir="${UNB}/Firmware/software/apps/${app}" +appdstdir="${builddir}/${app}" + +# Is the application available? +unb_exec $0 msg=no test -d ${appsrcdir} + +# Make sure BSP is up-to-date. +unb_exec $0 msg="Calling run_bsp" run_bsp ${toolset} $* + +if [ -z "${nolib}" ]; then + + # For now, we always generate the unb_common library. + if [ -f "${unbdstdir}/public.mk" ]; then + # assume the lib was already configured + # reload all the sourcefiles to make sure the lib + # contains all code available at this moment. + # do this by first removing all sources and + # then re-adding them + unb_exec $0 msg=no nios2-lib-update-makefile --lib-dir ${unbdstdir} --no-src + unb_exec $0 msg=no nios2-lib-update-makefile --lib-dir ${unbdstdir} \ + --add-src-dir ${unbsrcdir} + else + unb_info $0 "Configuring unb_common library" + # because of b0rkage in the nios2-lib-generate-makefile program + # where it concerns the public include directory we set this + # path correct in two steps. + # If you specify a public include dir (so it will be exported + # to an app's makefile) in the -generate-makefile command + # the library source directory will be prepended unconditionally. + # However, if you later, via the -update-makefile specify an + # include dir it will be interpreted as-is, without automagic + # prepending of any paths whatsoever + unb_exec $0 msg=no nios2-lib-generate-makefile --lib-name unb_lib \ + --bsp-dir ${bspdstdir} \ + --lib-dir ${unbdstdir} \ + --src-dir ${unbsrcdir} + unb_exec $0 msg=no nios2-lib-update-makefile --lib-dir ${unbdstdir} \ + --add-public-inc-dir ${unbsrcdir} + fi + + + # If there is already an app makefile, let's reload the appsourcedir + # so it will pick up new sourcefiles added to ${appsrcdir} since + # the last invocation + if [ -d "${appdstdir}" -a -f "${appdstdir}/Makefile" ]; then + # makefile exists, remove sources and re-add them + unb_exec $0 msg=no nios2-app-update-makefile --app-dir ${appdstdir} --no-src + unb_exec $0 msg=no nios2-app-update-makefile --app-dir ${appdstdir} \ + --add-src-dir ${appsrcdir} + else + # must generate the app makefile from scratch + unb_info $0 "Configuring application ${app}" + unb_exec $0 msg=no nios2-app-generate-makefile \ + --elf-name ${app}.elf \ + --bsp-dir ${bspdstdir} \ + --app-dir ${appdstdir} \ + --use-lib-dir ${unbdstdir} \ + --src-dir ${appsrcdir} \ + --set QUARTUS_PROJECT_DIR ${quartusdir} \ + --set OBJDUMP_INCLUDE_SOURCE 1 + unb_exec $0 msg=no nios2-app-update-makefile \ + --app-dir ${appdstdir} \ + --add-inc-dir ${appsrcdir} \ + --set-user-flags ${userflags} + fi + +#If we just want to build an app and don't want to include all the software modules +#just include common_types.h and build the app: +else + unb_info $0 "Configuring application ${app} - UNB library not included." + unb_exec $0 msg=no nios2-app-generate-makefile \ + --elf-name ${app}.elf \ + --bsp-dir ${bspdstdir} \ + --app-dir ${appdstdir} \ + --src-dir ${appsrcdir} \ + --set QUARTUS_PROJECT_DIR ${quartusdir} \ + --set OBJDUMP_INCLUDE_SOURCE 1 + unb_exec $0 msg=no nios2-app-update-makefile \ + --app-dir ${appdstdir} \ + --add-inc-dir ${unbsrcdir}/common \ + --set-user-flags ${userflags} +fi + +if [ -z "${skip_make}" ]; then + unb_exec $0 msg=no make -C ${appdstdir} +fi + + +#Create HEX from ELF +if [ -z "${hexname}" ]; then + hexname=onchip_memory2_0.hex +fi + +# figure out the onchip memory's base + end address +system_h=${bspdstdir}/system.h +if [ ! -f "${system_h}" ]; then + unb_error $0 "system.h file not found in BSP [${bspdstdir}]" + unb_error $0 "#############################################" + unb_error $0 " UNABLE TO RUN elf2hex" + exit 1 +fi + +onchip_base=`sed -n '/^[ ]*#define[ ]*ONCHIP_MEMORY2_0_BASE/{ s/^[ ]*#define[ ]*ONCHIP_MEMORY2_0_BASE[ ]*//; p}' ${system_h}` +onchip_span=`sed -n '/^[ ]*#define[ ]*ONCHIP_MEMORY2_0_SPAN/{ s/^[ ]*#define[ ]*ONCHIP_MEMORY2_0_SPAN[ ]*//; p}' ${system_h}` + +if [ -z "${onchip_base}" -o -z "${onchip_span}" ]; then + unb_error $0 "ONCHIP_MEMORY2_0_[BASE|SPAN] not found " + unb_error $0 " in BSP [${bspdstdir}]" + unb_error $0 "#############################################" + unb_error $0 " UNABLE TO RUN elf2hex" + exit 1 +fi + +# we must compute the end address and give it to elf2hex in hex +# the *NIX commanline calculators +onchip_base_dec=`printf "%d" ${onchip_base}` +onchip_span_dec=`printf "%d" ${onchip_span}` +onchip_end_dec=`expr ${onchip_base_dec} + ${onchip_span_dec} - 1` +onchip_end_hex=`printf "0x%x" ${onchip_end_dec}` +onchip_base=`printf "0x%x" ${onchip_base}` + +#Use user provided hex file name +unb_exec $0 msg="Creating HEX from ELF: ${hexname} [${onchip_base} -> ${onchip_end_hex}]" \ + elf2hex --input=${appdstdir}/${app}.elf \ + --output=${quartusdir}/${hexname} \ + --base=${onchip_base} --end=${onchip_end_hex} --width=32 \ + --create-lanes=0 + +unb_exec $0 msg="Calling run_reg" run_reg ${toolset} $* + +unb_info $0 "Done" diff --git a/tools/quartus/run_app_clean b/tools/quartus/run_app_clean new file mode 100755 index 0000000000000000000000000000000000000000..781eb7dd3854b729d5c7e69347af983666bd8bfe --- /dev/null +++ b/tools/quartus/run_app_clean @@ -0,0 +1,111 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# +# Copyright (C) 2010 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# -------------------------------------------------------------------------- # +# + +# Run this tool with at least the commandline arguments: +# run_app_clean toolset design_name +# example: +# run_app_clean unb2 unb2_minimal + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + + + +# treat unset variables as an error - better fail loudly. +# implication is that "$1" and "$2" etc cannot be used in tests +# as they may be quite unset, eg when the user did not enter +# them on the commandline. +# now you get to parse the commandline and explicitly extract +# the info you want or fill in with defaults +# bonus: extragratis failure if, for some reason, the ${UNB} +# directory is not set. +set -u + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ... ($0 is untouched) + + +project= +app= +# parse cmdline +for arg ; do + case ${arg} in + app=*) + # if app not already set, set it now + if [ -n "${app}" ]; then + unb_error $0 "Do not pass more than one app name!" + fi + app=`echo ${arg} | sed 's/^app=//'` + ;; + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + ;; + * ) + # only accept one non-option argument, the project name + if [ -n "${project}" ]; then + unb_error $0 "You cannot pass more than one project names" + fi + project=${arg} + ;; + esac +done + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +if [ -z "${app}" ]; then + app= + unb_info $0 "No app name passed. Deleting BSP, UNB_LIB and compiled apps." +fi + +# if the appdir does not exist. what to do? +# technically it's a failure; you can't clean something that isn't there +# logically one could reason: there is no need to clean something that +# isn't there so the post-condition is the same in both +# situations (exist + clean) vs (!exist + !clean). +# For now I (H. Verkouter) lean towards the logical clause since I think +# a non-fatal failure at this stage should not break other scripts +appdir="${PRJ}/build/quartus/${project}/software/${app}" + +if [ -d "${appdir}" ]; then + unb_exec $0 msg=no rm -Rf ${appdir} +fi +unb_info $0 "Done." diff --git a/tools/quartus/run_bsp b/tools/quartus/run_bsp new file mode 100755 index 0000000000000000000000000000000000000000..848ba550167fe3a7d926fb68e291cdaa793bd891 --- /dev/null +++ b/tools/quartus/run_bsp @@ -0,0 +1,158 @@ +#!/bin/bash +# +# +# Run this tool with at least the commandline arguments: +# run_bsp toolset design_name +# example: +# run_bsp unb2 unb2_minimal + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + + + +# This script creates the ucosii_net_zipfs Board Support Package (BSP). +set -u + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ... ($0 is untouched) + +force= +project= +skip_make= + +# BSP HAL settings default to +# a reduced functionality BSP +# (but much less code+data footprint) +# use "--bloat" to compile a +# fullfledged BSP +# NOTE: you'll never get C++ or +# (clean) exit support +hal_lightweight_driver=true +hal_enable_small_libc=1 + +# parse cmdline +for arg ; do + case ${arg} in + --force) + force=${arg} + shift + ;; + --no-make) + skip_make=${arg} + shift + ;; + + --nolib) + shift + ;; + + --bloat) + shift + hal_lightweight_driver=false + hal_enable_small_libc=0 + ;; + + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + shift + ;; + * ) + # only accept one non-option argument, the project name + if [ -n "${project}" ]; then + break + #unb_error $0 "You cannot pass more than one project names" + fi + project=${arg} + shift + ;; + esac +done + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +# now we can generate paths +quartusdir="${PRJ}/build/quartus/${project}" +builddir="${quartusdir}/software" +bspdir="${builddir}/bsp" + +# assert the quartusdir exists +unb_exec $0 msg=no test -d ${quartusdir} + +# If we have a makefile see if no-one changed the sopcinfo +# (since if they did we must re-generate files). +# Otherwise we must generate the BSP package + +# if "--force" given we build from scratch +if [ -n "${force}" ]; then + \rm -rf ${bspdir} +fi + +if [ -d "${bspdir}" -a -f "${bspdir}/Makefile" ]; then + #Check if sopcinfo file is newer that current BSP + # Note: HV/DS We do this in this clumsy way since + # "make -C ${bspdir} -n" and checking the exitcode + # does not work on Windows. Winders cannot discriminate + # between "time-of-last-access" and "time-of-last-modification" + # whereas under Linux this works like a charm. + # The result was that under Windows "make -n" would + # always indicate that the target needed to be rebuilt. + # Maybe there is another reason - fact is that "make" + # didn't work on windows. This does. + sopcfile=$(ls ${quartusdir}/*sopcinfo 2>/dev/null | sed -n '1p') + if [ -z "${sopcfile}" ]; then + unb_error $0 "No sopc(info) file?!!" + fi + if [ ${sopcfile} -nt ${bspdir}/settings.bsp ]; then + unb_info $0 "Someone has been tinkering with .sopcinfo" + unb_info $0 "Regenerating the BSP files" + unb_exec $0 msg=no nios2-bsp-generate-files \ + --bsp-dir ${bspdir} \ + --settings ${bspdir}/settings.bsp + fi +else + # we must generate the BSP files + unb_info $0 "Generating BSP files for ${project}" + unb_exec $0 msg=no nios2-bsp hal ${bspdir} ${quartusdir} $* +fi + +# check if we've already updated the BSP settings to our likings +if [ -f ${bspdir}/public.mk ]; then + updated_settings=`sed -n '/^ALT_CPPFLAGS *+= *-DALT_USE_DIRECT_DRIVERS/p' ${bspdir}/public.mk` + if [ -z "${updated_settings}" ]; then + # nope, not updated yet - set the settings we would like the bsp to have + unb_exec $0 nios2-bsp-update-settings --settings ${bspdir}/settings.bsp \ + --set hal.enable_lightweight_device_driver_api ${hal_lightweight_driver} \ + --set hal.enable_c_plus_plus 0 \ + --set hal.enable_clean_exit 0 \ + --set hal.enable_exit 0 \ + --set hal.enable_small_c_library ${hal_enable_small_libc} + unb_exec $0 msg=no nios2-bsp-generate-files \ + --bsp-dir ${bspdir} \ + --settings ${bspdir}/settings.bsp + # to prevent the make to complain about settings.bsp newer than Makefile ... + touch ${bspdir}/Makefile + fi +fi + +if [ -z "${skip_make}" ]; then + unb_exec $0 msg=no make -C ${bspdir} +fi diff --git a/tools/quartus/run_mif b/tools/quartus/run_mif new file mode 100755 index 0000000000000000000000000000000000000000..bd955e5f0a5e8a3fed74d083beda3b588c710505 --- /dev/null +++ b/tools/quartus/run_mif @@ -0,0 +1,151 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# +# Copyright (C) 2012 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# -------------------------------------------------------------------------- # + +# Run this tool with at least the commandline arguments: +# run_mif toolset design_name +# example: +# run_mif unb2 unb2_minimal +# + +# Convert character to ascii decimal value, print as hex +ord () +{ + printf "%02x" $(( ( 256 + $(printf '%d' "'$1"))%256 )) +} + + + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + +set -u + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ... ($0 is untouched) + + +project= +rev= + +# parse cmdline +for arg ; do + case ${arg} in + --rev=*) + rev=`echo ${arg} | sed 's/^--rev=//'` + ;; + rev=*) + rev=`echo ${arg} | sed 's/^rev=//'` + ;; + --*) # some other option we don't care about + ;; + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + ;; + * ) + # only accept one non-option argument, the project name + if [ -n "${project}" ]; then + unb_error $0 "You cannot pass more than one project name" + fi + project=${arg} + ;; + esac +done + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +quartusdir="${PRJ}/build/quartus/${project}" +builddir="${quartusdir}/software" +bspdstdir="${builddir}/bsp" + +if [ -z "${rev}" ]; then + project_rev="${project}" + unb_info $0 "No project revision passed, defaulting to ${project_rev}" +else + if [ -f "${quartusdir}/${rev}.qsf" ]; then + project_rev="${rev}" + unb_info $0 "Selecting project revision ${project_rev}" + else + unb_error $0 "Invalid project revision" + fi +fi + +reg_file=${quartusdir}/${project_rev}.reg +if [ ! -f "${reg_file}" ]; then + unb_error $0 "${project_rev}.reg file not found in [${quartusdir}]." + exit 1 +fi + +echo "DEPTH = 1024;" > ${quartusdir}/${project_rev}.mif +echo "WIDTH = 32;" >> ${quartusdir}/${project_rev}.mif +echo "ADDRESS_RADIX = DEC;" >> ${quartusdir}/${project_rev}.mif +echo "DATA_RADIX = HEX;" >> ${quartusdir}/${project_rev}.mif +echo "CONTENT BEGIN" >> ${quartusdir}/${project_rev}.mif + +unb_info $0 "Writing ${quartusdir}/${project_rev}.reg contents to ${quartusdir}/${project_rev}.mif" + +address=0 +charcnt=0 +while IFS= read -r -n1 char +do + # 4 bytes per word address: print one address per 4 chars + if [ $charcnt -eq 0 ] ; then + printf "%s" "$address" >> ${quartusdir}/${project_rev}.mif + printf " : " >> ${quartusdir}/${project_rev}.mif + fi + + ord "${char}" >> ${quartusdir}/${project_rev}.mif + + charcnt=`expr $charcnt + 1` + + # last char of word, print semicolon and newline, increment word address + if [ $(( $charcnt % 4 )) -eq 0 ] ; then + printf ";\n" >> ${quartusdir}/${project_rev}.mif + address=`expr $address + 1` + charcnt=0 + fi + +done < "${reg_file}" + +printf "\n" >> ${quartusdir}/${project_rev}.mif +echo "END;" >> ${quartusdir}/${project_rev}.mif + +unb_info $0 "Done" + diff --git a/tools/quartus/run_qcomp b/tools/quartus/run_qcomp new file mode 100755 index 0000000000000000000000000000000000000000..2916642d7f0ce721b463b5374ea8d6854e7d244e --- /dev/null +++ b/tools/quartus/run_qcomp @@ -0,0 +1,124 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# +# Copyright (C) 2012 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# -------------------------------------------------------------------------- # +# + +# Run this tool with at least the commandline arguments: +# run_qcomp toolset design_name +# example: +# run_qcomp unb2 unb2_minimal + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + + +# treat unset variables as an error - better fail loudly. +# implication is that "$1" and "$2" etc cannot be used in tests +# as they may be quite unset, eg when the user did not enter +# them on the commandline. +# now you get to parse the commandline and explicitly extract +# the info you want or fill in with defaults +# bonus: extragratis failure if, for some reason, the ${UNB} +# directory is not set. +set -u + + + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ... ($0 is untouched) + +project= +rev= +os= +# parse cmdline +for arg ; do + case ${arg} in + --32bit) + os=32 + ;; + --rev=*) + rev=`echo ${arg} | sed 's/^--rev=//'` + ;; + rev=*) + rev=`echo ${arg} | sed 's/^rev=//'` + ;; + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + ;; + * ) + # only accept one non-option argument, the project name + if [ -n "${project}" ]; then + unb_error $0 "You cannot pass more than one project names" + fi + project=${arg} + ;; + esac +done + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +# check if the quartus project directory is there +quartusdir="${PRJ}/build/quartus/${project}" +unb_exec $0 msg=no test -d ${quartusdir} + +if [ -z "${rev}" ]; then + project_rev="${project}" + unb_info $0 "No project revision passed, defaulting to ${project_rev}" +else + if [ -f "${quartusdir}/${rev}.qsf" ]; then + project_rev="${rev}" + unb_info $0 "Selecting project revision ${project_rev}" + else + unb_error $0 "Invalid project revision" + fi +fi + +cd ${quartusdir} + +if [ -z "${os}" ]; then + unb_info $0 "Assuming 64-bit OS. Pass '--32bit' to use 32-bit" + mem_width='--64bit' +else + unb_info $0 "Using 32-bit mode" + mem_width= +fi + +unb_info $0 "Performing full compile of project ${project_rev}" +quartus_sh $mem_width --flow compile ${project_rev} diff --git a/tools/quartus/run_qsys b/tools/quartus/run_qsys new file mode 100755 index 0000000000000000000000000000000000000000..82c05b51bb004123c69e721b32caa0f6e1404d29 --- /dev/null +++ b/tools/quartus/run_qsys @@ -0,0 +1,139 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# +# Copyright (C) 2010 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# -------------------------------------------------------------------------- # + +# Run this tool with the commandline arguments: +# run_qsys toolset design_name +# example: +# run_qsys unb2 unb2_minimal +# + + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + +# do NOT tolerate use of undefined variables +set -u + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ... ($0 is untouched) + +project= +qsysfile= + +# parse cmdline +for arg ; do + case ${arg} in + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + ;; + * ) + # only accept one non-option argument, the project name + if [ -n "${project}" ]; then + if [ -n "${qsysfile}" ]; then + unb_error $0 "Please specify only two non-option parameters:\na project name and, optionally, an QSYS filename" + fi + qsysfile=${arg} + else + project=${arg} + fi + ;; + esac +done + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +# Form name of quartusdir and check if it indeed exists +quartusdir="${PRJ}/build/quartus/${project}" +unb_exec $0 msg=no test -d ${quartusdir} + +# the QSYS file is optional. If it is omitted choose the first +# one we find. Let user know we do this +if [ -z "${qsysfile}" ]; then + qsysfile=$(ls ${quartusdir}/*qsys 2>/dev/null | sed -n '1p') + if [ -z "${qsysfile}" ]; then + unb_error $0 "No QSYS files found in ${quartusdir}" + fi + qsysfile=`basename ${qsysfile}` + qsysfilebase=`basename ${qsysfile} .qsys` + unb_info $0 "SELECTING DEFAULT QSYS FILE ${qsysfile} (${qsysfilebase})" +fi +unb_exec $0 msg=no test -f "${quartusdir}/${qsysfile}" + +# Great. Having asserted our preconditions, let's do it! +# note: we want unb_exec to display a slightly different msg +# AND ip-generate returns exitcode 4 on succesfull completion +# rather than the standard 0 ... +cd ${quartusdir} +txt="Generating QSYS system for project ${project}." + +unb_info $0 "generate files for simulation" +unb_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \ + --output-directory=${quartusdir}/${qsysfilebase}/simulation/ \ + --file-set=SIM_VHDL \ + --report-file=sopcinfo:${quartusdir}/${qsysfilebase}.sopcinfo \ + --report-file=html:${quartusdir}/${qsysfilebase}.html \ + --report-file=csv:${quartusdir}/${qsysfilebase}.csv \ + --report-file=spd:${quartusdir}/${qsysfilebase}.spd \ + --component-file=${quartusdir}/${qsysfile} + +unb_info $0 "create modelsim project" +unb_exec $0 msg="${txt}" expect=0 sim-script-gen --spd=${quartusdir}/${qsysfilebase}.spd \ + --output-directory=${quartusdir}/${qsysfilebase}/simulation/ + + +unb_info $0 "generate .bsf" +unb_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \ + --output-directory=${quartusdir}/${qsysfilebase}/ \ + --report-file=bsf:${quartusdir}/${qsysfilebase}.bsf \ + --component-file=${quartusdir}/${qsysfile} + + +unb_info $0 "generate HDL files for synthesis" +unb_exec $0 msg="${txt}" expect=0 ip-generate --project-directory=${quartusdir}/ \ + --output-directory=${quartusdir}/${qsysfilebase}/synthesis/ \ + --file-set=QUARTUS_SYNTH \ + --report-file=sopcinfo:${quartusdir}/${qsysfilebase}.sopcinfo \ + --report-file=html:${quartusdir}/${qsysfilebase}.html \ + --report-file=qip:${quartusdir}/${qsysfilebase}/synthesis/${qsysfilebase}.qip \ + --component-file=${quartusdir}/${qsysfile} + +unb_info $0 "QSYS generated successfully." + diff --git a/tools/quartus/run_quartus b/tools/quartus/run_quartus index 39d00dcad1e967ccd2f3e2046915a9b8250026cb..9ddc9cc91cd5880b9f78bcd556bc68e8578244e4 100755 --- a/tools/quartus/run_quartus +++ b/tools/quartus/run_quartus @@ -23,7 +23,7 @@ # General tool and project settings # - use '. <script>.sh' to have the settings apply in this shell, otherwise they get lost when <script>.sh returns -# Tool settings for selected target "", "unb1", or "unb2" (where "" defaults to target "unb1") +# Tool settings for selected target "unb1", or "unb2" . ${RADIOHDL}/tools/quartus/set_quartus ${1:-} # Start the Quartus GUI diff --git a/tools/quartus/run_rbf b/tools/quartus/run_rbf new file mode 100755 index 0000000000000000000000000000000000000000..731e7155cbe56d9a2f41f3daee7113ab27f6ccda --- /dev/null +++ b/tools/quartus/run_rbf @@ -0,0 +1,116 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# +# Copyright (C) 2012 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# -------------------------------------------------------------------------- # + +# Run this tool with at least the commandline arguments: +# run_rbf toolset design_name +# example: +# run_rbf unb2 unb2_minimal + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + + + +set -u + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ... ($0 is untouched) + +# display some info about ourselves +myself="${UNB}/Firmware/software/build/$(basename $0)" + +project= +rev= + +# parse cmdline +for arg ; do + case ${arg} in + --rev=*) + rev=`echo ${arg} | sed 's/^--rev=//'` + ;; + rev=*) + rev=`echo ${arg} | sed 's/^rev=//'` + ;; + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + ;; + --*) # some other option we don't care about + ;; + * ) + # only accept one non-option argument, the project name + if [ -n "${project}" ]; then + unb_error $0 "You cannot pass more than one project name" + fi + project=${arg} + ;; + esac +done + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +quartusdir="${PRJ}/build/quartus/${project}" + +if [ -z "${rev}" ]; then + project_rev="${project}" + unb_info $0 "No project revision passed, defaulting to ${project_rev}" +else + if [ -f "${PRJ}/Firmware/designs/${project}/build/synth/quartus/${rev}.qsf" ]; then + project_rev="${rev}" + unb_info $0 "Selecting project revision ${project_rev}" + else + unb_error $0 "Invalid project revision" + fi +fi + +sof_file=${quartusdir}/${project_rev}.sof +if [ ! -f "${sof_file}" ]; then + unb_error $0 "${project_rev}.sof not found in ${quartusdir}/" + exit 1 +fi + +echo "Bitstream_compression=on" > /tmp/temp_options_file + +unb_info $0 "Converting ${quartusdir}/${project_rev}.sof to compressed Raw Binary File" + +unb_exec $0 quartus_cpf -c --option=/tmp/temp_options_file ${quartusdir}/${project_rev}.sof ${quartusdir}/${project_rev}.rbf + +unb_info $0 "Done" + diff --git a/tools/quartus/run_reg b/tools/quartus/run_reg new file mode 100755 index 0000000000000000000000000000000000000000..7b78369e260822ab0bae9b3ca9573eb061bca050 --- /dev/null +++ b/tools/quartus/run_reg @@ -0,0 +1,137 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# +# Copyright (C) 2012 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# -------------------------------------------------------------------------- # + +# Run this tool with at least the commandline arguments: +# run_reg toolset design_name +# example: +# run_reg unb2 unb2_minimal + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + + + +set -u + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ($0 is untouched) + +# display some info about ourselves +myself="${UNB}/Firmware/software/build/$(basename $0)" + +project= +rev= + +# parse cmdline +for arg ; do + case ${arg} in + --rev=*) + rev=`echo ${arg} | sed 's/^--rev=//'` + ;; + rev=*) + rev=`echo ${arg} | sed 's/^rev=//'` + ;; + --*) # some other option we don't care about + ;; + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + ;; + * ) + # only accept one non-option argument, the project name + if [ -n "${project}" ]; then + unb_error $0 "You cannot pass more than one project name" + fi + project=${arg} + ;; + esac +done + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +quartusdir="${PRJ}/build/quartus/${project}" +builddir="${quartusdir}/software" +bspdstdir="${builddir}/bsp" + +if [ -z "${rev}" ]; then + project_rev="${project}" + unb_info $0 "No project revision passed, defaulting to ${project_rev}" +else + if [ -f "${quartusdir}/${rev}.qsf" ]; then + project_rev="${rev}" + unb_info $0 "Selecting project revision ${project_rev}" + else + unb_error $0 "Invalid project revision" + fi +fi + +system_h=${bspdstdir}/system.h +if [ ! -f "${system_h}" ]; then + unb_error $0 "system.h file not found in [${bspdstdir}]" + exit 1 +fi + +unb_info $0 "Extracting peripherals from ${bspdstdir}/system.h:" + +# Extract lines with 'BASE' or 'SPAN', remove ALT* stuff etc., remove '0x' prefix, remove '#define' and peripheral name preceding '_SPAN', remove '_BASE', finally replace newlines with spaces. +egrep "BASE|SPAN" ${system_h} | egrep -v 'ALT|TIMER|SYSTEM_INFO|ONCHIP_MEMORY2_0|JTAG_UART' | sed -e "s/\0x//g" | sed 's/^#define //' | sed 's/^.*_SPAN //' | sed -e "s/\_BASE//g" | sed ':a;N;$!ba;s/\n/ /g' > ${quartusdir}/${project_rev}.reg + +cat ${quartusdir}/${project_rev}.reg + +# Add a null character to the end of the file. +printf '\0' >> ${quartusdir}/${project_rev}.reg + +# sed: extract first number on the line (returned by wc) = size +size=`wc -c ${quartusdir}/${project_rev}.reg | sed 's/\([0-9]*\).*/\1/'` + +# See if byte size happens to be on word boundary, if not pad with more null characters +while [ $(( $size % 4 )) -ne 0 ] +do + printf '\0' >> ${quartusdir}/${project_rev}.reg + size=`wc -c ${quartusdir}/${project_rev}.reg | sed 's/\([0-9]*\).*/\1/'` +done + +unb_info $0 "Created ${quartusdir}/${project_rev}.reg" +unb_info $0 "Size of ${project_rev}.reg: ${size} bytes" + +unb_exec $0 msg="Calling unb2_mif to convert ${project_rev}.reg to ${project_rev}.mif" unb2_mif $* + +unb_info $0 "Done" + diff --git a/tools/quartus/run_sof b/tools/quartus/run_sof new file mode 100755 index 0000000000000000000000000000000000000000..bf38e8c03b258b0a60b808137b2e1673b63a7a3c --- /dev/null +++ b/tools/quartus/run_sof @@ -0,0 +1,325 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# +# Copyright (C) 2011 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# -------------------------------------------------------------------------- # +# +# Run this tool with at least the commandline arguments: +# run_sof toolset design_name +# example: +# run_sof unb2 unb2_minimal + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ... ($0 is untouched) + +command= +project= +fpgas= +cable= + +# Single board node ID's +frontnodes="0 1 2 3" +backnodes="4 5 6 7" + +# Multi board node ID's +frontnodes0="00 01 02 03" +backnodes0="04 05 06 07" +frontnodes1="10 11 12 13" +backnodes1="14 15 16 17" +frontnodes2="20 21 22 23" +backnodes2="24 25 26 27" +frontnodes3="30 31 32 33" +backnodes3="34 35 36 37" + +timelimited= +rev= + +# parse cmdline +for arg ; do + case ${arg} in + --timelimited) + timelimited="_time_limited" + ;; + --cable=*) + cable=`echo ${arg} | sed 's/^cable=//'` + ;; + --rev=*) + rev=`echo ${arg} | sed 's/^--rev=//'` + ;; + --sof=*) + sof=`echo ${arg} | sed 's/^--sof=//'` + ;; + sof=*) + sof=`echo ${arg} | sed 's/^sof=//'` + ;; + rev=*) + rev=`echo ${arg} | sed 's/^rev=//'` + ;; + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + ;; + * ) + # first non-option argument is the project name, + # all other following non-option arguments are taken + # to be nodes + if [ -n "${project}" ]; then + # if we encounter one of the "magic" strings .. + # we shortcircuit. stop commandlineprocessing + # and set nodes to whatever we take them to mean + lcarg=`echo ${arg} | tr [A-Z] [a-z]` + # Single board arguments: + if [ "${lcarg}" = "all" ]; then + nodes="${nodes} ${frontnodes} ${backnodes}" + elif [ "${lcarg}" = "fn" ]; then + nodes="${nodes} ${frontnodes}" + elif [ "${lcarg}" = "bn" ]; then + nodes="${nodes} ${backnodes}" + + # Multi board arguments: + elif [ "${lcarg}" = "0all" ]; then + nodes="${nodes} ${frontnodes0} ${backnodes0}" + elif [ "${lcarg}" = "0fn" ]; then + nodes="${nodes} ${frontnodes0}" + elif [ "${lcarg}" = "0bn" ]; then + nodes="${nodes} ${backnodes0}" + + elif [ "${lcarg}" = "1all" ]; then + nodes="${nodes} ${frontnodes1} ${backnodes1}" + elif [ "${lcarg}" = "1fn" ]; then + nodes="${nodes} ${frontnodes1}" + elif [ "${lcarg}" = "1bn" ]; then + nodes="${nodes} ${backnodes1}" + + elif [ "${lcarg}" = "2all" ]; then + nodes="${nodes} ${frontnodes2} ${backnodes2}" + elif [ "${lcarg}" = "2fn" ]; then + nodes="${nodes} ${frontnodes2}" + elif [ "${lcarg}" = "2bn" ]; then + nodes="${nodes} ${backnodes2}" + + elif [ "${lcarg}" = "3all" ]; then + nodes="${nodes} ${frontnodes3} ${backnodes3}" + elif [ "${lcarg}" = "3fn" ]; then + nodes="${nodes} ${frontnodes3}" + elif [ "${lcarg}" = "3bn" ]; then + nodes="${nodes} ${backnodes3}" + + else + nodes="${nodes} ${arg}" + fi + else + project=${arg} + fi + ;; + esac +done + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +if [ -z "${nodes}" ]; then + unb_error $0 "Please specify one or more nodes: [0..7] (single board) or [0..3][0..7] (multi board)" +fi + +# check if the quartusdirectory does exist +# (such that it won't fail with a cryptic error but with +# a readable one +quartusdir[1]="${PRJ}/build/quartus/${project}" +unb_exec $0 msg=no test -d ${quartusdir[1]} + +if [ -z "${rev}" ]; then + project_rev="${project}" + unb_info $0 "No project revision passed, defaulting to ${project_rev}" +else + if [ -f "${quartusdir[1]}/${rev}.qsf" ]; then + project_rev="${rev}" + unb_info $0 "Selecting project revision ${project_rev}" + else + unb_error $0 "Invalid project revision" + fi +fi + +if [ -z "${sof}" ]; then + : +else + if [ -f "${quartusdir[1]}/${sof}.sof" ]; then + project_rev="${sof}" + unb_info $0 "Selecting programming file ${project_rev}.sof" + else + unb_error $0 "Invalid programming file" + fi +fi + +#Convert user passed node to actual FPGA JTAG ID +#=============================================== + +# ..First detect if we're using single board or multi board (rack) notation +charcount= +digits= +for node in ${nodes}; do + # Count digits + charcount=`echo ${node} | wc -c` + # Assign to $digits only the first time, compare to $digits the rest of the iterations + if [ -z "${digits}" ]; then + digits=${charcount} + if [ "${digits}" = 2 -o "${digits}" = 3 ]; then + # Do nothing + : + else + unb_error $0 "Invalid node ID. Use [0..7] (single board) or [0..3][0..7] (multi board)" + fi + else + # Check if the rest of the passed nodes have the same notation + if [ "${charcount}" != "${digits}" ]; then + unb_error $0 "Inconsistent node IDs. Use either [0..7] (single board) or [0..3][0..7] (multi board)" + fi + fi +done + +# Now we have a proper list of nodes. Convert it to FPGA JTAG ID's. +fpga= +fpgas= +if [ "${digits}" = 2 ]; then + unb_info $0 "Processing single-board node list." + for node in ${nodes}; do + # don't accept node id>7 + if [ ${node} -gt 7 ]; then + unb_error $0 "Node ID exceeds single UniBoard range [0..7]. If desired, use multi-board node IDs [0..3][0..7]" + fi + # Append node number plus 1 to fpga list + fpgas="${fpgas} $(expr ${node} + 1)" + done +fi + + + +# In the UniRack, the JTAG board IDs for board 0 (JTAG ID 1..8) and board 1 (JTAG ID 9..16) are swapped. +# This makes it use counter loops and such, so we'll just use an associative array to map +# the multi-board IDs to actual FPGA JTAG ID. +match= +if [ "${digits}" = 3 ]; then + unb_info $0 "Processing multi-board node list." + declare -A node_jtag=(\ + ["00"]="9"\ + ["01"]="10"\ + ["02"]="11"\ + ["03"]="12"\ + ["04"]="13"\ + ["05"]="14"\ + ["06"]="15"\ + ["07"]="16"\ + ["10"]="1"\ + ["11"]="2"\ + ["12"]="3"\ + ["13"]="4"\ + ["14"]="5"\ + ["15"]="6"\ + ["16"]="7"\ + ["17"]="8"\ + ["20"]="17"\ + ["21"]="18"\ + ["22"]="19"\ + ["23"]="20"\ + ["24"]="21"\ + ["25"]="22"\ + ["26"]="23"\ + ["27"]="24"\ + ["30"]="25"\ + ["31"]="26"\ + ["32"]="27"\ + ["33"]="28"\ + ["34"]="29"\ + ["35"]="30"\ + ["36"]="31"\ + ["37"]="32"\ + ) + # uncomment the following line to print the associative array (node ID - jtag ID) + # for node in "${!node_jtag[@]}"; do echo "$node - ${node_jtag["$node"]}"; done + + # Now append an fpga JTAG ID to our fpga list for every match between the list of passed + # nodes (e.g. '00 01 02') and our associative array + for node in ${nodes}; do + match=0 + # Loop through our array + for ar_node in "${!node_jtag[@]}"; do + # Look for matching node ID + if [ ${ar_node} = ${node} ]; then + # Found a match! Append corresponding JTAG ID to our FPGA list. + fpgas="${fpgas} ${node_jtag["$node"]}" + match=1 + fi + done + # Match should be 1, otherwise user passed non-existent node ID. + if [ "${match}" = 0 ]; then + unb_error $0 "Invalid node ID. Node IDs should be passed as [0..3][0..7]" + fi + done +fi + +#Prepare second part of command: '-o p;my_project.sof@1 -o p\;my_project.sof@2' etc. +for fpga in ${fpgas}; do + command="${command} -o p;${quartusdir[1]}/${project_rev}${timelimited}.sof@${fpga}" +done + +if [ "${timelimited}" != "_time_limited" ]; then + if [ -f "${quartusdir[1]}/${project_rev}_time_limited.sof" ]; then + unb_warning $0 "Also a time-limited SOF file present. Add --timelimited to use that file" + fi +fi + +if [ -z "${cable}" ]; then + if [ -n "${UNB_DEFAULT_CABLE+x}" ]; then + unb_info $0 "Programming FPGAs @ JTAG IDs:${fpgas} on cable UNB_DEFAULT_CABLE" + unb_exec $0 quartus_pgm -m jtag ${command} --cable=${UNB_DEFAULT_CABLE} + else + unb_info $0 "Programming FPGAs @ JTAG IDs:${fpgas} on default cable 1" + unb_exec $0 quartus_pgm -m jtag ${command} --cable=1 + fi +else + unb_info $0 "Programming FPGAs @ JTAG IDs:${fpgas} with argument ${cable}" + unb_exec $0 quartus_pgm -m jtag ${command} ${cable} +fi + +#Example of full command to program fpgas 1 and 2 with unb_mesh_nios.sof: +#quartus_pgm -c USB-BLASTER -m jtag -o p\;unb_mesh_nios.sof@1 -o p\;unb_mesh_nios.sof@2 + +# Wish list: multi SOF support: +# unb2_sof unb_mesh 1 unb_tr_nonbonded --rev=bn_tr_nonbonded bn diff --git a/tools/quartus/run_sopc b/tools/quartus/run_sopc new file mode 100755 index 0000000000000000000000000000000000000000..7f11b2fd07ce5a329b5d1984b9ba88f448da4d9e --- /dev/null +++ b/tools/quartus/run_sopc @@ -0,0 +1,109 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# +# Copyright (C) 2010 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# -------------------------------------------------------------------------- # +# + +# Run this tool with at least the commandline arguments: +# run_sopc toolset design_name +# example: +# run_sopc unb1 unb1_minimal +# + +if [ ! $1 ]; then + echo "error: missing argument for toolset" + exit 1 +fi + + + +# do NOT tolerate use of undefined variables +set -u + +# read generic functions/definitions +. ${UNB}/Firmware/software/build/generic.sh + +toolset=$1 +. ${RADIOHDL}/tools/quartus/set_quartus ${toolset} +shift # shift left commandline args: $2 becomes $1 ... ($0 is untouched) + +project= +sopcfile= + +# parse cmdline +for arg ; do + case ${arg} in + *=* ) + # it was an option. skip it - if we wanted to, + # we could process them over here + ;; + * ) + # only accept one non-option argument, the project name + if [ -n "${project}" ]; then + if [ -n "${sopcfile}" ]; then + unb_error $0 "Please specify only two non-option parameters:\na project name and, optionally, an SOPC filename" + fi + sopcfile=${arg} + else + project=${arg} + fi + ;; + esac +done + +PRJS="${RADIOHDL}" + +PRJ= +for prj in ${PRJS} + do + if [ -d "${prj}/build/quartus/${project}" ]; then + PRJ=${prj} + fi + done +if [ -z "${project}" -o -z "${PRJ}" ]; then + unb_error $0 "Please enter a valid project name as parameter" +fi + +# Form name of quartusdir and check if it indeed exists +quartusdir="${PRJ}/build/quartus/${project}" +unb_exec $0 msg=no test -d ${quartusdir} + +# the SOPC file is optional. If it is omitted choose the first +# one we find. Let user know we do this +if [ -z "${sopcfile}" ]; then + sopcfile=$(ls ${quartusdir}/*sopc 2>/dev/null | sed -n '1p') + if [ -z "${sopcfile}" ]; then + unb_error $0 "No SOPC files found in ${quartusdir}" + fi + sopcfile=`basename ${sopcfile}` + unb_info $0 "SELECTING DEFAULT SOPC FILE ${sopcfile}" +fi +unb_exec $0 msg=no test -f "${quartusdir}/${sopcfile}" + +# Great. Having asserted our preconditions, let's do it! +# note: we want unb_exec to display a slightly different msg +# AND sopc_builder returns exitcode 4 on succesfull completion +# rather than the standard 0 ... +cd ${quartusdir} +txt="Generating SOPC system for project ${project}." +unb_exec $0 msg="${txt}" expect=4 sopc_builder --generate=1 ${sopcfile} + +unb_info $0 "SOPC generated successfully." diff --git a/tools/quartus/set_quartus b/tools/quartus/set_quartus index cd1e09b3756ac99473f0f6c43e1b7516cf114314..5bf890caac4a3d99e981fdddb93a1ab63774426a 100755 --- a/tools/quartus/set_quartus +++ b/tools/quartus/set_quartus @@ -22,28 +22,23 @@ # Purpose: Map command line argument to a tool version # Description: -# By using command line arguments like "", "unb1", "unb2" to select the tool +# By using command line arguments like "unb1" or "unb2" to select the tool # version it is easier to manage combinations of tool versions. # General tool and project settings # - use '. <script>.sh' to have the settings apply in this shell, otherwise they get lost when <script>.sh returns # Select target -TARGET=${1:-} -if [ "${TARGET}" = "" ]; then - TARGET="default" -fi -echo "Make Quartus settings for RadioHDL with target: ${TARGET}" +TOOLSET=${1:-} +echo "Make Quartus settings for RadioHDL with tool setting: ${TOOLSET}" # Select tool version -if [ "${TARGET}" = "default" ]; then - . ${RADIOHDL}/tools/quartus/quartus_version.sh 11.1 -elif [ "${TARGET}" = "unb1" ]; then +if [ "${TOOLSET}" = "unb1" ]; then . ${RADIOHDL}/tools/quartus/quartus_version.sh 11.1 -elif [ "${TARGET}" = "unb2" ]; then +elif [ "${TOOLSET}" = "unb2" ]; then . ${RADIOHDL}/tools/quartus/quartus_version.sh 14.0a10 else - echo "error: unknown target" + echo "error: unknown tool setting: ${TOOLSET} (choose 'unb1' or 'unb2')" exit 1 fi