Fix running on different environment issue

Now completely shifted to Ubuntu 18.04 setup should work for everyone
This commit is contained in:
jl7719 2020-12-14 17:38:39 +00:00
parent 2d935d9211
commit 51dbe68ea8
6 changed files with 23 additions and 93 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
exec/* exec/*
!exec/executable.txt
inputs/*.log.txt inputs/*.log.txt
inputs/*.out.txt inputs/*.out.txt
mips_cpu_harvard.vcd mips_cpu_harvard.vcd

1
exec/executable.txt Normal file
View file

@ -0,0 +1 @@
A folder for executables

View file

@ -73,10 +73,8 @@ Alu Operations:
Ops ALUOps; //Note confusing naming to avoid potential duplicate variable naming errors, as a result of enum implemetnation. Ops ALUOps; //Note confusing naming to avoid potential duplicate variable naming errors, as a result of enum implemetnation.
assign ALUOps = ALUOp;
always_comb begin always_comb begin
assign ALUOps = ALUOp;
case(ALUOps) case(ALUOps)
ADD: begin ADD: begin
ALURes = $signed(A) + $signed(B); ALURes = $signed(A) + $signed(B);

View file

@ -42,7 +42,7 @@ typedef enum logic[5:0]{
SW = 6'd43 SW = 6'd43
} op_enum; } op_enum;
op_enum op; op_enum op;
assign op = Instr[31:26];
typedef enum logic[5:0]{ typedef enum logic[5:0]{
SLL = 6'd0, SLL = 6'd0,
@ -68,7 +68,7 @@ typedef enum logic[5:0]{
SLTU = 6'd43 SLTU = 6'd43
} funct_enum; } funct_enum;
funct_enum funct; funct_enum funct;
assign funct = Instr[5:0];
typedef enum logic[4:0]{ typedef enum logic[4:0]{
BLTZ = 5'd0, BLTZ = 5'd0,
@ -77,11 +77,12 @@ typedef enum logic[4:0]{
BGEZAL = 5'd17 BGEZAL = 5'd17
} rt_enum; } rt_enum;
rt_enum rt; rt_enum rt;
assign rt = Instr[20:16];
always @(*) begin always @(*) begin
assign op = Instr[31:26];
assign funct = Instr[5:0];
assign rt = Instr[20:16];
//CtrlRegDst logic //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 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 CtrlRegDst = 2'd0; //Write address comes from rt

View file

@ -1,9 +1,6 @@
#!/bin/bash #!/bin/bash
#**Delete command for windows before submission** # 1. Source File & Source Directory Parsing
#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_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=$(ls ${SRC_DIR} | grep -E "harvard|memory|alu|regfile|pc|control");
SRC_TEMP=""; SRC_TEMP="";
@ -12,15 +9,16 @@ do
SRC_TEMP+=${SRC_DIR}/${src}" "; SRC_TEMP+=${SRC_DIR}/${src}" ";
done done
SRC=${SRC_TEMP} SRC=${SRC_TEMP}
#echo ${SRC};
# Instruction Argument
# 2. Instruction Argument
INSTR=${2:-"No instruction specified: running all testcases"}; # e.g. addiu 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" ]]; if [[ ${INSTR} == "No instruction specified: running all testcases" ]];
then then
# All Testcase Files
TESTCASES=$(find ./inputs ! -name '*ref*' ! -name '*log*' ! -name '*out*' ! -name '*inputs*' ! -name '*data*' | sed 's#.*/##'); TESTCASES=$(find ./inputs ! -name '*ref*' ! -name '*log*' ! -name '*out*' ! -name '*inputs*' ! -name '*data*' | sed 's#.*/##');
#echo ${TESTCASES} #echo ${TESTCASES}
for TESTCASE in ${TESTCASES} for TESTCASE in ${TESTCASES}
@ -29,17 +27,15 @@ then
#echo ${TESTCASE}; #echo ${TESTCASE};
TESTCASE="${TESTCASE%%.*}"; TESTCASE="${TESTCASE%%.*}";
#/mnt/c/Windows/System32/cmd.exe /C \
iverilog -Wall -g2012 \ iverilog -Wall -g2012 \
-s mips_cpu_harvard_tb \ -s mips_cpu_harvard_tb \
-P mips_cpu_harvard_tb.INSTR_INIT_FILE=\"inputs/${TESTCASE}.txt\" \ -P mips_cpu_harvard_tb.INSTR_INIT_FILE=\"inputs/${TESTCASE}.txt\" \
-P mips_cpu_harvard_tb.DATA_INIT_FILE=\"inputs/${TESTCASE}.data.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 \ -o exec/mips_cpu_harvard_tb_${TESTCASE} testbench/mips_cpu_harvard_tb.v \
${SRC} 2> /dev/null ${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)
./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
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
if diff -w ./inputs/${TESTCASE}.out.txt ./inputs/${TESTCASE}.ref.txt &> /dev/null # compare
then then
echo ${TESTCASE} ${TESTCASE} "Pass"; echo ${TESTCASE} ${TESTCASE} "Pass";
else else
@ -47,19 +43,19 @@ else
fi fi
done done
# 3-2 Running SINGLE testcase of specified instruction
else else
# Run Testcase File Of Specified Instruction
#/mnt/c/Windows/System32/cmd.exe /C \
iverilog -Wall -g2012 \ iverilog -Wall -g2012 \
-s mips_cpu_harvard_tb \ -s mips_cpu_harvard_tb \
-P mips_cpu_harvard_tb.INSTR_INIT_FILE=\"inputs/${INSTR}.txt\" \ -P mips_cpu_harvard_tb.INSTR_INIT_FILE=\"inputs/${INSTR}.txt\" \
-P mips_cpu_harvard_tb.DATA_INIT_FILE=\"inputs/${INSTR}.data.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 \ -o exec/mips_cpu_harvard_tb_${INSTR} testbench/mips_cpu_harvard_tb.v \
${SRC} 2> /dev/null ${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) ./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 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 if diff -w ./inputs/${INSTR}.out.txt ./inputs/${INSTR}.ref.txt &> /dev/null # compare
then then
echo ${INSTR} ${INSTR} "Pass"; echo ${INSTR} ${INSTR} "Pass";
else else

View file

@ -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