spi/tests/mk.sh

86 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
run_test() {
POL=$1
PHASE=$2
MASTER_TYPE=$3
SLAVE_TYPE=$4
DIR=$5
WID=$6
MODS=$7
EXTARG=$8
WIDLEN=$(printf "import math\nprint(math.floor(math.log2($WID) + 1))" | python3 -)
echo "running $POL$PHASE $MASTER_TYPE"
verilator --cc --exe -I.. -Wall -Wno-unused --trace --trace-fst \
--top-module simtop \
-GPOLARITY=$POL -GPHASE=$PHASE -GWID=$WID -CFLAGS -DWID=$WID \
-GWID_LEN=$WIDLEN \
-DSPI_MASTER_TYPE=$MASTER_TYPE -DSPI_SLAVE_TYPE=$SLAVE_TYPE \
-DVCDFILE="\"$DIR.fst\"" \
-DSIMULATION \
--Mdir $DIR \
$EXTARG \
simtop.v write_read.cpp $MODS \
|| exit 1
cd "$DIR"
make -f Vsimtop.mk
./Vsimtop
}
for POL in 0 1; do
for PHASE in 0 1; do
( \
run_test $POL $PHASE \
spi_master spi_slave \
simtop_$POL$PHASE 24 \
"../spi_master.v ../spi_slave.v"
) || exit 1
( \
run_test $POL $PHASE \
spi_master_ss spi_slave \
simtop_ss$POL$PHASE 24 \
"../spi_master_ss.v ../spi_slave.v" \
"-DSPI_MASTER_SS -CFLAGS -DSPI_MASTER_SS"
) || exit 1
( \
run_test $POL $PHASE \
spi_master_no_write spi_slave_no_read \
simtop_no_write_$POL$PHASE 24 \
"../spi_master_no_write.v ../spi_slave_no_read.v" \
"-DSPI_MASTER_NO_WRITE -CFLAGS -DSPI_MASTER_NO_WRITE"
) || exit 1
( \
run_test $POL $PHASE \
spi_master_ss_no_write spi_slave_no_read \
simtop_ss_no_write_$POL$PHASE 24 \
"../spi_master_ss_no_write.v ../spi_slave_no_read.v" \
"-DSPI_MASTER_NO_WRITE -CFLAGS -DSPI_MASTER_NO_WRITE
-DSPI_MASTER_SS -CFLAGS -DSPI_MASTER_SS"
) || exit 1
( \
run_test $POL $PHASE \
spi_master_no_read spi_slave_no_write \
simtop_no_read_$POL$PHASE 24 \
"../spi_master_no_read.v ../spi_slave_no_write.v" \
"-DSPI_MASTER_NO_READ -CFLAGS -DSPI_MASTER_NO_READ"
) || exit 1
( \
run_test $POL $PHASE \
spi_master_ss_no_read spi_slave_no_write \
simtop_ss_no_read_$POL$PHASE 24 \
"../spi_master_ss_no_read.v ../spi_slave_no_write.v" \
"-DSPI_MASTER_NO_READ -CFLAGS -DSPI_MASTER_NO_READ
-DSPI_MASTER_SS -CFLAGS -DSPI_MASTER_SS"
) || exit 1
done
done