From 0df3c15528ffe3fcf04a084ebe80984ecc0ec37e Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 15 Jan 2021 23:40:44 +0100 Subject: Updated scripts with version from stale branch. --- libraries/vendors/README.md | 3 + libraries/vendors/compile-altera.sh | 1042 +++++++++++++--------------- libraries/vendors/compile-intel.sh | 931 ++++++++++++------------- libraries/vendors/compile-lattice.sh | 599 ++++++++++++---- libraries/vendors/compile-osvvm.sh | 46 +- libraries/vendors/compile-uvvm.sh | 508 ++++++++------ libraries/vendors/compile-xilinx-ise.sh | 459 ++++++------ libraries/vendors/compile-xilinx-vivado.sh | 405 +++++------ libraries/vendors/shared.psm1 | 4 +- libraries/vendors/shared.sh | 85 ++- 10 files changed, 2172 insertions(+), 1910 deletions(-) (limited to 'libraries') diff --git a/libraries/vendors/README.md b/libraries/vendors/README.md index 72fbaee65..f177afc9d 100644 --- a/libraries/vendors/README.md +++ b/libraries/vendors/README.md @@ -114,6 +114,9 @@ For a detailed documentation and all command line options see - Missing features - Implement `--clean` commands +- describe usage with -P + +- document offered procedures and functions ------------------------ Author: Patrick Lehmann diff --git a/libraries/vendors/compile-altera.sh b/libraries/vendors/compile-altera.sh index b51f077a2..33216d7cf 100755 --- a/libraries/vendors/compile-altera.sh +++ b/libraries/vendors/compile-altera.sh @@ -1,8 +1,4 @@ #! /usr/bin/env bash -# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- -# vim: tabstop=2:shiftwidth=2:noexpandtab -# kate: tab-width 2; replace-tabs off; indent-width 2; -# # ============================================================================== # Authors: # Patrick Lehmann @@ -10,7 +6,7 @@ # Bash Script: # Script to compile the simulation libraries from Altera # Quartus for GHDL on Linux -# +# # Description: # ------------------------------------ # This is a Bash script (executable) which: @@ -18,6 +14,7 @@ # - compiles all Altera Quartus-II simulation libraries and packages # # ============================================================================== +# Copyright (C) 2017-2021 Patrick Lehmann - Boetzingen, Germany # Copyright (C) 2015-2016 Patrick Lehmann - Dresden, Germany # # This program is free software: you can redistribute it and/or modify @@ -34,113 +31,125 @@ # along with this program. If not, see . # ============================================================================== -# --------------------------------------------- -# work around for Darwin (Mac OS) +# Work around for Darwin (Mac OS) READLINK=readlink; if [[ $(uname) == "Darwin" ]]; then READLINK=greadlink; fi -# save working directory +# Save working directory WorkingDir=$(pwd) ScriptDir="$(dirname $0)" ScriptDir="$($READLINK -f $ScriptDir)" -# source configuration file from GHDL's 'vendors' library directory -. $ScriptDir/../ansi_color.sh -. $ScriptDir/config.sh -. $ScriptDir/shared.sh - -# command line argument processing -NO_COMMAND=1 -SKIP_EXISTING_FILES=0 +# Source Bash utilities +source $ScriptDir/../ansi_color.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading Bash utilities.${ANSI_NOCOLOR}" ; exit 1; fi + + +# Command line argument processing +COMMAND=1 +CLEAN=0 +COMPILE_ALTERA=0 +COMPILE_MAX=0 +COMPILE_CYCLONE=0 +COMPILE_ARRIA=0 +COMPILE_STRATIX=0 +COMPILE_NM=0 +VERBOSE=0 +DEBUG=0 +FILTERING=0 # TODO: 1 SKIP_LARGE_FILES=0 SUPPRESS_WARNINGS=0 HALT_ON_ERROR=0 VHDLStandard=93 -GHDLBinDir="" DestDir="" SrcDir="" while [[ $# > 0 ]]; do - key="$1" - case $key in + case "$1" in -c|--clean) - CLEAN=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + CLEAN=1 + ;; -a|--all) - COMPILE_ALL=TRUE - NO_COMMAND=0 - ;; + COMMAND=2 + ;; --altera) - COMPILE_ALTERA=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_ALTERA=1 + ;; --max) - COMPILE_MAX=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_MAX=1 + ;; --cyclone) - COMPILE_CYCLONE=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_CYCLONE=1 + ;; --arria) - COMPILE_ARRIA=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_ARRIA=1 + ;; --stratix) - COMPILE_STRATIX=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_STRATIX=1 + ;; --nanometer) - COMPILE_NM=TRUE - NO_COMMAND=0 - ;; - -h|--help) - HELP=TRUE - NO_COMMAND=0 - ;; - -s|--skip-existing) - SKIP_EXISTING_FILES=1 - ;; + COMMAND=3 + COMPILE_NM=1 + ;; -S|--skip-largefiles) - SKIP_LARGE_FILES=1 - ;; - -n|--no-warnings) - SUPPRESS_WARNINGS=1 - ;; - -H|--halt-on-error) - HALT_ON_ERROR=1 - ;; + SKIP_LARGE_FILES=1 + ;; --vhdl93) - VHDLStandard=93 - ;; + VHDLStandard=93 + ;; --vhdl2008) - VHDLStandard=2008 - ;; + VHDLStandard=2008 + ;; + -v|--verbose) + VERBOSE=1 + ;; + -d|--debug) + VERBOSE=1 + DEBUG=1 + ;; + -h|--help) + COMMAND=0 + break + ;; + -n|--no-filter) + FILTERING=0 + ;; + -N|--no-warnings) + SUPPRESS_WARNINGS=1 + ;; + -H|--halt-on-error) + HALT_ON_ERROR=1 + ;; --ghdl) - GHDLBinDir="$2" - shift # skip argument - ;; + GHDL="$2" # overwrite a potentially existing GHDL environment variable + shift # skip argument + ;; --src) - SrcDir="$2" - shift # skip argument - ;; + SrcDir="$2" + shift # skip argument + ;; --out) - DestDir="$2" - shift # skip argument - ;; + DestDir="$2" + shift # skip argument + ;; *) # unknown option - echo 1>&2 -e "${COLORED_ERROR} Unknown command line option '$key'.${ANSI_NOCOLOR}" - exit -1 - ;; + echo 1>&2 -e "\n${COLORED_ERROR} Unknown command line option '$1'.${ANSI_NOCOLOR}" + COMMAND=0 + break + ;; esac - shift # past argument or value + shift # parsed argument or value done -if [ $NO_COMMAND -eq 1 ]; then - HELP=TRUE -fi +ERRORCOUNT=0 +Libraries=() -if [ "$HELP" == "TRUE" ]; then - test $NO_COMMAND -eq 1 && echo 1>&2 -e "\n${COLORED_ERROR} No command selected." +if [[ $COMMAND -le 1 ]]; then + test $COMMAND -eq 1 && echo 1>&2 -e "\n${COLORED_ERROR} No command selected.${ANSI_NOCOLOR}" echo "" echo "Synopsis:" echo " A script to compile the Altera Quartus simulation libraries for GHDL on Linux." @@ -150,51 +159,53 @@ if [ "$HELP" == "TRUE" ]; then echo " Use the adv. options or edit 'config.sh' to supply paths and default params." echo "" echo "Usage:" - echo " compile-altera.sh | [] []" + echo " compile-altera.sh [] | [] []" echo "" echo "Common commands:" - echo " -h --help Print this help page" - echo " -c --clean Remove all generated files" + echo " -h --help Print this help page" + echo " -c --clean Remove all generated files" echo "" echo "Libraries:" - echo " -a --all Compile all Altera simulation libraries." - echo " --altera Compile the Altera standard libraries: lpm, sgate, altera, altera_mf, altera_lnsim." - echo " --max Compile the Altera Max device libraries." - echo " --cyclone Compile the Altera Cyclone device libraries." - echo " --arria Compile the Altera Arria device libraries." - echo " --stratix Compile the Altera Stratix device libraries." - echo " --nanometer Unknown device library." + echo " -a --all Compile all Altera simulation libraries." + echo " --altera Compile the Altera standard libraries: lpm, sgate, altera, altera_mf, altera_lnsim." + echo " --max Compile the Altera Max device libraries." + echo " --cyclone Compile the Altera Cyclone device libraries." + echo " --arria Compile the Altera Arria device libraries." + echo " --stratix Compile the Altera Stratix device libraries." + echo " --nanometer Unknown device library." echo "" echo "Library compile options:" - echo " --vhdl93 Compile the libraries with VHDL-93." - echo " --vhdl2008 Compile the libraries with VHDL-2008." - echo " -s --skip-existing Skip already compiled files (an *.o file exists)." - echo " -S --skip-largefiles Don't compile large files. Exclude *HSSI* and *HIP* files." - echo " -H --halt-on-error Halt on error(s)." + echo " --vhdl93 Compile the libraries with VHDL-93." + echo " --vhdl2008 Compile the libraries with VHDL-2008." + echo " -S --skip-largefiles Don't compile large files. Exclude *HSSI* and *HIP* files." + echo " -H --halt-on-error Halt on error(s)." echo "" echo "Advanced options:" - echo " --ghdl Path to GHDL's binary directory, e.g. /usr/local/bin" - echo " --out Name of the output directory, e.g. xilinx-vivado" - echo " --src Path to the sources, e.g. /opt/altera/16.0/quartus/eda/sim_lib" + echo " --ghdl Path to GHDL's executable, e.g. /usr/local/bin/ghdl" + echo " --out Name of the output directory, e.g. uvvm_util" + echo " --src Path to the sources." echo "" echo "Verbosity:" - echo " -n --no-warnings Suppress all warnings. Show only error messages." + echo " -v --verbose Print verbose messages." + echo " -d --debug Print debug messages." +# echo " -n --no-filter Disable output filtering scripts." + echo " -N --no-warnings Suppress all warnings. Show only error messages." echo "" - exit 0 + exit $COMMAND fi -if [ "$COMPILE_ALL" == "TRUE" ]; then - COMPILE_ALTERA=TRUE - COMPILE_MAX=TRUE - COMPILE_CYCLONE=TRUE - COMPILE_ARRIA=TRUE - COMPILE_STRATIX=TRUE - COMPILE_NM=TRUE +if [[ $COMMAND -eq 2 ]]; then + COMPILE_ALTERA=1 + COMPILE_MAX=1 + COMPILE_CYCLONE=1 + COMPILE_ARRIA=1 + COMPILE_STRATIX=1 + COMPILE_NM=1 fi -if [ $VHDLStandard -eq 2008 ]; then - echo -e "${ANSI_RED}Not all Altera packages are VHDL-2008 compatible! Setting HALT_ON_ERROR to FALSE.${ANSI_NOCOLOR}" - HALT_ON_ERROR=0 +if [[ $VHDLStandard -eq 2008 ]]; then + echo -e "${ANSI_RED}Not all Altera packages are VHDL-2008 compatible! Setting CONTINUE_ON_ERROR to TRUE.${ANSI_NOCOLOR}" + CONTINUE_ON_ERROR=1 fi DefaultDirectories=("/opt/Altera" "/opt/altera") @@ -202,8 +213,8 @@ if [ ! -z $QUARTUS_ROOTDIR ]; then EnvSourceDir=$QUARTUS_ROOTDIR/${SourceDirectories[AlteraQuartus]} else for DefaultDir in ${DefaultDirectories[@]}; do - for Major in 17 16 15 14 13; do - for Minor in 3 2 1 0; do + for Major in 16 15 14 13; do + for Minor in 1 0; do Dir=$DefaultDir/${Major}.${Minor}/quartus if [ -d $Dir ]; then EnvSourceDir=$Dir/${SourceDirectories[AlteraQuartus]} @@ -214,14 +225,19 @@ else done fi +# Source configuration file from GHDL's 'vendors' library directory +echo -e "${ANSI_MAGENTA}Loading environment...${ANSI_NOCOLOR}" +source $ScriptDir/config.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading configuration.${ANSI_NOCOLOR}" ; exit 1; fi +source $ScriptDir/shared.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading further procedures.${ANSI_NOCOLOR}"; exit 1; fi + # -> $SourceDirectories # -> $DestinationDirectories # -> $SrcDir # -> $DestDir -# -> $GHDLBinDir # <= $SourceDirectory # <= $DestinationDirectory -# <= $GHDLBinary SetupDirectories AlteraQuartus "Altera Quartus" # create "osvvm" directory and change to it @@ -229,33 +245,31 @@ SetupDirectories AlteraQuartus "Altera Quartus" CreateDestinationDirectory cd $DestinationDirectory - -# => $SUPPRESS_WARNINGS -# <= $GRC_COMMAND -SetupGRCat - - # -> $VHDLStandard # <= $VHDLVersion # <= $VHDLStandard # <= $VHDLFlavor GHDLSetup -# define global GHDL Options -GHDL_OPTIONS=(-fexplicit -frelaxed-rules --no-vital-checks --warn-binding --mb-comments) +# Extend global GHDL Options +Analyze_Parameters+=( + -fexplicit + --no-vital-checks + -Wbinding + -Wno-hide + -Wno-others + -Wno-parenthesis + --ieee=$VHDLFlavor + --std=$VHDLStandard + -P$DestinationDirectory +) -GHDL_PARAMS=(--ieee=$VHDLFlavor --std=$VHDLStandard -P$DestinationDirectory) -GHDL_PARAMS+=(${GHDL_OPTIONS[@]}) - -STOPCOMPILING=0 -ERRORCOUNT=0 - # Cleanup directories # ============================================================================== -if [ "$CLEAN" == "TRUE" ]; then +if [[ $CLEAN -eq 1 ]]; then echo 1>&2 -e "${COLORED_ERROR} '--clean' is not implemented!" - exit -1 + exit 1 echo -e "${ANSI_YELLOW}Cleaning up vendor directory ...${ANSI_NOCOLOR}" rm *.o 2> /dev/null rm *.cf 2> /dev/null @@ -264,520 +278,418 @@ fi # Altera standard libraries # ============================================================================== -# compile lpm library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ALTERA" == "TRUE" ]; then - Library="lpm" - Files=( - 220pack.vhd - 220model.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi - -# compile sgate library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ALTERA" == "TRUE" ]; then - Library="sgate" - Files=( - sgate_pack.vhd - sgate.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi - -# compile altera library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ALTERA" == "TRUE" ]; then - Library="altera" - Files=( - altera_europa_support_lib.vhd - altera_primitives_components.vhd - altera_primitives.vhd - altera_standard_functions.vhd - altera_syn_attributes.vhd - alt_dspbuilder_package.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi +StructName="LPM" +Files=( + 220pack.vhd + 220model.vhd +) +CreateLibraryStruct $StructName "lpm" "." $VHDLVersion "${Files[@]}" +test $COMPILE_ALTERA -eq 1 && Libraries+=($StructName) + +StructName="SGATE" +Files=( + sgate_pack.vhd + sgate.vhd +) +CreateLibraryStruct $StructName "sgate" "." $VHDLVersion "${Files[@]}" +test $COMPILE_ALTERA -eq 1 && Libraries+=($StructName) + +StructName="ALTERA" +Files=( + altera_europa_support_lib.vhd + altera_primitives_components.vhd + altera_primitives.vhd + altera_standard_functions.vhd + altera_syn_attributes.vhd + alt_dspbuilder_package.vhd +) +CreateLibraryStruct $StructName "altera" "." $VHDLVersion "${Files[@]}" +test $COMPILE_ALTERA -eq 1 && Libraries+=($StructName) + +StructName="ALTERA_MF" +Files=( + altera_mf_components.vhd + altera_mf.vhd +) +CreateLibraryStruct $StructName "altera_mf" "." $VHDLVersion "${Files[@]}" +test $COMPILE_ALTERA -eq 1 && Libraries+=($StructName) + + +StructName="ALTERA_LNSIM" +Files=( + altera_lnsim_components.vhd +) +CreateLibraryStruct $StructName "altera_lnsim" "." $VHDLVersion "${Files[@]}" +test $COMPILE_ALTERA -eq 1 && Libraries+=($StructName) -# compile altera_mf library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ALTERA" == "TRUE" ]; then - Library="altera_mf" - Files=( - altera_mf_components.vhd - altera_mf.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi - -# compile altera_lnsim library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ALTERA" == "TRUE" ]; then - Library="altera_lnsim" - Files=( - altera_lnsim_components.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi # Altera device libraries # ============================================================================== -# compile Max library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_MAX" == "TRUE" ]; then - Library="max" - Files=( - max_atoms.vhd - max_components.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi - -# compile MaxII library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_MAX" == "TRUE" ]; then - Library="maxii" - Files=( - maxii_atoms.vhd - maxii_components.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi - -# compile MaxV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_MAX" == "TRUE" ]; then - Library="maxv" - Files=( - maxv_atoms.vhd - maxv_components.vhd +test $VERBOSE -eq 1 && echo -e " Searching available devices ..." + +# Max library +StructName="MAX" +Files=( + max_atoms.vhd + max_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Max'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "max" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_MAX -eq 1 && Libraries+=($StructName) +fi + +# Max II library +StructName="MAX_II" +Files=( + maxii_atoms.vhd + maxii_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Max II'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "maxii" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_MAX -eq 1 && Libraries+=($StructName) +fi + +# Max V library +StructName="MAX_V" +Files=( + maxv_atoms.vhd + maxv_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Max V'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "maxv" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_MAX -eq 1 && Libraries+=($StructName) +fi + +# Arria II library +StructName="ARRIA_II" +Files=( + arriaii_atoms.vhd + arriaii_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + arriaii_hssi_components.vhd + arriaii_hssi_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria II'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriaii" "." $VHDLVersion "${Files[@]}" -# compile ArriaII library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ]; then - Library="arriaii" - Files=( - arriaii_atoms.vhd - arriaii_components.vhd - ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - arriaii_hssi_components.vhd - arriaii_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) fi -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ] && [ $SKIP_LARGE_FILES -eq 0 ]; then - Library="arriaii_pcie_hip" +# Arria II (PCIe) library +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + StructName="ARRIA_II_PCIe" Files=( arriaii_pcie_hip_components.vhd arriaii_pcie_hip_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done + if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria II (PCIe)'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriaii_pcie_hip" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) + fi fi -# compile ArriaIIGZ library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ]; then - Library="arriaiigz" - Files=( - arriaiigz_atoms.vhd - arriaiigz_components.vhd +# ArriaII GZ library +StructName="ARRIA_II_GZ" +Files=( + arriaiigz_atoms.vhd + arriaiigz_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + arriaiigz_hssi_components.vhd ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - arriaiigz_hssi_components.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria II GZ'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriaiigz" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) fi -# compile ArriaV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ]; then - Library="arriav" - Files=( - arriav_atoms.vhd - arriav_components.vhd +# ArriaV library +StructName="ARRIA_V" +Files=( + arriav_atoms.vhd + arriav_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + arriav_hssi_components.vhd + arriav_hssi_atoms.vhd ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - arriav_hssi_components.vhd - arriav_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria V'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriav" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) fi -# compile ArriaVGZ library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ]; then - Library="arriavgz" - Files=( - arriavgz_atoms.vhd - arriavgz_components.vhd +# Arria V GZ library +StructName="ARRIA_V_GZ" +Files=( + arriavgz_atoms.vhd + arriavgz_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + arriavgz_hssi_components.vhd + arriavgz_hssi_atoms.vhd ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - arriavgz_hssi_components.vhd - arriavgz_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria V GZ'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriavgz" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) fi -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ] && [ $SKIP_LARGE_FILES -eq 0 ]; then - Library="arriavgz_pcie_hip" +# Arria V GZ (PCIe) library +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + StructName="ARRIA_V_GZ_PCIe" Files=( arriavgz_pcie_hip_components.vhd arriavgz_pcie_hip_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi -# compile Cyclone library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CYCLONE" == "TRUE" ]; then - Library="cyclone" - Files=( - cyclone_atoms.vhd - cyclone_components.vhd - ) - - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - FullPath="$SourceDirectory/$File" - #Don't put nonexisting files. - if [ -f $FullPath ]; then - SourceFiles+=($FullPath) - elif [ $SUPPRESS_WARNINGS -eq 0 ] ; then - echo -e "${ANSI_YELLOW}File ${FullPath} not found.${ANSI_NOCOLOR}" - fi - done + if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria V GZ (PCIe)'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriavgz_pcie_hip" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) + fi fi -# compile CycloneII library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CYCLONE" == "TRUE" ]; then - Library="cycloneii" - Files=( - cycloneii_atoms.vhd - cycloneii_components.vhd - ) - - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - FullPath="$SourceDirectory/$File" - #Don't put nonexisting files. - if [ -f $FullPath ]; then - SourceFiles+=($FullPath) - elif [ $SUPPRESS_WARNINGS -eq 0 ] ; then - echo -e "${ANSI_YELLOW}File ${FullPath} not found.${ANSI_NOCOLOR}" - fi - done - GHDLCompilePackages -fi -# compile Cyclone III library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CYCLONE" == "TRUE" ]; then - Library="cycloneiii" - Files=( - cycloneiii_atoms.vhd - cycloneiii_components.vhd +# Cyclone library +StructName="CYCLONE" +Files=( + cyclone_atoms.vhd + cyclone_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Cyclone'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "cyclone" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_CYCLONE -eq 1 && Libraries+=($StructName) +fi + +# Cyclone II library +StructName="CYCLONE_II" +Files=( + cycloneii_atoms.vhd + cycloneii_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Cyclone II'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "cycloneii" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_CYCLONE -eq 1 && Libraries+=($StructName) +fi + +# Cyclone III library +StructName="CYCLONE_III" +Files=( + cycloneiii_atoms.vhd + cycloneiii_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Cyclone III'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "cycloneiii" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_CYCLONE -eq 1 && Libraries+=($StructName) +fi + +# Cyclone IV library +StructName="CYCLONE_IV" +Files=( + cycloneiv_atoms.vhd + cycloneiv_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + cycloneiv_hssi_components.vhd + cycloneiv_hssi_atoms.vhd ) - - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - FullPath="$SourceDirectory/$File" - #Don't put nonexisting files. - if [ -f $FullPath ]; then - SourceFiles+=($FullPath) - elif [ $SUPPRESS_WARNINGS -eq 0 ] ; then - echo -e "${ANSI_YELLOW}File ${FullPath} not found.${ANSI_NOCOLOR}" - fi - done - - GHDLCompilePackages fi -# compile CycloneIV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CYCLONE" == "TRUE" ]; then - Library="cycloneiv" - Files=( - cycloneiv_atoms.vhd - cycloneiv_components.vhd - ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - cycloneiv_hssi_components.vhd - cycloneiv_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Cyclone IV'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "cycloneiv" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_CYCLONE -eq 1 && Libraries+=($StructName) fi -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CYCLONE" == "TRUE" ] && [ $SKIP_LARGE_FILES -eq 0 ]; then - Library="cycloneiv_pcie_hip" +# Cyclone IV (PCIe) library +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + StructName="CYCLONE_IV_PCIe" Files=( cycloneiv_pcie_hip_components.vhd cycloneiv_pcie_hip_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done + if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Cyclone IV (PCIe)'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "cycloneiv_pcie_hip" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_CYCLONE -eq 1 && Libraries+=($StructName) + fi fi -# compile CycloneIVE library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CYCLONE" == "TRUE" ]; then - Library="cycloneive" - Files=( - cycloneive_atoms.vhd - cycloneive_components.vhd +# Cyclone IV E library +StructName="CYCLONE_IV_E" +Files=( + cycloneive_atoms.vhd + cycloneive_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Cyclone IV E'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "cycloneive" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_CYCLONE -eq 1 && Libraries+=($StructName) +fi + +# Cyclone V library +StructName="CYCLONE_V" +Files=( + cyclonev_atoms.vhd + cyclonev_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + cyclonev_hssi_components.vhd + cyclonev_hssi_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Cyclone V'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "cyclonev" "." $VHDLVersion "${Files[@]}" -# compile CycloneV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CYCLONE" == "TRUE" ]; then - Library="cyclonev" - Files=( - cyclonev_atoms.vhd - cyclonev_components.vhd - ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - cyclonev_hssi_components.vhd - cyclonev_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - FullPath="$SourceDirectory/$File" - #Don't put nonexisting files. - if [ -f $FullPath ]; then - SourceFiles+=($FullPath) - elif [ $SUPPRESS_WARNINGS -eq 0 ] ; then - echo -e "${ANSI_YELLOW}File ${FullPath} not found.${ANSI_NOCOLOR}" - fi - done - - GHDLCompilePackages + test $COMPILE_CYCLONE -eq 1 && Libraries+=($StructName) fi -# compile StratixIV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_STRATIX" == "TRUE" ]; then - Library="stratixiv" - Files=( - stratixiv_atoms.vhd - stratixiv_components.vhd +# Stratix IV library +StructName="STRATIX_IV" +Files=( + stratixiv_atoms.vhd + stratixiv_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + stratixiv_hssi_components.vhd + stratixiv_hssi_atoms.vhd ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - stratixiv_hssi_components.vhd - stratixiv_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Stratix IV'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "stratixiv" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_STRATIX -eq 1 && Libraries+=($StructName) fi -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_STRATIX" == "TRUE" ] && [ $SKIP_LARGE_FILES -eq 0 ]; then - Library="stratixiv_pcie_hip" +# Stratix IV (PCIe) library +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + StructName="STRATIX_IV_PCIe" Files=( stratixiv_pcie_hip_components.vhd stratixiv_pcie_hip_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done + if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Stratix IV (PCIe)'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "stratixiv_pcie_hip" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_STRATIX -eq 1 && Libraries+=($StructName) + fi fi -# compile StratixV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_STRATIX" == "TRUE" ]; then - Library="stratixv" - Files=( - stratixv_atoms.vhd - stratixv_components.vhd +# Stratix V library +StructName="STRATIX_V" +Files=( + stratixv_atoms.vhd + stratixv_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + stratixv_hssi_components.vhd + stratixv_hssi_atoms.vhd ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - stratixv_hssi_components.vhd - stratixv_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Stratix V'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "stratixv" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_STRATIX -eq 1 && Libraries+=($StructName) fi -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_STRATIX" == "TRUE" ] && [ $SKIP_LARGE_FILES -eq 0 ]; then - Library="stratixv_pcie_hip" +# Stratix V (PCIe) library +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + StructName="STRATIX_V_PCIe" Files=( stratixv_pcie_hip_components.vhd stratixv_pcie_hip_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done + if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Stratix V (PCIe)'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "stratixv_pcie_hip" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_STRATIX -eq 1 && Libraries+=($StructName) + fi fi -# compile fiftyfivenm library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_NM" == "TRUE" ]; then - Library="fiftyfivenm" - Files=( - fiftyfivenm_atoms.vhd - fiftyfivenm_components.vhd +# 55 nm library +StructName="NM_55" +Files=( + fiftyfivenm_atoms.vhd + fiftyfivenm_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device '55 nm'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "fiftyfivenm" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_NM -eq 1 && Libraries+=($StructName) +fi + +# 20 nm library +StructName="NM_20" +Files=( + twentynm_atoms.vhd + twentynm_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + twentynm_hip_components.vhd + twentynm_hip_atoms.vhd + twentynm_hssi_components.vhd + twentynm_hssi_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device '20 nm'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "twentynm" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_NM -eq 1 && Libraries+=($StructName) fi -# compile twentynm library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_NM" == "TRUE" ]; then - Library="twentynm" - Files=( - twentynm_atoms.vhd - twentynm_components.vhd - ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - twentynm_hip_components.vhd - twentynm_hip_atoms.vhd - twentynm_hssi_components.vhd - twentynm_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +# if [[ $DEBUG -eq 1 ]]; then + # for StructName in ${Libraries[*]}; do + # PrintLibraryStruct $StructName " " + # done +# fi - GHDLCompilePackages -fi +# Compile libraries +if [[ "$Libraries" != "" ]]; then + Compile "$SourceDirectory" "${Libraries[*]}" -echo "--------------------------------------------------------------------------------" -echo -n "Compiling Altera Quartus libraries " -if [ $ERRORCOUNT -gt 0 ]; then - echo -e $COLORED_FAILED + echo "--------------------------------------------------------------------------------" + echo -e "Compiling Altera Quartus packages and device libraries $(test $ERRORCOUNT -eq 0 && echo $COLORED_SUCCESSFUL || echo $COLORED_FAILED)" else - echo -e $COLORED_SUCCESSFUL + echo -e "${ANSI_RED}Neither Altera Quartus packages nor device libraries selected.${ANSI_NOCOLOR}" fi diff --git a/libraries/vendors/compile-intel.sh b/libraries/vendors/compile-intel.sh index 250292ce1..fb61f10bd 100755 --- a/libraries/vendors/compile-intel.sh +++ b/libraries/vendors/compile-intel.sh @@ -1,16 +1,12 @@ #! /usr/bin/env bash -# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- -# vim: tabstop=2:shiftwidth=2:noexpandtab -# kate: tab-width 2; replace-tabs off; indent-width 2; -# # ============================================================================== # Authors: # Patrick Lehmann -# +# # Bash Script: # Script to compile the simulation libraries from Altera # Quartus for GHDL on Linux -# +# # Description: # ------------------------------------ # This is a Bash script (executable) which: @@ -18,6 +14,7 @@ # - compiles all Altera Quartus-II simulation libraries and packages # # ============================================================================== +# Copyright (C) 2017-2021 Patrick Lehmann - Boetzingen, Germany # Copyright (C) 2015-2016 Patrick Lehmann - Dresden, Germany # # This program is free software: you can redistribute it and/or modify @@ -34,176 +31,190 @@ # along with this program. If not, see . # ============================================================================== -# --------------------------------------------- -# work around for Darwin (Mac OS) +# Work around for Darwin (Mac OS) READLINK=readlink; if [[ $(uname) == "Darwin" ]]; then READLINK=greadlink; fi -# save working directory +# Save working directory WorkingDir=$(pwd) ScriptDir="$(dirname $0)" ScriptDir="$($READLINK -f $ScriptDir)" -# source configuration file from GHDL's 'vendors' library directory -. $ScriptDir/../ansi_color.sh -. $ScriptDir/config.sh -. $ScriptDir/shared.sh - -# command line argument processing -NO_COMMAND=1 -SKIP_EXISTING_FILES=0 +# Source Bash utilities +source $ScriptDir/../ansi_color.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading Bash utilities.${ANSI_NOCOLOR}" ; exit 1; fi + + +# Command line argument processing +COMMAND=1 +CLEAN=0 +COMPILE_ALTERA=0 +COMPILE_MAX=0 +COMPILE_CYCLONE=0 +COMPILE_ARRIA=0 +COMPILE_STRATIX=0 +COMPILE_NM=0 +VERBOSE=0 +DEBUG=0 +FILTERING=0 # TODO: 1 SKIP_LARGE_FILES=0 SUPPRESS_WARNINGS=0 HALT_ON_ERROR=0 VHDLStandard=93 -GHDLBinDir="" DestDir="" SrcDir="" while [[ $# > 0 ]]; do - key="$1" - case $key in + case "$1" in -c|--clean) - CLEAN=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + CLEAN=1 + ;; -a|--all) - COMPILE_ALL=TRUE - NO_COMMAND=0 - ;; + COMMAND=2 + ;; --altera) - COMPILE_ALTERA=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_ALTERA=1 + ;; --max) - COMPILE_MAX=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_MAX=1 + ;; --cyclone) - COMPILE_CYCLONE=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_CYCLONE=1 + ;; --arria) - COMPILE_ARRIA=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_ARRIA=1 + ;; --stratix) - COMPILE_STRATIX=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_STRATIX=1 + ;; --nanometer) - COMPILE_NM=TRUE - NO_COMMAND=0 - ;; - -h|--help) - HELP=TRUE - NO_COMMAND=0 - ;; - -s|--skip-existing) - SKIP_EXISTING_FILES=1 - ;; + COMMAND=3 + COMPILE_NM=1 + ;; -S|--skip-largefiles) - SKIP_LARGE_FILES=1 - ;; - -n|--no-warnings) - SUPPRESS_WARNINGS=1 - ;; - -H|--halt-on-error) - HALT_ON_ERROR=1 - ;; + SKIP_LARGE_FILES=1 + ;; --vhdl93) - VHDLStandard=93 - ;; + VHDLStandard=93 + ;; --vhdl2008) - VHDLStandard=2008 - ;; + VHDLStandard=2008 + ;; + -v|--verbose) + VERBOSE=1 + ;; + -d|--debug) + VERBOSE=1 + DEBUG=1 + ;; + -h|--help) + COMMAND=0 + break + ;; + -n|--no-filter) + FILTERING=0 + ;; + -N|--no-warnings) + SUPPRESS_WARNINGS=1 + ;; + -H|--halt-on-error) + HALT_ON_ERROR=1 + ;; --ghdl) - GHDLBinDir="$2" - shift # skip argument - ;; + GHDL="$2" # overwrite a potentially existing GHDL environment variable + shift # skip argument + ;; --src) - SrcDir="$2" - shift # skip argument - ;; + SrcDir="$2" + shift # skip argument + ;; --out) - DestDir="$2" - shift # skip argument - ;; + DestDir="$2" + shift # skip argument + ;; *) # unknown option - echo 1>&2 -e "${COLORED_ERROR} Unknown command line option '$key'.${ANSI_NOCOLOR}" - exit -1 - ;; + echo 1>&2 -e "\n${COLORED_ERROR} Unknown command line option '$1'.${ANSI_NOCOLOR}" + COMMAND=0 + break + ;; esac - shift # past argument or value + shift # parsed argument or value done -if [ $NO_COMMAND -eq 1 ]; then - HELP=TRUE -fi +ERRORCOUNT=0 +Libraries=() -if [ "$HELP" == "TRUE" ]; then - test $NO_COMMAND -eq 1 && echo 1>&2 -e "\n${COLORED_ERROR} No command selected." +if [[ $COMMAND -le 1 ]]; then + test $COMMAND -eq 1 && echo 1>&2 -e "\n${COLORED_ERROR} No command selected.${ANSI_NOCOLOR}" echo "" echo "Synopsis:" - echo " A script to compile the Altera Quartus simulation libraries for GHDL on Linux." + echo " A script to compile the Intel Quartus Prime simulation libraries for GHDL on Linux." echo " One library folder 'lib/v??' per VHDL library will be created relative to the current" echo " working directory." echo "" echo " Use the adv. options or edit 'config.sh' to supply paths and default params." echo "" echo "Usage:" - echo " compile-altera.sh | [] []" + echo " compile-intel.sh [] | [] []" echo "" echo "Common commands:" - echo " -h --help Print this help page" - echo " -c --clean Remove all generated files" + echo " -h --help Print this help page" + echo " -c --clean Remove all generated files" echo "" echo "Libraries:" - echo " -a --all Compile all Altera simulation libraries." - echo " --altera Compile the Altera standard libraries: lpm, sgate, altera, altera_mf, altera_lnsim." - echo " --max Compile the Altera Max device libraries." - echo " --cyclone Compile the Altera Cyclone device libraries." - echo " --arria Compile the Altera Arria device libraries." - echo " --stratix Compile the Altera Stratix device libraries." - echo " --nanometer Unknown device library." + echo " -a --all Compile all Intel simulation libraries." + echo " --intel Compile the Altera standard libraries: lpm, sgate, altera, altera_mf, altera_lnsim." + echo " --max Compile the Intel Max device libraries." + echo " --cyclone Compile the Intel Cyclone device libraries." + echo " --arria Compile the Intel Arria device libraries." + echo " --stratix Compile the Intel Stratix device libraries." + echo " --nanometer Unknown device library." echo "" echo "Library compile options:" - echo " --vhdl93 Compile the libraries with VHDL-93." - echo " --vhdl2008 Compile the libraries with VHDL-2008." - echo " -s --skip-existing Skip already compiled files (an *.o file exists)." - echo " -S --skip-largefiles Don't compile large files. Exclude *HSSI* and *HIP* files." - echo " -H --halt-on-error Halt on error(s)." + echo " --vhdl93 Compile the libraries with VHDL-93." + echo " --vhdl2008 Compile the libraries with VHDL-2008." + echo " -S --skip-largefiles Don't compile large files. Exclude *HSSI* and *HIP* files." + echo " -H --halt-on-error Halt on error(s)." echo "" echo "Advanced options:" - echo " --ghdl Path to GHDL's binary directory, e.g. /usr/local/bin" - echo " --out Name of the output directory, e.g. xilinx-vivado" - echo " --src Path to the sources, e.g. /opt/altera/16.0/quartus/eda/sim_lib" + echo " --ghdl Path to GHDL's executable, e.g. /usr/local/bin/ghdl" + echo " --out Name of the output directory, e.g. uvvm_util" + echo " --src Path to the sources." echo "" echo "Verbosity:" - echo " -n --no-warnings Suppress all warnings. Show only error messages." + echo " -v --verbose Print verbose messages." + echo " -d --debug Print debug messages." +# echo " -n --no-filter Disable output filtering scripts." + echo " -N --no-warnings Suppress all warnings. Show only error messages." echo "" - exit 0 + exit $COMMAND fi -if [ "$COMPILE_ALL" == "TRUE" ]; then - COMPILE_ALTERA=TRUE - COMPILE_MAX=TRUE - COMPILE_CYCLONE=TRUE - COMPILE_ARRIA=TRUE - COMPILE_STRATIX=TRUE - COMPILE_NM=TRUE +if [[ $COMMAND -eq 2 ]]; then + COMPILE_ALTERA=1 + COMPILE_MAX=1 + COMPILE_CYCLONE=1 + COMPILE_ARRIA=1 + COMPILE_STRATIX=1 + COMPILE_NM=1 fi -if [ $VHDLStandard -eq 2008 ]; then - echo -e "${ANSI_RED}Not all Altera packages are VHDL-2008 compatible! Setting HALT_ON_ERROR to FALSE.${ANSI_NOCOLOR}" - HALT_ON_ERROR=0 +if [[ $VHDLStandard -eq 2008 ]]; then + echo -e "${ANSI_RED}Not all Altera packages are VHDL-2008 compatible! Setting CONTINUE_ON_ERROR to TRUE.${ANSI_NOCOLOR}" + CONTINUE_ON_ERROR=1 fi -DefaultDirectories=("/opt/Altera" "/opt/altera") +DefaultDirectories=("/opt/IntelFPGA" "/opt/intelfpga" "/opt/Intel" "/opt/intel" "/opt/Altera" "/opt/altera") if [ ! -z $QUARTUS_ROOTDIR ]; then EnvSourceDir=$QUARTUS_ROOTDIR/${SourceDirectories[AlteraQuartus]} else for DefaultDir in ${DefaultDirectories[@]}; do - for Major in 17 16 15 14 13; do - for Minor in 3 2 1 0; do + for Major in 21 20 19 18 17 16; do + for Minor in 4 3 2 1 0; do Dir=$DefaultDir/${Major}.${Minor}/quartus if [ -d $Dir ]; then EnvSourceDir=$Dir/${SourceDirectories[AlteraQuartus]} @@ -214,499 +225,433 @@ else done fi +# Source configuration file from GHDL's 'vendors' library directory +echo -e "${ANSI_MAGENTA}Loading environment...${ANSI_NOCOLOR}" +source $ScriptDir/config.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading configuration.${ANSI_NOCOLOR}" ; exit 1; fi +source $ScriptDir/shared.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading further procedures.${ANSI_NOCOLOR}"; exit 1; fi + # -> $SourceDirectories # -> $DestinationDirectories # -> $SrcDir # -> $DestDir -# -> $GHDLBinDir # <= $SourceDirectory # <= $DestinationDirectory -# <= $GHDLBinary -SetupDirectories AlteraQuartus "Altera Quartus" +SetupDirectories AlteraQuartus "Intel Quartus" # create "osvvm" directory and change to it # => $DestinationDirectory CreateDestinationDirectory cd $DestinationDirectory - # => $SUPPRESS_WARNINGS # <= $GRC_COMMAND SetupGRCat - # -> $VHDLStandard # <= $VHDLVersion # <= $VHDLStandard # <= $VHDLFlavor GHDLSetup -# define global GHDL Options -GHDL_OPTIONS=(-fexplicit -frelaxed-rules --no-vital-checks --warn-binding --mb-comments) - - -GHDL_PARAMS=(--ieee=$VHDLFlavor --std=$VHDLStandard -P$DestinationDirectory) -GHDL_PARAMS+=(${GHDL_OPTIONS[@]}) - -STOPCOMPILING=0 -ERRORCOUNT=0 +# Extend global GHDL Options +Analyze_Parameters+=( + -fexplicit + --no-vital-checks + -Wbinding + -Wno-hide + -Wno-others + -Wno-parenthesis + --ieee=$VHDLFlavor + --std=$VHDLStandard + -P$DestinationDirectory +) # Cleanup directories # ============================================================================== -if [ "$CLEAN" == "TRUE" ]; then +if [[ $CLEAN -eq 1 ]]; then echo 1>&2 -e "${COLORED_ERROR} '--clean' is not implemented!" - exit -1 + exit 1 echo -e "${ANSI_YELLOW}Cleaning up vendor directory ...${ANSI_NOCOLOR}" rm *.o 2> /dev/null rm *.cf 2> /dev/null fi -# Altera standard libraries +# Intel standard libraries # ============================================================================== -# compile lpm library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ALTERA" == "TRUE" ]; then - Library="lpm" - Files=( - 220pack.vhd - 220model.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi - -# compile sgate library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ALTERA" == "TRUE" ]; then - Library="sgate" - Files=( - sgate_pack.vhd - sgate.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages +StructName="LPM" +Files=( + 220pack.vhd + 220model.vhd +) +CreateLibraryStruct $StructName "lpm" "." $VHDLVersion "${Files[@]}" +test $COMPILE_ALTERA -eq 1 && Libraries+=($StructName) + +StructName="SGATE" +Files=( + sgate_pack.vhd + sgate.vhd +) +CreateLibraryStruct $StructName "sgate" "." $VHDLVersion "${Files[@]}" +test $COMPILE_ALTERA -eq 1 && Libraries+=($StructName) + +StructName="ALTERA" +Files=( + altera_europa_support_lib.vhd + altera_primitives_components.vhd + altera_primitives.vhd + altera_standard_functions.vhd + altera_syn_attributes.vhd + alt_dspbuilder_package.vhd +) +CreateLibraryStruct $StructName "altera" "." $VHDLVersion "${Files[@]}" +test $COMPILE_ALTERA -eq 1 && Libraries+=($StructName) + +StructName="ALTERA_MF" +Files=( + altera_mf_components.vhd + altera_mf.vhd +) +CreateLibraryStruct $StructName "altera_mf" "." $VHDLVersion "${Files[@]}" +test $COMPILE_ALTERA -eq 1 && Libraries+=($StructName) + + +StructName="ALTERA_LNSIM" +Files=( + altera_lnsim_components.vhd +) +CreateLibraryStruct $StructName "altera_lnsim" "." $VHDLVersion "${Files[@]}" +test $COMPILE_ALTERA -eq 1 && Libraries+=($StructName) + +# Intel device libraries +# ============================================================================== +test $VERBOSE -eq 1 && echo -e " Searching available devices ..." + +# Max library +StructName="MAX" +Files=( + max_atoms.vhd + max_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Max'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "max" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_MAX -eq 1 && Libraries+=($StructName) fi -# compile altera library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ALTERA" == "TRUE" ]; then - Library="altera" - Files=( - altera_europa_support_lib.vhd - altera_primitives_components.vhd - altera_primitives.vhd - altera_standard_functions.vhd - altera_syn_attributes.vhd - alt_dspbuilder_package.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages +# Max II library +StructName="MAX_II" +Files=( + maxii_atoms.vhd + maxii_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Max II'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "maxii" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_MAX -eq 1 && Libraries+=($StructName) fi -# compile altera_mf library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ALTERA" == "TRUE" ]; then - Library="altera_mf" - Files=( - altera_mf_components.vhd - altera_mf.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages +# Max V library +StructName="MAX_V" +Files=( + maxv_atoms.vhd + maxv_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Max V'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "maxv" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_MAX -eq 1 && Libraries+=($StructName) fi -# compile altera_lnsim library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ALTERA" == "TRUE" ]; then - Library="altera_lnsim" - Files=( - altera_lnsim_components.vhd +# Arria II library +StructName="ARRIA_II" +Files=( + arriaii_atoms.vhd + arriaii_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + arriaii_hssi_components.vhd + arriaii_hssi_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria II'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriaii" "." $VHDLVersion "${Files[@]}" -# Altera device libraries -# ============================================================================== -# compile Max library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_MAX" == "TRUE" ]; then - Library="max" - Files=( - max_atoms.vhd - max_components.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) fi -# compile MaxII library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_MAX" == "TRUE" ]; then - Library="maxii" +# Arria II (PCIe) library +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + StructName="ARRIA_II_PCIe" Files=( - maxii_atoms.vhd - maxii_components.vhd + arriaii_pcie_hip_components.vhd + arriaii_pcie_hip_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done + if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria II (PCIe)'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriaii_pcie_hip" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) + fi fi -# compile MaxV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_MAX" == "TRUE" ]; then - Library="maxv" - Files=( - maxv_atoms.vhd - maxv_components.vhd +# ArriaII GZ library +StructName="ARRIA_II_GZ" +Files=( + arriaiigz_atoms.vhd + arriaiigz_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + arriaiigz_hssi_components.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria II GZ'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriaiigz" "." $VHDLVersion "${Files[@]}" -# compile ArriaII library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ]; then - Library="arriaii" - Files=( - arriaii_atoms.vhd - arriaii_components.vhd - ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - arriaii_hssi_components.vhd - arriaii_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) fi -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ] && [ $SKIP_LARGE_FILES -eq 0 ]; then - Library="arriaii_pcie_hip" - Files=( - arriaii_pcie_hip_components.vhd - arriaii_pcie_hip_atoms.vhd +# ArriaV library +StructName="ARRIA_V" +Files=( + arriav_atoms.vhd + arriav_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + arriav_hssi_components.vhd + arriav_hssi_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria V'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriav" "." $VHDLVersion "${Files[@]}" -# compile ArriaIIGZ library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ]; then - Library="arriaiigz" - Files=( - arriaiigz_atoms.vhd - arriaiigz_components.vhd - ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - arriaiigz_hssi_components.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) fi -# compile ArriaV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ]; then - Library="arriav" - Files=( - arriav_atoms.vhd - arriav_components.vhd +# Arria V GZ library +StructName="ARRIA_V_GZ" +Files=( + arriavgz_atoms.vhd + arriavgz_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + arriavgz_hssi_components.vhd + arriavgz_hssi_atoms.vhd ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - arriav_hssi_components.vhd - arriav_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria V GZ'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriavgz" "." $VHDLVersion "${Files[@]}" -# compile ArriaVGZ library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ]; then - Library="arriavgz" - Files=( - arriavgz_atoms.vhd - arriavgz_components.vhd - ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - arriavgz_hssi_components.vhd - arriavgz_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) fi -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_ARRIA" == "TRUE" ] && [ $SKIP_LARGE_FILES -eq 0 ]; then - Library="arriavgz_pcie_hip" +# Arria V GZ (PCIe) library +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + StructName="ARRIA_V_GZ_PCIe" Files=( arriavgz_pcie_hip_components.vhd arriavgz_pcie_hip_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done + if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Arria V GZ (PCIe)'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "arriavgz_pcie_hip" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_ARRIA -eq 1 && Libraries+=($StructName) + fi fi -# compile CycloneIV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CYCLONE" == "TRUE" ]; then - Library="cycloneiv" - Files=( - cycloneiv_atoms.vhd - cycloneiv_components.vhd +# Cyclone IV library +StructName="CYCLONE_IV" +Files=( + cycloneiv_atoms.vhd + cycloneiv_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + cycloneiv_hssi_components.vhd + cycloneiv_hssi_atoms.vhd ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - cycloneiv_hssi_components.vhd - cycloneiv_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Cyclone IV'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "cycloneiv" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_CYCLONE -eq 1 && Libraries+=($StructName) fi -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CYCLONE" == "TRUE" ] && [ $SKIP_LARGE_FILES -eq 0 ]; then - Library="cycloneiv_pcie_hip" +# Cyclone IV (PCIe) library +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + StructName="CYCLONE_IV_PCIe" Files=( cycloneiv_pcie_hip_components.vhd cycloneiv_pcie_hip_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done + if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Cyclone IV (PCIe)'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "cycloneiv_pcie_hip" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_CYCLONE -eq 1 && Libraries+=($StructName) + fi fi -# compile CycloneIVE library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CYCLONE" == "TRUE" ]; then - Library="cycloneive" - Files=( - cycloneive_atoms.vhd - cycloneive_components.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages +# Cyclone IV E library +StructName="CYCLONE_IV_E" +Files=( + cycloneive_atoms.vhd + cycloneive_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Cyclone IV E'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "cycloneive" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_CYCLONE -eq 1 && Libraries+=($StructName) fi -# compile CycloneV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CYCLONE" == "TRUE" ]; then - Library="cyclonev" - Files=( - cyclonev_atoms.vhd - cyclonev_components.vhd +# Cyclone V library +StructName="CYCLONE_V" +Files=( + cyclonev_atoms.vhd + cyclonev_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + cyclonev_hssi_components.vhd + cyclonev_hssi_atoms.vhd ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - cyclonev_hssi_components.vhd - cyclonev_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Cyclone V'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "cyclonev" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_CYCLONE -eq 1 && Libraries+=($StructName) fi -# compile StratixIV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_STRATIX" == "TRUE" ]; then - Library="stratixiv" - Files=( - stratixiv_atoms.vhd - stratixiv_components.vhd +# Stratix IV library +StructName="STRATIX_IV" +Files=( + stratixiv_atoms.vhd + stratixiv_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + stratixiv_hssi_components.vhd + stratixiv_hssi_atoms.vhd ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - stratixiv_hssi_components.vhd - stratixiv_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Stratix IV'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "stratixiv" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_STRATIX -eq 1 && Libraries+=($StructName) fi -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_STRATIX" == "TRUE" ] && [ $SKIP_LARGE_FILES -eq 0 ]; then - Library="stratixiv_pcie_hip" +# Stratix IV (PCIe) library +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + StructName="STRATIX_IV_PCIe" Files=( stratixiv_pcie_hip_components.vhd stratixiv_pcie_hip_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done + if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Stratix IV (PCIe)'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "stratixiv_pcie_hip" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_STRATIX -eq 1 && Libraries+=($StructName) + fi fi -# compile StratixV library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_STRATIX" == "TRUE" ]; then - Library="stratixv" - Files=( - stratixv_atoms.vhd - stratixv_components.vhd +# Stratix V library +StructName="STRATIX_V" +Files=( + stratixv_atoms.vhd + stratixv_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + stratixv_hssi_components.vhd + stratixv_hssi_atoms.vhd ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - stratixv_hssi_components.vhd - stratixv_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Stratix V'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "stratixv" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_STRATIX -eq 1 && Libraries+=($StructName) fi -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_STRATIX" == "TRUE" ] && [ $SKIP_LARGE_FILES -eq 0 ]; then - Library="stratixv_pcie_hip" +# Stratix V (PCIe) library +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + StructName="STRATIX_V_PCIe" Files=( stratixv_pcie_hip_components.vhd stratixv_pcie_hip_atoms.vhd ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done + if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'Stratix V (PCIe)'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "stratixv_pcie_hip" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_STRATIX -eq 1 && Libraries+=($StructName) + fi fi -# compile fiftyfivenm library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_NM" == "TRUE" ]; then - Library="fiftyfivenm" - Files=( - fiftyfivenm_atoms.vhd - fiftyfivenm_components.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages +# 55 nm library +StructName="NM_55" +Files=( + fiftyfivenm_atoms.vhd + fiftyfivenm_components.vhd +) +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device '55 nm'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "fiftyfivenm" "." $VHDLVersion "${Files[@]}" + + test $COMPILE_NM -eq 1 && Libraries+=($StructName) fi -# compile twentynm library -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_NM" == "TRUE" ]; then - Library="twentynm" - Files=( - twentynm_atoms.vhd - twentynm_components.vhd +# 20 nm library +StructName="NM_20" +Files=( + twentynm_atoms.vhd + twentynm_components.vhd +) +if [[ $SKIP_LARGE_FILES -eq 0 ]]; then + Files+=( + twentynm_hip_components.vhd + twentynm_hip_atoms.vhd + twentynm_hssi_components.vhd + twentynm_hssi_atoms.vhd ) - if [ $SKIP_LARGE_FILES -eq 0 ]; then - Files+=( - twentynm_hip_components.vhd - twentynm_hip_atoms.vhd - twentynm_hssi_components.vhd - twentynm_hssi_atoms.vhd - ) - fi - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +fi +if [[ -f "$SourceDirectory/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device '20 nm'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "twentynm" "." $VHDLVersion "${Files[@]}" - GHDLCompilePackages + test $COMPILE_NM -eq 1 && Libraries+=($StructName) fi -echo "--------------------------------------------------------------------------------" -echo -n "Compiling Altera Quartus libraries " -if [ $ERRORCOUNT -gt 0 ]; then - echo -e $COLORED_FAILED +# if [[ $DEBUG -eq 1 ]]; then + # for StructName in ${Libraries[*]}; do + # PrintLibraryStruct $StructName " " + # done +# fi + +if [[ $Libraries != "" ]]; then + Compile "$SourceDirectory" "${Libraries[*]}" + + echo "--------------------------------------------------------------------------------" + echo -e "Compiling Intel Quartus packages and device libraries $(test $ERRORCOUNT -eq 0 && echo $COLORED_SUCCESSFUL || echo $COLORED_FAILED)" else - echo -e $COLORED_SUCCESSFUL + echo -e "${ANSI_RED}Neither Intel Quartus packages nor device libraries selected.${ANSI_NOCOLOR}" fi diff --git a/libraries/vendors/compile-lattice.sh b/libraries/vendors/compile-lattice.sh index 60d71a348..df67c0bcb 100755 --- a/libraries/vendors/compile-lattice.sh +++ b/libraries/vendors/compile-lattice.sh @@ -1,17 +1,13 @@ #! /usr/bin/env bash -# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- -# vim: tabstop=2:shiftwidth=2:noexpandtab -# kate: tab-width 2; replace-tabs off; indent-width 2; -# # ============================================================================== # Authors: # Markus Koch # Patrick Lehmann -# +# # Bash Script: # Script to compile the simulation libraries from Lattice # Diamond for GHDL on Linux -# +# # Description: # ------------------------------------ # This is a Bash script (executable) which: @@ -19,6 +15,7 @@ # - compiles all Lattice Diamond simulation libraries and packages # # ============================================================================== +# Copyright (C) 2017-2021 Patrick Lehmann - Boetzingen, Germany # Copyright (C) 2015-2016 Patrick Lehmann - Dresden, Germany # Copyright (C) 2015-2016 Markus Koch # @@ -36,92 +33,111 @@ # along with this program. If not, see . # ============================================================================== -# --------------------------------------------- -# work around for Darwin (Mac OS) +# Work around for Darwin (Mac OS) READLINK=readlink; if [[ $(uname) == "Darwin" ]]; then READLINK=greadlink; fi -# save working directory +# Save working directory WorkingDir=$(pwd) ScriptDir="$(dirname $0)" ScriptDir="$($READLINK -f $ScriptDir)" -DeviceList="ec ecp ecp2 ecp3 ecp5u lptm lptm2 machxo machxo2 machxo3l machxo3d sc scm xp xp2" +# Source Bash utilities +source $ScriptDir/../ansi_color.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading Bash utilities.${ANSI_NOCOLOR}" ; exit 1; fi + + +DeviceList="EC ECP ECP2 ECP3 ECP5U LPTM LPTM2 MACHXO MACHXO2 MACHXO3L SC SCM XP XP2" +for Device in $DeviceList; do + declare "DEV_${Device}_Enable"=0 +done -# source configuration file from GHDL's 'vendors' library directory -. $ScriptDir/../ansi_color.sh -. $ScriptDir/config.sh -. $ScriptDir/shared.sh -# command line argument processing -NO_COMMAND=1 -SKIP_EXISTING_FILES=0 +# Command line argument processing +COMMAND=1 +CLEAN=0 +VERBOSE=0 +DEBUG=0 +FILTERING=0 # TODO: 1 SUPPRESS_WARNINGS=0 HALT_ON_ERROR=0 VHDLStandard=93 -GHDLBinDir="" DestDir="" SrcDir="" while [[ $# > 0 ]]; do - key="$1" - case $key in + case "$1" in -c|--clean) - CLEAN=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + CLEAN=1 + ;; -a|--all) - # All does not change the deviceList -> all selected - NO_COMMAND=0 - ;; - -d|--device) - DeviceList="$2" - shift - NO_COMMAND=0 - ;; - -h|--help) - HELP=TRUE - NO_COMMAND=0 - ;; - -s|--skip-existing) - SKIP_EXISTING_FILES=1 - ;; - -n|--no-warnings) - SUPPRESS_WARNINGS=1 - ;; - -H|--halt-on-error) - HALT_ON_ERROR=1 - ;; + COMMAND=2 + ;; --vhdl93) - VHDLStandard=93 - ;; + VHDLStandard=93 + ;; --vhdl2008) - VHDLStandard=2008 - ;; + VHDLStandard=2008 + ;; + -v|--verbose) + VERBOSE=1 + ;; + -d|--debug) + VERBOSE=1 + DEBUG=1 + ;; + -h|--help) + COMMAND=0 + break + ;; + -n|--no-filter) + FILTERING=0 + ;; + -N|--no-warnings) + SUPPRESS_WARNINGS=1 + ;; + -H|--halt-on-error) + HALT_ON_ERROR=1 + ;; --ghdl) - GHDLBinDir="$2" - shift # skip argument - ;; + GHDL="$2" # overwrite a potentially existing GHDL environment variable + shift # skip argument + ;; --src) - SrcDir="$2" - shift # skip argument - ;; + SrcDir="$2" + shift # skip argument + ;; --out) - DestDir="$2" - shift # skip argument - ;; + DestDir="$2" + shift # skip argument + ;; *) # unknown option - echo 1>&2 -e "${COLORED_ERROR} Unknown command line option '$key'.${ANSI_NOCOLOR}" - exit -1 - ;; + FOUND=0 + if [[ "${1:0:2}" == "--" ]]; then + key=${1:2}; key=${key,,} + for Device in $DeviceList; do + if [[ $key == ${Device,,} ]]; then + declare "DEV_${Device}_Enable"=1 + COMMAND=3 + FOUND=1 + break + fi + done + fi + if [[ $FOUND -eq 0 ]]; then + echo 1>&2 -e "\n${COLORED_ERROR} Unknown command line option '$1'.${ANSI_NOCOLOR}" + COMMAND=0 + break + fi + ;; esac - shift # past argument or value + shift # parsed argument or value done -if [ $NO_COMMAND -eq 1 ]; then - HELP=TRUE -fi +ERRORCOUNT=0 +Libraries=() -if [ "$HELP" == "TRUE" ]; then - test $NO_COMMAND -eq 1 && echo 1>&2 -e "\n${COLORED_ERROR} No command selected." +if [[ $COMMAND -le 1 ]]; then + test $COMMAND -eq 1 && echo 1>&2 -e "\n${COLORED_ERROR} No command selected.${ANSI_NOCOLOR}" echo "" echo "Synopsis:" echo " A script to compile the Lattice Diamond simulation libraries for GHDL on Linux." @@ -134,31 +150,44 @@ if [ "$HELP" == "TRUE" ]; then echo " compile-lattice.sh | [] []" echo "" echo "Common commands:" - echo " -h --help Print this help page" - echo " -c --clean Remove all generated files" + echo " -h --help Print this help page" + echo " -c --clean Remove all generated files" echo "" echo "Libraries:" - echo " -a --all Compile all Lattice simulation libraries." - echo " -d --device Compile only the specified device libraries. Device can be:" - echo " \"$deviceList\"" + echo " -a --all Compile all Lattice simulation libraries." + for Device in $DeviceList; do + printf " --%-19s Device primitives for '%s'.\n" "${Device,,}" "$Device" + done echo "" echo "Library compile options:" - echo " --vhdl93 Compile the libraries with VHDL-93." - echo " --vhdl2008 Compile the libraries with VHDL-2008." - echo " -s --skip-existing Skip already compiled files (an *.o file exists)." - echo " -H --halt-on-error Halt on error(s)." + echo " --vhdl93 Compile the libraries with VHDL-93." + echo " --vhdl2008 Compile the libraries with VHDL-2008." + echo " -H --halt-on-error Halt on error(s)." echo "" echo "Advanced options:" - echo " --ghdl Path to GHDL's binary directory, e.g. /usr/local/bin" - echo " --out Name of the output directory, e.g. xilinx-vivado" - echo " --src Path to the sources." + echo " --ghdl Path to GHDL's executable, e.g. /usr/local/bin/ghdl" + echo " --out Name of the output directory, e.g. uvvm_util" + echo " --src Path to the sources." echo "" echo "Verbosity:" - echo " -n --no-warnings Suppress all warnings. Show only error messages." + echo " -v --verbose Print verbose messages." + echo " -d --debug Print debug messages." +# echo " -n --no-filter Disable output filtering scripts." + echo " -N --no-warnings Suppress all warnings. Show only error messages." echo "" - exit 0 + exit $COMMAND +fi + +if [[ $COMMAND -eq 2 ]]; then + for Device in $DeviceList; do + declare "DEV_${Device}_Enable"=1 + done fi +if [[ $VHDLStandard -eq 2008 ]]; then + echo -e "${ANSI_RED}Not all Lattice packages are VHDL-2008 compatible! Setting CONTINUE_ON_ERROR to TRUE.${ANSI_NOCOLOR}" + CONTINUE_ON_ERROR=1 +fi DefaultDirectories=("/usr/local/diamond" "/opt/Diamond" "/opt/diamond") if [ ! -z $LSC_DIAMOND ]; then @@ -166,7 +195,7 @@ if [ ! -z $LSC_DIAMOND ]; then else for DefaultDir in ${DefaultDirectories[@]}; do for Major in 3; do - for Minor in 8 7 6 5; do + for Minor in 12 11 10 9 8 7 6 5; do Dir=$DefaultDir/${Major}.${Minor}_x64 if [ -d $Dir ]; then EnvSourceDir=$Dir/${SourceDirectories[LatticeDiamond]} @@ -177,20 +206,20 @@ else done fi -if [ $VHDLStandard -eq 2008 ]; then - echo -e "${ANSI_RED}Not all Lattice packages are VHDL-2008 compatible! Setting HALT_ON_ERROR to FALSE.${ANSI_NOCOLOR}" - HALT_ON_ERROR=0 -fi +# Source configuration file from GHDL's 'vendors' library directory +echo -e "${ANSI_MAGENTA}Loading environment...${ANSI_NOCOLOR}" +source $ScriptDir/config.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading configuration.${ANSI_NOCOLOR}" ; exit 1; fi +source $ScriptDir/shared.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading further procedures.${ANSI_NOCOLOR}"; exit 1; fi # -> $SourceDirectories # -> $DestinationDirectories # -> $SrcDir # -> $EnvSourceDir # -> $DestDir -# -> $GHDLBinDir # <= $SourceDirectory # <= $DestinationDirectory -# <= $GHDLBinary SetupDirectories LatticeDiamond "Lattice Diamond" # create "lattice" directory and change to it @@ -203,84 +232,360 @@ cd $DestinationDirectory # <= $GRC_COMMAND SetupGRCat - # -> $VHDLStandard # <= $VHDLVersion # <= $VHDLStandard # <= $VHDLFlavor GHDLSetup +# Extend global GHDL Options +Analyze_Parameters+=( + -fexplicit + --no-vital-checks + -Wbinding + -Wno-hide + -Wno-others + -Wno-parenthesis + --ieee=$VHDLFlavor + --std=$VHDLStandard + -P$DestinationDirectory +) -# define global GHDL Options -GHDL_OPTIONS=(-fexplicit -frelaxed-rules --no-vital-checks --warn-binding --mb-comments) - - -GHDL_PARAMS=(--ieee=$VHDLFlavor --std=$VHDLStandard) -GHDL_PARAMS+=(${GHDL_OPTIONS[@]}) - - -STOPCOMPILING=0 -ERRORCOUNT=0 # Cleanup directory # ============================================================================== -if [ "$CLEAN" == "TRUE" ]; then +if [[ $CLEAN -eq 1 ]]; then echo 1>&2 -e "${COLORED_ERROR} '--clean' is not implemented!" - exit -1 + exit 1 echo -e "${ANSI_YELLOW}Cleaning up vendor directory ...${ANSI_NOCOLOR}" rm *.o 2> /dev/null rm *.cf 2> /dev/null fi +# Excluded: pmi +# # Lattice device libraries # ============================================================================== -# Excluded: pmi -declare -A FileLists -FileLists[ec]="ORCA_CMB.vhd ORCA_SEQ.vhd ORCACOMP.vhd ORCA_LUT.vhd ORCA_MISC.vhd ORCA_CNT.vhd ORCA_IO.vhd ORCA_MEM.vhd" -FileLists[ecp]="ORCA_CMB.vhd ORCA_SEQ.vhd ORCACOMP.vhd ORCA_LUT.vhd ORCA_MISC.vhd ORCA_CNT.vhd ORCA_IO.vhd ORCA_MEM.vhd" -FileLists[ecp2]="ECP2_CMB.vhd ECP2_SEQ.vhd ECP2COMP.vhd ECP2_CNT.vhd ECP2_IO.vhd ECP2_LUT.vhd ECP2_MEM.vhd ECP2_MISC.vhd ECP2_MULT.vhd ECP2_SL.vhd" -FileLists[ecp3]="ECP3_CMB.vhd ECP3_SEQ.vhd ECP3COMP.vhd ECP3_CNT.vhd ECP3_IO.vhd ECP3_LUT.vhd ECP3_MEM.vhd ECP3_MISC.vhd ECP3_MULT.vhd ECP3_SL.vhd" -FileLists[ecp5u]="ECP5U_CMB.vhd ECP5U_SEQ.vhd ECP5UCOMP.vhd ECP5U_IO.vhd ECP5U_LUT.vhd ECP5U_MEM.vhd ECP5U_MISC.vhd ECP5U_SL.vhd gsr_pur_assign.vhd" -FileLists[lptm]="MACHXO_CMB.vhd MACHXO_SEQ.vhd MACHXOCOMP.vhd MACHXO_CNT.vhd MACHXO_IO.vhd MACHXO_LUT.vhd MACHXO_MEM.vhd MACHXO_MISC.vhd" -FileLists[lptm2]="MACHXO2_CMB.vhd MACHXO2_SEQ.vhd MACHXO2COMP.vhd gsr_pur_assign.vhd MACHXO2_CNT.vhd MACHXO2_IO.vhd MACHXO2_LUT.vhd MACHXO2_MEM.vhd MACHXO2_MISC.vhd" -FileLists[machxo]="MACHXO_CMB.vhd MACHXO_SEQ.vhd MACHXOCOMP.vhd MACHXO_CNT.vhd MACHXO_IO.vhd MACHXO_LUT.vhd MACHXO_MEM.vhd MACHXO_MISC.vhd" -FileLists[machxo2]="MACHXO2_CMB.vhd MACHXO2_SEQ.vhd MACHXO2COMP.vhd MACHXO2_CNT.vhd gsr_pur_assign.vhd MACHXO2_IO.vhd MACHXO2_LUT.vhd MACHXO2_MEM.vhd MACHXO2_MISC.vhd" -FileLists[machxo3l]="MACHXO3L_CMB.vhd MACHXO3L_SEQ.vhd MACHXO3LCOMP.vhd gsr_pur_assign.vhd MACHXO3L_CNT.vhd MACHXO3L_IO.vhd MACHXO3L_LUT.vhd MACHXO3L_MEM.vhd MACHXO3L_MISC.vhd" -FileLists[machxo3d]="MACHXO3D_CMB.vhd MACHXO3D_SEQ.vhd MACHXO3DCOMP.vhd gsr_pur_assign.vhd MACHXO3D_CNT.vhd MACHXO3D_IO.vhd MACHXO3D_LUT.vhd MACHXO3D_MEM.vhd MACHXO3D_MISC.vhd" -FileLists[sc]="ORCA_CMB.vhd ORCA_SEQ.vhd ORCACOMP.vhd ORCA_CNT.vhd ORCA_IO.vhd ORCA_MEM.vhd ORCA_MIS.vhd ORCA_SL.vhd" -FileLists[scm]="ORCA_CMB.vhd ORCA_SEQ.vhd ORCACOMP.vhd ORCA_CNT.vhd ORCA_IO.vhd ORCA_MEM.vhd ORCA_MIS.vhd ORCA_SL.vhd" -FileLists[xp]="ORCA_CMB.vhd ORCA_SEQ.vhd ORCACOMP.vhd ORCA_LUT.vhd ORCA_MISC.vhd ORCA_CNT.vhd ORCA_IO.vhd ORCA_MEM.vhd" -FileLists[xp2]="XP2_CMB.vhd XP2_SEQ.vhd XP2COMP.vhd XP2_CNT.vhd XP2_IO.vhd XP2_LUT.vhd XP2_MEM.vhd XP2_MISC.vhd XP2_MULT.vhd XP2_SL.vhd" - -for device in $DeviceList; do - Library=$device - LibraryDirectory=$DestinationDirectory/$Library/$VHDLVersion - mkdir -p $LibraryDirectory - cd $LibraryDirectory - echo -e "${ANSI_YELLOW}Compiling library '$Library'...${ANSI_NOCOLOR}" - - DeviceSourceDirectory="$SourceDirectory/$device/src" - for File in ${FileLists[$device]}; do - File="$DeviceSourceDirectory/$File" - FileName=$(basename "$File") - FileName="${device}_$FileName" - if [ $SKIP_EXISTING_FILES -eq 1 ] && [ -e "${FileName%.*}.o" ]; then - echo -e "${ANSI_CYAN}Skipping file '$File'${ANSI_NOCOLOR}" - else - echo -e "${ANSI_CYAN}Analyzing file '$File'${ANSI_NOCOLOR}" - $GHDLBinary -a ${GHDL_PARAMS[@]} --work=$Library "$File" 2>&1 | $GRC_COMMAND - if [ $? -ne 0 ]; then - let ERRORCOUNT++ - test $HALT_ON_ERROR -eq 1 && break 2 - fi - fi - done -done +# EC devices +StructName="EC" +SourceDir="ec/src" +Files=( + ORCA_CMB.vhd + ORCA_SEQ.vhd + ORCACOMP.vhd + ORCA_LUT.vhd + ORCA_MISC.vhd + ORCA_CNT.vhd + ORCA_IO.vhd + ORCA_MEM.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'EC'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "ec" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +else + echo "not found: $SourceDirectory/$Files" + +fi + +# ECP devices +StructName="ECP" +SourceDir="ecp/src" +Files=( + ORCA_CMB.vhd + ORCA_SEQ.vhd + ORCACOMP.vhd + ORCA_LUT.vhd + ORCA_MISC.vhd + ORCA_CNT.vhd + ORCA_IO.vhd + ORCA_MEM.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'ECP'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "ecp" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + + +# ECP2 devices +StructName="ECP2" +SourceDir="ecp2/src" +Files=( + ECP2_CMB.vhd + ECP2_SEQ.vhd + ECP2COMP.vhd + ECP2_CNT.vhd + ECP2_IO.vhd + ECP2_LUT.vhd + ECP2_MEM.vhd + ECP2_MISC.vhd + ECP2_MULT.vhd + ECP2_SL.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'ECP2'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "ecp2" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# ECP3 devices +StructName="ECP3" +SourceDir="ecp3/src" +Files=( + ECP3_CMB.vhd + ECP3_SEQ.vhd + ECP3COMP.vhd + ECP3_CNT.vhd + ECP3_IO.vhd + ECP3_LUT.vhd + ECP3_MEM.vhd + ECP3_MISC.vhd + ECP3_MULT.vhd + ECP3_SL.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'ECP3'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "ecp3" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# ECP5U devices +StructName="ECP5U" +SourceDir="ecp5u/src" +Files=( + ECP5U_CMB.vhd + ECP5U_SEQ.vhd + ECP5UCOMP.vhd + ECP5U_IO.vhd + ECP5U_LUT.vhd + ECP5U_MEM.vhd + ECP5U_MISC.vhd + ECP5U_SL.vhd + gsr_pur_assign.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'ECP5U'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "ecp5u" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# LPTM devices +StructName="LPTM" +SourceDir="lptm/src" +Files=( + MACHXO_CMB.vhd + MACHXO_SEQ.vhd + MACHXOCOMP.vhd + MACHXO_CNT.vhd + MACHXO_IO.vhd + MACHXO_LUT.vhd + MACHXO_MEM.vhd + MACHXO_MISC.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'LPTM'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "lptm" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# LPTM2 devices +StructName="LPTM2" +SourceDir="lptm2/src" +Files=( + MACHXO2_CMB.vhd + MACHXO2_SEQ.vhd + MACHXO2COMP.vhd + gsr_pur_assign.vhd + MACHXO2_CNT.vhd + MACHXO2_IO.vhd + MACHXO2_LUT.vhd + MACHXO2_MEM.vhd + MACHXO2_MISC.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'LPTM2'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "lptm2" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# MachXO devices +StructName="MACHXO" +SourceDir="machxo/src" +Files=( + MACHXO_CMB.vhd + MACHXO_SEQ.vhd + MACHXOCOMP.vhd + MACHXO_CNT.vhd + MACHXO_IO.vhd + MACHXO_LUT.vhd + MACHXO_MEM.vhd + MACHXO_MISC.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'MachXO'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "machxo" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# MachXO2 devices +StructName="MACHXO2" +SourceDir="machxo2/src" +Files=( + MACHXO2_CMB.vhd + MACHXO2_SEQ.vhd + MACHXO2COMP.vhd + MACHXO2_CNT.vhd + gsr_pur_assign.vhd + MACHXO2_IO.vhd + MACHXO2_LUT.vhd + MACHXO2_MEM.vhd + MACHXO2_MISC.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'MachXO2'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "machxo2" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# MachXO3L devices +StructName="MACHXO3L" +SourceDir="machxo3l/src" +Files=( + MACHXO3L_CMB.vhd + MACHXO3L_SEQ.vhd + MACHXO3LCOMP.vhd + gsr_pur_assign.vhd + MACHXO3L_CNT.vhd + MACHXO3L_IO.vhd + MACHXO3L_LUT.vhd + MACHXO3L_MEM.vhd + MACHXO3L_MISC.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'MachXO3L'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "machxo3l" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# SC devices +StructName="SC" +SourceDir="sc/src" +Files=( + ORCA_CMB.vhd + ORCA_SEQ.vhd + ORCACOMP.vhd + ORCA_CNT.vhd + ORCA_IO.vhd + ORCA_MEM.vhd + ORCA_MIS.vhd + ORCA_SL.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'SC'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "sc" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# SCM devices +StructName="SCM" +SourceDir="scm/src" +Files=( + ORCA_CMB.vhd + ORCA_SEQ.vhd + ORCACOMP.vhd + ORCA_CNT.vhd + ORCA_IO.vhd + ORCA_MEM.vhd + ORCA_MIS.vhd + ORCA_SL.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'SCM'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "scm" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# XP devices +StructName="XP" +SourceDir="xp/src" +Files=( + ORCA_CMB.vhd + ORCA_SEQ.vhd + ORCACOMP.vhd + ORCA_LUT.vhd + ORCA_MISC.vhd + ORCA_CNT.vhd + ORCA_IO.vhd + ORCA_MEM.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'XP'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "xp" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# XP2 devices +StructName="XP2" +SourceDir="xp2/src" +Files=( + XP2_CMB.vhd + XP2_SEQ.vhd + XP2COMP.vhd + XP2_CNT.vhd + XP2_IO.vhd + XP2_LUT.vhd + XP2_MEM.vhd + XP2_MISC.vhd + XP2_MULT.vhd + XP2_SL.vhd +) +if [[ -f "$SourceDirectory/$SourceDir/$Files" ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Found device 'XP2'.${ANSI_NOCOLOR}" + CreateLibraryStruct $StructName "xp2" $SourceDir $VHDLVersion "${Files[@]}" + + VarName="DEV_${StructName}_Enable" + test ${!VarName} -eq 1 && Libraries+=($StructName) +fi + +# if [[ $DEBUG -eq 1 ]]; then + # for StructName in ${Libraries[*]}; do + # PrintLibraryStruct $StructName " " + # done +# fi + +# Compile libraries +if [[ "$Libraries" != "" ]]; then + Compile "$SourceDirectory" "${Libraries[*]}" -echo "--------------------------------------------------------------------------------" -echo -n "Compiling Lattice Diamond libraries " -if [ $ERRORCOUNT -gt 0 ]; then - echo -e $COLORED_FAILED + echo "--------------------------------------------------------------------------------" + echo -e "Compiling Lattice device libraries $(test $ERRORCOUNT -eq 0 && echo $COLORED_SUCCESSFUL || echo $COLORED_FAILED)" else - echo -e $COLORED_SUCCESSFUL + echo -e "${ANSI_RED}No Lattice device library selected.${ANSI_NOCOLOR}" fi diff --git a/libraries/vendors/compile-osvvm.sh b/libraries/vendors/compile-osvvm.sh index b1d1a2701..d2f4b674d 100755 --- a/libraries/vendors/compile-osvvm.sh +++ b/libraries/vendors/compile-osvvm.sh @@ -2,18 +2,18 @@ # ============================================================================== # Authors: # Patrick Lehmann -# +# # Bash Script: Script to compile the OSVVM library for GHDL on Linux -# +# # Description: # ------------------------------------ # This is a Bash script (executable) which: # - creates a subdirectory in the current working directory -# - compiles all OSVVM packages +# - compiles all OSVVM packages # # ============================================================================== # Copyright (C) 2015-2016 Patrick Lehmann - Dresden, Germany -# +# # 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 2 of the License, or @@ -47,7 +47,7 @@ CLEAN=0 COMPILE_OSVVM=0 VERBOSE=0 DEBUG=0 -FILTERING=0 # TODO: 1 +FILTERING=1 SUPPRESS_WARNINGS=0 HALT_ON_ERROR=0 DestDir="" @@ -161,11 +161,17 @@ fi # Source configuration file from GHDL's 'vendors' library directory +echo -e "${ANSI_MAGENTA}Loading environment...${ANSI_NOCOLOR}" source $ScriptDir/config.sh if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading configuration.${ANSI_NOCOLOR}" ; exit 1; fi source $ScriptDir/shared.sh if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading further procedures.${ANSI_NOCOLOR}"; exit 1; fi +# <= $VHDLVersion +# <= $VHDLStandard +# <= $VHDLFlavor +GHDLSetup 2008 + # -> $SourceDirectories # -> $DestinationDirectories # -> $SrcDir @@ -180,23 +186,29 @@ CreateDestinationDirectory cd $DestinationDirectory -# => $SUPPRESS_WARNINGS -# <= $GRC_COMMAND -SetupGRCat - - # Extend global GHDL Options Analyze_Parameters+=( -fexplicit - --no-vital-checks -Wbinding - -Wno-hide - -Wno-others - -Wno-static - --std=08 +) +if [[ $DEBUG -eq 0 ]]; then + Analyze_Parameters+=( + -Wno-hide + ) +fi +if [[ ! (VERBOSE -eq 1) && ($DEBUG -eq 1) ]]; then + Analyze_Parameters+=( + -Wno-others + -Wno-static + ) +fi +Analyze_Parameters+=( + --ieee=$VHDLFlavor + --no-vital-checks + --std=$VHDLStandard + -frelaxed -P$DestinationDirectory ) -VHDLVersion="v08" # Cleanup directory @@ -210,7 +222,7 @@ fi # Library osvvm # ============================================================================== -StructName="OSVVM" +StructName="OSVVM_osvvm" Files=( NamePkg.vhd OsvvmGlobalPkg.vhd diff --git a/libraries/vendors/compile-uvvm.sh b/libraries/vendors/compile-uvvm.sh index 5ff3e30f3..43ec35e79 100755 --- a/libraries/vendors/compile-uvvm.sh +++ b/libraries/vendors/compile-uvvm.sh @@ -1,23 +1,19 @@ #! /usr/bin/env bash -# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- -# vim: tabstop=2:shiftwidth=2:noexpandtab -# kate: tab-width 2; replace-tabs off; indent-width 2; -# # ============================================================================== # Authors: # Patrick Lehmann -# +# # Bash Script: Script to compile the UVVM library for GHDL on Linux -# +# # Description: # ------------------------------------ # This is a Bash script (executable) which: # - creates a subdirectory in the current working directory -# - compiles all UVVM packages +# - compiles all UVVM packages # # ============================================================================== -# Copyright (C) 2015-2017 Patrick Lehmann - Dresden, Germany -# Copyright (C) 2017 Patrick Lehmann - Freiburg, Germany +# Copyright (C) 2017-2021 Patrick Lehmann - Boetzingen, Germany +# Copyright (C) 2015-2016 Patrick Lehmann - Dresden, Germany # # 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 @@ -33,294 +29,378 @@ # along with this program. If not, see . # ============================================================================== -# --------------------------------------------- -# work around for Darwin (Mac OS) -if greadlink --version > /dev/null 2>&1 ; then - READLINK=greadlink -else - READLINK=readlink -fi +# Work around for Darwin (Mac OS) +READLINK=readlink; if [[ $(uname) == "Darwin" ]]; then READLINK=greadlink; fi -# save working directory +# Save working directory WorkingDir=$(pwd) ScriptDir="$(dirname $0)" ScriptDir="$($READLINK -f $ScriptDir)" -# source configuration file from GHDL's 'vendors' library directory -if [ -f $ScriptDir/../ansi_color.sh ]; then - . $ScriptDir/../ansi_color.sh -fi -. $ScriptDir/config.sh -. $ScriptDir/shared.sh - -uvvm_pkgs="uvvm_util - uvvm_vvc_framework - xConstrRandFuncCov -" - -uvvm_vips=" - bitvis_vip_scoreboard - bitvis_vip_avalon_mm - bitvis_vip_avalon_st - bitvis_vip_axilite - bitvis_vip_axistream - bitvis_vip_clock_generator - bitvis_vip_error_injection - bitvis_vip_gmii - bitvis_vip_gpio - bitvis_vip_i2c - bitvis_vip_rgmii - bitvis_vip_sbi - bitvis_vip_spi - bitvis_vip_uart - bitvis_vip_hvvc_to_vvc_bridge - bitvis_vip_ethernet - bitvis_irqc - bitvis_vip_spec_cov -" - -# command line argument processing -NO_COMMAND=1 +# Source Bash utilities +source $ScriptDir/../ansi_color.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading Bash utilities.${ANSI_NOCOLOR}" ; exit 1; fi + + +# Command line argument processing +COMMAND=1 +CLEAN=0 +COMPILE_UVVM=0 +COMPILE_UVVM_UTILITIES=0 +COMPILE_UVVM_VVC_FRAMEWORK=0 +COMPILE_UVVM_VIP=0 +COMPILE_UVVM_VIP_AVALON_MM=0 +COMPILE_UVVM_VIP_AXILITE=0 +COMPILE_UVVM_VIP_AXISTREAM=0 +COMPILE_UVVM_VIP_CLOCK_GENERATOR=0 +COMPILE_UVVM_VIP_GPIO=0 +COMPILE_UVVM_VIP_I2C=0 +COMPILE_UVVM_VIP_SBI=0 +COMPILE_UVVM_VIP_SCOREBOARD=0 +COMPILE_UVVM_VIP_SPI=0 +COMPILE_UVVM_VIP_UART=0 +VERBOSE=0 +DEBUG=0 +FILTERING=1 SUPPRESS_WARNINGS=0 HALT_ON_ERROR=0 -GHDLBinDir="" DestDir="" SrcDir="" while [[ $# > 0 ]]; do - key="$1" - case $key in + case "$1" in -c|--clean) - CLEAN=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + CLEAN=1 + ;; -a|--all) - COMPILE_ALL=TRUE - NO_COMMAND=0 - ;; + COMMAND=2 + ;; --uvvm) - COMPILE_UVVM=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM=1 + ;; --uvvm-vip) - COMPILE_UVVM_VIP=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM_VIP=1 + ;; --uvvm-utilities) - COMPILE_uvvm_util=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM_UTILITIES=1 + ;; --uvvm-vvc-framework) - COMPILE_uvvm_vvc_framework=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM_VVC_FRAMEWORK=1 + ;; --uvvm-vip-avalon_mm) - COMPILE_vip_avalon_mm=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM_VIP_AVALON_MM=1 + ;; --uvvm-vip-axi_lite) - COMPILE_vip_axilite=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM_VIP_AXILITE=1 + ;; --uvvm-vip-axi_stream) - COMPILE_vip_axistream=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM_VIP_AXISTREAM=1 + ;; + --uvvm-vip-clock) + COMMAND=3 + COMPILE_UVVM_VIP_CLOCK_GENERATOR=1 + ;; --uvvm-vip-gpio) - COMPILE_vip_gpio=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM_VIP_GPIO=1 + ;; --uvvm-vip-i2c) - COMPILE_vip_i2c=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM_VIP_I2C=1 + ;; --uvvm-vip-sbi) - COMPILE_vip_sbi=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM_VIP_SBI=1 + ;; --uvvm-vip-spi) - COMPILE_vip_spi=TRUE - NO_COMMAND=0 - ;; - --uvvm-vip-uart) - COMPILE_vip_uart=TRUE - NO_COMMAND=0 - ;; - --uvvm-vip-wishbone) - COMPILE_vip_wishbone=TRUE - NO_COMMAND=0 - ;; - --uvvm-vip-clock_generator) - COMPILE_vip_clock_generator=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM_VIP_SPI=1 + ;; --uvvm-vip-scoreboard) - COMPILE_vip_scoreboard=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UVVM_VIP_SCOREBOARD=1 + ;; + --uvvm-vip-uart) + COMMAND=3 + COMPILE_UVVM_VIP_UART=1 + ;; + -v|--verbose) + VERBOSE=1 + ;; + -d|--debug) + VERBOSE=1 + DEBUG=1 + ;; -h|--help) - HELP=TRUE - NO_COMMAND=0 - ;; - -n|--no-warnings) - SUPPRESS_WARNINGS=1 - ;; + COMMAND=0 + break + ;; + -n|--no-filter) + FILTERING=0 + ;; + -N|--no-warnings) + SUPPRESS_WARNINGS=1 + ;; -H|--halt-on-error) - HALT_ON_ERROR=1 - ;; + HALT_ON_ERROR=1 + ;; --ghdl) - GHDLBinDir="$2" - shift # skip argument - ;; - --src) - SrcDir="$2" - shift # skip argument - ;; - --out) - DestDir="$2" - shift # skip argument - ;; + GHDL="$2" # overwrite a potentially existing GHDL environment variable + shift # skip argument + ;; + --source) + SrcDir="$2" + shift # skip argument + ;; + --output) + DestDir="$2" + shift # skip argument + ;; *) # unknown option - echo 1>&2 -e "${COLORED_ERROR} Unknown command line option '$key'.${ANSI_NOCOLOR}" - exit -1 - ;; + echo 1>&2 -e "\n${COLORED_ERROR} Unknown command line option '$1'.${ANSI_NOCOLOR}" + COMMAND=0 + break + ;; esac - shift # past argument or value + shift # parsed argument or value done -# makes no sense to enable it for UVVM -SKIP_EXISTING_FILES=0 - -if [ $NO_COMMAND -eq 1 ]; then - HELP=TRUE -fi +ERRORCOUNT=0 -if [ "$HELP" == "TRUE" ]; then - test $NO_COMMAND -eq 1 && echo 1>&2 -e "/n${COLORED_ERROR} No command selected." +if [[ $COMMAND -le 1 ]]; then + test $COMMAND -eq 1 && echo 1>&2 -e "\n${COLORED_ERROR} No command selected.${ANSI_NOCOLOR}" echo "" echo "Synopsis:" - echo " A script to compile the simulation library 'uvvm_util' for GHDL on Linux." - echo " A library folder 'uvvm_util/v08' will be created relative to the current" + echo " A script to compile the simulation library 'uvvm' for GHDL on Linux." + echo " A library folder 'uvvm/v08' will be created relative to the current" echo " working directory." echo "" - echo " Use the adv. options or edit 'config.sh' to supply paths and default params." + echo " Use the adv. options or edit 'config.sh' to supply paths and default parameters." echo "" echo "Usage:" - echo " compile-uvvm.sh | [] []" + echo " compile-uvvm.sh [] | [] []" echo "" echo "Common commands:" - echo " -h --help Print this help page" - echo " -c --clean Remove all generated files" + echo " -h --help Print this help page" + echo " -c --clean Remove all generated files" echo "" echo "Libraries:" - echo " -a --all Compile all libraries." - echo " --uvvm Compile UVVM library packages." - echo " --uvvm-vip Compile UVVM Verification IPs (VIPs)." + echo " -a --all Compile all libraries." + echo " --uvvm Compile UVVM library packages." + echo " --uvvm-vip Compile UVVM Verification IPs (VIPs)." echo "" echo "Common Packages:" - echo " --uvvm-utilities" - echo " --uvvm-vvc-framework" + echo " --uvvm-utilities UVVM utilities." + echo " --uvvm-vvc-framework VHDL Verification Component (VCC) framework." echo "" echo "Verification IPs:" - echo " --uvvm-vip-avalon_mm" - echo " --uvvm-vip-axi_lite" - echo " --uvvm-vip-axi_stream" - echo " --uvvm-vip-gpio" - echo " --uvvm-vip-i2c" - echo " --uvvm-vip-sbi" - echo " --uvvm-vip-spi" - echo " --uvvm-vip-uart" - echo " --uvvm-vip-wishbone" - echo " --uvvm-vip-clock_generator" - echo " --uvvm-vip-scoreboard" + echo " --uvvm-vip-avalon_mm Altera/Intel Avalon Memory Mapped" + echo " --uvvm-vip-axi_lite ARM AMBA AXI4 Lite" + echo " --uvvm-vip-axi_stream ARM AMBA AXI4 Stream" + echo " --uvvm-vip-clock Clock generator" + echo " --uvvm-vip-gpio General Purpose Input/Output (GPIO)" + echo " --uvvm-vip-i2c Inter-Integrated Circuit (I²C)" + echo " --uvvm-vip-sbi Simple Bus Interface" + echo " --uvvm-vip-scoreboard Scoreboard" + echo " --uvvm-vip-spi Serial Peripheral Interface" + echo " --uvvm-vip-uart Universal Asynchronous Receiver Transmitter (UART)" echo "" echo "Library compile options:" - echo " -H --halt-on-error Halt on error(s)." + echo " -H --halt-on-error Halt on error(s)." echo "" echo "Advanced options:" - echo " --ghdl Path to GHDL's binary directory, e.g. /usr/local/bin" - echo " --out Name of the output directory, e.g. uvvm_util" - echo " --src Path to the sources." + echo " --ghdl Path to GHDL's executable, e.g. /usr/local/bin/ghdl" + echo " --output Name of the output directory, e.g. uvvm_util" + echo " --source Path to the sources." echo "" echo "Verbosity:" - echo " -n --no-warnings Suppress all warnings. Show only error messages." + echo " -v --verbose Print verbose messages." + echo " -d --debug Print debug messages." +# echo " -n --no-filter Disable output filtering scripts." + echo " -N --no-warnings Suppress all warnings. Show only error messages." echo "" - exit 0 + exit $COMMAND fi -if [ "$COMPILE_ALL" == "TRUE" ]; then - for p in $uvvm_pkgs $uvvm_vips; do - eval "COMPILE_$p=TRUE" - done +if [[ $COMMAND -eq 2 ]]; then + COMPILE_UVVM=1 + COMPILE_UVVM_VIP=1 fi -if [ "$COMPILE_UVVM" == "TRUE" ]; then - for p in $uvvm_pkgs; do - eval "COMPILE_$p=TRUE" - done +if [[ $COMPILE_UVVM -eq 1 ]]; then + COMPILE_UVVM_UTILITIES=1 + COMPILE_UVVM_VVC_FRAMEWORK=1 fi -if [ "$COMPILE_UVVM_VIP" == "TRUE" ]; then - for p in $uvvm_vips; do - eval "COMPILE_$p=TRUE" - done +if [[ $COMPILE_UVVM_VIP -eq 1 ]]; then + COMPILE_UVVM_VIP_AVALON_MM=1 + COMPILE_UVVM_VIP_AXILITE=1 + COMPILE_UVVM_VIP_AXISTREAM=1 + COMPILE_UVVM_VIP_CLOCK_GENERATOR=1 + COMPILE_UVVM_VIP_GPIO=1 + COMPILE_UVVM_VIP_I2C=1 + COMPILE_UVVM_VIP_SBI=1 + COMPILE_UVVM_VIP_SCOREBOARD=1 + COMPILE_UVVM_VIP_SPI=1 + COMPILE_UVVM_VIP_UART=1 fi + +# Source configuration file from GHDL's 'vendors' library directory +echo -e "${ANSI_MAGENTA}Loading environment...${ANSI_NOCOLOR}" +source $ScriptDir/config.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading configuration.${ANSI_NOCOLOR}" ; exit 1; fi +source $ScriptDir/shared.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading further procedures.${ANSI_NOCOLOR}"; exit 1; fi + +# <= $VHDLVersion +# <= $VHDLStandard +# <= $VHDLFlavor +GHDLSetup 2008 + # -> $SourceDirectories # -> $DestinationDirectories # -> $SrcDir # -> $DestDir -# -> $GHDLBinDir # <= $SourceDirectory # <= $DestinationDirectory -# <= $GHDLBinary SetupDirectories UVVM "UVVM" -# create "uvvm_util" directory and change to it +# Create "uvvm" directory and change to it # => $DestinationDirectory CreateDestinationDirectory cd $DestinationDirectory -# => $SUPPRESS_WARNINGS -# <= $GRC_COMMAND -SetupGRCat - - -# define global GHDL Options -GHDL_OPTIONS=(-fexplicit -frelaxed-rules --no-vital-checks --warn-binding --mb-comments) +# Extend global GHDL Options +Analyze_Parameters+=( + -fexplicit + -Wbinding + -Wno-shared +) +if [[ $DEBUG -eq 0 ]]; then + Analyze_Parameters+=( + -Wno-hide + ) +fi +if [[ ! (VERBOSE -eq 1) && ($DEBUG -eq 1) ]]; then + Analyze_Parameters+=( + -Wno-others + -Wno-static + ) +fi +Analyze_Parameters+=( + --ieee=$VHDLFlavor + --no-vital-checks + --std=$VHDLStandard + -frelaxed + -P$DestinationDirectory +) -# create a set of GHDL parameters -GHDL_PARAMS=(--std=08 -P$DestinationDirectory) -GHDL_PARAMS+=(${GHDL_OPTIONS[@]}) # Cleanup directory # ============================================================================== -if [ "$CLEAN" == "TRUE" ]; then +if [[ $CLEAN -eq 1 ]]; then echo -e "${ANSI_YELLOW}Cleaning up vendor directory ...${ANSI_NOCOLOR}" rm *.o 2> /dev/null rm *.cf 2> /dev/null fi + # UVVM libraries # ============================================================================== -# compile uvvm_util packages -ERRORCOUNT=0 -for Library in $uvvm_pkgs $uvvm_vips; do - if [ x`eval "echo \\\$COMPILE_$Library"` == x"TRUE" ]; then - VHDLVersion="v08" - # append absolute source path - files=`sed -e '/#/d' < $SourceDirectory/$Library/script/compile_order.txt` - SourceFiles=() - for File in $files; do - SourceFiles+=("$SourceDirectory/$Library/script/$File") - done - - GHDLCompilePackages +test $VERBOSE -eq 1 && echo -e " ${ANSI_GRAY}Reading compile order files...${ANSI_NOCOLOR}" + +# Read uvvm_util library files +StructName="UVVM_UTIL" +LibraryPath="uvvm_util" +Files=() +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Reading compile order from '$SourceDirectory/$LibraryPath/script/compile_order.txt'${ANSI_NOCOLOR}" +while IFS= read -r File; do + if [[ ${File:0:2} == "# " ]]; then + if [[ ${File:2:7} == "library" ]]; then + LibraryName=${File:10:-1} fi -done - -echo "--------------------------------------------------------------------------------" -echo -n "Compiling UVVM packages " -if [ $ERRORCOUNT -gt 0 ]; then - echo -e $COLORED_FAILED + else + Files+=("${File:3:-1}") + fi +done < <(cat "$SourceDirectory/$LibraryPath/script/compile_order.txt") + +CreateLibraryStruct $StructName $LibraryName $LibraryPath $VHDLVersion "${Files[@]}" + +test $COMPILE_UVVM_UTILITIES -eq 1 && Libraries+=($StructName) + + +# Reading uvvm_vvc_framework library files +StructName="UVVM_VVC_FRAMEWORK" +LibraryPath="uvvm_vvc_framework" +Files=() +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Reading compile order from '$SourceDirectory/$LibraryPath/script/compile_order.txt'${ANSI_NOCOLOR}" +while IFS= read -r File; do + if [[ ${File:0:2} == "# " ]]; then + if [[ ${File:2:7} == "library" ]]; then + LibraryName=${File:10:-1} + fi + else + Files+=("${File:3:-1}") + fi +done < <(cat "$SourceDirectory/$LibraryPath/script/compile_order.txt") + +CreateLibraryStruct $StructName $LibraryName $LibraryPath $VHDLVersion "${Files[@]}" + +test $COMPILE_UVVM_VVC_FRAMEWORK -eq 1 && Libraries+=($StructName) + + +# Verification IPs +# ============================================================================== +VIPNames=() + +while IFS= read -r VIPDirectory; do + LibraryPath=$(basename "$VIPDirectory") + x="${LibraryPath%%_*}" + pos=${#x}+1 + l=${LibraryPath:$pos} + VIPName=${l^^} + + test $VERBOSE -eq 1 && echo -e " ${ANSI_GRAY}Found VIP '$VIPName' in '$LibraryPath'.${ANSI_NOCOLOR}" + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Reading compile order from '$SourceDirectory/$LibraryPath/script/compile_order.txt'${ANSI_NOCOLOR}" + + # Reading uvvm_vvc_framework library files + StructName=$VIPName + Files=() + + while IFS= read -r File; do + if [[ ${File:0:2} == "# " ]]; then + if [[ ${File:2:7} == "library" ]]; then + LibraryName=${File:10:-1} + fi + else + Files+=("${File:3:-1}") + fi + done < <(cat "$SourceDirectory/$LibraryPath/script/compile_order.txt") + + CreateLibraryStruct $StructName $LibraryName $LibraryPath $VHDLVersion "${Files[@]}" + + VarName="COMPILE_UVVM_${VIPName}" + test ${!VarName} -eq 1 && Libraries+=($StructName) +done < <(find $SourceDirectory/*vip* -type d -prune) + +# if [[ $DEBUG -eq 1 ]]; then + # for StructName in ${Libraries[*]}; do + # PrintLibraryStruct $StructName " " + # done +# fi + +if [[ $Libraries != "" ]]; then + Compile "$SourceDirectory" "${Libraries[*]}" + + echo "--------------------------------------------------------------------------------" + echo -e "Compiling UVVM packages and VIPs $(test $ERRORCOUNT -eq 0 && echo $COLORED_SUCCESSFUL || echo $COLORED_FAILED)" else - echo -e $COLORED_SUCCESSFUL + echo -e "${ANSI_RED}Neither UVVM packages nor VIPs selected.${ANSI_NOCOLOR}" fi diff --git a/libraries/vendors/compile-xilinx-ise.sh b/libraries/vendors/compile-xilinx-ise.sh index 623b3f309..3aabca7ba 100755 --- a/libraries/vendors/compile-xilinx-ise.sh +++ b/libraries/vendors/compile-xilinx-ise.sh @@ -1,16 +1,12 @@ #! /usr/bin/env bash -# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- -# vim: tabstop=2:shiftwidth=2:noexpandtab -# kate: tab-width 2; replace-tabs off; indent-width 2; -# # ============================================================================== -# Authors: +# Authors: # Patrick Lehmann -# +# # Bash Script: # Script to compile the simulation libraries from Xilinx ISE # for GHDL on Linux -# +# # Description: # ------------------------------------ # This is a Bash script (executable) which: @@ -18,6 +14,7 @@ # - compiles all Xilinx ISE simulation libraries and packages # # ============================================================================== +# Copyright (C) 2017-2021 Patrick Lehmann - Boetzingen, Germany # Copyright (C) 2015-2016 Patrick Lehmann - Dresden, Germany # # This program is free software: you can redistribute it and/or modify @@ -34,108 +31,120 @@ # along with this program. If not, see . # ============================================================================== -# --------------------------------------------- -# work around for Darwin (Mac OS) +# Work around for Darwin (Mac OS) READLINK=readlink; if [[ $(uname) == "Darwin" ]]; then READLINK=greadlink; fi -# save working directory +# Save working directory WorkingDir=$(pwd) ScriptDir="$(dirname $0)" ScriptDir="$($READLINK -f $ScriptDir)" -# source configuration file from GHDL's 'vendors' library directory -. $ScriptDir/../ansi_color.sh -. $ScriptDir/config.sh -. $ScriptDir/shared.sh - -# command line argument processing -NO_COMMAND=1 -SKIP_EXISTING_FILES=0 +# Source Bash utilities +source $ScriptDir/../ansi_color.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading Bash utilities.${ANSI_NOCOLOR}" ; exit 1; fi + + +# Command line argument processing +COMMAND=1 +CLEAN=0 +COMPILE_UNISIM=0 +COMPILE_UNIMACRO=0 +COMPILE_SIMPRIM=0 +COMPILE_CORELIB=0 +COMPILE_SECUREIP=0 +VERBOSE=0 +DEBUG=0 +FILTERING=0 # TODO: 1 SKIP_LARGE_FILES=0 SUPPRESS_WARNINGS=0 -HALT_ON_ERROR=0 +CONTINUE_ON_ERROR=1 VHDLStandard=93 GHDLBinDir="" DestDir="" SrcDir="" while [[ $# > 0 ]]; do - key="$1" - case $key in + case "$1" in -c|--clean) - CLEAN=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + CLEAN=1 + ;; -a|--all) - COMPILE_ALL=TRUE - NO_COMMAND=0 - ;; + COMMAND=2 + ;; --unisim) - COMPILE_UNISIM=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UNISIM=1 + ;; --unimacro) - COMPILE_UNIMACRO=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UNIMACRO=1 + ;; --simprim) - COMPILE_SIMPRIM=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_SIMPRIM=1 + ;; --corelib) - COMPILE_CORELIB=TRUE - NO_COMMAND=0 - ;; - --secureip) - COMPILE_SECUREIP=TRUE - ;; - -h|--help) - HELP=TRUE - NO_COMMAND=0 - ;; - -s|--skip-existing) - SKIP_EXISTING_FILES=1 - ;; + COMMAND=3 + COMPILE_CORELIB=1 + ;; + --with-secureip) + COMPILE_SECUREIP=1 + ;; -S|--skip-largefiles) - SKIP_LARGE_FILES=1 - ;; - -n|--no-warnings) - SUPPRESS_WARNINGS=1 - ;; - -H|--halt-on-error) - HALT_ON_ERROR=1 - ;; + SKIP_LARGE_FILES=1 + ;; --vhdl93) - VHDLStandard=93 - ;; + VHDLStandard=93 + ;; --vhdl2008) - VHDLStandard=2008 - ;; + VHDLStandard=2008 + ;; + -v|--verbose) + VERBOSE=1 + ;; + -d|--debug) + VERBOSE=1 + DEBUG=1 + ;; + -h|--help) + COMMAND=0 + break + ;; + -n|--no-filter) + FILTERING=0 + ;; + -N|--no-warnings) + SUPPRESS_WARNINGS=1 + ;; + -H|--halt-on-error) + CONTINUE_ON_ERROR=0 + ;; --ghdl) - GHDLBinDir="$2" - shift # skip argument - ;; + GHDL="$2" # overwrite a potentially existing GHDL environment variable + shift # skip argument + ;; --src) - SrcDir="$2" - shift # skip argument - ;; + SrcDir="$2" + shift # skip argument + ;; --out) - DestDir="$2" - shift # skip argument - ;; + DestDir="$2" + shift # skip argument + ;; *) # unknown option - echo 1>&2 -e "${COLORED_ERROR} Unknown command line option '$key'.${ANSI_NOCOLOR}" - exit -1 - ;; + echo 1>&2 -e "\n${COLORED_ERROR} Unknown command line option '$1'.${ANSI_NOCOLOR}" + COMMAND=0 + break + ;; esac - shift # past argument or value + shift # parsed argument or value done -if [ $NO_COMMAND -eq 1 ]; then - HELP=TRUE -fi +ERRORCOUNT=0 +Libraries=() -if [ "$HELP" == "TRUE" ]; then - test $NO_COMMAND -eq 1 && echo 1>&2 -e "\n${COLORED_ERROR} No command selected." +if [[ $COMMAND -le 1 ]]; then + test $COMMAND -eq 1 && echo 1>&2 -e "\n${COLORED_ERROR} No command selected.${ANSI_NOCOLOR}" echo "" echo "Synopsis:" echo " A script to compile the Xilinx ISE simulation libraries for GHDL on Linux." @@ -148,46 +157,48 @@ if [ "$HELP" == "TRUE" ]; then echo " compile-xilinx-ise.sh | [] []" echo "" echo "Common commands:" - echo " -h --help Print this help page" - echo " -c --clean Remove all generated files" + echo " -h --help Print this help page" + echo " -c --clean Remove all generated files" echo "" echo "Libraries:" - echo " -a --all Compile all Xilinx simulation libraries." - echo " --unisim Compile the unisim library." - echo " --unimacro Compile the unimacro library." - echo " --simprim Compile the simprim library." - echo " --corelib Compile the corelib library." - echo " --secureip Compile the secureip library." + echo " -a --all Compile all Xilinx simulation libraries." + echo " --unisim Compile the unisim library." + echo " --unimacro Compile the unimacro library." + echo " --simprim Compile the simprim library." + echo " --corelib Compile the corelib library." + echo " --with-secureip Compile the secureip library." echo "" echo "Library compile options:" - echo " --vhdl93 Compile the libraries with VHDL-93." - echo " --vhdl2008 Compile the libraries with VHDL-2008." - echo " -s --skip-existing Skip already compiled files (an *.o file exists)." - echo " -S --skip-largefiles Don't compile large entities like DSP and PCIe primitives." - echo " -H --halt-on-error Halt on error(s)." + echo " --vhdl93 Compile the libraries with VHDL-93." + echo " --vhdl2008 Compile the libraries with VHDL-2008." + echo " -S --skip-largefiles Don't compile large files. Exclude *HSSI* and *HIP* files." + echo " -H --halt-on-error Halt on error(s)." echo "" echo "Advanced options:" - echo " --ghdl Path to GHDL's binary directory, e.g. /usr/local/bin" - echo " --out Name of the output directory, e.g. xilinx-ise" - echo " --src Path to the sources, e.g. /opt/Xilinx/14.7/ISE_DS/ISE/vhdl/src" + echo " --ghdl Path to GHDL's executable, e.g. /usr/local/bin/ghdl" + echo " --out Name of the output directory, e.g. uvvm_util" + echo " --src Path to the sources." echo "" echo "Verbosity:" - echo " -n --no-warnings Suppress all warnings. Show only error messages." + echo " -v --verbose Print verbose messages." + echo " -d --debug Print debug messages." +# echo " -n --no-filter Disable output filtering scripts." + echo " -N --no-warnings Suppress all warnings. Show only error messages." echo "" - exit 0 + exit $COMMAND fi -if [ "$COMPILE_ALL" == "TRUE" ]; then - COMPILE_UNISIM=TRUE - COMPILE_UNIMACRO=TRUE - COMPILE_SIMPRIM=TRUE - COMPILE_CORELIB=TRUE - COMPILE_SECUREIP=TRUE +if [[ $COMMAND -eq 2 ]]; then + COMPILE_UNISIM=1 + COMPILE_UNIMACRO=1 + COMPILE_SIMPRIM=1 + COMPILE_CORELIB=1 + COMPILE_SECUREIP=1 fi -if [ $VHDLStandard -eq 2008 ]; then - echo -e "${ANSI_RED}Not all Xilinx primitives are VHDL-2008 compatible! Setting HALT_ON_ERROR to FALSE.${ANSI_NOCOLOR}" - HALT_ON_ERROR=0 +if [[ $VHDLStandard -eq 2008 ]]; then + echo -e "${ANSI_RED}Not all Xilinx primitives are VHDL-2008 compatible! Setting CONTINUE_ON_ERROR to TRUE.${ANSI_NOCOLOR}" + CONTINUE_ON_ERROR=1 fi @@ -208,15 +219,20 @@ else done fi +# Source configuration file from GHDL's 'vendors' library directory +echo -e "${ANSI_MAGENTA}Loading environment...${ANSI_NOCOLOR}" +source $ScriptDir/config.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading configuration.${ANSI_NOCOLOR}" ; exit 1; fi +source $ScriptDir/shared.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading further procedures.${ANSI_NOCOLOR}"; exit 1; fi + # -> $SourceDirectories # -> $DestinationDirectories # -> $SrcDir # -> $EnvSourceDir # -> $DestDir -# -> $GHDLBinDir # <= $SourceDirectory # <= $DestinationDirectory -# <= $GHDLBinary SetupDirectories XilinxISE "Xilinx ISE" # create "xilinx-ise" directory and change to it @@ -236,21 +252,26 @@ SetupGRCat # <= $VHDLFlavor GHDLSetup -# define global GHDL Options -GHDL_OPTIONS=(-fexplicit -frelaxed-rules --no-vital-checks --warn-binding --mb-comments) - -GHDL_PARAMS=(--ieee=$VHDLFlavor --std=$VHDLStandard -P$DestinationDirectory) -GHDL_PARAMS+=(${GHDL_OPTIONS[@]}) - - -STOPCOMPILING=0 -ERRORCOUNT=0 +# Extend global GHDL Options +Analyze_Parameters+=( + -fexplicit + --no-vital-checks + -Wbinding + -Wno-hide + -Wno-others + -Wno-parenthesis + -Wno-library + -Wno-pure + --ieee=$VHDLFlavor + --std=$VHDLStandard + -P$DestinationDirectory +) # Cleanup directory # ============================================================================== -if [ "$CLEAN" == "TRUE" ]; then +if [[ $CLEAN -eq 1 ]]; then echo 1>&2 -e "${COLORED_ERROR} '--clean' is not implemented!" - exit -1 + exit 1 echo -e "${ANSI_YELLOW}Cleaning up vendor directory ...${ANSI_NOCOLOR}" rm *.o 2> /dev/null rm *.cf 2> /dev/null @@ -258,129 +279,107 @@ fi # Library unisim # ============================================================================== -# compile unisim packages -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNISIM" == "TRUE" ]; then - Library="unisim" - Files=( - ${Library}s/unisim_VPKG.vhd - ${Library}s/unisim_VCOMP.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi +test $VERBOSE -eq 1 && echo -e " ${ANSI_GRAY}Reading compile order files...${ANSI_NOCOLOR}" + +# Reading unisim files +StructName="UNISIM" +Library="unisim" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Reading compile order from '$SourceDirectory/${Library}s/primitive/vhdl_analyze_order'${ANSI_NOCOLOR}" +Files=( + unisim_VPKG.vhd + unisim_VCOMP.vhd +) +while IFS= read -r File; do + Files+=("primitive/$File") +done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/${Library}s/primitive/vhdl_analyze_order") + +CreateLibraryStruct $StructName $Library "${Library}s" $VHDLVersion "${Files[@]}" +test $COMPILE_UNISIM -eq 1 && Libraries+=($StructName) + +# Reading unisim secureip files +StructName="UNISIM_SECUREIP" +Library="unisim" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Reading compile order from '$SourceDirectory/${Library}s/secureip/vhdl_analyze_order'${ANSI_NOCOLOR}" +Files=() +while IFS= read -r File; do + Files+=("secureip/$File") +done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/${Library}s/secureip/vhdl_analyze_order") + +CreateLibraryStruct $StructName "secureip" "${Library}s" $VHDLVersion "${Files[@]}" +test $COMPILE_UNISIM -eq 1 && test $COMPILE_SECUREIP -eq 1 && Libraries+=($StructName) -# compile unisim primitives -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNISIM" == "TRUE" ]; then - Library="unisim" - SourceFiles=() - while IFS= read -r File; do - SourceFiles+=("$SourceDirectory/${Library}s/primitive/$File") - done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/${Library}s/primitive/vhdl_analyze_order") - - GHDLCompileLibrary -fi - -# compile unisim secureip primitives -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNISIM" == "TRUE" ] && [ "$COMPILE_SECUREIP" == "TRUE" ]; then - Library="secureip" - SourceFiles=() - while IFS= read -r File; do - SourceFiles+=("$SourceDirectory/unisims/$Library/$File") - done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/unisims/$Library/vhdl_analyze_order") - - GHDLCompileLibrary -fi # Library unimacro # ============================================================================== -# compile unimacro packages -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNIMACRO" == "TRUE" ]; then - Library="unimacro" - Files=( - $Library/unimacro_VCOMP.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +# Reading unimacro files +StructName="UNIMACRO" +Library="unimacro" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Scanning directory '$SourceDirectory/$Library/' for '*_MACRO.vhd'${ANSI_NOCOLOR}" +Files=( + $Library/unimacro_VCOMP.vhd +) +Files=( $(cd $SourceDirectory/$Library; LC_COLLATE=C ls *_MACRO.vhd) ) - GHDLCompilePackages -fi - -# compile unimacro macros -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNIMACRO" == "TRUE" ]; then - Library="unimacro" - SourceFiles=($(LC_COLLATE=C ls $SourceDirectory/$Library/*_MACRO.vhd)) +CreateLibraryStruct $StructName $Library $Library $VHDLVersion "${Files[@]}" +test $COMPILE_UNIMACRO -eq 1 && Libraries+=($StructName) - GHDLCompileLibrary -fi # Library simprim # ============================================================================== -# compile simprim packages -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_SIMPRIM" == "TRUE" ]; then - Library="simprim" - Files=( - ${Library}s/simprim_Vpackage.vhd - ${Library}s/simprim_Vcomponents.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") +# Reading simprim files +StructName="SIMPRIM" +Library="simprim" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Reading compile order from '$SourceDirectory/${Library}s/primitive/other/vhdl_analyze_order'${ANSI_NOCOLOR}" +Files=( + simprim_Vpackage.vhd + simprim_Vcomponents.vhd +) +# while IFS= read -r File; do + # Files+=("primitive/other/$File") +# done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/${Library}s/primitive/other/vhdl_analyze_order") + +CreateLibraryStruct $StructName $Library "${Library}s" $VHDLVersion "${Files[@]}" +test $COMPILE_SIMPRIM -eq 1 && Libraries+=($StructName) + + +# Reading simprim secureip files +StructName="SIMPRIM_SECUREIP" +Library="simprim" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Reading compile order from '$SourceDirectory/${Library}s/secureip/other/vhdl_analyze_order'${ANSI_NOCOLOR}" +Files=() +while IFS= read -r File; do + Files+=("secureip/other/$File") +done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/${Library}s/secureip/other/vhdl_analyze_order") + +CreateLibraryStruct $StructName "secureip" "${Library}s" $VHDLVersion "${Files[@]}" +test $COMPILE_SIMPRIM -eq 1 && test $COMPILE_SECUREIP -eq 1 && Libraries+=($StructName) + + +# Library xilinxcorelib +# ============================================================================== +# Reading corelib files +StructName="CORELIB" +Library="xilinxcorelib" +Files=() +while IFS= read -r File; do + Files+=("$File") +done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/XilinxCoreLib/vhdl_analyze_order") + +CreateLibraryStruct $StructName $Library "XilinxCoreLib" $VHDLVersion "${Files[@]}" +test $COMPILE_CORELIB -eq 1 && Libraries+=($StructName) + +if [[ $DEBUG -eq 1 ]]; then + for StructName in ${Libraries[*]}; do + PrintLibraryStruct $StructName " " done - - GHDLCompilePackages fi -# compile simprim primitives -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_SIMPRIM" == "TRUE" ]; then - Library="simprim" - SourceFiles=() - while IFS= read -r File; do - SourceFiles+=("$SourceDirectory/${Library}s/primitive/other/$File") - done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/${Library}s/primitive/other/vhdl_analyze_order") - - GHDLCompileLibrary -fi - -# compile simprim secureip primitives -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_SIMPRIM" == "TRUE" ] && [ "$COMPILE_SECUREIP" == "TRUE" ]; then - Library="secureip" - SourceFiles=() - while IFS= read -r File; do - SourceFiles+=("$SourceDirectory/simprims/$Library/other/$File") - done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/simprims/$Library/other/vhdl_analyze_order") - - GHDLCompileLibrary -fi - -# Library corelib -# ============================================================================== -# compile corelib packages -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_CORELIB" == "TRUE" ]; then - Library="xilinxcorelib" - - # append absolute source path - SourceFiles=() - while IFS= read -r File; do - SourceFiles+=("$SourceDirectory/XilinxCoreLib/$File") - done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/XilinxCoreLib/vhdl_analyze_order") - - GHDLCompilePackages -fi +# Compile libraries +if [[ "$Libraries" != "" ]]; then + Compile "$SourceDirectory" "${Libraries[*]}" - -echo "--------------------------------------------------------------------------------" -echo -n "Compiling Xilinx ISE libraries " -if [ $ERRORCOUNT -gt 0 ]; then - echo -e $COLORED_FAILED + echo "--------------------------------------------------------------------------------" + echo -e "Compiling Xilinx ISE libraries $(test $ERRORCOUNT -eq 0 && echo $COLORED_SUCCESSFUL || echo $COLORED_FAILED)" else - echo -e $COLORED_SUCCESSFUL + echo -e "${ANSI_RED}No Xilinx ISE libraries selected.${ANSI_NOCOLOR}" fi diff --git a/libraries/vendors/compile-xilinx-vivado.sh b/libraries/vendors/compile-xilinx-vivado.sh index 19ed9e523..279a9447f 100755 --- a/libraries/vendors/compile-xilinx-vivado.sh +++ b/libraries/vendors/compile-xilinx-vivado.sh @@ -1,16 +1,12 @@ #! /usr/bin/env bash -# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- -# vim: tabstop=2:shiftwidth=2:noexpandtab -# kate: tab-width 2; replace-tabs off; indent-width 2; -# # ============================================================================== # Authors: # Patrick Lehmann -# +# # Bash Script: # Script to compile the simulation libraries from Xilinx Vivado # for GHDL on Linux -# +# # Description: # ------------------------------------ # This is a Bash script (executable) which: @@ -18,6 +14,7 @@ # - compiles all Xilinx Vivado simulation libraries and packages # # ============================================================================== +# Copyright (C) 2017-2021 Patrick Lehmann - Boetzingen, Germany # Copyright (C) 2015-2016 Patrick Lehmann - Dresden, Germany # # This program is free software: you can redistribute it and/or modify @@ -34,104 +31,115 @@ # along with this program. If not, see . # ============================================================================== -# --------------------------------------------- -# work around for Darwin (Mac OS) +# Work around for Darwin (Mac OS) READLINK=readlink; if [[ $(uname) == "Darwin" ]]; then READLINK=greadlink; fi -# save working directory +# Save working directory WorkingDir=$(pwd) ScriptDir="$(dirname $0)" ScriptDir="$($READLINK -f $ScriptDir)" -# source configuration file from GHDL's 'vendors' library directory -. $ScriptDir/../ansi_color.sh -. $ScriptDir/config.sh -. $ScriptDir/shared.sh - -# command line argument processing -NO_COMMAND=1 -SKIP_EXISTING_FILES=0 +# Source Bash utilities +source $ScriptDir/../ansi_color.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading Bash utilities.${ANSI_NOCOLOR}" ; exit 1; fi + + +# Command line argument processing +COMMAND=1 +CLEAN=0 +COMPILE_UNISIM=0 +COMPILE_UNIMACRO=0 +COMPILE_UNIFAST=0 +COMPILE_SECUREIP=0 +VERBOSE=0 +DEBUG=0 +FILTERING=0 # TODO: 1 SKIP_LARGE_FILES=0 SUPPRESS_WARNINGS=0 -HALT_ON_ERROR=0 +CONTINUE_ON_ERROR=0 VHDLStandard=93 GHDLBinDir="" DestDir="" SrcDir="" while [[ $# > 0 ]]; do - key="$1" - case $key in + case "$1" in -c|--clean) - CLEAN=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + CLEAN=1 + ;; -a|--all) - COMPILE_ALL=TRUE - NO_COMMAND=0 - ;; + COMMAND=2 + ;; --unisim) - COMPILE_UNISIM=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UNISIM=1 + ;; --unimacro) - COMPILE_UNIMACRO=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_UNIMACRO=1 + ;; --unifast) - COMPILE_UNIFAST=TRUE - NO_COMMAND=0 - ;; - --secureip) - COMPILE_SECUREIP=TRUE - ;; - -h|--help) - HELP=TRUE - NO_COMMAND=0 - ;; - -s|--skip-existing) - SKIP_EXISTING_FILES=1 - ;; + COMMAND=3 + COMPILE_UNIFAST=1 + ;; + --with-secureip) + COMPILE_SECUREIP=1 + ;; -S|--skip-largefiles) - SKIP_LARGE_FILES=1 - ;; - -n|--no-warnings) - SUPPRESS_WARNINGS=1 - ;; - -H|--halt-on-error) - HALT_ON_ERROR=1 - ;; + SKIP_LARGE_FILES=1 + ;; --vhdl93) - VHDLStandard=93 - ;; + VHDLStandard=93 + ;; --vhdl2008) - VHDLStandard=2008 - ;; + VHDLStandard=2008 + ;; + -v|--verbose) + VERBOSE=1 + ;; + -d|--debug) + VERBOSE=1 + DEBUG=1 + ;; + -h|--help) + COMMAND=0 + break + ;; + -n|--no-filter) + FILTERING=0 + ;; + -N|--no-warnings) + SUPPRESS_WARNINGS=1 + ;; + -H|--halt-on-error) + CONTINUE_ON_ERROR=1 + ;; --ghdl) - GHDLBinDir="$2" - shift # skip argument - ;; + GHDL="$2" # overwrite a potentially existing GHDL environment variable + shift # skip argument + ;; --src) - SrcDir="$2" - shift # skip argument - ;; + SrcDir="$2" + shift # skip argument + ;; --out) - DestDir="$2" - shift # skip argument - ;; + DestDir="$2" + shift # skip argument + ;; *) # unknown option - echo 1>&2 -e "${COLORED_ERROR} Unknown command line option '$key'.${ANSI_NOCOLOR}" - exit -1 - ;; + echo 1>&2 -e "\n${COLORED_ERROR} Unknown command line option '$1'.${ANSI_NOCOLOR}" + COMMAND=0 + break + ;; esac - shift # past argument or value + shift # parsed argument or value done -if [ $NO_COMMAND -eq 1 ]; then - HELP=TRUE -fi +ERRORCOUNT=0 +Libraries=() -if [ "$HELP" == "TRUE" ]; then - test $NO_COMMAND -eq 1 && echo 1>&2 -e "/n${COLORED_ERROR} No command selected." +if [[ $COMMAND -le 1 ]]; then + test $COMMAND -eq 1 && echo 1>&2 -e "\n${COLORED_ERROR} No command selected.${ANSI_NOCOLOR}" echo "" echo "Synopsis:" echo " A script to compile the Xilinx Vivado simulation libraries for GHDL on Linux." @@ -144,44 +152,46 @@ if [ "$HELP" == "TRUE" ]; then echo " compile-xilinx-vivado.sh | [] []" echo "" echo "Common commands:" - echo " -h --help Print this help page" - echo " -c --clean Remove all generated files" + echo " -h --help Print this help page" + echo " -c --clean Remove all generated files" echo "" echo "Libraries:" - echo " -a --all Compile all Xilinx simulation libraries." - echo " --unisim Compile the unisim library." - echo " --unimacro Compile the unimacro library." - echo " --unifast Compile the unifast library." - echo " --secureip Compile the secureip library." + echo " -a --all Compile all Xilinx simulation libraries." + echo " --unisim Compile the unisim library." + echo " --unimacro Compile the unimacro library." + echo " --unifast Compile the unifast library." + echo " --with-secureip Compile the secureip library." echo "" echo "Library compile options:" - echo " --vhdl93 Compile the libraries with VHDL-93." - echo " --vhdl2008 Compile the libraries with VHDL-2008." - echo " -s --skip-existing Skip already compiled files (an *.o file exists)." - echo " -S --skip-largefiles Don't compile large entities like DSP and PCIe primitives." - echo " -H --halt-on-error Halt on error(s)." + echo " --vhdl93 Compile the libraries with VHDL-93." + echo " --vhdl2008 Compile the libraries with VHDL-2008." + echo " -S --skip-largefiles Don't compile large files. Exclude *HSSI* and *HIP* files." + echo " -H --halt-on-error Halt on error(s)." echo "" echo "Advanced options:" - echo " --ghdl Path to GHDL's binary directory, e.g. /usr/local/bin" - echo " --out Name of the output directory, e.g. xilinx-vivado" - echo " --src Path to the sources, e.g. /opt/Xilinx/Vivado/2016.3/data/vhdl/src" + echo " --ghdl Path to GHDL's executable, e.g. /usr/local/bin/ghdl" + echo " --out Name of the output directory, e.g. uvvm_util" + echo " --src Path to the sources." echo "" echo "Verbosity:" - echo " -n --no-warnings Suppress all warnings. Show only error messages." + echo " -v --verbose Print verbose messages." + echo " -d --debug Print debug messages." +# echo " -n --no-filter Disable output filtering scripts." + echo " -N --no-warnings Suppress all warnings. Show only error messages." echo "" - exit 0 + exit $COMMAND fi -if [ "$COMPILE_ALL" == "TRUE" ]; then - COMPILE_UNISIM=TRUE - COMPILE_UNIMACRO=TRUE - COMPILE_UNIFAST=TRUE - COMPILE_SECUREIP=TRUE +if [[ $COMMAND -eq 2 ]]; then + COMPILE_UNISIM=1 + COMPILE_UNIMACRO=1 + COMPILE_UNIFAST=1 + COMPILE_SECUREIP=1 fi -if [ $VHDLStandard -eq 2008 ]; then - echo -e "${ANSI_RED}Not all Xilinx primitives are VHDL-2008 compatible! Setting HALT_ON_ERROR to FALSE.${ANSI_NOCOLOR}" - HALT_ON_ERROR=0 +if [[ $VHDLStandard -eq 2008 ]]; then + echo -e "${ANSI_RED}Not all Xilinx primitives are VHDL-2008 compatible! Setting CONTINUE_ON_ERROR to TRUE.${ANSI_NOCOLOR}" + CONTINUE_ON_ERROR=1 fi @@ -190,7 +200,7 @@ if [ ! -z $XILINX_VIVADO ]; then EnvSourceDir=$XILINX_VIVADO/${SourceDirectories[XilinxVivado]} else for DefaultDir in ${DefaultDirectories[@]}; do - for Major in 2017 2016 2015 2014; do + for Major in 2021 2020 2019 2018 2017 2016 2015 2014; do for Minor in 4 3 2 1; do Dir=$DefaultDir/${Major}.${Minor} if [ -d $Dir ]; then @@ -202,15 +212,20 @@ else done fi +# Source configuration file from GHDL's 'vendors' library directory +echo -e "${ANSI_MAGENTA}Loading environment...${ANSI_NOCOLOR}" +source $ScriptDir/config.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading configuration.${ANSI_NOCOLOR}" ; exit 1; fi +source $ScriptDir/shared.sh +if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading further procedures.${ANSI_NOCOLOR}"; exit 1; fi + # -> $SourceDirectories # -> $DestinationDirectories # -> $SrcDir # -> $EnvSourceDir # -> $DestDir -# -> $GHDLBinDir # <= $SourceDirectory # <= $DestinationDirectory -# <= $GHDLBinary SetupDirectories XilinxVivado "Xilinx Vivado" # create "xilinx-vivado" directory and change to it @@ -219,7 +234,7 @@ CreateDestinationDirectory cd $DestinationDirectory -# => $SUPPRESS_WARNINGS +# -> $SUPPRESS_WARNINGS # <= $GRC_COMMAND SetupGRCat @@ -230,21 +245,27 @@ SetupGRCat # <= $VHDLFlavor GHDLSetup -# define global GHDL Options -GHDL_OPTIONS=(-fexplicit -frelaxed-rules --no-vital-checks --warn-binding --mb-comments) - -GHDL_PARAMS=(--ieee=$VHDLFlavor --std=$VHDLStandard -P$DestinationDirectory) -GHDL_PARAMS+=(${GHDL_OPTIONS[@]}) - - -STOPCOMPILING=0 -ERRORCOUNT=0 +# Extend global GHDL Options +Analyze_Parameters+=( + -fexplicit + + --no-vital-checks + -Wbinding + -Wno-hide + -Wno-others + -Wno-parenthesis + -Wno-library + -Wno-pure + --ieee=$VHDLFlavor + --std=$VHDLStandard + -P$DestinationDirectory +) # Cleanup directory # ============================================================================== -if [ "$CLEAN" == "TRUE" ]; then +if [[ $CLEAN -eq 1 ]]; then echo 1>&2 -e "${COLORED_ERROR} '--clean' is not implemented!" - exit -1 + exit 1 echo -e "${ANSI_YELLOW}Cleaning up vendor directory ...${ANSI_NOCOLOR}" rm *.o 2> /dev/null rm *.cf 2> /dev/null @@ -252,96 +273,84 @@ fi # Library unisim # ============================================================================== -# compile unisim packages -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNISIM" == "TRUE" ]; then - Library="unisim" - Files=( - ${Library}s/unisim_VPKG.vhd - ${Library}s/unisim_VCOMP.vhd - ${Library}s/retarget_VCOMP.vhd - ${Library}s/unisim_retarget_VCOMP.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi - -# compile unisim primitives -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNISIM" == "TRUE" ]; then - Library="unisim" - SourceFiles=() - while IFS= read -r File; do - SourceFiles+=("$SourceDirectory/${Library}s/primitive/$File") - done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/${Library}s/primitive/vhdl_analyze_order") - - GHDLCompileLibrary -fi +test $VERBOSE -eq 1 && echo -e " ${ANSI_GRAY}Reading compile order files...${ANSI_NOCOLOR}" + +# Reading unisim files +StructName="UNISIM" +Library="unisim" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Reading compile order from '$SourceDirectory/${Library}s/primitive/vhdl_analyze_order'${ANSI_NOCOLOR}" +Files=( + unisim_VPKG.vhd + unisim_retarget_VCOMP.vhd +) +while IFS= read -r File; do + Files+=("primitive/$File") +done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/${Library}s/primitive/vhdl_analyze_order") + +# Reading unisim retarget files +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Reading compile order from '$SourceDirectory/${Library}s/retarget/vhdl_analyze_order'${ANSI_NOCOLOR}" +while IFS= read -r File; do + Files+=("retarget/$File") +done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/${Library}s/retarget/vhdl_analyze_order") + +CreateLibraryStruct $StructName $Library "${Library}s" $VHDLVersion "${Files[@]}" +test $COMPILE_UNISIM -eq 1 && Libraries+=($StructName) + +# Reading unisim secureip files +StructName="UNISIM_SECUREIP" +Library="unisim" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Scanning directory '$SourceDirectory/${Library}s/secureip' for '*.vhd'${ANSI_NOCOLOR}" +Files=( $(cd $SourceDirectory/${Library}s/secureip; LC_COLLATE=C ls *.vhd) ) + +CreateLibraryStruct $StructName "secureip" "${Library}s/secureip" $VHDLVersion "${Files[@]}" +test $COMPILE_UNISIM -eq 1 && test $COMPILE_SECUREIP -eq 1 && Libraries+=($StructName) -# compile unisim retarget primitives -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNISIM" == "TRUE" ]; then - Library="unisim" - SourceFiles="$(LC_COLLATE=C ls $SourceDirectory/${Library}s/retarget/*.vhd)" - GHDLCompileLibrary -fi +# Library unimacro +# ============================================================================== +# Reading unimacro files +StructName="UNIMACRO" +Library="unimacro" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Scanning directory '$SourceDirectory/$Library/' for '*_MACRO.vhd'${ANSI_NOCOLOR}" +Files=( + unimacro_VCOMP.vhd +) +while IFS= read -r File; do + Files+=("$File") +done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/$Library/vhdl_analyze_order") + +CreateLibraryStruct $StructName $Library $Library $VHDLVersion "${Files[@]}" +test $COMPILE_UNIMACRO -eq 1 && Libraries+=($StructName) + +# Library unifast +# ============================================================================== +StructName="UNIFAST" +Library="unifast" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Reading compile order from '$SourceDirectory/$Library/primitive/vhdl_analyze_order'${ANSI_NOCOLOR}" +Files=() +while IFS= read -r File; do + Files+=("$File") +done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/$Library/primitive/vhdl_analyze_order") -# compile unisim secureip primitives -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNISIM" == "TRUE" ] && [ "$COMPILE_SECUREIP" == "TRUE" ]; then - Library="secureip" - SourceFiles="$(LC_COLLATE=C ls $SourceDirectory/unisims/$Library/*.vhd)" +CreateLibraryStruct $StructName $Library "$Library/primitive" $VHDLVersion "${Files[@]}" +test $COMPILE_UNIFAST -eq 1 && Libraries+=($StructName) - GHDLCompileLibrary -fi +# Reading unifast secureip files +StructName="UNIFAST_SECUREIP" +Library="unifast" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Scanning directory '$SourceDirectory/$Library/secureip' for '*.vhd'${ANSI_NOCOLOR}" +Files=( $(cd $SourceDirectory/$Library/secureip; LC_COLLATE=C ls *.vhd) ) -# Library unimacro -# ============================================================================== -# compile unimacro packages -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNIMACRO" == "TRUE" ]; then - Library="unimacro" - Files=( - $Library/unimacro_VCOMP.vhd - ) - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done +CreateLibraryStruct $StructName "secureip" "$Library/secureip" $VHDLVersion "${Files[@]}" +test $COMPILE_UNIFAST -eq 1 && test $COMPILE_SECUREIP -eq 1 && Libraries+=($StructName) - GHDLCompilePackages -fi - -# compile unimacro macros -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNIMACRO" == "TRUE" ]; then - Library="unimacro" - SourceFiles=() - while IFS= read -r File; do - SourceFiles+=("$SourceDirectory/${Library}/$File") - done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/${Library}/vhdl_analyze_order") - - GHDLCompileLibrary -fi -# Library UNIFAST -# ============================================================================== -# compile unisim primitives -if [ $STOPCOMPILING -eq 0 ] && [ "$COMPILE_UNIFAST" == "TRUE" ]; then - Library="unifast" - SourceFiles=() - while IFS= read -r File; do - SourceFiles+=("$SourceDirectory/${Library}/primitive/$File") - done < <(grep --no-filename -R '^[a-zA-Z]' "$SourceDirectory/${Library}/primitive/vhdl_analyze_order") - - GHDLCompileLibrary -fi +# Compile libraries +if [[ "$Libraries" != "" ]]; then + Compile "$SourceDirectory" "${Libraries[*]}" -echo "--------------------------------------------------------------------------------" -echo -n "Compiling Xilinx Vivado libraries " -if [ $ERRORCOUNT -gt 0 ]; then - echo -e $COLORED_FAILED + echo "--------------------------------------------------------------------------------" + echo -e "Compiling Xilinx Vivado libraries $(test $ERRORCOUNT -eq 0 && echo $COLORED_SUCCESSFUL || echo $COLORED_FAILED)" else - echo -e $COLORED_SUCCESSFUL + echo -e "${ANSI_RED}No Xilinx Vivado libraries selected.${ANSI_NOCOLOR}" fi diff --git a/libraries/vendors/shared.psm1 b/libraries/vendors/shared.psm1 index 8c7c0fb08..33f322e55 100644 --- a/libraries/vendors/shared.psm1 +++ b/libraries/vendors/shared.psm1 @@ -350,10 +350,12 @@ function Start-PrimitiveCompilation $EnableDebug -and (Write-Host " mkdir $LibraryDirectory" -ForegroundColor DarkGray ) | Out-Null mkdir $LibraryDirectory -ErrorAction SilentlyContinue | Out-Null $EnableDebug -and (Write-Host " cd $LibraryDirectory" -ForegroundColor DarkGray ) | Out-Null + cd $LibraryDirectory + $ErrorCount = 0 foreach ($File in $SourceFiles) - { Write-Host " Analyzing primitive file '$File'" -ForegroundColor DarkCyan + { $EnableVerbose -and (Write-Host " Analyzing primitive file '$File'" -ForegroundColor DarkCyan ) | Out-Null $InvokeExpr = "& '$GHDLBinary' " + ($GHDLOptions -join " ") + " --work=$Library " + $File + " 2>&1" $EnableDebug -and (Write-Host " $InvokeExpr" -ForegroundColor DarkGray ) | Out-Null $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings -Indent:"$Indent" diff --git a/libraries/vendors/shared.sh b/libraries/vendors/shared.sh index 7112b4bb7..5d234d91c 100755 --- a/libraries/vendors/shared.sh +++ b/libraries/vendors/shared.sh @@ -1,7 +1,3 @@ -# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- -# vim: tabstop=2:shiftwidth=2:noexpandtab -# kate: tab-width 2; replace-tabs off; indent-width 2; -# # ============================================================================== # Authors: Patrick Lehmann # @@ -14,7 +10,7 @@ # ============================================================================== # Copyright (C) 2017-2021 Patrick Lehmann - Boetzingen, Germany # Copyright (C) 2015-2016 Patrick Lehmann - Dresden, Germany -# +# # 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 2 of the License, or @@ -50,9 +46,8 @@ else # fall back to GHDL found via PATH fi fi -# Analyze_Filter=GHDL/filter.analyze.sh +Analyze_Filter=filter.analyze.sh Analyze_Parameters=( - -frelaxed-rules --mb-comments ) @@ -60,9 +55,9 @@ VERBOSE=${VERBOSE:-0} DEBUG=${DEBUG:-0} CONTINUE_ON_ERROR=${CONTINUE_ON_ERROR:-0} -test $VERBOSE -eq 1 && echo -e " Declaring Bash functions for GHDL..." +test $VERBOSE -eq 1 && echo -e " Declaring Bash procedures for GHDL..." -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function SetupDirectories( )${ANSI_NOCOLOR}" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure SetupDirectories( )${ANSI_NOCOLOR}" # SetupDirectories # -> $Index # -> $Name @@ -112,7 +107,7 @@ SetupDirectories() { fi } -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function SetupGRCat( undocumented )${ANSI_NOCOLOR}" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure SetupGRCat( undocumented )${ANSI_NOCOLOR}" # SetupGRCat # -> undocumented SetupGRCat() { @@ -126,40 +121,40 @@ SetupGRCat() { fi } -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function CreateDestinationDirectory( undocumented )${ANSI_NOCOLOR}" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure CreateDestinationDirectory( undocumented )${ANSI_NOCOLOR}" # CreateDestinationDirectory # -> undocumented CreateDestinationDirectory() { if [ -d "$DestinationDirectory" ]; then - echo -e "${ANSI_YELLOW}Vendor directory '$DestinationDirectory' already exists.${ANSI_NOCOLOR}" + echo -e "${COLORED_WARNING} Vendor directory '$DestinationDirectory' already exists.${ANSI_NOCOLOR}" elif [ -f "$DestinationDirectory" ]; then echo 1>&2 -e "${COLORED_ERROR} Vendor directory '$DestinationDirectory' already exists as a file.${ANSI_NOCOLOR}" exit 1 else - echo -e "${ANSI_YELLOW}Creating vendor directory: '$DestinationDirectory'.${ANSI_NOCOLOR}" + echo -e "Creating vendor directory: '$DestinationDirectory'.${ANSI_NOCOLOR}" mkdir -p "$DestinationDirectory" fi } -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function GHDLSetup( )${ANSI_NOCOLOR}" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure GHDLSetup( )${ANSI_NOCOLOR}" # GHDLSetup -# -> $VHDLStandard # FIXME: make it a real parameter +# -> $VHDLStandard # <= $VHDLVersion # <= $VHDLStandard # <= $VHDLFlavor GHDLSetup() { - if [ $VHDLStandard -eq 93 ]; then + if [ $1 -eq 93 ]; then VHDLVersion="v93" VHDLStandard="93c" VHDLFlavor="synopsys" - elif [ $VHDLStandard -eq 2008 ]; then + elif [ $1 -eq 2008 ]; then VHDLVersion="v08" VHDLStandard="08" VHDLFlavor="synopsys" fi } -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function CreateVHDLLibrary( )${ANSI_NOCOLOR}" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure CreateVHDLLibrary( )${ANSI_NOCOLOR}" # CreateLibraryStruct # -> $StructName # -> $LibraryName @@ -177,7 +172,7 @@ CreateLibraryStruct() { FilesRef=( "$*" ) } -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function DeleteLibraryStruct( )${ANSI_NOCOLOR}" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure DeleteLibraryStruct( )${ANSI_NOCOLOR}" # DeleteLibraryStruct # -> $StructName DeleteLibraryStruct() { @@ -189,7 +184,7 @@ DeleteLibraryStruct() { unset "${StructName}_Files" } -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function PrintLibraryStruct( )${ANSI_NOCOLOR}" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure PrintLibraryStruct( )${ANSI_NOCOLOR}" # PrintLibraryStruct # -> $StructName PrintLibraryStruct() { @@ -208,7 +203,7 @@ PrintLibraryStruct() { declare -A GHDLLibraryMapping -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function CreateVHDLLibrary( )${ANSI_NOCOLOR}" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure CreateVHDLLibrary( )${ANSI_NOCOLOR}" # CreateVHDLLibrary # -> $LibraryName # -> $DirectoryName @@ -228,7 +223,7 @@ CreateVHDLLibrary() { GHDLLibraryMapping[$LibraryName]=$LibraryDir } -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function AnalyzeVHDL( )${ANSI_NOCOLOR}" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure AnalyzeVHDL( )${ANSI_NOCOLOR}" # AnalyzeVHDL # -> $LibraryName # -> $SourceDirectory @@ -274,33 +269,33 @@ AnalyzeVHDL() { $GHDL -a ${Analyze_Parameters[@]} ${Parameters[@]} --work=$LibraryName --workdir=$DestinationDirectory "$SourceFile" ExitCode=$? if [[ $ExitCode -ne 0 ]]; then - echo 1>&2 -e "${COLORED_ERROR} While analyzing '$File'. ExitCode: $ExitCode${ANSI_NOCOLOR}" + echo 1>&2 -e "$Filter_Indent${COLORED_ERROR} While analyzing '$File'. ExitCode: $ExitCode${ANSI_NOCOLOR}" test $CONTINUE_ON_ERROR -eq 0 && exit 1 fi - # else - # test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}$GHDL -a ${Analyze_Parameters[*]} ${Parameters[*]} --work=$LibraryName \"$SourceFile\" | \\\\${ANSI_NOCOLOR}" - # test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}$GHDLScriptDir/$Analyze_Filter ${Filter_Parameters[*]} -i \"$Filter_Indent\"${ANSI_NOCOLOR}" - # $GHDL -a ${Analyze_Parameters[@]} ${Parameters[@]} --work=$LibraryName "$SourceFile" 2>&1 | $GHDLScriptDir/$Analyze_Filter ${Filter_Parameters[@]} -i "$Filter_Indent" - # local PiplineStatus=("${PIPESTATUS[@]}") - # if [[ ${PiplineStatus[0]} -ne 0 ]]; then - # echo 1>&2 -e "${COLORED_ERROR} While analyzing '$File'. ExitCode: ${PiplineStatus[0]}${ANSI_NOCOLOR}" - # if [[ $CONTINUE_ON_ERROR -eq 1 ]]; then - # exit 1; - # fi - # elif [[ ${PiplineStatus[1]} -ne 0 ]]; then - # case $(( ${PiplineStatus[1]} % 4 )) in - # TODO: implement CONTINUE_ON_ERROR in cases ... - # 3) echo 1>&2 -e "$Filter_Indent${ANSI_RED}Fatal errors detected by filtering script. ExitCode: ${PiplineStatus[1]}${ANSI_NOCOLOR}"; exit 1 ;; - # 2) echo 1>&2 -e "$Filter_Indent${ANSI_RED}Errors detected by filtering script. ExitCode: ${PiplineStatus[1]}${ANSI_NOCOLOR}"; exit 1 ;; - # 1) echo 1>&2 -e "$Filter_Indent${ANSI_YELLOW}Warnings detected by filtering script.${ANSI_NOCOLOR}" ;; - # 0) test $DEBUG -eq 1 && echo 1>&2 -e "$Filter_Indent${ANSI_YELLOW}Warnings detected by filtering script.${ANSI_NOCOLOR}" ;; - # esac - # fi + else + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}$GHDL -a ${Analyze_Parameters[*]} ${Parameters[*]} --work=$LibraryName \"$SourceFile\" 2>&1 | \\\\${ANSI_NOCOLOR}" + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}$ScriptDir/$Analyze_Filter ${Filter_Parameters[*]} -i \"$Filter_Indent\"${ANSI_NOCOLOR}" + $GHDL -a ${Analyze_Parameters[@]} ${Parameters[@]} --work=$LibraryName "$SourceFile" 2>&1 | $ScriptDir/$Analyze_Filter ${Filter_Parameters[@]} -i "$Filter_Indent" + local PiplineStatus=("${PIPESTATUS[@]}") + if [[ ${PiplineStatus[0]} -ne 0 ]]; then + echo 1>&2 -e "$Filter_Indent${COLORED_ERROR} While analyzing '$File'. ExitCode: ${PiplineStatus[0]}${ANSI_NOCOLOR}" + if [[ $CONTINUE_ON_ERROR -eq 1 ]]; then + exit 1; + fi + elif [[ ${PiplineStatus[1]} -ne 0 ]]; then + case $(( ${PiplineStatus[1]} % 4 )) in + # TODO: implement CONTINUE_ON_ERROR in cases ... + 3) echo 1>&2 -e "$Filter_Indent${ANSI_RED}Fatal errors detected by filtering script. ExitCode: ${PiplineStatus[1]}${ANSI_NOCOLOR}"; exit 1 ;; + 2) echo 1>&2 -e "$Filter_Indent${ANSI_RED}Errors detected by filtering script. ExitCode: ${PiplineStatus[1]}${ANSI_NOCOLOR}"; exit 1 ;; + 1) echo 1>&2 -e "$Filter_Indent${ANSI_YELLOW}Warnings detected by filtering script.${ANSI_NOCOLOR}" ;; + 0) test $DEBUG -eq 1 && echo 1>&2 -e "$Filter_Indent${ANSI_YELLOW}Warnings detected by filtering script.${ANSI_NOCOLOR}" ;; + esac + fi fi } -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function AnalyzeLibrary( )${ANSI_NOCOLOR}" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure AnalyzeLibrary( )${ANSI_NOCOLOR}" # AnalyzeLibrary # -> LibraryName # -> SourceDirectory @@ -315,13 +310,13 @@ AnalyzeLibrary() { echo -e "${ANSI_YELLOW}Analyzing files into library '$LibraryName'...${ANSI_NOCOLOR}" for File in $Files; do - test $VERBOSE -eq 1 && echo -e " Analyzing '$File'" + test $VERBOSE -eq 1 && echo -e "${ANSI_CYAN} Analyzing '$File'${ANSI_NOCOLOR}" AnalyzeVHDL $LibraryName "$SourceDirectory" "$LibraryPath" "$File" done } -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function Compile( )${ANSI_NOCOLOR}" +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure Compile( )${ANSI_NOCOLOR}" # Compile # -> SourceDirectory # -> VHDLLibraries -- cgit v1.2.3