1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
#! /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
#
# 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
#
# ==============================================================================
# Copyright (C) 2015-2016 Patrick Lehmann
#
# GHDL 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, or (at your option) any later
# version.
#
# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with GHDL; see the file COPYING. If not, write to the Free
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# ==============================================================================
# ---------------------------------------------
# save working directory
WorkingDir=$(pwd)
ScriptDir="$(dirname $0)"
ScriptDir="$(readlink -f $ScriptDir)"
# source configuration file from GHDL's 'vendors' library directory
source $ScriptDir/config.sh
source $ScriptDir/shared.sh
# command line argument processing
NO_COMMAND=TRUE
GHDLBinDir=""
DestDir=""
SrcDir=""
while [[ $# > 0 ]]; do
key="$1"
case $key in
-c|--clean)
CLEAN=TRUE
NO_COMMAND=FALSE
;;
-a|--all)
COMPILE_ALL=TRUE
NO_COMMAND=FALSE
;;
-o|--osvvm)
COMPILE_OSVVM=TRUE
NO_COMMAND=FALSE
;;
-s|--skip-existing)
SKIP_EXISTING_FILES=TRUE
;;
-n|--no-warnings)
SUPPRESS_WARNINGS=TRUE
;;
-H|--halt-on-error)
HALT_ON_ERROR=TRUE
;;
-h|--help)
HELP=TRUE
NO_COMMAND=FALSE
;;
--ghdl)
GHDLBinDir="$2"
shift # past argument
;;
--src)
SrcDir="$2"
shift # past argument
;;
--out)
DestDir="$2"
shift # past argument
;;
*) # unknown option
UNKNOWN_OPTION=TRUE
;;
esac
shift # past argument or value
done
if [ "$NO_COMMAND" == "TRUE" ]; then
HELP=TRUE
fi
if [ "$UNKNOWN_OPTION" == "TRUE" ]; then
echo -e $COLORED_ERROR "Unknown command line option.${ANSI_RESET}"
exit -1
elif [ "$HELP" == "TRUE" ]; then
if [ "$NO_COMMAND" == "TRUE" ]; then
echo -e $COLORED_ERROR " No command selected."
fi
echo ""
echo "Synopsis:"
echo " A script to compile the simulation library 'OSVVM' for GHDL on Linux."
echo " A library folder 'osvvm/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 ""
echo "Usage:"
echo " compile-osvvm.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 ""
echo "Libraries:"
echo " -a --all Compile all packages (default)."
echo " -o --osvvm Compile package osvvm."
echo ""
echo "Library compile options:"
echo " -s --skip-existing Skip already compiled files (an *.o file exists)."
echo " -H --halt-on-error Halt on error(s)."
echo ""
echo "Advanced options:"
echo " --ghdl <GHDL BinDir> Path to GHDL binary directory e.g. /usr/bin."
echo " --out <dir name> Name of the output directory."
echo " --src <Path to OSVVM> Name of the output directory."
echo ""
echo "Verbosity:"
echo " -n --no-warnings Suppress all warnings. Show only error messages."
echo ""
exit 0
fi
if [ "$COMPILE_ALL" == "TRUE" ]; then
COMPILE_OSVVM=TRUE
fi
SourceDirectory=${SourceDirectory[OSVVM]}
DestinationDir=${DestinationDirectory[OSVVM]}
# OSVVM 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
SourceDirectory=$SrcDir
fi
# OSVVM 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
DestinationDir=$DestDir
fi
# Use GHDL binary directory from command line argument, if set
if [ ! -z "$GHDLBinDir" ]; then
GHDLBinary=$GHDLBinDir/ghdl
if [[ ! -x "$GHDLBinary" ]]; then
echo -e "${COLORED_ERROR} GHDL not found or is not executable.${ANSI_RESET}"
exit -1
fi
else # fall back to GHDL found via PATH
GHDLBinary=$(which ghdl)
if [ $? -ne 0 ]; then
echo -e "${COLORED_ERROR} GHDL not found in PATH.${ANSI_RESET}"
echo -e " Use adv. options '--ghdl' to set the GHDL binary directory."
exit -1
fi
fi
if [ -z $SourceDirectory ] || [ -z $DestinationDir ]; then
echo -e "${COLORED_ERROR} OSVVM is not configured in '$ScriptDir/config.sh'${ANSI_RESET}"
echo -e " Use adv. options '--src' and '--out' or configure 'config.sh'."
exit -1
elif [ ! -d $SourceDirectory ]; then
echo -e "${COLORED_ERROR} Path '$SourceDir' does not exist.${ANSI_RESET}"
exit -1
fi
# append VHDL version folder
DestinationDir=$DestinationDir/v08
# set bash options
set -o pipefail
# define global GHDL Options
GHDL_OPTIONS=(-fexplicit -frelaxed-rules --no-vital-checks --warn-binding --mb-comments)
# create "osvvm" directory and change to it
if [[ -d "$DestinationDir" ]]; then
echo -e "${ANSI_YELLOW}Vendor directory '$DestinationDir' already exists.${ANSI_RESET}"
else
echo -e "${ANSI_YELLOW}Creating vendor directory: '$DestinationDir'${ANSI_RESET}"
mkdir -p "$DestinationDir"
fi
cd $DestinationDir
if [ -z "$(which grcat)" ]; then
# if grcat (generic colourizer) is not installed, use a dummy pipe command like 'cat'
GRC_COMMAND="cat"
else
if [ "$SUPPRESS_WARNINGS" == "TRUE" ]; then
GRC_COMMAND="grcat $ScriptDir/ghdl.skipwarning.grcrules"
else
GRC_COMMAND="grcat $ScriptDir/ghdl.grcrules"
fi
fi
# Cleanup directory
# ==============================================================================
if [ "$CLEAN" == "TRUE" ]; then
echo -e "${ANSI_YELLOW}Cleaning up directory ...${ANSI_RESET}"
rm *.o 2> /dev/null
rm *.cf 2> /dev/null
fi
# Library osvvm
# ==============================================================================
# compile osvvm packages
if [ "$COMPILE_OSVVM" == "TRUE" ]; then
echo -e "${ANSI_YELLOW}Compiling library 'osvvm' ...${ANSI_RESET}"
GHDL_PARAMS=(${GHDL_OPTIONS[@]})
GHDL_PARAMS+=(--std=08)
Files=(
NamePkg.vhd
OsvvmGlobalPkg.vhd
TextUtilPkg.vhd
TranscriptPkg.vhd
AlertLogPkg.vhd
MemoryPkg.vhd
MessagePkg.vhd
SortListPkg_int.vhd
RandomBasePkg.vhd
RandomPkg.vhd
CoveragePkg.vhd
OsvvmContext.vhd
)
echo $GHDLBinary
ERRORCOUNT=0
for File in ${Files[@]}; do
FileName=$(basename "$File")
if [ "$SKIP_EXISTING_FILES" == "TRUE" ] && [ -e "${FileName%.*}.o" ]; then
echo -e "${ANSI_CYAN}Skipping package '$File'${ANSI_RESET}"
else
echo -e "${ANSI_CYAN}Analyzing package '$File'${ANSI_RESET}"
$GHDLBinary -a ${GHDL_PARAMS[@]} --work=osvvm "$SourceDirectory/$File" 2>&1 | $GRC_COMMAND
if [ $? -ne 0 ]; then
let ERRORCOUNT++
if [ "$HALT_ON_ERROR" == "TRUE" ]; then
break
fi
fi
fi
done
echo "--------------------------------------------------------------------------------"
echo -n "Compiling OSVVM library "
if [ $ERRORCOUNT -gt 0 ]; then
echo -e $COLORED_FAILED
else
echo -e $COLORED_SUCCESSFUL
fi
fi
|