aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/vendors/compile-xilinx-ise.sh
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/vendors/compile-xilinx-ise.sh')
-rwxr-xr-xlibraries/vendors/compile-xilinx-ise.sh459
1 files changed, 229 insertions, 230 deletions
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 <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
-
-# 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 <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 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 <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. xilinx-ise"
- echo " --src <Path to lib> Path to the sources, e.g. /opt/Xilinx/14.7/ISE_DS/ISE/vhdl/src"
+ echo " --ghdl <GHDL binary> Path to GHDL's executable, e.g. /usr/local/bin/ghdl"
+ echo " --out <dir name> Name of the output directory, e.g. uvvm_util"
+ echo " --src <Path to UVVM> 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