spi/tests/mk.sh

86 lines
2.0 KiB
Bash
Raw Normal View History

2022-10-22 18:34:54 -04:00
#!/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 -)
2022-10-23 12:37:07 -04:00
echo "running $POL$PHASE $MASTER_TYPE"
verilator --cc --exe -I.. -Wall -Wno-unused --trace --trace-fst \
2022-10-22 18:34:54 -04:00
--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 \
2022-10-23 12:37:07 -04:00
-DVCDFILE="\"$DIR.fst\"" \
-DSIMULATION \
2022-10-22 18:34:54 -04:00
--Mdir $DIR \
$EXTARG \
2022-10-23 14:03:29 -04:00
simtop.v write_read.cpp $MODS \
|| exit 1
2022-10-22 18:34:54 -04:00
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"
2022-10-23 14:03:29 -04:00
) || exit 1
2022-10-22 18:34:54 -04:00
2022-10-23 12:37:07 -04:00
( \
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"
2022-10-23 14:03:29 -04:00
) || exit 1
2022-10-23 12:37:07 -04:00
( \
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"
2022-10-23 14:03:29 -04:00
) || exit 1
2022-10-23 12:37:07 -04:00
( \
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"
2022-10-23 14:03:29 -04:00
) || exit 1
2022-10-23 12:37:07 -04:00
( \
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"
2022-10-23 14:03:29 -04:00
) || exit 1
2022-10-23 12:37:07 -04:00
( \
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"
2022-10-23 14:03:29 -04:00
) || exit 1
2022-10-22 18:34:54 -04:00
done
done