From 7150487472c3960c8c5fd8eb66f49b755b1a524e Mon Sep 17 00:00:00 2001 From: jl7719 Date: Sun, 13 Dec 2020 14:54:53 +0900 Subject: [PATCH] Rename initialisation files --- rtl/mips_cpu_memory.v | 16 ++++++++-------- rtl/mips_cpu_pc.v | 4 +--- test/test_mips_cpu_harvard.sh | 15 ++++++++------- testbench/mips_cpu_harvard_tb.v | 6 +++--- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/rtl/mips_cpu_memory.v b/rtl/mips_cpu_memory.v index fa6ce75..05e3e46 100644 --- a/rtl/mips_cpu_memory.v +++ b/rtl/mips_cpu_memory.v @@ -13,8 +13,8 @@ module mips_cpu_memory( output logic[31:0] instr_readdata ); - parameter RAM_INIT_FILE = ""; - parameter MEM_INIT_FILE = ""; + parameter INSTR_INIT_FILE = ""; + parameter DATA_INIT_FILE = ""; reg [31:0] data_memory [0:31]; reg [31:0] instr_memory [0:31]; @@ -28,18 +28,18 @@ module mips_cpu_memory( instr_memory[i] = 0; end //Load contents from file if specified - if (RAM_INIT_FILE != "") begin - $display("RAM: Loading RAM contents from %s", RAM_INIT_FILE); - $readmemh(RAM_INIT_FILE, instr_memory); + if (INSTR_INIT_FILE != "") begin + $display("RAM: Loading RAM contents from %s", INSTR_INIT_FILE); + $readmemh(INSTR_INIT_FILE, instr_memory); end for (integer j = 0; j<$size(instr_memory); j++) begin $display("byte +%h: %h", 32'hBFC00000+j*4, instr_memory[j]); end - if (MEM_INIT_FILE != "") begin - $display("MEM: Loading MEM contents from %s", MEM_INIT_FILE); - $readmemh(MEM_INIT_FILE, data_memory); + if (DATA_INIT_FILE != "") begin + $display("MEM: Loading MEM contents from %s", DATA_INIT_FILE); + $readmemh(DATA_INIT_FILE, data_memory); end else begin $display("MEM FILE NOT GIVEN"); end diff --git a/rtl/mips_cpu_pc.v b/rtl/mips_cpu_pc.v index ba2fc68..e699907 100644 --- a/rtl/mips_cpu_pc.v +++ b/rtl/mips_cpu_pc.v @@ -36,15 +36,13 @@ always_ff @(posedge clk) begin end 2'd2: begin // Jump pc_next <= {pc_lit_next[31:28], instr[25:0], 2'b00}; - $display("Im JUMPING"); + $display("JUMPING"); $display("pc_lit_next: %h", pc_lit_next[31:28]); $display("instr: %b", instr[25:0]); $display("%h",pc_next); end 2'd3: begin // Jump using Register pc_next <= reg_readdata; - $display("Im JUMPING AROUND LOLOLOL"); - $display("%h",reg_readdata); end endcase end diff --git a/test/test_mips_cpu_harvard.sh b/test/test_mips_cpu_harvard.sh index 880488a..a4d2a48 100644 --- a/test/test_mips_cpu_harvard.sh +++ b/test/test_mips_cpu_harvard.sh @@ -21,18 +21,19 @@ INSTR=${2:-"No instruction specified: running all testcases"}; # e.g. addiu 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#.*/##'); + 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 - TESTCASE="${TESTCASE%%.*}"; #echo ${TESTCASE}; + TESTCASE="${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\" \ - -P mips_cpu_harvard_tb.MEM_INIT_FILE=\"inputs/${TESTCASE}.data.txt\" \ + -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) @@ -50,10 +51,10 @@ else /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\" \ - -P mips_cpu_harvard_tb.MEM_INIT_FILE=\"inputs/${INSTR}.data.txt\" \ + -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 + ${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 diff --git a/testbench/mips_cpu_harvard_tb.v b/testbench/mips_cpu_harvard_tb.v index b512ce0..34a5111 100644 --- a/testbench/mips_cpu_harvard_tb.v +++ b/testbench/mips_cpu_harvard_tb.v @@ -1,13 +1,13 @@ module mips_cpu_harvard_tb; - parameter RAM_INIT_FILE = "inputs/addiu.txt"; - parameter MEM_INIT_FILE = "inputs/addiu.data.txt"; + parameter INSTR_INIT_FILE = "inputs/addiu.txt"; + parameter DATA_INIT_FILE = "inputs/addiu.data.txt"; parameter TIMEOUT_CYCLES = 100; logic clk, clk_enable, reset, active, data_read, data_write; logic[31:0] register_v0, instr_address, instr_readdata, data_readdata, data_writedata, data_address; - mips_cpu_memory #(RAM_INIT_FILE, MEM_INIT_FILE) ramInst( + mips_cpu_memory #(INSTR_INIT_FILE, DATA_INIT_FILE) ramInst( .clk(clk), .data_address(data_address), .data_write(data_write),