From c93473a54d1ba46d7d7400a4c37b06d84f5f282a Mon Sep 17 00:00:00 2001 From: jl7719 Date: Thu, 10 Dec 2020 17:24:40 +0900 Subject: [PATCH] Update test_mips_cpu_harvard.sh Outputs Pass/Fail by comparing to INSTR.ref.txt files (need to add these per instr) --- inputs/addu.ref.txt | 1 + test/test_mips_cpu_harvard.sh | 43 ++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 inputs/addu.ref.txt diff --git a/inputs/addu.ref.txt b/inputs/addu.ref.txt new file mode 100644 index 0000000..301160a --- /dev/null +++ b/inputs/addu.ref.txt @@ -0,0 +1 @@ +8 \ No newline at end of file diff --git a/test/test_mips_cpu_harvard.sh b/test/test_mips_cpu_harvard.sh index 63cae06..3086986 100644 --- a/test/test_mips_cpu_harvard.sh +++ b/test/test_mips_cpu_harvard.sh @@ -1,11 +1,10 @@ #!/bin/bash -# should not create any files in the rtl dir -# but auxiliary files / dirs can be utilised - +#**Delete command for windows before submission** +#rm inputs/*.log.txt inputs/*.ref.txt # Source File & Source Directory Parsing -SRC_DIR=${1?Error: no source directory given in argument}; # e.g. ./rtl +SRC_DIR=${1?Error: no source directory given in argument}; # e.g. rtl SRC=$(ls ${SRC_DIR} | grep -E "harvard|memory|alu|regfile|pc|control"); SRC_TEMP=""; for src in ${SRC} @@ -13,40 +12,52 @@ do SRC_TEMP+=${SRC_DIR}/${src}" "; done SRC=${SRC_TEMP} -echo ${SRC} # Instruction Argument INSTR=${2:-"No instruction specified: running all testcases"}; # e.g. addiu -echo ${INSTR}; # Start Testing if [[ ${INSTR} == "No instruction specified: running all testcases" ]]; then # All Testcase Files - TESTCASES=$(ls ./inputs | grep ".txt"); - echo ${TESTCASES} + TESTCASES=$(find ./inputs ! -name '*ref*' ! -name '*log*' ! -name '*out*' ! -name 'inputs' | sed 's#.*/##'); + #echo ${TESTCASES} for TESTCASE in ${TESTCASES} do - # Run Each Testcase File - echo ${TESTCASE} -/mnt/c/Windows/System32/cmd.exe /C \ + # Run Each Testcase File + TESTCASE="${TESTCASE%%.*}"; + #echo ${TESTCASE}; +#/mnt/c/Windows/System32/cmd.exe /C \ iverilog -Wall -g2012 \ -s mips_cpu_harvard_tb \ -P mips_cpu_harvard_tb.RAM_INIT_FILE=\"inputs/${TESTCASE}.txt\" \ -o exec/mips_cpu_harvard_tb_${TESTCASE} testbench/mips_cpu_harvard_tb.v \ - ${SRC} -/mnt/c/Windows/System32/cmd.exe /C vvp ./exec/mips_cpu_harvard_tb_${TESTCASE}; + ${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 done else # Run Testcase File Of Specified Instruction - echo ${INSTR}; /mnt/c/Windows/System32/cmd.exe /C \ iverilog -Wall -g2012 \ -s mips_cpu_harvard_tb \ -P mips_cpu_harvard_tb.RAM_INIT_FILE=\"inputs/${INSTR}.txt\" \ -o exec/mips_cpu_harvard_tb_${INSTR} testbench/mips_cpu_harvard_tb.v \ - ${SRC} -/mnt/c/Windows/System32/cmd.exe /C vvp ./exec/mips_cpu_harvard_tb_${INSTR}; + ${SRC} 2> /dev/null +/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; fi +fi