#!/bin/sh
#Create a directory called svf under the board dir.
#Files in the svf dir should have the .svf extension.
#If you have an verify file put it in the svf dir called filenamev.svf
#Fill out files variable for all the .svf files.
file=$1
vfile=$2

filename=`echo $file | cut -f 1 -d .`
testplan="testplan."$filename
echo > $testplan
echo $file
echo "\n\nsub ${filename}_svf2vcl" >> $testplan
echo "! " >> $testplan
echo "! APG Test Consultants, Inc." >> $testplan
echo "! " >> $testplan
echo "Time_s = msec" >> $testplan
echo "print \"Programing ${filename} into device.\"" >> $testplan
svf2vcl -trstnode "*" svf/$file digital/$filename
for i in `ls digital/$filename.v[0-9][0-9] | sort`
do
	echo $i
        echo "    test \"$i\"" >> $testplan
# to produce debug object change following line to dcomp -D $i
	dcomp $i
done
echo "Time_e = msec" >> $testplan
echo "print \"Prog. Time = \"&val\$((Time_e - Time_s)/1000)" >> $testplan
echo "subend" >> $testplan

if [ -f svf/$vfile ]
then
echo $vfile
filename=`echo $vfile | cut -f 1 -d .`
echo "\n\nsub ${filename}_svf2vcl" >> $testplan
echo "! " >> $testplan
echo "! APG Test Consultants, Inc." >> $testplan
echo "! " >> $testplan
echo "Time_s = msec" >> $testplan
echo "print \"Verifying ${filename} for device.\"" >> $testplan
svf2vcl -verify -trstnode "*" svf/$vfile digital/$filename
for i in `ls digital/$filename.v[0-9][0-9] | sort`
do
	echo $i
        echo "    test \"$i\"" >> $testplan
# to produce debug object change following line to dcomp -D $i
	dcomp $i

done
echo "Time_e = msec" >> $testplan
echo "print \"Verifying Time = \"&val\$((Time_e - Time_s)/1000)" >> $testplan
echo "subend" >> $testplan
fi
