1999-08-17 17:57:43 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# verilog - A wrapper shell script for ivl
|
|
|
|
|
# Copyright (C) 1999 Stefan Petersen (spe@geda.seul.org)
|
|
|
|
|
#
|
|
|
|
|
# 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
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Setup variables
|
|
|
|
|
execPath=@bindir@
|
|
|
|
|
execIVLPP=${execPath}/ivlpp
|
|
|
|
|
execIVL=${execPath}/ivl
|
|
|
|
|
execCpp=/usr/bin/g++
|
|
|
|
|
|
1999-09-01 00:25:52 +02:00
|
|
|
vvmTarget="-t vvm"
|
|
|
|
|
xnfTarget="-t xnf"
|
1999-08-17 17:57:43 +02:00
|
|
|
|
|
|
|
|
tmpDir=/tmp
|
|
|
|
|
tmpPPFile=${tmpDir}/ivl$$.pp
|
|
|
|
|
tmpCCFile=${tmpDir}/ivl$$.cc
|
|
|
|
|
|
|
|
|
|
VPIModulePath=@libdir@/ivl:.
|
|
|
|
|
|
1999-09-01 00:25:52 +02:00
|
|
|
target=${vvmTarget}
|
1999-09-14 03:50:06 +02:00
|
|
|
targetSuffix=""
|
1999-08-17 17:57:43 +02:00
|
|
|
|
1999-09-01 00:25:52 +02:00
|
|
|
# If VPI module path aren't set up, warn at least
|
1999-08-17 17:57:43 +02:00
|
|
|
if test -z "${VPI_MODULE_PATH}" ; then
|
1999-09-01 00:25:52 +02:00
|
|
|
echo "Missing environment variable VPI_MODULE_PATH.";
|
|
|
|
|
echo "To be able to execute, set VPI_MODULE_PATH to ${VPIModulePath}";
|
1999-08-17 17:57:43 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Try to extract given parameters
|
1999-09-22 04:13:57 +02:00
|
|
|
parameter=`getopt D:I:Xxo:s: "$@"`
|
1999-09-14 03:50:06 +02:00
|
|
|
eval set -- "${parameter}"
|
|
|
|
|
while true ; do
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
|
-D) extDefines="${extDefines} -D$2" ; shift 2 ;;
|
|
|
|
|
-I) extIncPath="${extIncPath} -I $2" ; shift 2 ;;
|
|
|
|
|
-X) targetSuffix=".xnf" ; target=${xnfTarget} ; shift ;;
|
|
|
|
|
-o) outputFile=$2 ; shift 2 ;;
|
|
|
|
|
-s) topModule="-s $2 " ; shift 2 ;;
|
1999-09-22 04:13:57 +02:00
|
|
|
-x) execute="true"; shift ;;
|
1999-09-14 03:50:06 +02:00
|
|
|
--) shift ; break ;;
|
|
|
|
|
*) echo "Internal error! Arg is $1 " ; exit 1 ;;
|
|
|
|
|
esac
|
1999-08-17 17:57:43 +02:00
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
1999-09-14 03:50:06 +02:00
|
|
|
# The rest is filenames
|
|
|
|
|
verilogFile=$@;
|
1999-08-17 17:57:43 +02:00
|
|
|
|
1999-09-22 04:13:57 +02:00
|
|
|
if test -z "${verilogFile}" ; then
|
|
|
|
|
echo "Missing infile";
|
|
|
|
|
echo "verilog [-Dmacro[=defn]] [-Iincludepath] [-X] [-x] [-o outputfilename] [-s topmodule] sourcefile[s]" ;
|
|
|
|
|
exit 1;
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
1999-08-17 17:57:43 +02:00
|
|
|
# If no output file is given should we guess one or...?
|
1999-09-14 03:50:06 +02:00
|
|
|
# Assumes a few silly things if several files are given
|
1999-08-17 17:57:43 +02:00
|
|
|
if test -z "${outputFile}" ; then
|
1999-09-22 04:13:57 +02:00
|
|
|
outputFile=`echo ${verilogFile} | sed -e 's;.* ;;' | sed -e 's;\..*$;;'`
|
1999-09-14 03:50:06 +02:00
|
|
|
outputFile="${outputFile}${targetSuffix}" ;
|
1999-08-17 17:57:43 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Preprocess
|
|
|
|
|
${execIVLPP} ${extDefines} ${extIncPath} -L -o ${tmpPPFile} ${verilogFile}
|
|
|
|
|
if test $? -ne 0 ; then
|
1999-09-01 00:25:52 +02:00
|
|
|
echo "Preprocessing failed. Terminating compilation."
|
|
|
|
|
rm -f ${tmpPPFile}
|
1999-09-22 04:13:57 +02:00
|
|
|
exit 1
|
1999-08-17 17:57:43 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Compile preprocessed verilog file
|
1999-09-14 03:50:06 +02:00
|
|
|
${execIVL} ${target} -o ${tmpCCFile} ${topModule} ${tmpPPFile}
|
1999-08-17 17:57:43 +02:00
|
|
|
if test $? -ne 0 ; then
|
1999-09-01 00:25:52 +02:00
|
|
|
echo "Verilog compilation failed. Terminating compilation."
|
|
|
|
|
rm -f ${tmpCCFile}
|
1999-09-22 04:13:57 +02:00
|
|
|
exit 1
|
1999-08-17 17:57:43 +02:00
|
|
|
fi
|
|
|
|
|
rm -f ${tmpPPFile}
|
|
|
|
|
|
1999-09-14 03:50:06 +02:00
|
|
|
|
|
|
|
|
case "${targetSuffix}" in
|
|
|
|
|
|
|
|
|
|
.xnf) mv ${tmpCCFile} ${outputFile} ;;
|
|
|
|
|
|
|
|
|
|
"") ${execCpp} -rdynamic ${tmpCCFile} -o ${outputFile} -lvvm -ldl ;
|
|
|
|
|
if test $? -ne 0 ; then
|
|
|
|
|
echo "C++ compilation failed. Terminating compilation."
|
|
|
|
|
rm -f ${tmpCCFile}
|
1999-09-22 04:13:57 +02:00
|
|
|
exit 1
|
1999-09-14 03:50:06 +02:00
|
|
|
fi
|
|
|
|
|
rm -f ${tmpCCFile} ;;
|
|
|
|
|
|
|
|
|
|
*) echo "Internal error in target compilation." ; exit 1
|
|
|
|
|
|
|
|
|
|
esac
|
1999-09-22 04:13:57 +02:00
|
|
|
|
|
|
|
|
if test ${execute} ; then
|
|
|
|
|
./${outputFile}
|
|
|
|
|
fi
|