diff options
Diffstat (limited to 'libraries')
-rwxr-xr-x | libraries/vendors/compile-osvvm.sh | 263 | ||||
-rwxr-xr-x | libraries/vendors/config.sh | 84 | ||||
-rwxr-xr-x | libraries/vendors/shared.sh | 336 |
3 files changed, 435 insertions, 248 deletions
diff --git a/libraries/vendors/compile-osvvm.sh b/libraries/vendors/compile-osvvm.sh index 45c1db580..b1d1a2701 100755 --- a/libraries/vendors/compile-osvvm.sh +++ b/libraries/vendors/compile-osvvm.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 @@ -32,81 +28,89 @@ # along with this program. If not, see <gnu.org/licenses>. # ============================================================================== -# --------------------------------------------- -# 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 +# 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 -NO_COMMAND=1 +# Command line argument processing +COMMAND=1 +CLEAN=0 +COMPILE_OSVVM=0 +VERBOSE=0 +DEBUG=0 +FILTERING=0 # TODO: 1 SUPPRESS_WARNINGS=0 HALT_ON_ERROR=0 -GHDLBinDir="" DestDir="" SrcDir="" -while [[ $# > 0 ]]; do - key="$1" - case $key in +while [[ $# -gt 0 ]]; do + case "$1" in -c|--clean) - CLEAN=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + CLEAN=1 + ;; -a|--all) - COMPILE_ALL=TRUE - NO_COMMAND=0 - ;; + COMMAND=2 + ;; --osvvm) - COMPILE_OSVVM=TRUE - NO_COMMAND=0 - ;; + COMMAND=3 + COMPILE_OSVVM=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 # skip argument or value + shift # parsed argument or value done -# makes no sense to enable it for OSVVM -SKIP_EXISTING_FILES=0 - -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 simulation library 'OSVVM' for GHDL on Linux." @@ -116,46 +120,61 @@ if [ "$HELP" == "TRUE" ]; then echo " Use the adv. options or edit 'config.sh' to supply paths and default params." echo "" echo "Usage:" - echo " compile-osvvm.sh <common command>|<library> [<options>] [<adv. options>]" + echo " compile-osvvm.sh [<verbosity>] <common command>|<library> [<options>] [<adv. options>]" 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 " --osvvm Compile library osvvm." + echo " -a --all Compile all libraries." + echo " --osvvm Compile library osvvm." + # echo " --osvvm-vip Compile OSVVM Verification IPs (VIPs)." + # echo "" + # echo "Verification IPs:" + # echo " --osvvm-vip-axi ARM AMBA AXI4" 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 <GHDL bin dir> Path to GHDL's binary directory, e.g. /usr/local/bin" - echo " --out <dir name> Name of the output directory, e.g. vunit" - echo " --src <Path to OSVVM> Path to the sources." + echo " --ghdl <GHDL binary> Path to GHDL's executable, e.g. /usr/local/bin/ghdl" + echo " --output <dir name> Name of the output directory, e.g. osvvm" + echo " --source <Path to OSVVM> 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_OSVVM=TRUE +if [[ $COMMAND -eq 2 ]]; then + COMPILE_OSVVM=1 +# COMPILE_OSVVM_VIP=1 fi +# if [[ $COMPILE_OSVVM_VIP -eq 1 ]]; then + # COMPILE_OSVVM_VIP_AXI=1 +# fi + +# Source configuration file from GHDL's 'vendors' library directory +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 OSVVM "OSVVM" -# create "osvvm" directory and change to it +# Create "osvvm" directory and change to it # => $DestinationDirectory CreateDestinationDirectory cd $DestinationDirectory @@ -166,64 +185,68 @@ cd $DestinationDirectory SetupGRCat -# 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-static + --std=08 + -P$DestinationDirectory +) +VHDLVersion="v08" # Cleanup directory # ============================================================================== -if [ "$CLEAN" == "TRUE" ]; then +if [[ $CLEAN -eq 1 ]]; then echo -e "${ANSI_YELLOW}Cleaning up directory ...${ANSI_NOCOLOR}" rm *.o 2> /dev/null rm *.cf 2> /dev/null fi -# create local set of GHDL parameters -GHDL_PARAMS=(--std=08) -GHDL_PARAMS+=(${GHDL_OPTIONS[@]}) -VHDLVersion="v08" - # Library osvvm # ============================================================================== -# compile osvvm packages -ERRORCOUNT=0 -if [ "$COMPILE_OSVVM" == "TRUE" ]; then - Library="osvvm" - Files=( - NamePkg.vhd - OsvvmGlobalPkg.vhd - VendorCovApiPkg.vhd - TranscriptPkg.vhd - TextUtilPkg.vhd - AlertLogPkg.vhd - MessagePkg.vhd - SortListPkg_int.vhd - RandomBasePkg.vhd - RandomPkg.vhd - CoveragePkg.vhd - MemoryPkg.vhd - ScoreboardGenericPkg.vhd - ScoreboardPkg_slv.vhd - ScoreboardPkg_int.vhd - ResolutionPkg.vhd - TbUtilPkg.vhd - OsvvmContext.vhd - ) - - # append absolute source path - SourceFiles=() - for File in ${Files[@]}; do - SourceFiles+=("$SourceDirectory/$File") - done - - GHDLCompilePackages -fi - -echo "--------------------------------------------------------------------------------" -echo -n "Compiling OSVVM packages " -if [ $ERRORCOUNT -gt 0 ]; then - echo -e $COLORED_FAILED +StructName="OSVVM" +Files=( + NamePkg.vhd + OsvvmGlobalPkg.vhd + VendorCovApiPkg.vhd + TranscriptPkg.vhd + TextUtilPkg.vhd + AlertLogPkg.vhd + MessagePkg.vhd + SortListPkg_int.vhd + RandomBasePkg.vhd + RandomPkg.vhd + CoveragePkg.vhd + MemoryPkg.vhd + ScoreboardGenericPkg.vhd + ScoreboardPkg_slv.vhd + ScoreboardPkg_int.vhd + ResolutionPkg.vhd + TbUtilPkg.vhd + OsvvmContext.vhd +) +CreateLibraryStruct $StructName "osvvm" "." $VHDLVersion "${Files[@]}" +test $COMPILE_OSVVM -eq 1 && Libraries+=($StructName) + +# for VIPName in ${VIPNames[*]}; do + # VarName="COMPILE_OSVVM_${VIPName}" + # if [[ ${!VarName} -eq 1 ]]; then + # Libraries="$Libraries $VIPName" + # fi +# done + +# Compile libraries +if [[ "$Libraries" != "" ]]; then + Compile "$SourceDirectory" "${Libraries[*]}" + + echo "--------------------------------------------------------------------------------" + echo -e "Compiling OSVVM packages and VIPs $(test $ERRORCOUNT -eq 0 && echo $COLORED_SUCCESSFUL || echo $COLORED_FAILED)" else - echo -e $COLORED_SUCCESSFUL + echo -e "${ANSI_RED}Neither OSVVM packages nor VIPs selected.${ANSI_NOCOLOR}" fi diff --git a/libraries/vendors/config.sh b/libraries/vendors/config.sh index f756c00e1..035ce500f 100755 --- a/libraries/vendors/config.sh +++ b/libraries/vendors/config.sh @@ -1,7 +1,4 @@ #! /bin/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 @@ -30,42 +27,59 @@ # along with this program. If not, see <gnu.org/licenses>. # ============================================================================== - # Configure -# - vendor tool chain installation paths or -# - library root directories -# in the following dictionary. +# - Vendor tool chain installation paths or +# - Library root directories +# in the following dictionaries. +# +# These values are used if no command line argument (--source, --output) is +# passed to a compile script. An empty 'InstallationDirectory' string means not +# configured. Declare source directories depending on the installation paths of +# the 3rd party tools. Configure preferred output directories for each library +# set. # -# These values are used if no command line argument (--source) is passed to a -# compile script. Empty strings means not configured. -declare -A InstallationDirectories -InstallationDirectories[AlteraQuartus]="" # "/opt/altera/16.0/quartus" -InstallationDirectories[IntelQuartus]="" # "/opt/intelFPGA/20.1/quartus" -InstallationDirectories[LatticeDiamond]="" # "/usr/local/diamond/3.10_x64" -InstallationDirectories[OSVVM]="" # "~/git/github/osvvm" -InstallationDirectories[UVVM]="" # "~/git/github/uvvm_all" -InstallationDirectories[XilinxISE]="" # "/opt/Xilinx/14.7/ISE_DS/ISE" -InstallationDirectories[XilinxVivado]="" # "/opt/Xilinx/Vivado/2020.2" +declare -A Altera_Quartus_Settings=( + ["InstallationDirectory"]="" # "/opt/altera/16.0/quartus" + ["SourceDirectory"]="eda/sim_lib" + ["DestinationDirectory"]="altera" +) + +declare -A Intel_Quartus_Settings=( + ["InstallationDirectory"]="" # "/opt/intelFPGA/20.1/quartus" + ["SourceDirectory"]="eda/sim_lib" + ["DestinationDirectory"]="intel" +) + +declare -A Lattice_Diamond_Settings=( + ["InstallationDirectory"]="" # "/usr/local/diamond/3.10_x64" + ["SourceDirectory"]="cae_library/simulation/vhdl" + ["DestinationDirectory"]="lattice" +) + +declare -A OSVVM_Settings=( + ["InstallationDirectory"]="" # "~/git/github/OSVVM" + ["SourceDirectory"]="." + ["DestinationDirectory"]="." +) + +declare -A UVVM_Settings=( + ["InstallationDirectory"]="" # "~/git/github/UVVM" + ["SourceDirectory"]="." + ["DestinationDirectory"]="." +) + +declare -A Xilinx_ISE_Settings=( + ["InstallationDirectory"]="" # "/opt/Xilinx/14.7/ISE_DS/ISE" + ["SourceDirectory"]="eda/sim_lib" + ["DestinationDirectory"]="vhdl/src" +) -# Configure preferred output directories for each library set: -declare -A DestinationDirectories -DestinationDirectories[AlteraQuartus]="altera" -DestinationDirectories[IntelQuartus]="intel" -DestinationDirectories[LatticeDiamond]="lattice" -DestinationDirectories[OSVVM]="." # "osvvm" -DestinationDirectories[UVVM]="." -DestinationDirectories[XilinxISE]="xilinx-ise" -DestinationDirectories[XilinxVivado]="xilinx-vivado" +declare -A Xilinx_Vivado_Settings=( + ["InstallationDirectory"]="" # "/opt/Xilinx/Vivado/2020.2" + ["SourceDirectory"]="eda/sim_lib" + ["DestinationDirectory"]="data/vhdl/src" +) -# Declare source directories depending on the installation paths: -declare -A SourceDirectories -SourceDirectories[AlteraQuartus]="eda/sim_lib" -SourceDirectories[IntelQuartus]="eda/sim_lib" -SourceDirectories[LatticeDiamond]="cae_library/simulation/vhdl" -SourceDirectories[OSVVM]="." -SourceDirectories[UVVM]="." -SourceDirectories[XilinxISE]="vhdl/src" -SourceDirectories[XilinxVivado]="data/vhdl/src" # input files greater than $LARGE_FILESIZE are skipped if '--skip-largefiles' is set LARGE_FILESIZE=125000 diff --git a/libraries/vendors/shared.sh b/libraries/vendors/shared.sh index 4f6470b6e..7112b4bb7 100755 --- a/libraries/vendors/shared.sh +++ b/libraries/vendors/shared.sh @@ -1,17 +1,18 @@ # 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: This is a Bash resource file. -# +# +# Bash Script: This is a Bash resource file. +# # Description: # ------------------------------------ # TODO # # ============================================================================== +# 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 @@ -28,85 +29,92 @@ # along with this program. If not, see <gnu.org/licenses>. # ============================================================================== -# red texts -COLORED_ERROR="$ANSI_RED[ERROR]$ANSI_NOCOLOR" -COLORED_FAILED="$ANSI_RED[FAILED]$ANSI_NOCOLOR" - -# green texts -COLORED_DONE="$ANSI_GREEN[DONE]$ANSI_NOCOLOR" -COLORED_SUCCESSFUL="$ANSI_GREEN[SUCCESSFUL]$ANSI_NOCOLOR" # set bash options set -o pipefail +if [[ -n "$GHDL" ]]; then + if [[ ! -f "$GHDL" ]]; then + echo 1>&2 -e "${COLORED_ERROR} Found GHDL environment variable, but '$GHDL' is not a file.${ANSI_NOCOLOR}" + exit 1 + elif [[ ! -x "$GHDL" ]]; then + echo 1>&2 -e "${COLORED_ERROR} Found GHDL environment variable, but '$GHDL' is not executable.${ANSI_NOCOLOR}" + exit 1 + fi +else # fall back to GHDL found via PATH + GHDL=$(which ghdl 2>/dev/null) + if [[ $? -ne 0 ]]; then + echo 1>&2 -e "${COLORED_ERROR} GHDL not found in PATH.${ANSI_NOCOLOR}" + echo 1>&2 -e " Use adv. options '--ghdl' to set the GHDL binary directory." + exit 1 + fi +fi + +# Analyze_Filter=GHDL/filter.analyze.sh +Analyze_Parameters=( + -frelaxed-rules + --mb-comments +) + +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 $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function SetupDirectories( <Index> <Name> )${ANSI_NOCOLOR}" +# SetupDirectories +# -> $Index +# -> $Name +# <= $SourceDirectory +# <= $DestinationDirectory SetupDirectories() { - Index=$1 - Name=$2 + local Index=$1 + local Name=$2 + + declare -n Settings="${Index}_Settings" # source directory # ---------------------- # If a command line argument ('--src') was passed in, use it, else use the default value # from config.sh - if [ ! -z "$SrcDir" ]; then + if [[ ! -z "$SrcDir" ]]; then SourceDirectory=${SrcDir%/} # remove trailing slashes - elif [ ! -z "$EnvSourceDir" ]; then + elif [[ ! -z "$EnvSourceDir" ]]; then SourceDirectory=$EnvSourceDir # fall back to environment variable - elif [ ! -z "${InstallationDirectories[$Index]}" ]; then - SourceDirectory=${InstallationDirectories[$Index]}/${SourceDirectories[$Index]} # fall back to value from config.sh + elif [[ ! -z "${Settings[InstallationDirectory]}" ]]; then + SourceDirectory=${Settings[InstallationDirectory]}/${Settings[SourceDirectory]} # fall back to value from config.sh fi # output directory # ---------------------- # If a command line argument ('--out') was passed in, use it, else use the default value # from config.sh - if [ ! -z "$DestDir" ]; then + if [[ ! -z "$DestDir" ]]; then DestinationDirectory=${DestDir%/} # remove trailing slashes else - DestinationDirectory=${DestinationDirectories[$Index]} # fall back to value from config.sh + DestinationDirectory=${Settings[DestinationDirectory]} # fall back to value from config.sh fi - if [ -z $SourceDirectory ] || [ -z $DestinationDirectory ]; then + if [[ -z $SourceDirectory || -z $DestinationDirectory ]]; then echo 1>&2 -e "${COLORED_ERROR} $Name is not configured in '$ScriptDir/config.sh'.${ANSI_NOCOLOR}" echo 1>&2 -e " Use adv. options '--src' and '--out' or configure 'config.sh'." - exit -1 - elif [ ! -d $SourceDirectory ]; then + exit 1 + elif [[ ! -d $SourceDirectory ]]; then echo 1>&2 -e "${COLORED_ERROR} Path '$SourceDirectory' does not exist.${ANSI_NOCOLOR}" - exit -1 + exit 1 fi # Resolve paths to an absolute paths - if greadlink --version > /dev/null 2>&1 ; then - READLINK=greadlink - else - READLINK=readlink - fi + READLINK=readlink; if [[ $(uname) == "Darwin" ]]; then READLINK=greadlink; fi SourceDirectory=$($READLINK -f $SourceDirectory) if [[ ! "$DestinationDirectory" = /* ]]; then DestinationDirectory=$WorkingDir/$DestinationDirectory fi - - # Use GHDL binary directory from command line argument, if set - if [ ! -z "$GHDLBinDir" ]; then - GHDLBinary=${GHDLBinDir%/}/ghdl # remove trailing slashes - if [[ ! -x "$GHDLBinary" ]]; then - echo 1>&2 -e "${COLORED_ERROR} GHDL not found or is not executable.${ANSI_NOCOLOR}" - exit -1 - fi - elif [ ! -z "$GHDL" ]; then - if [ ! \( -f "$GHDL" -a -x "$GHDL" \) ]; then - echo 1>&2 -e "${COLORED_ERROR} Found GHDL environment variable, but '$GHDL' is not executable.${ANSI_NOCOLOR}" - exit -1 - fi - GHDLBinary=$GHDL - else # fall back to GHDL found via PATH - GHDLBinary=$(which ghdl 2>/dev/null) - if [ $? -ne 0 ]; then - echo 1>&2 -e "${COLORED_ERROR} GHDL not found in PATH.${ANSI_NOCOLOR}" - echo 1>&2 -e " Use adv. options '--ghdl' to set the GHDL binary directory." - exit -1 - fi - fi } +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function SetupGRCat( undocumented )${ANSI_NOCOLOR}" +# SetupGRCat +# -> undocumented SetupGRCat() { if [ -z "$(which grcat 2>/dev/null)" ]; then # if grcat (generic colourizer) is not installed, use a dummy pipe command like 'cat' @@ -118,18 +126,27 @@ SetupGRCat() { fi } +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function CreateDestinationDirectory( undocumented )${ANSI_NOCOLOR}" +# CreateDestinationDirectory +# -> undocumented CreateDestinationDirectory() { if [ -d "$DestinationDirectory" ]; then echo -e "${ANSI_YELLOW}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 + exit 1 else echo -e "${ANSI_YELLOW}Creating vendor directory: '$DestinationDirectory'.${ANSI_NOCOLOR}" mkdir -p "$DestinationDirectory" fi } +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function GHDLSetup( <VHDLStandard> )${ANSI_NOCOLOR}" +# GHDLSetup +# -> $VHDLStandard # FIXME: make it a real parameter +# <= $VHDLVersion +# <= $VHDLStandard +# <= $VHDLFlavor GHDLSetup() { if [ $VHDLStandard -eq 93 ]; then VHDLVersion="v93" @@ -142,52 +159,185 @@ GHDLSetup() { fi } -GHDLCompileLibrary() { - # assembling output directory - LibraryDirectory=$DestinationDirectory/$Library/$VHDLVersion - mkdir -p $LibraryDirectory - cd $LibraryDirectory - echo -e "${ANSI_YELLOW}Compiling library '$Library'...${ANSI_NOCOLOR}" - - for File in ${SourceFiles[@]}; do - FileName=$(basename "$File") - FileSize=($(wc -c $File)) - if [ $SKIP_EXISTING_FILES -eq 1 ] && [ -e "${FileName%.*}.o" ]; then - echo -e "${ANSI_CYAN}Skipping existing file '$File'${ANSI_NOCOLOR}" - elif [ $SKIP_LARGE_FILES -eq 1 ] && [ ${FileSize[0]} -gt $LARGE_FILESIZE ]; then - echo -e "${ANSI_CYAN}Skipping large file '$File'${ANSI_NOCOLOR}" - else - echo -e "${ANSI_DARKCYAN}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 && return 1 - fi - fi +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function CreateVHDLLibrary( <StructName> <LibraryName> <LibraryPath> <VHDLVersion> <Files[*]> )${ANSI_NOCOLOR}" +# CreateLibraryStruct +# -> $StructName +# -> $LibraryName +# -> $LibraryPath +# -> $VHDLVersion +# -> $Files[*] +CreateLibraryStruct() { + local StructName=$1; shift + + declare -g "${StructName}_LibraryName"=$1; shift + declare -g "${StructName}_LibraryPath"=$1; shift + declare -g "${StructName}_VHDLVersion"=$1; shift + + declare -n FilesRef="${StructName}_Files" + FilesRef=( "$*" ) +} + +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function DeleteLibraryStruct( <StructName> )${ANSI_NOCOLOR}" +# DeleteLibraryStruct +# -> $StructName +DeleteLibraryStruct() { + local StructName=$1 + + unset "${StructName}_VHDLVersion" + unset "${StructName}_LibraryName" + unset "${StructName}_LibraryPath" + unset "${StructName}_Files" +} + +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function PrintLibraryStruct( <StructName> )${ANSI_NOCOLOR}" +# PrintLibraryStruct +# -> $StructName +PrintLibraryStruct() { + local StructName=$1 + local Indentation=${2:-" "} + + local LibraryName="${StructName}_LibraryName"; local LibraryName=${!LibraryName} + local Files="${StructName}_Files[*]"; local Files=${!Files} + + echo -e "$Indentation${ANSI_DARK_GRAY}VHDL Library name: $LibraryName${ANSI_NOCOLOR}" + for File in ${Files[*]}; do + echo -e "$Indentation ${ANSI_DARK_GRAY}$File${ANSI_NOCOLOR}" done - return 0 } -GHDLCompilePackages() { - # assembling output directory - LibraryDirectory=$DestinationDirectory/$Library/$VHDLVersion - mkdir -p $LibraryDirectory - cd $LibraryDirectory - echo -e "${ANSI_YELLOW}Compiling library '$Library'...${ANSI_NOCOLOR}" - - for File in ${SourceFiles[@]}; do - FileName=$(basename "$File") - if [ $SKIP_EXISTING_FILES -eq 1 ] && [ -e "${FileName%.*}.o" ]; then - echo -e "${ANSI_CYAN}Skipping existing package '$File'${ANSI_NOCOLOR}" - else - echo -e "${ANSI_DARKCYAN}Analyzing package '$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 && return 1 - fi + +declare -A GHDLLibraryMapping + +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function CreateVHDLLibrary( <LibraryName> <DirectoryName> <VHDLVersion> )${ANSI_NOCOLOR}" +# CreateVHDLLibrary +# -> $LibraryName +# -> $DirectoryName +# -> $VHDLVersion +CreateVHDLLibrary() { + local LibraryName=$1 + local DirectoryName=$2 + local VHDLVersion=${3:-"v08"} + + echo -e "${ANSI_YELLOW}Creating VHDL Library '$LibraryName'...${ANSI_NOCOLOR}" + + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}mkdir -p \"$DirectoryName/$VHDLVersion\"${ANSI_NOCOLOR}" + mkdir -p "$DirectoryName/$VHDLVersion" + + LibraryDir="$(pwd)/$DirectoryName/$VHDLVersion" + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}Mapping library $LibraryName to '$LibraryDir'.${ANSI_NOCOLOR}" + GHDLLibraryMapping[$LibraryName]=$LibraryDir +} + +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function AnalyzeVHDL( <LibraryName> <SourceDirectory> <LibraryPath> <File> )${ANSI_NOCOLOR}" +# AnalyzeVHDL +# -> $LibraryName +# -> $SourceDirectory +# -> $LibraryPath +# -> $File +AnalyzeVHDL() { + local LibraryName=$1 + local SourceDirectory=$2 + local LibraryPath=$3 + local File=$4 + + local DestinationDirectory=${GHDLLibraryMapping[$LibraryName]} + + if [[ $DEBUG -eq 1 ]]; then + local Parameters=( + -v + ) + local Filter_Parameters=( + -d + ) + local Filter_Indent=" " + elif [[ $VERBOSE -eq 1 ]]; then + local Parameters=() + local Filter_Parameters=( + -v + ) + local Filter_Indent=" " + else + local Parameters=() + local Filter_Parameters=() + local Filter_Indent=" " + fi + + local SourceFile="$SourceDirectory/$LibraryPath/$File" + + if [[ ! -f "$SourceFile" ]]; then + echo 1>&2 -e "${COLORED_ERROR} Source file '$SourceFile' not found.${ANSI_NOCOLOR}" + test $CONTINUE_ON_ERROR -eq 0 && exit 1 + fi + + if [[ $FILTERING -eq 0 ]]; then + test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}$GHDL -a ${Analyze_Parameters[*]} ${Parameters[*]} --work=$LibraryName \"$SourceFile\"${ANSI_NOCOLOR}" + $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}" + 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 + fi +} + + +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function AnalyzeLibrary( <LibraryName> <SourceDirectory> <LibraryPath> <Files[*]> )${ANSI_NOCOLOR}" +# AnalyzeLibrary +# -> LibraryName +# -> SourceDirectory +# -> LibraryPath +# -> Files[*] +AnalyzeLibrary() { + local LibraryName=$1; shift + local SourceDirectory=$1; shift + local LibraryPath=$1; shift + local Files=$@ + + echo -e "${ANSI_YELLOW}Analyzing files into library '$LibraryName'...${ANSI_NOCOLOR}" + + for File in $Files; do + test $VERBOSE -eq 1 && echo -e " Analyzing '$File'" + + AnalyzeVHDL $LibraryName "$SourceDirectory" "$LibraryPath" "$File" done - return 0 } +test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}function Compile( <SourceDirectory> <Libraries> )${ANSI_NOCOLOR}" +# Compile +# -> SourceDirectory +# -> VHDLLibraries +Compile() { + local SourceDirectory=$1 + local VHDLLibraries=$2 + + for VHDLLibrary in $VHDLLibraries; do + local LibraryName="${VHDLLibrary}_LibraryName"; local LibraryName=${!LibraryName} + local LibraryPath="${VHDLLibrary}_LibraryPath"; local LibraryPath=${!LibraryPath} + local VHDLVersion="${VHDLLibrary}_VHDLVersion"; local VHDLVersion=${!VHDLVersion} + local Files="${VHDLLibrary}_Files[*]"; local Files=${!Files} + + echo -e "${ANSI_LIGHT_CYAN}Analyzing library '$LibraryName'...${ANSI_NOCOLOR}" + + CreateVHDLLibrary $LibraryName $LibraryName $VHDLVersion + AnalyzeLibrary $LibraryName "$SourceDirectory" "$LibraryPath" "$Files" + done +} |