2020-11-24 05:20:29 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-12-10 08:24:40 +00:00
|
|
|
#**Delete command for windows before submission**
|
2020-12-11 10:45:13 +00:00
|
|
|
#rm inputs/*.log.txt inputs/*.out.txt
|
2020-12-04 14:44:48 +00:00
|
|
|
|
|
|
|
# Source File & Source Directory Parsing
|
2020-12-10 08:24:40 +00:00
|
|
|
SRC_DIR=${1?Error: no source directory given in argument}; # e.g. rtl
|
2020-12-04 14:44:48 +00:00
|
|
|
SRC=$(ls ${SRC_DIR} | grep -E "harvard|memory|alu|regfile|pc|control");
|
|
|
|
SRC_TEMP="";
|
|
|
|
for src in ${SRC}
|
|
|
|
do
|
|
|
|
SRC_TEMP+=${SRC_DIR}/${src}" ";
|
|
|
|
done
|
|
|
|
SRC=${SRC_TEMP}
|
|
|
|
|
|
|
|
# Instruction Argument
|
|
|
|
INSTR=${2:-"No instruction specified: running all testcases"}; # e.g. addiu
|
|
|
|
|
|
|
|
# Start Testing
|
|
|
|
if [[ ${INSTR} == "No instruction specified: running all testcases" ]];
|
|
|
|
then
|
|
|
|
# All Testcase Files
|
2020-12-10 08:24:40 +00:00
|
|
|
TESTCASES=$(find ./inputs ! -name '*ref*' ! -name '*log*' ! -name '*out*' ! -name 'inputs' | sed 's#.*/##');
|
|
|
|
#echo ${TESTCASES}
|
2020-12-04 14:44:48 +00:00
|
|
|
for TESTCASE in ${TESTCASES}
|
|
|
|
do
|
2020-12-10 08:24:40 +00:00
|
|
|
# Run Each Testcase File
|
|
|
|
TESTCASE="${TESTCASE%%.*}";
|
|
|
|
#echo ${TESTCASE};
|
|
|
|
#/mnt/c/Windows/System32/cmd.exe /C \
|
2020-12-09 07:47:58 +00:00
|
|
|
iverilog -Wall -g2012 \
|
|
|
|
-s mips_cpu_harvard_tb \
|
2020-12-11 10:45:13 +00:00
|
|
|
-P mips_cpu_harvard_tb.RAM_INIT_FILE=\"inputs/${TESTCASE}.txt\"
|
2020-12-09 07:47:58 +00:00
|
|
|
-o exec/mips_cpu_harvard_tb_${TESTCASE} testbench/mips_cpu_harvard_tb.v \
|
2020-12-10 08:24:40 +00:00
|
|
|
${SRC} 2> /dev/null
|
|
|
|
/mnt/c/Windows/System32/cmd.exe /C vvp ./exec/mips_cpu_harvard_tb_${TESTCASE} &> ./inputs/${TESTCASE}.log.txt; # log file for debugging (contains $display)
|
|
|
|
echo "$(tail -1 ./inputs/${TESTCASE}.log.txt)" > ./inputs/${TESTCASE}.out.txt; # register v0 output to compare with reference
|
|
|
|
if diff -w ./inputs/${TESTCASE}.out.txt ./inputs/${TESTCASE}.ref.txt &> /dev/null # compare
|
|
|
|
then
|
|
|
|
echo ${TESTCASE} ${TESTCASE} "Pass";
|
|
|
|
else
|
|
|
|
printf '%s %s %s%d %s%d%s\n' "${TESTCASE}" "${TESTCASE}" "Fail Output=" "$(tail -1 ./inputs/${TESTCASE}.out.txt)" "Ref=" "$(tail -1 ./inputs/${TESTCASE}.ref.txt)" 2> /dev/null;
|
|
|
|
fi
|
2020-12-04 14:44:48 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
else
|
|
|
|
# Run Testcase File Of Specified Instruction
|
2020-12-09 07:47:58 +00:00
|
|
|
/mnt/c/Windows/System32/cmd.exe /C \
|
|
|
|
iverilog -Wall -g2012 \
|
2020-12-06 06:44:58 +00:00
|
|
|
-s mips_cpu_harvard_tb \
|
|
|
|
-P mips_cpu_harvard_tb.RAM_INIT_FILE=\"inputs/${INSTR}.txt\" \
|
2020-12-11 10:45:13 +00:00
|
|
|
-P mips_cpu_harvard_tb.MEM_INIT_FILE=\"inputs/${INSTR}.data.txt\" \
|
2020-12-09 07:47:58 +00:00
|
|
|
-o exec/mips_cpu_harvard_tb_${INSTR} testbench/mips_cpu_harvard_tb.v \
|
2020-12-12 06:59:14 +00:00
|
|
|
${SRC} 2> /dev/null
|
2020-12-10 08:24:40 +00:00
|
|
|
/mnt/c/Windows/System32/cmd.exe /C vvp ./exec/mips_cpu_harvard_tb_${INSTR} &> ./inputs/${INSTR}.log.txt; # log file for debugging (contains $display)
|
|
|
|
echo "$(tail -1 ./inputs/${INSTR}.log.txt)" > ./inputs/${INSTR}.out.txt; # register v0 output to compare with reference
|
|
|
|
if diff -w ./inputs/${INSTR}.out.txt ./inputs/${INSTR}.ref.txt &> /dev/null # compare
|
|
|
|
then
|
|
|
|
echo ${INSTR} ${INSTR} "Pass";
|
|
|
|
else
|
|
|
|
printf '%s %s %s%d %s%d%s\n' "${INSTR}" "${INSTR}" "Fail Output=" "$(tail -1 ./inputs/${INSTR}.out.txt)" "Ref=" "$(tail -1 ./inputs/${INSTR}.ref.txt)" 2> /dev/null;
|
2020-12-04 14:44:48 +00:00
|
|
|
fi
|
|
|
|
|
2020-12-10 08:24:40 +00:00
|
|
|
fi
|