1
0
mirror of https://github.com/wfjm/w11.git synced 2026-05-04 23:26:38 +00:00
Files
wfjm.w11/tools/bin/tbrun_tbw
Walter F.J. Mueller e1479d4e5d - Add Arty support (BRAM only)
- Add sysmon/xadc support (for nexys4,basys3,arty designs)
- Add Vivado simulator support (DPI not yet working)
2016-03-19 15:45:59 +00:00

118 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
# $Id: tbrun_tbw 727 2016-02-07 13:58:47Z mueller $
#
# Copyright 2014-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
# License disclaimer see LICENSE_gpl_v2.txt in $RETROBASE directory
#
# Revision History:
# Date Rev Version Comment
# 2016-02-06 727 1.1 add vivado xsim support; Makefile.ise support
# 2014-12-27 622 1.0.1 add --stack, --ghw, --tbw, --pcom
# 2014-12-26 621 1.0 Initial version
#
docmd ()
{
echo "$1"
if [[ -z "$optdry" ]] ; then
eval "$1"
fi
}
optdry=""
optlsuf=""
optstack=""
optghw=""
opttbw=""
optpcom=""
# handle options
while (( $# > 0 )) ; do
case $1 in
-dry|--dry) optdry=$1 ; shift 1 ;;
-lsuf|--lsuf) optlsuf=$2 ; shift 2 ;;
-stack|--stack) optstack=$2 ; shift 2 ;;
-ghw|--ghw) optghw=$2 ; shift 2 ;;
-tbw|--tbw) opttbw=$2 ; shift 2 ;;
-pcom|--pcom) optpcom=$1 ; shift 1 ;;
-*) echo "tbrun_tbw-E: invalid option '$1'"; exit 1 ;;
*) break;;
esac
done
tbench=$1
stimfile=$2
# complain if no tbench defined
if (( $# == 0 )) ; then
echo "Usage: tbrun_tbw [opts] testbench [stimfile]"
echo " Options:"
echo " --dry dry run, print commands, don't execute"
echo " --lsuf suff use '_<suff>.log' as suffix for log file"
echo " --stack nnn use <nnn> as ghdl stack size"
echo " --ghw fname write ghw file with name '<fname>.ghw"
echo " --tbw opts append <opts> to tbw command"
exit 1
fi
# defaults
isghdl=true
makeopts=""
# check for ISim
isisim=""
if [[ $tbench =~ _ISim ]] ; then
isisim=true
isghdl=""
if [[ -f "Makefile.ise" ]] ; then
makeopts="-f Makefile.ise"
fi
fi
# check for XSim
isxsim=""
if [[ $tbench =~ _XSim ]] ; then
isxsim=true
isghdl=""
fi
# check for ghdl with _ssim, _fsim, _osim, _tsim
isghdlxsim=""
if [[ -n "$isghdl" ]] && [[ $tbench =~ _[sfot]sim$ ]] ; then
isghdlxsim=true
logsuff=""
fi
# issue makes
if [[ -n "$isghdlxsim" ]] ; then docmd "make ghdl_tmp_clean"; fi
docmd "make $makeopts $tbench"
exitstat=$?
if [[ -n "$isghdlxsim" ]] ; then docmd "make ghdl_tmp_clean"; fi
if (( $exitstat > 0 )) ; then exit $exitstat; fi
# determine logfile name
logsuff="_dsim"
if [[ $tbench =~ _[sfot]sim$ ]] ; then logsuff=""; fi
if [[ -n "$optlsuf" ]] ; then logsuff="_$optlsuf"; fi
logfile="${tbench}${logsuff}.log"
# now build actual test command (a tbw|filter|tee|egrep pipe)
cmd="time tbw $tbench"
if [[ -n "$isisim" ]] ; then cmd+=" -run"; fi
if [[ -n "$isxsim" ]] ; then cmd+=" -run"; fi
if [[ -n "$stimfile" ]] ; then cmd+=" $stimfile"; fi
if [[ -n "$opttbw" ]] ; then cmd+=" $opttbw"; fi
if [[ -n "$optstack" ]] ; then cmd+=" --stack-max-size=$optstack"; fi
if [[ -n "$optghw" ]] ; then cmd+=" --wave=$optghw.ghw"; fi
cmd+=" 2>&1"
if [[ -n "$isghdl" ]] ; then cmd+=" | ghdl_assert_filter"; fi
cmd+=" | tee $logfile"
pcomtag=""
if [[ -n "$optpcom" ]] ; then pcomtag="^C|"; fi
# FAIL, PASS, DONE come from tbs; ERROR comes from ISim
cmd+=" | egrep \"(${pcomtag}-[EFW]:|ERROR|FAIL|PASS|DONE)\""
docmd "$cmd"