2020-11-24 05:20:29 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-12-16 15:58:03 +00:00
|
|
|
SRC_DIR=${1?Error: no source directory given in argument};
|
2020-12-18 12:42:58 +00:00
|
|
|
SRC=$(find ${SRC_DIR}/*);
|
2020-12-16 15:58:03 +00:00
|
|
|
SRC_TEMP="";
|
|
|
|
for src in ${SRC}
|
|
|
|
do
|
2020-12-16 20:15:08 +00:00
|
|
|
SRC_TEMP+=${src}" ";
|
2020-12-16 15:58:03 +00:00
|
|
|
done
|
2020-12-16 20:15:08 +00:00
|
|
|
SRC=${SRC_TEMP};
|
2020-12-16 15:58:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
INSTR=${2:-"No instruction specified: running all testcases"};
|
|
|
|
|
|
|
|
if [[ ${INSTR} == "No instruction specified: running all testcases" ]];
|
|
|
|
then
|
|
|
|
for DIR in inputs/*/
|
|
|
|
do
|
|
|
|
DIR=$(basename ${DIR});
|
2020-12-18 10:51:30 +00:00
|
|
|
LOOP=$(find inputs/${DIR}/* ! -name '*ref*' ! -name '*log*' ! -name '*data*' ! -name '*out*' ! -name '*stderr*' ! -name '*diff*');
|
2020-12-16 15:58:03 +00:00
|
|
|
for TESTCASE in ${LOOP}
|
|
|
|
do
|
|
|
|
TESTCASE=$([[ ${TESTCASE} =~ /([^./]+)\. ]] && echo "${BASH_REMATCH[1]}");
|
|
|
|
iverilog -Wall -g2012 \
|
2020-12-16 20:15:08 +00:00
|
|
|
-s mips_cpu_bus_tb \
|
2020-12-18 12:42:58 +00:00
|
|
|
-P mips_cpu_bus_tb.INSTR_INIT_FILE=\"inputs/${DIR}/${TESTCASE}.instr.txt\" \
|
2020-12-16 20:15:08 +00:00
|
|
|
-P mips_cpu_bus_tb.DATA_INIT_FILE=\"inputs/${DIR}/${TESTCASE}.data.txt\" \
|
2020-12-20 16:42:37 +00:00
|
|
|
-P mips_cpu_bus_tb.TESTCASE=\"inputs/${DIR}/${TESTCASE}.vcd\" \
|
2020-12-17 14:34:42 +00:00
|
|
|
-o exec/mips_cpu_bus_tb_${TESTCASE} testbench/mips_cpu_bus_tb.v testbench/mips_cpu_bus_memory.v \
|
2020-12-18 10:41:01 +00:00
|
|
|
${SRC} 2> inputs/${DIR}/${TESTCASE}.stderr.txt
|
2020-12-16 20:15:08 +00:00
|
|
|
./exec/mips_cpu_bus_tb_${TESTCASE} &> ./inputs/${DIR}/${TESTCASE}.log.txt; # log file for debugging (contains $display)
|
2020-12-16 15:58:03 +00:00
|
|
|
echo "$(tail -1 ./inputs/${DIR}/${TESTCASE}.log.txt)" > ./inputs/${DIR}/${TESTCASE}.out.txt; # register v0 output to compare with reference
|
2020-12-18 10:41:01 +00:00
|
|
|
if diff -w ./inputs/${DIR}/${TESTCASE}.out.txt ./inputs/${DIR}/${TESTCASE}.ref.txt &> inputs/${DIR}/${TESTCASE}.diff.txt # compare
|
2020-12-16 15:58:03 +00:00
|
|
|
then
|
|
|
|
echo ${TESTCASE} ${DIR} "Pass";
|
|
|
|
else
|
|
|
|
printf '%s %s %s%d %s%d%s\n' "${TESTCASE}" "${DIR}" "Fail Output=" "$(tail -1 ./inputs/${DIR}/${TESTCASE}.out.txt)" "Ref=" "$(tail -1 ./inputs/${DIR}/${TESTCASE}.ref.txt)" 2> /dev/null;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
else
|
2020-12-18 10:51:30 +00:00
|
|
|
LOOP=$(find inputs/${INSTR}/* ! -name '*ref*' ! -name '*log*' ! -name '*data*' ! -name '*out*' ! -name '*stderr*' ! -name '*diff*');
|
2020-12-16 15:58:03 +00:00
|
|
|
for TESTCASE in ${LOOP}
|
|
|
|
do
|
|
|
|
TESTCASE=$([[ ${TESTCASE} =~ /([^./]+)\. ]] && echo "${BASH_REMATCH[1]}");
|
|
|
|
iverilog -Wall -g2012 \
|
2020-12-16 20:15:08 +00:00
|
|
|
-s mips_cpu_bus_tb \
|
2020-12-18 12:42:58 +00:00
|
|
|
-P mips_cpu_bus_tb.INSTR_INIT_FILE=\"inputs/${INSTR}/${TESTCASE}.instr.txt\" \
|
2020-12-16 20:15:08 +00:00
|
|
|
-P mips_cpu_bus_tb.DATA_INIT_FILE=\"inputs/${INSTR}/${TESTCASE}.data.txt\" \
|
2020-12-20 16:42:37 +00:00
|
|
|
-P mips_cpu_bus_tb.TESTCASE=\"inputs/${INSTR}/${TESTCASE}.vcd\" \
|
2020-12-17 13:58:07 +00:00
|
|
|
-o exec/mips_cpu_bus_tb_${TESTCASE} testbench/mips_cpu_bus_tb.v testbench/mips_cpu_bus_memory.v \
|
2020-12-18 10:41:01 +00:00
|
|
|
${SRC} 2> inputs/${INSTR}/${TESTCASE}.stderr.txt
|
2020-12-16 20:15:08 +00:00
|
|
|
./exec/mips_cpu_bus_tb_${TESTCASE} &> ./inputs/${INSTR}/${TESTCASE}.log.txt; # log file for debugging (contains $display)
|
2020-12-16 15:58:03 +00:00
|
|
|
echo "$(tail -1 ./inputs/${INSTR}/${TESTCASE}.log.txt)" > ./inputs/${INSTR}/${TESTCASE}.out.txt; # register v0 output to compare with reference
|
2020-12-18 10:41:01 +00:00
|
|
|
if diff -w ./inputs/${INSTR}/${TESTCASE}.out.txt ./inputs/${INSTR}/${TESTCASE}.ref.txt &> inputs/${INSTR}/${TESTCASE}.diff.txt # compare
|
2020-12-16 15:58:03 +00:00
|
|
|
then
|
|
|
|
echo ${TESTCASE} ${INSTR} "Pass";
|
|
|
|
else
|
|
|
|
printf '%s %s %s%d %s%d%s\n' "${TESTCASE}" "${INSTR}" "Fail Output=" "$(tail -1 ./inputs/${INSTR}/${TESTCASE}.out.txt)" "Ref=" "$(tail -1 ./inputs/${INSTR}/${TESTCASE}.ref.txt)" 2> /dev/null;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|