From 51dbe68ea85ab427a1dcafa6f5ed8dbb3d17bbbe Mon Sep 17 00:00:00 2001 From: jl7719 Date: Mon, 14 Dec 2020 17:38:39 +0000 Subject: [PATCH] Fix running on different environment issue Now completely shifted to Ubuntu 18.04 setup should work for everyone --- .gitignore | 1 + exec/executable.txt | 1 + rtl/mips_cpu_alu.v | 4 +- rtl/mips_cpu_control.v | 9 ++-- test/test_mips_cpu_harvard.sh | 34 ++++++-------- test/test_mips_cpu_harvard_windows.sh | 67 --------------------------- 6 files changed, 23 insertions(+), 93 deletions(-) create mode 100644 exec/executable.txt delete mode 100755 test/test_mips_cpu_harvard_windows.sh diff --git a/.gitignore b/.gitignore index 6d3b2db..2b0cdb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ exec/* +!exec/executable.txt inputs/*.log.txt inputs/*.out.txt mips_cpu_harvard.vcd \ No newline at end of file diff --git a/exec/executable.txt b/exec/executable.txt new file mode 100644 index 0000000..0775409 --- /dev/null +++ b/exec/executable.txt @@ -0,0 +1 @@ +A folder for executables \ No newline at end of file diff --git a/rtl/mips_cpu_alu.v b/rtl/mips_cpu_alu.v index 3001548..ba26f57 100644 --- a/rtl/mips_cpu_alu.v +++ b/rtl/mips_cpu_alu.v @@ -73,10 +73,8 @@ Alu Operations: Ops ALUOps; //Note confusing naming to avoid potential duplicate variable naming errors, as a result of enum implemetnation. -assign ALUOps = ALUOp; - always_comb begin - + assign ALUOps = ALUOp; case(ALUOps) ADD: begin ALURes = $signed(A) + $signed(B); diff --git a/rtl/mips_cpu_control.v b/rtl/mips_cpu_control.v index c4f0322..d3fe86f 100644 --- a/rtl/mips_cpu_control.v +++ b/rtl/mips_cpu_control.v @@ -42,7 +42,7 @@ typedef enum logic[5:0]{ SW = 6'd43 } op_enum; op_enum op; -assign op = Instr[31:26]; + typedef enum logic[5:0]{ SLL = 6'd0, @@ -68,7 +68,7 @@ typedef enum logic[5:0]{ SLTU = 6'd43 } funct_enum; funct_enum funct; -assign funct = Instr[5:0]; + typedef enum logic[4:0]{ BLTZ = 5'd0, @@ -77,11 +77,12 @@ typedef enum logic[4:0]{ BGEZAL = 5'd17 } rt_enum; rt_enum rt; -assign rt = Instr[20:16]; - always @(*) begin + assign op = Instr[31:26]; + assign funct = Instr[5:0]; + assign rt = Instr[20:16]; //CtrlRegDst logic if((op==ADDIU) || (op==ANDI) || (op==LB) || (op==LBU) || (op==LH) || (op==LHU) || (op==LUI) || (op==LW) || (op==LWL) || (op==LWR) || (op==ORI) || (op==SLTI) || (op==SLTIU) || (op==XORI))begin CtrlRegDst = 2'd0; //Write address comes from rt diff --git a/test/test_mips_cpu_harvard.sh b/test/test_mips_cpu_harvard.sh index f051312..0b094b4 100755 --- a/test/test_mips_cpu_harvard.sh +++ b/test/test_mips_cpu_harvard.sh @@ -1,9 +1,6 @@ #!/bin/bash -#**Delete command for windows before submission** -#rm inputs/*.log.txt inputs/*.out.txt - -# Source File & Source Directory Parsing +# 1. Source File & Source Directory Parsing 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=""; @@ -12,15 +9,16 @@ do SRC_TEMP+=${SRC_DIR}/${src}" "; done SRC=${SRC_TEMP} -#echo ${SRC}; -# Instruction Argument + +# 2. Instruction Argument INSTR=${2:-"No instruction specified: running all testcases"}; # e.g. addiu -# Start Testing + +# 3. Start Testing +# 3-1. Running ALL testcases when instruction not specified. if [[ ${INSTR} == "No instruction specified: running all testcases" ]]; then - # All Testcase Files TESTCASES=$(find ./inputs ! -name '*ref*' ! -name '*log*' ! -name '*out*' ! -name '*inputs*' ! -name '*data*' | sed 's#.*/##'); #echo ${TESTCASES} for TESTCASE in ${TESTCASES} @@ -29,17 +27,15 @@ then #echo ${TESTCASE}; TESTCASE="${TESTCASE%%.*}"; -#/mnt/c/Windows/System32/cmd.exe /C \ iverilog -Wall -g2012 \ -s mips_cpu_harvard_tb \ -P mips_cpu_harvard_tb.INSTR_INIT_FILE=\"inputs/${TESTCASE}.txt\" \ -P mips_cpu_harvard_tb.DATA_INIT_FILE=\"inputs/${TESTCASE}.data.txt\" \ -o exec/mips_cpu_harvard_tb_${TESTCASE} testbench/mips_cpu_harvard_tb.v \ ${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 +./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 @@ -47,19 +43,19 @@ else fi done +# 3-2 Running SINGLE testcase of specified instruction else - # Run Testcase File Of Specified Instruction -#/mnt/c/Windows/System32/cmd.exe /C \ + iverilog -Wall -g2012 \ -s mips_cpu_harvard_tb \ -P mips_cpu_harvard_tb.INSTR_INIT_FILE=\"inputs/${INSTR}.txt\" \ -P mips_cpu_harvard_tb.DATA_INIT_FILE=\"inputs/${INSTR}.data.txt\" \ -o exec/mips_cpu_harvard_tb_${INSTR} testbench/mips_cpu_harvard_tb.v \ ${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 + +./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 diff --git a/test/test_mips_cpu_harvard_windows.sh b/test/test_mips_cpu_harvard_windows.sh deleted file mode 100755 index a4d2a48..0000000 --- a/test/test_mips_cpu_harvard_windows.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -#**Delete command for windows before submission** -#rm inputs/*.log.txt inputs/*.out.txt - -# Source File & Source Directory Parsing -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} -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 - -# Start Testing -if [[ ${INSTR} == "No instruction specified: running all testcases" ]]; -then - # All Testcase Files - TESTCASES=$(find ./inputs ! -name '*ref*' ! -name '*log*' ! -name '*out*' ! -name '*inputs*' ! -name '*data*' | sed 's#.*/##'); - #echo ${TESTCASES} - for TESTCASE in ${TESTCASES} - do - # Run Each Testcase File - #echo ${TESTCASE}; - TESTCASE="${TESTCASE%%.*}"; - -/mnt/c/Windows/System32/cmd.exe /C \ -iverilog -Wall -g2012 \ - -s mips_cpu_harvard_tb \ - -P mips_cpu_harvard_tb.INSTR_INIT_FILE=\"inputs/${TESTCASE}.txt\" \ - -P mips_cpu_harvard_tb.DATA_INIT_FILE=\"inputs/${TESTCASE}.data.txt\" \ - -o exec/mips_cpu_harvard_tb_${TESTCASE} testbench/mips_cpu_harvard_tb.v \ - ${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 -/mnt/c/Windows/System32/cmd.exe /C \ -iverilog -Wall -g2012 \ - -s mips_cpu_harvard_tb \ - -P mips_cpu_harvard_tb.INSTR_INIT_FILE=\"inputs/${INSTR}.txt\" \ - -P mips_cpu_harvard_tb.DATA_INIT_FILE=\"inputs/${INSTR}.data.txt\" \ - -o exec/mips_cpu_harvard_tb_${INSTR} testbench/mips_cpu_harvard_tb.v \ - ${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