From 77a88d8019b20e9c6d5167892962878c3e0289bb Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Thu, 4 Feb 2021 19:22:09 +0000 Subject: [PATCH 01/46] busybear: check initial values also --- .../testbench/testbench-busybear.sv | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 920a20443..8d184328f 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -111,7 +111,12 @@ module testbench_busybear(); generate for(i=1; i<32; i++) begin always @(dut.ieu.dp.regf.rf[i]) begin - if ($time != 0) begin + if ($time == 0) begin + scan_file_rf = $fscanf(data_file_rf, "%x\n", regExpected); + if (dut.ieu.dp.regf.rf[i] != regExpected) begin + $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.ieu.dp.regf.rf[i], regExpected); + end + end else begin scan_file_rf = $fscanf(data_file_rf, "%d\n", regNumExpected); scan_file_rf = $fscanf(data_file_rf, "%x\n", regExpected); if (i != regNumExpected) begin @@ -162,6 +167,20 @@ module testbench_busybear(); end end + integer totalCSR = 0; + logic [99:0] StartCSRexpected[63:0]; + string StartCSRname[99:0]; + initial begin + while(1) begin + scan_file_csr = $fscanf(data_file_csr, "%s\n", StartCSRname[totalCSR]); + if(StartCSRname[totalCSR] == "---") begin + break; + end + scan_file_csr = $fscanf(data_file_csr, "%x\n", StartCSRexpected[totalCSR]); + totalCSR = totalCSR + 1; + end + end + `define CHECK_CSR(CSR) \ string CSR; \ logic [63:0] expected``CSR``; \ @@ -174,7 +193,15 @@ module testbench_busybear(); $display("%t ps, instr %0d: %s changed, expected %s", $time, instrs, `"CSR`", CSR); \ end \ if(dut.priv.csr.``CSR``_REGW != ``expected``CSR) begin \ - $display("%t ps, instr %0d: %s does not equal %s expected: %x, %x", $time, instrs, CSR, CSR, dut.priv.csr.``CSR``_REGW, ``expected``CSR); \ + $display("%t ps, instr %0d: %s does not equal %s expected: %x, %x", $time, instrs, `"CSR`", CSR, dut.priv.csr.``CSR``_REGW, ``expected``CSR); \ + end \ + end else begin \ + for(integer j=0; j Date: Thu, 4 Feb 2021 20:13:36 +0000 Subject: [PATCH 02/46] busybear: add more CSRs --- .../testbench/testbench-busybear.sv | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 8d184328f..6e68b3b65 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -181,40 +181,44 @@ module testbench_busybear(); end end - `define CHECK_CSR(CSR) \ + `define CHECK_CSR2(CSR, PATH) \ string CSR; \ logic [63:0] expected``CSR``; \ //CSR checking \ - always @(dut.priv.csr.``CSR``_REGW) begin \ + always @(``PATH``.``CSR``_REGW) begin \ if ($time > 1) begin \ scan_file_csr = $fscanf(data_file_csr, "%s\n", CSR); \ scan_file_csr = $fscanf(data_file_csr, "%x\n", expected``CSR``); \ if(CSR.icompare(`"CSR`")) begin \ $display("%t ps, instr %0d: %s changed, expected %s", $time, instrs, `"CSR`", CSR); \ end \ - if(dut.priv.csr.``CSR``_REGW != ``expected``CSR) begin \ - $display("%t ps, instr %0d: %s does not equal %s expected: %x, %x", $time, instrs, `"CSR`", CSR, dut.priv.csr.``CSR``_REGW, ``expected``CSR); \ + if(``PATH``.``CSR``_REGW != ``expected``CSR) begin \ + $display("%t ps, instr %0d: %s does not equal %s expected: %x, %x", $time, instrs, `"CSR`", CSR, ``PATH``.``CSR``_REGW, ``expected``CSR); \ end \ end else begin \ for(integer j=0; j Date: Thu, 4 Feb 2021 22:03:45 +0000 Subject: [PATCH 03/46] Change CSR reset and available bits to conform to OVPsim Now actually keeping perfectly in line with OVP for the first 100k instrs. Yay. --- wally-pipelined/regression/wally-busybear.do | 9 ++++++++- wally-pipelined/src/privileged/csrm.sv | 5 +++-- wally-pipelined/src/privileged/csrs.sv | 2 +- wally-pipelined/src/privileged/csrsr.sv | 18 +++++++++--------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index 1099676e3..bafc1b5b8 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -31,7 +31,7 @@ vlog +incdir+../config/busybear ../testbench/*.sv ../src/*/*.sv -suppress 2583 # start and run simulation # remove +acc flag for faster sim during regressions if there is no need to access internal signals vopt +acc work.testbench_busybear -o workopt -vsim workopt +vsim workopt -suppress 8852 view wave @@ -48,6 +48,13 @@ add wave /testbench_busybear/lastInstrF add wave /testbench_busybear/speculative add wave /testbench_busybear/lastPC2 add wave -divider +#add wave -hex /testbench_busybear/dut/priv/csr/MTVEC_REG +#add wave -hex /testbench_busybear/dut/priv/csr/MSTATUS_REG +#add wave -hex /testbench_busybear/dut/priv/csr/SCOUNTEREN_REG +#add wave -hex /testbench_busybear/dut/priv/csr/MIE_REG +#add wave -hex /testbench_busybear/dut/priv/csr/MIDELEG_REG +#add wave -hex /testbench_busybear/dut/priv/csr/MEDELEG_REG +add wave -divider # registers! add wave -hex /testbench_busybear/regExpected add wave -hex /testbench_busybear/regNumExpected diff --git a/wally-pipelined/src/privileged/csrm.sv b/wally-pipelined/src/privileged/csrm.sv index 6e56c079b..0ef268638 100644 --- a/wally-pipelined/src/privileged/csrm.sv +++ b/wally-pipelined/src/privileged/csrm.sv @@ -108,7 +108,8 @@ module csrm #(parameter assign WriteMCOUNTINHIBITM = CSRMWriteM && (CSRAdrM == MCOUNTINHIBIT); // CSRs - flopenl #(`XLEN) MTVECreg(clk, reset, WriteMTVECM, CSRWriteValM, `RESET_VECTOR, MTVEC_REGW); + //flopenl #(`XLEN) MTVECreg(clk, reset, WriteMTVECM, CSRWriteValM, `RESET_VECTOR, MTVEC_REGW); + flopenl #(`XLEN) MTVECreg(clk, reset, WriteMTVECM, CSRWriteValM, `XLEN'b0, MTVEC_REGW); generate if (`S_SUPPORTED | (`U_SUPPORTED & `N_SUPPORTED)) begin // DELEG registers should exist flopenl #(`XLEN) MEDELEGreg(clk, reset, WriteMEDELEGM, CSRWriteValM & MEDELEG_MASK, zero, MEDELEG_REGW); @@ -125,7 +126,7 @@ module csrm #(parameter flopenr #(`XLEN) MEPCreg(clk, reset, WriteMEPCM, NextEPCM, MEPC_REGW); flopenr #(`XLEN) MCAUSEreg(clk, reset, WriteMCAUSEM, NextCauseM, MCAUSE_REGW); flopenr #(`XLEN) MTVALreg(clk, reset, WriteMTVALM, NextMtvalM, MTVAL_REGW); - flopenl #(32) MCOUNTERENreg(clk, reset, WriteMCOUNTERENM, CSRWriteValM[31:0], allones, MCOUNTEREN_REGW); + flopenl #(32) MCOUNTERENreg(clk, reset, WriteMCOUNTERENM, {CSRWriteValM[31:2],1'b0,CSRWriteValM[0]}, 32'b0, MCOUNTEREN_REGW); flopenl #(32) MCOUNTINHIBITreg(clk, reset, WriteMCOUNTINHIBITM, CSRWriteValM[31:0], allones, MCOUNTINHIBIT_REGW); flopenr #(`XLEN) PMPADDR0reg(clk, reset, WritePMPADDR0M, CSRWriteValM, PMPADDR0_REGW); // PMPCFG registers are a pair of 64-bit in RV64 and four 32-bit in RV32 diff --git a/wally-pipelined/src/privileged/csrs.sv b/wally-pipelined/src/privileged/csrs.sv index 9de3723a5..e8520320d 100644 --- a/wally-pipelined/src/privileged/csrs.sv +++ b/wally-pipelined/src/privileged/csrs.sv @@ -83,7 +83,7 @@ module csrs #(parameter flopenl #(`XLEN) SCAUSEreg(clk, reset, WriteSCAUSEM, NextCauseM, zero, SCAUSE_REGW); flopenr #(`XLEN) STVALreg(clk, reset, WriteSTVALM, NextMtvalM, STVAL_REGW); flopenr #(`XLEN) SATPreg(clk, reset, WriteSATPM, CSRWriteValM, SATP_REGW); - flopenl #(32) SCOUNTERENreg(clk, reset, WriteSCOUNTERENM, CSRWriteValM[31:0], allones, SCOUNTEREN_REGW); + flopenl #(32) SCOUNTERENreg(clk, reset, WriteSCOUNTERENM, {CSRWriteValM[31:2],1'b0,CSRWriteValM[0]}, 32'b0, SCOUNTEREN_REGW); if (`N_SUPPORTED) begin flopenl #(`XLEN) SEDELEGreg(clk, reset, WriteSEDELEGM, CSRWriteValM & SEDELEG_MASK, zero, SEDELEG_REGW); flopenl #(`XLEN) SIDELEGreg(clk, reset, WriteSIDELEGM, CSRWriteValM, zero, SIDELEG_REGW); diff --git a/wally-pipelined/src/privileged/csrsr.sv b/wally-pipelined/src/privileged/csrsr.sv index 6db96dcc5..66f3eb91a 100644 --- a/wally-pipelined/src/privileged/csrsr.sv +++ b/wally-pipelined/src/privileged/csrsr.sv @@ -109,15 +109,15 @@ module csrsr ( if (reset) begin STATUS_SUM_INT <= 0; STATUS_MPRV_INT <= 0; // Per Priv 3.3 - STATUS_FS_INT <= 2'b01; // initial - STATUS_MPP <= `M_MODE; - STATUS_SPP <= 1'b1; - STATUS_MPIE <= 1; - STATUS_SPIE <= `S_SUPPORTED; - STATUS_UPIE <= `U_SUPPORTED; + STATUS_FS_INT <= 0; //2'b01; // initial + STATUS_MPP <= 0; //`M_MODE; + STATUS_SPP <= 0; //1'b1; + STATUS_MPIE <= 0; //1; + STATUS_SPIE <= 0; //`S_SUPPORTED; + STATUS_UPIE <= 0; // `U_SUPPORTED; STATUS_MIE <= 0; // Per Priv 3.3 - STATUS_SIE <= `S_SUPPORTED; - STATUS_UIE <= `U_SUPPORTED; + STATUS_SIE <= 0; // `S_SUPPORTED; + STATUS_UIE <= 0; // `U_SUPPORTED; end else begin if (WriteMSTATUSM) begin STATUS_SUM_INT <= CSRWriteValM[18]; @@ -179,4 +179,4 @@ module csrsr ( // *** add code to track STATUS_FS_INT for dirty floating point registers end end -endmodule \ No newline at end of file +endmodule From 01b1b1705da928784a7c80928fb453b3baa165c1 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Sun, 7 Feb 2021 03:14:48 +0000 Subject: [PATCH 05/46] Busybear: next week of updates - move parsed instructions out of git, to /courses/e190ax/busybear_boot - parsed first 1M instructions, and now parse from split GDB runs - now at about 230k instructions, can't progress further for now since atomic instructions aren't implemented yet --- wally-pipelined/regression/wally-busybear.do | 3 +- .../testbench/testbench-busybear.sv | 75 +++++++++++-------- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index bafc1b5b8..3aa499968 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -138,6 +138,5 @@ add wave /testbench_busybear/InstrWName #set DefaultRadix hexadecimal # #-- Run the Simulation -run 1483850 -#run -all +run -all ##quit diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 6e68b3b65..3406b6e5c 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -47,59 +47,59 @@ module testbench_busybear(); // read pc trace file integer data_file_PC, scan_file_PC; initial begin - data_file_PC = $fopen("../busybear-testgen/parsedPC.txt", "r"); + data_file_PC = $fopen("/courses/e190ax/busybear_boot/parsedPC.txt", "r"); if (data_file_PC == 0) begin $display("file couldn't be opened"); - $stop; + #10; $stop; end end integer data_file_PCW, scan_file_PCW; initial begin - data_file_PCW = $fopen("../busybear-testgen/parsedPC.txt", "r"); + data_file_PCW = $fopen("/courses/e190ax/busybear_boot/parsedPC.txt", "r"); if (data_file_PCW == 0) begin $display("file couldn't be opened"); - $stop; + #10; $stop; end end // read register trace file integer data_file_rf, scan_file_rf; initial begin - data_file_rf = $fopen("../busybear-testgen/parsedRegs.txt", "r"); + data_file_rf = $fopen("/courses/e190ax/busybear_boot/parsedRegs.txt", "r"); if (data_file_rf == 0) begin $display("file couldn't be opened"); - $stop; + #10; $stop; end end // read CSR trace file integer data_file_csr, scan_file_csr; initial begin - data_file_csr = $fopen("../busybear-testgen/parsedCSRs.txt", "r"); + data_file_csr = $fopen("/courses/e190ax/busybear_boot/parsedCSRs.txt", "r"); if (data_file_csr == 0) begin $display("file couldn't be opened"); - $stop; + #10; $stop; end end // read memreads trace file integer data_file_memR, scan_file_memR; initial begin - data_file_memR = $fopen("../busybear-testgen/parsedMemRead.txt", "r"); + data_file_memR = $fopen("/courses/e190ax/busybear_boot/parsedMemRead.txt", "r"); if (data_file_memR == 0) begin $display("file couldn't be opened"); - $stop; + #10; $stop; end end // read memwrite trace file integer data_file_memW, scan_file_memW; initial begin - data_file_memW = $fopen("../busybear-testgen/parsedMemWrite.txt", "r"); + data_file_memW = $fopen("/courses/e190ax/busybear_boot/parsedMemWrite.txt", "r"); if (data_file_memW == 0) begin $display("file couldn't be opened"); - $stop; + #10; $stop; end end @@ -115,6 +115,7 @@ module testbench_busybear(); scan_file_rf = $fscanf(data_file_rf, "%x\n", regExpected); if (dut.ieu.dp.regf.rf[i] != regExpected) begin $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.ieu.dp.regf.rf[i], regExpected); + #10; $stop; end end else begin scan_file_rf = $fscanf(data_file_rf, "%d\n", regNumExpected); @@ -124,6 +125,7 @@ module testbench_busybear(); end if (dut.ieu.dp.regf.rf[i] != regExpected) begin $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.ieu.dp.regf.rf[i], regExpected); + #10; $stop; end end end @@ -136,13 +138,14 @@ module testbench_busybear(); if (dut.MemRWM[1]) begin if($feof(data_file_memR)) begin $display("no more memR data to read"); - $stop; + #10; $stop; end scan_file_memR = $fscanf(data_file_memR, "%x\n", readAdrExpected); scan_file_memR = $fscanf(data_file_memR, "%x\n", HRDATA); #1; if (HADDR != readAdrExpected) begin $display("%t ps, instr %0d: HADDR does not equal readAdrExpected: %x, %x", $time, instrs, HADDR, readAdrExpected); + #10; $stop; end end end @@ -154,15 +157,17 @@ module testbench_busybear(); if (HWRITE) begin if($feof(data_file_memW)) begin $display("no more memW data to read"); - $stop; + #10; $stop; end scan_file_memW = $fscanf(data_file_memW, "%x\n", writeDataExpected); scan_file_memW = $fscanf(data_file_memW, "%x\n", writeAdrExpected); if (writeDataExpected != HWDATA) begin $display("%t ps, instr %0d: HWDATA does not equal writeDataExpected: %x, %x", $time, instrs, HWDATA, writeDataExpected); + #10; $stop; end if (writeAdrExpected != HADDR) begin $display("%t ps, instr %0d: HADDR does not equal writeAdrExpected: %x, %x", $time, instrs, HADDR, writeAdrExpected); + #10; $stop; end end end @@ -194,12 +199,14 @@ module testbench_busybear(); end \ if(``PATH``.``CSR``_REGW != ``expected``CSR) begin \ $display("%t ps, instr %0d: %s does not equal %s expected: %x, %x", $time, instrs, `"CSR`", CSR, ``PATH``.``CSR``_REGW, ``expected``CSR); \ + #10; $stop; \ end \ end else begin \ for(integer j=0; j Date: Thu, 11 Feb 2021 22:42:58 -0500 Subject: [PATCH 07/46] busybear: more updates now gets to instruction 839037 before failing also updates to match new gdb output format umm there seems to be something wrong with the SSTATUS CSR. Just leaving it out for now, will come back and check it later --- wally-pipelined/testbench/testbench-busybear.sv | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 3406b6e5c..14a2ab0f0 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -227,6 +227,8 @@ module testbench_busybear(); `CHECK_CSR(MTVEC) `CHECK_CSR2(SATP, dut.priv.csr.genblk1.csrs.genblk1) `CHECK_CSR(SCOUNTEREN) + `CHECK_CSR(SIE) + //`CHECK_CSR(SSTATUS) logic speculative; initial begin @@ -291,6 +293,10 @@ module testbench_busybear(); InstrF = 32'b0010011; $display("warning: NOPing out %s at PC=%0x", PCtext, PCF); end + if(InstrF[28:27] != 2'b11 && InstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD + InstrF = {12'b0, InstrF[19:7], 7'b0000011}; + $display("warning: replacing AMO instr %s at PC=%0x with ld", PCtext, PCF); + end // then expected PC value scan_file_PC = $fscanf(data_file_PC, "%x\n", pcExpected); if (instrs <= 10 || (instrs <= 100 && instrs % 10 == 0) || From 79fb83409f22372443f1dafd62cd72bc68d632f4 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Thu, 11 Feb 2021 23:06:12 -0500 Subject: [PATCH 08/46] bump into virtual/physcial memory? --- wally-pipelined/testbench/testbench-busybear.sv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 14a2ab0f0..b478c1f5f 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -247,7 +247,7 @@ module testbench_busybear(); #10; $stop; end scan_file_PCW = $fscanf(data_file_PCW, "%s\n", PCtextW); - if (PCtextW != "ret" && PCtextW != "fence" && PCtextW != "nop" && PCtextW != "mret") begin + if (PCtextW != "ret" && PCtextW != "fence" && PCtextW != "nop" && PCtextW != "mret" && PCtextW != "sfence.vma" && PCtextW != "unimp") begin scan_file_PC = $fscanf(data_file_PCW, "%s\n", PCtext2W); PCtextW = {PCtextW, " ", PCtext2W}; end @@ -284,7 +284,7 @@ module testbench_busybear(); end // first read instruction scan_file_PC = $fscanf(data_file_PC, "%s\n", PCtext); - if (PCtext != "ret" && PCtext != "fence" && PCtext != "nop" && PCtext != "mret") begin + if (PCtext != "ret" && PCtext != "fence" && PCtext != "nop" && PCtext != "mret" && PCtext != "sfence.vma" && PCtext != "unimp") begin scan_file_PC = $fscanf(data_file_PC, "%s\n", PCtext2); PCtext = {PCtext, " ", PCtext2}; end From dd3a5b74a1418037be9fcbdc5fe1dc4f98b990aa Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Fri, 12 Feb 2021 17:21:56 +0000 Subject: [PATCH 09/46] busybear: slightly neater error handling --- .../testbench/testbench-busybear.sv | 60 ++++++++----------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index b478c1f5f..8036c40e7 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -50,7 +50,7 @@ module testbench_busybear(); data_file_PC = $fopen("/courses/e190ax/busybear_boot/parsedPC.txt", "r"); if (data_file_PC == 0) begin $display("file couldn't be opened"); - #10; $stop; + $stop; end end @@ -59,7 +59,7 @@ module testbench_busybear(); data_file_PCW = $fopen("/courses/e190ax/busybear_boot/parsedPC.txt", "r"); if (data_file_PCW == 0) begin $display("file couldn't be opened"); - #10; $stop; + $stop; end end @@ -69,7 +69,7 @@ module testbench_busybear(); data_file_rf = $fopen("/courses/e190ax/busybear_boot/parsedRegs.txt", "r"); if (data_file_rf == 0) begin $display("file couldn't be opened"); - #10; $stop; + $stop; end end @@ -79,7 +79,7 @@ module testbench_busybear(); data_file_csr = $fopen("/courses/e190ax/busybear_boot/parsedCSRs.txt", "r"); if (data_file_csr == 0) begin $display("file couldn't be opened"); - #10; $stop; + $stop; end end @@ -89,7 +89,7 @@ module testbench_busybear(); data_file_memR = $fopen("/courses/e190ax/busybear_boot/parsedMemRead.txt", "r"); if (data_file_memR == 0) begin $display("file couldn't be opened"); - #10; $stop; + $stop; end end @@ -99,9 +99,14 @@ module testbench_busybear(); data_file_memW = $fopen("/courses/e190ax/busybear_boot/parsedMemWrite.txt", "r"); if (data_file_memW == 0) begin $display("file couldn't be opened"); - #10; $stop; + $stop; end end + integer warningCount = 0; + `define ERROR \ + #10; \ + $display("processed %0d instructions with %0d warnings", instrs, warningCount); \ + $stop; logic [63:0] pcExpected; logic [63:0] regExpected; @@ -115,7 +120,7 @@ module testbench_busybear(); scan_file_rf = $fscanf(data_file_rf, "%x\n", regExpected); if (dut.ieu.dp.regf.rf[i] != regExpected) begin $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.ieu.dp.regf.rf[i], regExpected); - #10; $stop; + `ERROR end end else begin scan_file_rf = $fscanf(data_file_rf, "%d\n", regNumExpected); @@ -125,7 +130,7 @@ module testbench_busybear(); end if (dut.ieu.dp.regf.rf[i] != regExpected) begin $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.ieu.dp.regf.rf[i], regExpected); - #10; $stop; + `ERROR end end end @@ -138,14 +143,14 @@ module testbench_busybear(); if (dut.MemRWM[1]) begin if($feof(data_file_memR)) begin $display("no more memR data to read"); - #10; $stop; + `ERROR end scan_file_memR = $fscanf(data_file_memR, "%x\n", readAdrExpected); scan_file_memR = $fscanf(data_file_memR, "%x\n", HRDATA); #1; if (HADDR != readAdrExpected) begin $display("%t ps, instr %0d: HADDR does not equal readAdrExpected: %x, %x", $time, instrs, HADDR, readAdrExpected); - #10; $stop; + `ERROR end end end @@ -157,17 +162,17 @@ module testbench_busybear(); if (HWRITE) begin if($feof(data_file_memW)) begin $display("no more memW data to read"); - #10; $stop; + `ERROR end scan_file_memW = $fscanf(data_file_memW, "%x\n", writeDataExpected); scan_file_memW = $fscanf(data_file_memW, "%x\n", writeAdrExpected); if (writeDataExpected != HWDATA) begin $display("%t ps, instr %0d: HWDATA does not equal writeDataExpected: %x, %x", $time, instrs, HWDATA, writeDataExpected); - #10; $stop; + `ERROR end if (writeAdrExpected != HADDR) begin $display("%t ps, instr %0d: HADDR does not equal writeAdrExpected: %x, %x", $time, instrs, HADDR, writeAdrExpected); - #10; $stop; + `ERROR end end end @@ -199,14 +204,14 @@ module testbench_busybear(); end \ if(``PATH``.``CSR``_REGW != ``expected``CSR) begin \ $display("%t ps, instr %0d: %s does not equal %s expected: %x, %x", $time, instrs, `"CSR`", CSR, ``PATH``.``CSR``_REGW, ``expected``CSR); \ - #10; $stop; \ + `ERROR \ end \ end else begin \ for(integer j=0; j Date: Fri, 12 Feb 2021 19:56:20 +0000 Subject: [PATCH 10/46] busybear: allow testbench to ignore lack of MMU for now I'd really like to go over this with someone else, not sure if this is a good thing to be doing If it is, we're at 1M instructions! --- wally-pipelined/regression/wally-busybear.do | 2 +- .../testbench/testbench-busybear.sv | 44 +++++++++++++++---- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index 3aa499968..5a210b598 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -31,7 +31,7 @@ vlog +incdir+../config/busybear ../testbench/*.sv ../src/*/*.sv -suppress 2583 # start and run simulation # remove +acc flag for faster sim during regressions if there is no need to access internal signals vopt +acc work.testbench_busybear -o workopt -vsim workopt -suppress 8852 +vsim workopt -suppress 8852,12070 view wave diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 8036c40e7..69c485b08 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -102,7 +102,30 @@ module testbench_busybear(); $stop; end end + + logic[63:0] adrTranslation[4:0]; + string translationType[4:0] = {"rf", "writeAdr", "PCW", "PC", "readAdr"}; integer warningCount = 0; + initial begin + for(int i=0; i<5; i++) begin + adrTranslation[i] = 64'b0; + end + end + + function logic equal(logic[63:0] adr, logic[63:0] adrExpected, integer func); + if (adr[11:0] !== adrExpected[11:0]) begin + equal = 1'b0; + end else begin + equal = 1'b1; + if ((adr+adrTranslation[func]) !== adrExpected) begin + adrTranslation[func] = adrExpected - adr; + $display("warning: probably new address translation %x for %s at instr %0d", adrTranslation[func], translationType[func], instrs); + warningCount += 1; + end + end + endfunction + + `define ERROR \ #10; \ $display("processed %0d instructions with %0d warnings", instrs, warningCount); \ @@ -127,11 +150,16 @@ module testbench_busybear(); scan_file_rf = $fscanf(data_file_rf, "%x\n", regExpected); if (i != regNumExpected) begin $display("%t ps, instr %0d: wrong register changed: %0d, %0d expected", $time, instrs, i, regNumExpected); + `ERROR end - if (dut.ieu.dp.regf.rf[i] != regExpected) begin + if (~equal(dut.ieu.dp.regf.rf[i],regExpected, 0)) begin $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.ieu.dp.regf.rf[i], regExpected); `ERROR end + if (dut.ieu.dp.regf.rf[i] !== regExpected) begin + force dut.ieu.dp.regf.rf[i] = regExpected; + release dut.ieu.dp.regf.rf[i]; + end end end end @@ -148,7 +176,7 @@ module testbench_busybear(); scan_file_memR = $fscanf(data_file_memR, "%x\n", readAdrExpected); scan_file_memR = $fscanf(data_file_memR, "%x\n", HRDATA); #1; - if (HADDR != readAdrExpected) begin + if (~equal(HADDR,readAdrExpected,4)) begin $display("%t ps, instr %0d: HADDR does not equal readAdrExpected: %x, %x", $time, instrs, HADDR, readAdrExpected); `ERROR end @@ -170,7 +198,7 @@ module testbench_busybear(); $display("%t ps, instr %0d: HWDATA does not equal writeDataExpected: %x, %x", $time, instrs, HWDATA, writeDataExpected); `ERROR end - if (writeAdrExpected != HADDR) begin + if (~equal(writeAdrExpected,HADDR,1)) begin $display("%t ps, instr %0d: HADDR does not equal writeAdrExpected: %x, %x", $time, instrs, HADDR, writeAdrExpected); `ERROR end @@ -228,7 +256,7 @@ module testbench_busybear(); `CHECK_CSR(MIE) `CHECK_CSR2(MISA, dut.priv.csr.genblk1.csrm) `CHECK_CSR2(MSCRATCH, dut.priv.csr.genblk1.csrm) - `CHECK_CSR(MSTATUS) + //`CHECK_CSR(MSTATUS) `CHECK_CSR(MTVEC) `CHECK_CSR2(SATP, dut.priv.csr.genblk1.csrs.genblk1) `CHECK_CSR(SCOUNTEREN) @@ -259,7 +287,7 @@ module testbench_busybear(); scan_file_PCW = $fscanf(data_file_PCW, "%x\n", InstrWExpected); // then expected PC value scan_file_PCW = $fscanf(data_file_PCW, "%x\n", PCWExpected); - if(dut.ifu.PCW != PCWExpected) begin + if(~equal(dut.ifu.PCW,PCWExpected,2)) begin $display("%t ps, instr %0d: PCW does not equal PCW expected: %x, %x", $time, instrs, dut.ifu.PCW, PCWExpected); `ERROR end @@ -278,8 +306,8 @@ module testbench_busybear(); lastInstrF = InstrF; lastPC <= PCF; lastPC2 <= lastPC; - if (speculative && lastPC != pcExpected) begin - speculative = (PCF != pcExpected); + if (speculative && ~equal(lastPC,pcExpected,3)) begin + speculative = ~equal(PCF,pcExpected,3); end else begin if($feof(data_file_PC)) begin @@ -332,7 +360,7 @@ module testbench_busybear(); endcase //check things! - if ((~speculative) && (PCF !== pcExpected)) begin + if ((~speculative) && (~equal(PCF,pcExpected,3))) begin $display("%t ps, instr %0d: PC does not equal PC expected: %x, %x", $time, instrs, PCF, pcExpected); `ERROR end From 43f9abdbedc5408bfe696cbea60334b4e6eb5b42 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Tue, 16 Feb 2021 20:03:24 -0500 Subject: [PATCH 12/46] busybear testbench: check (almost) all the CSRs --- wally-pipelined/src/privileged/csrs.sv | 2 +- .../testbench/testbench-busybear.sv | 25 ++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/wally-pipelined/src/privileged/csrs.sv b/wally-pipelined/src/privileged/csrs.sv index e8520320d..b0fa13b8e 100644 --- a/wally-pipelined/src/privileged/csrs.sv +++ b/wally-pipelined/src/privileged/csrs.sv @@ -77,7 +77,7 @@ module csrs #(parameter assign WriteSCOUNTERENM = CSRSWriteM && (CSRAdrM == SCOUNTEREN); // CSRs - flopenl #(`XLEN) STVECreg(clk, reset, WriteSTVECM, CSRWriteValM, `RESET_VECTOR, STVEC_REGW); + flopenl #(`XLEN) STVECreg(clk, reset, WriteSTVECM, CSRWriteValM, zero, STVEC_REGW); flopenr #(`XLEN) SSCRATCHreg(clk, reset, WriteSSCRATCHM, CSRWriteValM, SSCRATCH_REGW); flopenr #(`XLEN) SEPCreg(clk, reset, WriteSEPCM, NextEPCM, SEPC_REGW); flopenl #(`XLEN) SCAUSEreg(clk, reset, WriteSCAUSEM, NextCauseM, zero, SCAUSE_REGW); diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 69c485b08..fa9b64473 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -247,21 +247,34 @@ module testbench_busybear(); end `define CHECK_CSR(CSR) \ `CHECK_CSR2(CSR, dut.priv.csr) + `define CSRM dut.priv.csr.genblk1.csrm + `define CSRS dut.priv.csr.genblk1.csrs.genblk1 //`CHECK_CSR(FCSR) + `CHECK_CSR2(MCAUSE, `CSRM) `CHECK_CSR(MCOUNTEREN) `CHECK_CSR(MEDELEG) - `CHECK_CSR(MIDELEG) + `CHECK_CSR(MEPC) //`CHECK_CSR(MHARTID) + `CHECK_CSR(MIDELEG) `CHECK_CSR(MIE) - `CHECK_CSR2(MISA, dut.priv.csr.genblk1.csrm) - `CHECK_CSR2(MSCRATCH, dut.priv.csr.genblk1.csrm) - //`CHECK_CSR(MSTATUS) + //`CHECK_CSR(MIP) + `CHECK_CSR2(MISA, `CSRM) + `CHECK_CSR2(MSCRATCH, `CSRM) + `CHECK_CSR(MSTATUS) + `CHECK_CSR2(MTVAL, `CSRM) `CHECK_CSR(MTVEC) - `CHECK_CSR2(SATP, dut.priv.csr.genblk1.csrs.genblk1) + //`CHECK_CSR2(PMPADDR0, `CSRM) + //`CHECK_CSR2(PMPCFG0, `CSRM) + `CHECK_CSR2(SATP, `CSRS) + `CHECK_CSR2(SCAUSE, `CSRS) `CHECK_CSR(SCOUNTEREN) + `CHECK_CSR(SEPC) `CHECK_CSR(SIE) - //`CHECK_CSR(SSTATUS) + `CHECK_CSR2(SSCRATCH, `CSRS) + `CHECK_CSR(SSTATUS) + `CHECK_CSR2(STVAL, `CSRS) + `CHECK_CSR(STVEC) logic speculative; initial begin From c42c485377c3f6bec57d329158ef496d652d0cc5 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Tue, 23 Feb 2021 18:59:06 +0000 Subject: [PATCH 13/46] busybear: instantiate soc instead of hart --- wally-pipelined/regression/wally-busybear.do | 116 +++++++++--------- .../src/wally/wallypipelinedsocbusybear.sv | 81 ++++++++++++ .../testbench/testbench-busybear.sv | 92 +++++++------- 3 files changed, 186 insertions(+), 103 deletions(-) create mode 100644 wally-pipelined/src/wally/wallypipelinedsocbusybear.sv diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index 2eb67e6ba..a6b50c23f 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -42,84 +42,84 @@ add wave /testbench_busybear/reset add wave -divider add wave -hex /testbench_busybear/PCtext add wave -hex /testbench_busybear/pcExpected -add wave -hex /testbench_busybear/dut/ifu/PCF -add wave -hex /testbench_busybear/dut/ifu/InstrF +add wave -hex /testbench_busybear/dut/hart/ifu/PCF +add wave -hex /testbench_busybear/dut/hart/ifu/InstrF add wave /testbench_busybear/lastInstrF add wave /testbench_busybear/speculative add wave /testbench_busybear/lastPC2 add wave -divider -#add wave -hex /testbench_busybear/dut/priv/csr/MTVEC_REG -#add wave -hex /testbench_busybear/dut/priv/csr/MSTATUS_REG -#add wave -hex /testbench_busybear/dut/priv/csr/SCOUNTEREN_REG -#add wave -hex /testbench_busybear/dut/priv/csr/MIE_REG -#add wave -hex /testbench_busybear/dut/priv/csr/MIDELEG_REG -#add wave -hex /testbench_busybear/dut/priv/csr/MEDELEG_REG +#add wave -hex /testbench_busybear/dut/hart/priv/csr/MTVEC_REG +#add wave -hex /testbench_busybear/dut/hart/priv/csr/MSTATUS_REG +#add wave -hex /testbench_busybear/dut/hart/priv/csr/SCOUNTEREN_REG +#add wave -hex /testbench_busybear/dut/hart/priv/csr/MIE_REG +#add wave -hex /testbench_busybear/dut/hart/priv/csr/MIDELEG_REG +#add wave -hex /testbench_busybear/dut/hart/priv/csr/MEDELEG_REG add wave -divider # registers! add wave -hex /testbench_busybear/regExpected add wave -hex /testbench_busybear/regNumExpected add wave -hex /testbench_busybear/HWRITE -add wave -hex /testbench_busybear/dut/MemRWM[1] +add wave -hex /testbench_busybear/dut/hart/MemRWM[1] add wave -hex /testbench_busybear/HWDATA add wave -hex /testbench_busybear/HRDATA add wave -hex /testbench_busybear/HADDR -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[1] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[2] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[3] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[4] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[5] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[6] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[7] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[8] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[9] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[10] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[11] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[12] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[13] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[14] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[15] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[16] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[17] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[18] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[19] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[20] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[21] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[22] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[23] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[24] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[25] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[26] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[27] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[28] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[29] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[30] -add wave -hex /testbench_busybear/dut/ieu/dp/regf/rf[31] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[1] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[2] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[3] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[4] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[5] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[6] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[7] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[8] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[9] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[10] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[11] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[12] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[13] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[14] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[15] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[16] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[17] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[18] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[19] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[20] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[21] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[22] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[23] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[24] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[25] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[26] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[27] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[28] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[29] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[30] +add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[31] add wave /testbench_busybear/InstrFName -add wave -hex /testbench_busybear/dut/ifu/PCD -#add wave -hex /testbench_busybear/dut/ifu/InstrD +add wave -hex /testbench_busybear/dut/hart/ifu/PCD +#add wave -hex /testbench_busybear/dut/hart/ifu/InstrD add wave /testbench_busybear/InstrDName #add wave -divider -add wave -hex /testbench_busybear/dut/ifu/PCE -##add wave -hex /testbench_busybear/dut/ifu/InstrE +add wave -hex /testbench_busybear/dut/hart/ifu/PCE +##add wave -hex /testbench_busybear/dut/hart/ifu/InstrE add wave /testbench_busybear/InstrEName -#add wave -hex /testbench_busybear/dut/ieu/dp/SrcAE -#add wave -hex /testbench_busybear/dut/ieu/dp/SrcBE -add wave -hex /testbench_busybear/dut/ieu/dp/ALUResultE -#add wave /testbench_busybear/dut/ieu/dp/PCSrcE +#add wave -hex /testbench_busybear/dut/hart/ieu/dp/SrcAE +#add wave -hex /testbench_busybear/dut/hart/ieu/dp/SrcBE +add wave -hex /testbench_busybear/dut/hart/ieu/dp/ALUResultE +#add wave /testbench_busybear/dut/hart/ieu/dp/PCSrcE #add wave -divider -add wave -hex /testbench_busybear/dut/ifu/PCM -##add wave -hex /testbench_busybear/dut/ifu/InstrM +add wave -hex /testbench_busybear/dut/hart/ifu/PCM +##add wave -hex /testbench_busybear/dut/hart/ifu/InstrM add wave /testbench_busybear/InstrMName -#add wave /testbench_busybear/dut/dmem/dtim/memwrite -#add wave -hex /testbench_busybear/dut/dmem/AdrM -#add wave -hex /testbench_busybear/dut/dmem/WriteDataM +#add wave /testbench_busybear/dut/hart/dmem/dtim/memwrite +#add wave -hex /testbench_busybear/dut/hart/dmem/AdrM +#add wave -hex /testbench_busybear/dut/hart/dmem/WriteDataM #add wave -divider -add wave -hex /testbench_busybear/dut/ifu/PCW -##add wave -hex /testbench_busybear/dut/ifu/InstrW +add wave -hex /testbench_busybear/dut/hart/ifu/PCW +##add wave -hex /testbench_busybear/dut/hart/ifu/InstrW add wave /testbench_busybear/InstrWName -#add wave /testbench_busybear/dut/ieu/dp/RegWriteW -#add wave -hex /testbench_busybear/dut/ieu/dp/ResultW -#add wave -hex /testbench_busybear/dut/ieu/dp/RdW +#add wave /testbench_busybear/dut/hart/ieu/dp/RegWriteW +#add wave -hex /testbench_busybear/dut/hart/ieu/dp/ResultW +#add wave -hex /testbench_busybear/dut/hart/ieu/dp/RdW #add wave -divider ##add ww #add wave -hex -r /testbench_busybear/* diff --git a/wally-pipelined/src/wally/wallypipelinedsocbusybear.sv b/wally-pipelined/src/wally/wallypipelinedsocbusybear.sv new file mode 100644 index 000000000..26df7681a --- /dev/null +++ b/wally-pipelined/src/wally/wallypipelinedsocbusybear.sv @@ -0,0 +1,81 @@ +/////////////////////////////////////////// +// wally-pipelinedsoc.sv +// +// Written: David_Harris@hmc.edu 6 November 2020 +// Modified: +// +// Purpose: System on chip including pipelined processor and memories +// Full RV32/64IC instruction set +// +// Note: the CSRs do not support the following features +//- Disabling portions of the instruction set with bits of the MISA register +//- Changing from RV64 to RV32 by writing the SXL/UXL bits of the STATUS register +// As of January 2020, virtual memory is not yet supported +// +// A component of the Wally configurable RISC-V project. +// +// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, +// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +// is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT +// OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +/////////////////////////////////////////// + +`include "wally-config.vh" + +module wallypipelinedsocbusybear ( + input logic clk, reset, + // AHB Lite Interface + // inputs from external memory + input logic [`AHBW-1:0] HRDATAEXT, + input logic HREADYEXT, HRESPEXT, + // outputs to external memory, shared with uncore memory + output logic HCLK, HRESETn, + output logic [31:0] HADDR, + output logic [`AHBW-1:0] HWDATA, + output logic HWRITE, + output logic [2:0] HSIZE, + output logic [2:0] HBURST, + output logic [3:0] HPROT, + output logic [1:0] HTRANS, + output logic HMASTLOCK, + // I/O Interface + input logic [31:0] GPIOPinsIn, + output logic [31:0] GPIOPinsOut, GPIOPinsEn, + input logic UARTSin, + output logic UARTSout, + // to instruction memory *** remove later + output logic [`XLEN-1:0] PCF, + input logic [31:0] InstrF, + input logic [`AHBW-1:0] HRDATA // from AHB mux in uncore +); + + + // Uncore signals + logic HREADY, HRESP; + logic InstrAccessFaultF, DataAccessFaultM; + logic TimerIntM, SwIntM; // from CLINT + logic ExtIntM = 0; // not yet connected + + + // for now, seem to need these to be like this + // until we get a better idea + assign HREADY = 1; + assign HRESP = 0; + assign InstrAccessFaultF = 0; + assign DataAccessFaultM = 0; + + // instantiate processor and memories + wallypipelinedhart hart(.*); + + //imem imem(.AdrF(PCF[`XLEN-1:1]), .*); // temporary until uncore memory is finished*** + //uncore uncore(.HWDATAIN(HWDATA), .*); +endmodule diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index fa9b64473..198d0b062 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -24,19 +24,15 @@ module testbench_busybear(); logic [1:0] HTRANS; logic HMASTLOCK; logic HCLK, HRESETn; + logic [`AHBW-1:0] HRDATAEXT; + logic HREADYEXT, HRESPEXT; + logic UARTSout; assign GPIOPinsIn = 0; assign UARTSin = 1; - assign HREADY = 1; - assign HRESP = 0; - assign HRDATA = 0; - - // for now, seem to need these to be zero until we get a better idea - assign InstrAccessFaultF = 0; - assign DataAccessFaultM = 0; // instantiate processor and memories - wallypipelinedhart dut(.*); + wallypipelinedsocbusybear dut(.*); // initialize test initial @@ -103,26 +99,32 @@ module testbench_busybear(); end end - logic[63:0] adrTranslation[4:0]; - string translationType[4:0] = {"rf", "writeAdr", "PCW", "PC", "readAdr"}; integer warningCount = 0; - initial begin - for(int i=0; i<5; i++) begin - adrTranslation[i] = 64'b0; - end - end + //logic[63:0] adrTranslation[4:0]; + //string translationType[4:0] = {"rf", "writeAdr", "PCW", "PC", "readAdr"}; + //initial begin + // for(int i=0; i<5; i++) begin + // adrTranslation[i] = 64'b0; + // end + //end + + //function logic equal(logic[63:0] adr, logic[63:0] adrExpected, integer func); + // if (adr[11:0] !== adrExpected[11:0]) begin + // equal = 1'b0; + // end else begin + // equal = 1'b1; + // if ((adr+adrTranslation[func]) !== adrExpected) begin + // adrTranslation[func] = adrExpected - adr; + // $display("warning: probably new address translation %x for %s at instr %0d", adrTranslation[func], translationType[func], instrs); + // warningCount += 1; + // end + // end + //endfunction + + // pretty sure this isn't necessary anymore, but keeping this for now since its easier function logic equal(logic[63:0] adr, logic[63:0] adrExpected, integer func); - if (adr[11:0] !== adrExpected[11:0]) begin - equal = 1'b0; - end else begin - equal = 1'b1; - if ((adr+adrTranslation[func]) !== adrExpected) begin - adrTranslation[func] = adrExpected - adr; - $display("warning: probably new address translation %x for %s at instr %0d", adrTranslation[func], translationType[func], instrs); - warningCount += 1; - end - end + equal = adr === adrExpected; endfunction @@ -138,11 +140,11 @@ module testbench_busybear(); genvar i; generate for(i=1; i<32; i++) begin - always @(dut.ieu.dp.regf.rf[i]) begin + always @(dut.hart.ieu.dp.regf.rf[i]) begin if ($time == 0) begin scan_file_rf = $fscanf(data_file_rf, "%x\n", regExpected); - if (dut.ieu.dp.regf.rf[i] != regExpected) begin - $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.ieu.dp.regf.rf[i], regExpected); + if (dut.hart.ieu.dp.regf.rf[i] != regExpected) begin + $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.hart.ieu.dp.regf.rf[i], regExpected); `ERROR end end else begin @@ -152,13 +154,13 @@ module testbench_busybear(); $display("%t ps, instr %0d: wrong register changed: %0d, %0d expected", $time, instrs, i, regNumExpected); `ERROR end - if (~equal(dut.ieu.dp.regf.rf[i],regExpected, 0)) begin - $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.ieu.dp.regf.rf[i], regExpected); + if (~equal(dut.hart.ieu.dp.regf.rf[i],regExpected, 0)) begin + $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.hart.ieu.dp.regf.rf[i], regExpected); `ERROR end - if (dut.ieu.dp.regf.rf[i] !== regExpected) begin - force dut.ieu.dp.regf.rf[i] = regExpected; - release dut.ieu.dp.regf.rf[i]; + if (dut.hart.ieu.dp.regf.rf[i] !== regExpected) begin + force dut.hart.ieu.dp.regf.rf[i] = regExpected; + release dut.hart.ieu.dp.regf.rf[i]; end end end @@ -167,8 +169,8 @@ module testbench_busybear(); logic [`XLEN-1:0] readAdrExpected; // this might need to change - always @(dut.MemRWM[1] or HADDR) begin - if (dut.MemRWM[1]) begin + always @(dut.hart.MemRWM[1] or HADDR) begin + if (dut.hart.MemRWM[1]) begin if($feof(data_file_memR)) begin $display("no more memR data to read"); `ERROR @@ -246,9 +248,9 @@ module testbench_busybear(); end \ end `define CHECK_CSR(CSR) \ - `CHECK_CSR2(CSR, dut.priv.csr) - `define CSRM dut.priv.csr.genblk1.csrm - `define CSRS dut.priv.csr.genblk1.csrs.genblk1 + `CHECK_CSR2(CSR, dut.hart.priv.csr) + `define CSRM dut.hart.priv.csr.genblk1.csrm + `define CSRS dut.hart.priv.csr.genblk1.csrs.genblk1 //`CHECK_CSR(FCSR) `CHECK_CSR2(MCAUSE, `CSRM) @@ -286,8 +288,8 @@ module testbench_busybear(); string PCtextW, PCtext2W; logic [31:0] InstrWExpected; logic [63:0] PCWExpected; - always @(dut.ifu.PCW or dut.ieu.InstrValidW) begin - if(dut.ieu.InstrValidW && dut.ifu.PCW != 0) begin + always @(dut.hart.ifu.PCW or dut.hart.ieu.InstrValidW) begin + if(dut.hart.ieu.InstrValidW && dut.hart.ifu.PCW != 0) begin if($feof(data_file_PCW)) begin $display("no more PC data to read"); `ERROR @@ -300,8 +302,8 @@ module testbench_busybear(); scan_file_PCW = $fscanf(data_file_PCW, "%x\n", InstrWExpected); // then expected PC value scan_file_PCW = $fscanf(data_file_PCW, "%x\n", PCWExpected); - if(~equal(dut.ifu.PCW,PCWExpected,2)) begin - $display("%t ps, instr %0d: PCW does not equal PCW expected: %x, %x", $time, instrs, dut.ifu.PCW, PCWExpected); + if(~equal(dut.hart.ifu.PCW,PCWExpected,2)) begin + $display("%t ps, instr %0d: PCW does not equal PCW expected: %x, %x", $time, instrs, dut.hart.ifu.PCW, PCWExpected); `ERROR end //if(it.InstrW != InstrWExpected) begin @@ -384,9 +386,9 @@ module testbench_busybear(); string InstrFName, InstrDName, InstrEName, InstrMName, InstrWName; logic [31:0] InstrW; instrNameDecTB dec(InstrF, InstrFName); - instrTrackerTB it(clk, reset, dut.ieu.dp.FlushE, - dut.ifu.InstrD, dut.ifu.InstrE, - dut.ifu.InstrM, InstrW, + instrTrackerTB it(clk, reset, dut.hart.ieu.dp.FlushE, + dut.hart.ifu.InstrD, dut.hart.ifu.InstrE, + dut.hart.ifu.InstrM, InstrW, InstrDName, InstrEName, InstrMName, InstrWName); // generate clock to sequence tests From 5394d38e4a47f6b5b703eaaf99a3a482e756b4fa Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Tue, 23 Feb 2021 19:38:19 +0000 Subject: [PATCH 14/46] busybear: remove unused signals --- wally-pipelined/testbench/testbench-busybear.sv | 4 ---- 1 file changed, 4 deletions(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 198d0b062..1b34a1fc5 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -9,12 +9,8 @@ module testbench_busybear(); // instantiate device to be tested logic [`XLEN-1:0] PCF; logic [31:0] InstrF; - logic InstrAccessFaultF, DataAccessFaultM; - logic TimerIntM = 0, SwIntM = 0; // from CLINT - logic ExtIntM = 0; // not yet connected logic [`AHBW-1:0] HRDATA; - logic HREADY, HRESP; logic [31:0] HADDR; logic [`AHBW-1:0] HWDATA; logic HWRITE; From 7b7e87bd0b7289680123a24c349265cb44143d71 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Tue, 23 Feb 2021 22:01:23 +0000 Subject: [PATCH 15/46] busybear: start adding ram --- wally-pipelined/regression/wally-busybear.do | 2 + .../testbench/testbench-busybear.sv | 56 ++++++++++++++----- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index a6b50c23f..cd9225d77 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -48,6 +48,8 @@ add wave /testbench_busybear/lastInstrF add wave /testbench_busybear/speculative add wave /testbench_busybear/lastPC2 add wave -divider +add wave -hex /testbench_busybear/readPC +add wave -hex /testbench_busybear/readRAM #add wave -hex /testbench_busybear/dut/hart/priv/csr/MTVEC_REG #add wave -hex /testbench_busybear/dut/hart/priv/csr/MSTATUS_REG #add wave -hex /testbench_busybear/dut/hart/priv/csr/SCOUNTEREN_REG diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 1b34a1fc5..13a7b2211 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -140,18 +140,18 @@ module testbench_busybear(); if ($time == 0) begin scan_file_rf = $fscanf(data_file_rf, "%x\n", regExpected); if (dut.hart.ieu.dp.regf.rf[i] != regExpected) begin - $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.hart.ieu.dp.regf.rf[i], regExpected); + $display("%0t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.hart.ieu.dp.regf.rf[i], regExpected); `ERROR end end else begin scan_file_rf = $fscanf(data_file_rf, "%d\n", regNumExpected); scan_file_rf = $fscanf(data_file_rf, "%x\n", regExpected); if (i != regNumExpected) begin - $display("%t ps, instr %0d: wrong register changed: %0d, %0d expected", $time, instrs, i, regNumExpected); + $display("%0t ps, instr %0d: wrong register changed: %0d, %0d expected", $time, instrs, i, regNumExpected); `ERROR end if (~equal(dut.hart.ieu.dp.regf.rf[i],regExpected, 0)) begin - $display("%t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.hart.ieu.dp.regf.rf[i], regExpected); + $display("%0t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.hart.ieu.dp.regf.rf[i], regExpected); `ERROR end if (dut.hart.ieu.dp.regf.rf[i] !== regExpected) begin @@ -162,6 +162,27 @@ module testbench_busybear(); end end endgenerate + + `define MAX_RAM 'h8000000 + logic [`XLEN-1:0] RAM[`MAX_RAM:0]; + logic [`XLEN-1:0] readRAM, readPC; + integer RAMAdr, RAMPC; + assign RAMAdr = HADDR - 'h80000000; + assign RAMPC = PCF - 'h80000000; + always @(HWDATA or HADDR or HSIZE or HWRITE or dut.hart.MemRWM[1]) begin + if ((HWRITE || dut.hart.MemRWM[1]) && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin + if (HWRITE) begin + RAM[RAMAdr] = HWDATA; + end else begin + readRAM = RAM[RAMAdr]; + end + end + end + always @(PCF) begin + if (PCF >= 'h80000000 && PCF <= 'h87FFFFFF) begin + readPC = RAM[RAMPC]; + end + end logic [`XLEN-1:0] readAdrExpected; // this might need to change @@ -175,7 +196,12 @@ module testbench_busybear(); scan_file_memR = $fscanf(data_file_memR, "%x\n", HRDATA); #1; if (~equal(HADDR,readAdrExpected,4)) begin - $display("%t ps, instr %0d: HADDR does not equal readAdrExpected: %x, %x", $time, instrs, HADDR, readAdrExpected); + $display("%0t ps, instr %0d: HADDR does not equal readAdrExpected: %x, %x", $time, instrs, HADDR, readAdrExpected); + `ERROR + end + if (HRDATA != readRAM && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin + $display("warning %0t ps, instr %0d: HRDATA does not equal readRAM: %x, %x from address %x", $time, instrs, HRDATA, readRAM, HADDR); + warningCount += 1; `ERROR end end @@ -183,7 +209,7 @@ module testbench_busybear(); logic [`XLEN-1:0] writeDataExpected, writeAdrExpected; // this might need to change - always @(HWDATA or HADDR or HSIZE) begin + always @(HWDATA or HADDR or HSIZE or HWRITE) begin #1; if (HWRITE) begin if($feof(data_file_memW)) begin @@ -193,11 +219,11 @@ module testbench_busybear(); scan_file_memW = $fscanf(data_file_memW, "%x\n", writeDataExpected); scan_file_memW = $fscanf(data_file_memW, "%x\n", writeAdrExpected); if (writeDataExpected != HWDATA) begin - $display("%t ps, instr %0d: HWDATA does not equal writeDataExpected: %x, %x", $time, instrs, HWDATA, writeDataExpected); + $display("%0t ps, instr %0d: HWDATA does not equal writeDataExpected: %x, %x", $time, instrs, HWDATA, writeDataExpected); `ERROR end if (~equal(writeAdrExpected,HADDR,1)) begin - $display("%t ps, instr %0d: HADDR does not equal writeAdrExpected: %x, %x", $time, instrs, HADDR, writeAdrExpected); + $display("%0t ps, instr %0d: HADDR does not equal writeAdrExpected: %x, %x", $time, instrs, HADDR, writeAdrExpected); `ERROR end end @@ -226,17 +252,17 @@ module testbench_busybear(); scan_file_csr = $fscanf(data_file_csr, "%s\n", CSR); \ scan_file_csr = $fscanf(data_file_csr, "%x\n", expected``CSR``); \ if(CSR.icompare(`"CSR`")) begin \ - $display("%t ps, instr %0d: %s changed, expected %s", $time, instrs, `"CSR`", CSR); \ + $display("%0t ps, instr %0d: %s changed, expected %s", $time, instrs, `"CSR`", CSR); \ end \ if(``PATH``.``CSR``_REGW != ``expected``CSR) begin \ - $display("%t ps, instr %0d: %s does not equal %s expected: %x, %x", $time, instrs, `"CSR`", CSR, ``PATH``.``CSR``_REGW, ``expected``CSR); \ + $display("%0t ps, instr %0d: %s does not equal %s expected: %x, %x", $time, instrs, `"CSR`", CSR, ``PATH``.``CSR``_REGW, ``expected``CSR); \ `ERROR \ end \ end else begin \ for(integer j=0; j Date: Wed, 24 Feb 2021 01:51:18 +0000 Subject: [PATCH 16/46] busybear: add support for subwords in ram this is really weird and i'm not sure if i did it right. I'd love if @kaveh could review it --- .../testbench/testbench-busybear.sv | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 13a7b2211..dc4d91587 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -30,6 +30,7 @@ module testbench_busybear(); // instantiate processor and memories wallypipelinedsocbusybear dut(.*); + // initialize test initial begin @@ -163,18 +164,19 @@ module testbench_busybear(); end endgenerate - `define MAX_RAM 'h8000000 - logic [`XLEN-1:0] RAM[`MAX_RAM:0]; + logic [`XLEN-1:0] RAM[('h8000000 >> 3):0]; logic [`XLEN-1:0] readRAM, readPC; integer RAMAdr, RAMPC; - assign RAMAdr = HADDR - 'h80000000; - assign RAMPC = PCF - 'h80000000; + assign RAMAdr = (HADDR - 'h80000000) >> 3; + assign RAMPC = (PCF - 'h80000000) >> 3; + logic [63:0] readMask; + assign readMask = ((1 << (8*(1 << HSIZE))) - 1) << 8 * HADDR[2:0]; always @(HWDATA or HADDR or HSIZE or HWRITE or dut.hart.MemRWM[1]) begin if ((HWRITE || dut.hart.MemRWM[1]) && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin if (HWRITE) begin - RAM[RAMAdr] = HWDATA; + RAM[RAMAdr] = (RAM[RAMAdr] & (~readMask)) | ((HWDATA << 8 * HADDR[2:0]) & readMask); end else begin - readRAM = RAM[RAMAdr]; + readRAM = RAM[RAMAdr] & readMask; end end end @@ -199,8 +201,9 @@ module testbench_busybear(); $display("%0t ps, instr %0d: HADDR does not equal readAdrExpected: %x, %x", $time, instrs, HADDR, readAdrExpected); `ERROR end - if (HRDATA != readRAM && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin - $display("warning %0t ps, instr %0d: HRDATA does not equal readRAM: %x, %x from address %x", $time, instrs, HRDATA, readRAM, HADDR); + + if (((readMask & HRDATA) != (readMask & readRAM)) && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin + $display("warning %0t ps, instr %0d: HRDATA does not equal readRAM: %x, %x from address %x, %x", $time, instrs, HRDATA, readRAM, HADDR, HSIZE); warningCount += 1; `ERROR end From b7f4e72eec809444a3809b2585e746b26be9d7a8 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Wed, 24 Feb 2021 02:02:28 +0000 Subject: [PATCH 17/46] busybear: add bootram section in the same manner as ram --- .../testbench/testbench-busybear.sv | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index dc4d91587..cf19857af 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -165,10 +165,11 @@ module testbench_busybear(); endgenerate logic [`XLEN-1:0] RAM[('h8000000 >> 3):0]; + logic [`XLEN-1:0] bootram[('h2000 >> 3):0]; logic [`XLEN-1:0] readRAM, readPC; integer RAMAdr, RAMPC; - assign RAMAdr = (HADDR - 'h80000000) >> 3; - assign RAMPC = (PCF - 'h80000000) >> 3; + assign RAMAdr = (HADDR - (HADDR > 'h2fff ? 'h80000000 : 'h1000)) >> 3; + assign RAMPC = (PCF - (PCF > 'h2fff ? 'h80000000 : 'h1000)) >> 3; logic [63:0] readMask; assign readMask = ((1 << (8*(1 << HSIZE))) - 1) << 8 * HADDR[2:0]; always @(HWDATA or HADDR or HSIZE or HWRITE or dut.hart.MemRWM[1]) begin @@ -185,6 +186,21 @@ module testbench_busybear(); readPC = RAM[RAMPC]; end end + // there's almost certianly a better way than just copying this, but its simple enough for now: + always @(HWDATA or HADDR or HSIZE or HWRITE or dut.hart.MemRWM[1]) begin + if ((HWRITE || dut.hart.MemRWM[1]) && (HADDR >= 'h1000 && HADDR <= 'h2FFF)) begin + if (HWRITE) begin + bootram[RAMAdr] = (bootram[RAMAdr] & (~readMask)) | ((HWDATA << 8 * HADDR[2:0]) & readMask); + end else begin + readRAM = bootram[RAMAdr] & readMask; + end + end + end + always @(PCF) begin + if (PCF >= 'h1000 && PCF <= 'h2FFF) begin + readPC = bootram[RAMPC]; + end + end logic [`XLEN-1:0] readAdrExpected; // this might need to change From 06f73fe5fe1b9b6a38f2418a8c6ebd590939d9b7 Mon Sep 17 00:00:00 2001 From: kaveh pezeshki Date: Tue, 23 Feb 2021 21:28:33 -0800 Subject: [PATCH 18/46] added comments for RAM and bootram, removed trailing whitepace --- .../testbench/testbench-busybear.sv | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index cf19857af..834a52ca9 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -7,7 +7,7 @@ module testbench_busybear(); logic [31:0] GPIOPinsOut, GPIOPinsEn; // instantiate device to be tested - logic [`XLEN-1:0] PCF; + logic [`XLEN-1:0] PCF; logic [31:0] InstrF; logic [`AHBW-1:0] HRDATA; @@ -26,7 +26,7 @@ module testbench_busybear(); assign GPIOPinsIn = 0; assign UARTSin = 1; - + // instantiate processor and memories wallypipelinedsocbusybear dut(.*); @@ -36,7 +36,7 @@ module testbench_busybear(); begin reset <= 1; # 22; reset <= 0; end - + // read pc trace file integer data_file_PC, scan_file_PC; initial begin @@ -44,7 +44,7 @@ module testbench_busybear(); if (data_file_PC == 0) begin $display("file couldn't be opened"); $stop; - end + end end integer data_file_PCW, scan_file_PCW; @@ -53,7 +53,7 @@ module testbench_busybear(); if (data_file_PCW == 0) begin $display("file couldn't be opened"); $stop; - end + end end // read register trace file @@ -63,7 +63,7 @@ module testbench_busybear(); if (data_file_rf == 0) begin $display("file couldn't be opened"); $stop; - end + end end // read CSR trace file @@ -73,7 +73,7 @@ module testbench_busybear(); if (data_file_csr == 0) begin $display("file couldn't be opened"); $stop; - end + end end // read memreads trace file @@ -83,9 +83,9 @@ module testbench_busybear(); if (data_file_memR == 0) begin $display("file couldn't be opened"); $stop; - end + end end - + // read memwrite trace file integer data_file_memW, scan_file_memW; initial begin @@ -93,7 +93,7 @@ module testbench_busybear(); if (data_file_memW == 0) begin $display("file couldn't be opened"); $stop; - end + end end integer warningCount = 0; @@ -163,7 +163,18 @@ module testbench_busybear(); end end endgenerate - + + // RAM and bootram are addressed in 64-bit blocks - this logic handles R/W + // including subwords. Brief explanation on signals: + // + // readMask: bitmask of bits to read / write, left-shifted to align with + // nearest 64-bit boundary - examples + // HSIZE = 0 -> readMask = 11111111 + // HSIZE = 1 -> readMask = 1111111111111111 + // + // In the linux boot, the processor spends the first ~5 instructions in + // bootram, before jr jumps to main RAM + logic [`XLEN-1:0] RAM[('h8000000 >> 3):0]; logic [`XLEN-1:0] bootram[('h2000 >> 3):0]; logic [`XLEN-1:0] readRAM, readPC; @@ -175,7 +186,7 @@ module testbench_busybear(); always @(HWDATA or HADDR or HSIZE or HWRITE or dut.hart.MemRWM[1]) begin if ((HWRITE || dut.hart.MemRWM[1]) && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin if (HWRITE) begin - RAM[RAMAdr] = (RAM[RAMAdr] & (~readMask)) | ((HWDATA << 8 * HADDR[2:0]) & readMask); + RAM[RAMAdr] = (RAM[RAMAdr] & (~readMask)) | ((HWDATA << 8 * HADDR[2:0]) & readMask); // aligns write data for correct subword size end else begin readRAM = RAM[RAMAdr] & readMask; end @@ -225,7 +236,7 @@ module testbench_busybear(); end end end - + logic [`XLEN-1:0] writeDataExpected, writeAdrExpected; // this might need to change always @(HWDATA or HADDR or HSIZE or HWRITE) begin @@ -253,7 +264,7 @@ module testbench_busybear(); string StartCSRname[99:0]; initial begin while(1) begin - scan_file_csr = $fscanf(data_file_csr, "%s\n", StartCSRname[totalCSR]); + scan_file_csr = $fscanf(data_file_csr, "%s\n", StartCSRname[totalCSR]); if(StartCSRname[totalCSR] == "---") begin break; end @@ -261,7 +272,7 @@ module testbench_busybear(); totalCSR = totalCSR + 1; end end - + `define CHECK_CSR2(CSR, PATH) \ string CSR; \ logic [63:0] expected``CSR``; \ @@ -289,8 +300,8 @@ module testbench_busybear(); end \ end `define CHECK_CSR(CSR) \ - `CHECK_CSR2(CSR, dut.hart.priv.csr) - `define CSRM dut.hart.priv.csr.genblk1.csrm + `CHECK_CSR2(CSR, dut.hart.priv.csr) + `define CSRM dut.hart.priv.csr.genblk1.csrm `define CSRS dut.hart.priv.csr.genblk1.csrs.genblk1 //`CHECK_CSR(FCSR) @@ -357,7 +368,7 @@ module testbench_busybear(); integer instrs; initial begin instrs = 0; - end + end always @(PCF) begin lastInstrF = InstrF; lastPC <= PCF; @@ -395,7 +406,7 @@ module testbench_busybear(); end instrs += 1; // are we at a branch/jump? - casex (lastInstrF[31:0]) + casex (lastInstrF[31:0]) 32'b00000000001000000000000001110011, // URET 32'b00010000001000000000000001110011, // SRET 32'b00110000001000000000000001110011, // MRET From ddaf67c0434b32638d15e7b278853688058b572c Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Wed, 24 Feb 2021 18:44:50 +0000 Subject: [PATCH 19/46] busybear: preload bootram thanks to Prof Stine for the .do file commands @kaveh can you check line 201? it does nothing, but things break when I remove that line --- wally-pipelined/regression/wally-busybear.do | 3 +++ wally-pipelined/testbench/testbench-busybear.sv | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index cd9225d77..cc8fa8cde 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -27,11 +27,14 @@ vlib work-busybear # "Extra checking for conflicts with always_comb done at vopt time" # because vsim will run vopt vlog +incdir+../config/busybear ../testbench/*.sv ../src/*/*.sv -suppress 2583 + # start and run simulation # remove +acc flag for faster sim during regressions if there is no need to access internal signals vopt +acc work.testbench_busybear -o workopt vsim workopt -suppress 8852,12070 +mem load -startaddress 0 -endaddress 1024 -filltype value -fillradix hex -filldata 0 /testbench_busybear/bootram +mem load -startaddress 0 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/bootram view wave diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 834a52ca9..95408558d 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -177,7 +177,8 @@ module testbench_busybear(); logic [`XLEN-1:0] RAM[('h8000000 >> 3):0]; logic [`XLEN-1:0] bootram[('h2000 >> 3):0]; - logic [`XLEN-1:0] readRAM, readPC; + logic [`XLEN-1:0] readRAM; + logic [31:0] readPC; integer RAMAdr, RAMPC; assign RAMAdr = (HADDR - (HADDR > 'h2fff ? 'h80000000 : 'h1000)) >> 3; assign RAMPC = (PCF - (PCF > 'h2fff ? 'h80000000 : 'h1000)) >> 3; @@ -194,7 +195,7 @@ module testbench_busybear(); end always @(PCF) begin if (PCF >= 'h80000000 && PCF <= 'h87FFFFFF) begin - readPC = RAM[RAMPC]; + readPC = RAM[RAMPC] >> PCF[2] * 32; end end // there's almost certianly a better way than just copying this, but its simple enough for now: @@ -208,8 +209,9 @@ module testbench_busybear(); end end always @(PCF) begin + $write(""); // I know this does nothing, the first instruction doesn't load for me without it if (PCF >= 'h1000 && PCF <= 'h2FFF) begin - readPC = bootram[RAMPC]; + readPC = bootram[RAMPC] >> PCF[2] * 32; end end @@ -431,7 +433,7 @@ module testbench_busybear(); $display("%0t ps, instr %0d: PC does not equal PC expected: %x, %x", $time, instrs, PCF, pcExpected); `ERROR end - if (readPC != InstrF) begin + if ((~speculative) && (readPC != InstrF)) begin $display("%0t ps, instr %0d: readPC does not equal InstrF: %x, %x", $time, instrs, readPC, InstrF); warningCount += 1; end From 251aa982eb70e0dc60acd3aee379aa604ad25ac2 Mon Sep 17 00:00:00 2001 From: kaveh pezeshki Date: Wed, 24 Feb 2021 11:35:28 -0800 Subject: [PATCH 20/46] condensed always blocks to avoid race conditions --- .../testbench/testbench-busybear.sv | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 95408558d..5e95c710c 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -184,7 +184,11 @@ module testbench_busybear(); assign RAMPC = (PCF - (PCF > 'h2fff ? 'h80000000 : 'h1000)) >> 3; logic [63:0] readMask; assign readMask = ((1 << (8*(1 << HSIZE))) - 1) << 8 * HADDR[2:0]; + + logic [`XLEN-1:0] readAdrExpected; + always @(HWDATA or HADDR or HSIZE or HWRITE or dut.hart.MemRWM[1]) begin + if ((HWRITE || dut.hart.MemRWM[1]) && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin if (HWRITE) begin RAM[RAMAdr] = (RAM[RAMAdr] & (~readMask)) | ((HWDATA << 8 * HADDR[2:0]) & readMask); // aligns write data for correct subword size @@ -192,14 +196,7 @@ module testbench_busybear(); readRAM = RAM[RAMAdr] & readMask; end end - end - always @(PCF) begin - if (PCF >= 'h80000000 && PCF <= 'h87FFFFFF) begin - readPC = RAM[RAMPC] >> PCF[2] * 32; - end - end - // there's almost certianly a better way than just copying this, but its simple enough for now: - always @(HWDATA or HADDR or HSIZE or HWRITE or dut.hart.MemRWM[1]) begin + if ((HWRITE || dut.hart.MemRWM[1]) && (HADDR >= 'h1000 && HADDR <= 'h2FFF)) begin if (HWRITE) begin bootram[RAMAdr] = (bootram[RAMAdr] & (~readMask)) | ((HWDATA << 8 * HADDR[2:0]) & readMask); @@ -207,17 +204,7 @@ module testbench_busybear(); readRAM = bootram[RAMAdr] & readMask; end end - end - always @(PCF) begin - $write(""); // I know this does nothing, the first instruction doesn't load for me without it - if (PCF >= 'h1000 && PCF <= 'h2FFF) begin - readPC = bootram[RAMPC] >> PCF[2] * 32; - end - end - logic [`XLEN-1:0] readAdrExpected; - // this might need to change - always @(dut.hart.MemRWM[1] or HADDR) begin if (dut.hart.MemRWM[1]) begin if($feof(data_file_memR)) begin $display("no more memR data to read"); @@ -240,6 +227,7 @@ module testbench_busybear(); end logic [`XLEN-1:0] writeDataExpected, writeAdrExpected; + // this might need to change always @(HWDATA or HADDR or HSIZE or HWRITE) begin #1; @@ -372,6 +360,16 @@ module testbench_busybear(); instrs = 0; end always @(PCF) begin + + if (PCF >= 'h80000000 && PCF <= 'h87FFFFFF) begin + readPC = RAM[RAMPC] >> PCF[2] * 32; + end + + //$write(""); // I know this does nothing, the first instruction doesn't load for me without it + if (PCF >= 'h1000 && PCF <= 'h2FFF) begin + readPC = bootram[RAMPC] >> PCF[2] * 32; + end + lastInstrF = InstrF; lastPC <= PCF; lastPC2 <= lastPC; From adadc21fc61a551fc41b9866275913649b206adb Mon Sep 17 00:00:00 2001 From: kaveh pezeshki Date: Fri, 26 Feb 2021 02:22:08 -0800 Subject: [PATCH 21/46] restored --- wally-pipelined/testbench/testbench-busybear.sv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 5e95c710c..682898ca7 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -365,7 +365,7 @@ module testbench_busybear(); readPC = RAM[RAMPC] >> PCF[2] * 32; end - //$write(""); // I know this does nothing, the first instruction doesn't load for me without it + $write(""); // I know this does nothing, the first instruction doesn't load for me without it if (PCF >= 'h1000 && PCF <= 'h2FFF) begin readPC = bootram[RAMPC] >> PCF[2] * 32; end From 2782ca2480320b29dbf3101addcb7cda43e6f084 Mon Sep 17 00:00:00 2001 From: kaveh Pezeshki Date: Fri, 26 Feb 2021 13:41:16 -0500 Subject: [PATCH 22/46] fixed sensitivity list on error checking always block, removed useless once and for all --- wally-pipelined/testbench/testbench-busybear.sv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 682898ca7..195ef6f70 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -204,7 +204,9 @@ module testbench_busybear(); readRAM = bootram[RAMAdr] & readMask; end end + end + always @(dut.hart.MemRWM[1] or HADDR) begin if (dut.hart.MemRWM[1]) begin if($feof(data_file_memR)) begin $display("no more memR data to read"); @@ -365,7 +367,6 @@ module testbench_busybear(); readPC = RAM[RAMPC] >> PCF[2] * 32; end - $write(""); // I know this does nothing, the first instruction doesn't load for me without it if (PCF >= 'h1000 && PCF <= 'h2FFF) begin readPC = bootram[RAMPC] >> PCF[2] * 32; end From 4c7b185d904ae35563a6e4ffa8af3433293db678 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Fri, 26 Feb 2021 20:26:54 +0000 Subject: [PATCH 23/46] busybear: add main ram loading, better instr checking also --- wally-pipelined/regression/wally-busybear.do | 4 ++- .../testbench/testbench-busybear.sv | 34 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index cc8fa8cde..bf3d9d078 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -35,6 +35,8 @@ vopt +acc work.testbench_busybear -o workopt vsim workopt -suppress 8852,12070 mem load -startaddress 0 -endaddress 1024 -filltype value -fillradix hex -filldata 0 /testbench_busybear/bootram mem load -startaddress 0 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/bootram +mem load -startaddress 0 -endaddress 16777216 -filltype value -fillradix hex -filldata 0 /testbench_busybear/RAM +mem load -startaddress 0 -i "/courses/e190ax/busybear_boot/ram.txt" -format hex /testbench_busybear/RAM view wave @@ -51,7 +53,7 @@ add wave /testbench_busybear/lastInstrF add wave /testbench_busybear/speculative add wave /testbench_busybear/lastPC2 add wave -divider -add wave -hex /testbench_busybear/readPC +add wave -hex /testbench_busybear/readInstrF add wave -hex /testbench_busybear/readRAM #add wave -hex /testbench_busybear/dut/hart/priv/csr/MTVEC_REG #add wave -hex /testbench_busybear/dut/hart/priv/csr/MSTATUS_REG diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 195ef6f70..5dc7a8c20 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -178,7 +178,7 @@ module testbench_busybear(); logic [`XLEN-1:0] RAM[('h8000000 >> 3):0]; logic [`XLEN-1:0] bootram[('h2000 >> 3):0]; logic [`XLEN-1:0] readRAM; - logic [31:0] readPC; + logic [31:0] readInstrF; integer RAMAdr, RAMPC; assign RAMAdr = (HADDR - (HADDR > 'h2fff ? 'h80000000 : 'h1000)) >> 3; assign RAMPC = (PCF - (PCF > 'h2fff ? 'h80000000 : 'h1000)) >> 3; @@ -361,14 +361,22 @@ module testbench_busybear(); initial begin instrs = 0; end + logic [31:0] InstrMask; + logic forcedInstr; always @(PCF) begin if (PCF >= 'h80000000 && PCF <= 'h87FFFFFF) begin - readPC = RAM[RAMPC] >> PCF[2] * 32; + readInstrF = RAM[RAMPC] >> PCF[2:1] * 16; + if (PCF[2:1] == 2'b11) begin + readInstrF |= RAM[RAMPC+1] << 16; + end end if (PCF >= 'h1000 && PCF <= 'h2FFF) begin - readPC = bootram[RAMPC] >> PCF[2] * 32; + readInstrF = bootram[RAMPC] >> PCF[2:1] * 16; + if (PCF[2:1] == 2'b11) begin + readInstrF |= bootram[RAMPC+1] << 16; + end end lastInstrF = InstrF; @@ -392,11 +400,18 @@ module testbench_busybear(); InstrF = 32'b0010011; $display("warning: NOPing out %s at PC=%0x", PCtext, PCF); warningCount += 1; + forcedInstr = 1; end - if(InstrF[28:27] != 2'b11 && InstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD - InstrF = {12'b0, InstrF[19:7], 7'b0000011}; - $display("warning: replacing AMO instr %s at PC=%0x with ld", PCtext, PCF); - warningCount += 1; + else begin + if(InstrF[28:27] != 2'b11 && InstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD + InstrF = {12'b0, InstrF[19:7], 7'b0000011}; + $display("warning: replacing AMO instr %s at PC=%0x with ld", PCtext, PCF); + warningCount += 1; + forcedInstr = 1; + end + else begin + forcedInstr = 0; + end end // then expected PC value scan_file_PC = $fscanf(data_file_PC, "%x\n", pcExpected); @@ -432,8 +447,9 @@ module testbench_busybear(); $display("%0t ps, instr %0d: PC does not equal PC expected: %x, %x", $time, instrs, PCF, pcExpected); `ERROR end - if ((~speculative) && (readPC != InstrF)) begin - $display("%0t ps, instr %0d: readPC does not equal InstrF: %x, %x", $time, instrs, readPC, InstrF); + InstrMask = InstrF[1:0] == 2'b11 ? 32'hFFFFFFFF : 32'h0000FFFF; + if ((~forcedInstr) && (~speculative) && ((InstrMask & readInstrF) != (InstrMask & InstrF))) begin + $display("%0t ps, instr %0d: readInstrF does not equal InstrF: %x, %x, PC: %x", $time, instrs, readInstrF, InstrF, PCF); warningCount += 1; end end From 0596d61a2a9cfa21c3a854ecafcde3479a3d2994 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Sun, 28 Feb 2021 06:02:21 +0000 Subject: [PATCH 24/46] busybear: instantiate normal wallypipelinedsoc --- .../src/wally/wallypipelinedsocbusybear.sv | 81 ------------------- .../testbench/testbench-busybear.sv | 2 +- 2 files changed, 1 insertion(+), 82 deletions(-) delete mode 100644 wally-pipelined/src/wally/wallypipelinedsocbusybear.sv diff --git a/wally-pipelined/src/wally/wallypipelinedsocbusybear.sv b/wally-pipelined/src/wally/wallypipelinedsocbusybear.sv deleted file mode 100644 index 26df7681a..000000000 --- a/wally-pipelined/src/wally/wallypipelinedsocbusybear.sv +++ /dev/null @@ -1,81 +0,0 @@ -/////////////////////////////////////////// -// wally-pipelinedsoc.sv -// -// Written: David_Harris@hmc.edu 6 November 2020 -// Modified: -// -// Purpose: System on chip including pipelined processor and memories -// Full RV32/64IC instruction set -// -// Note: the CSRs do not support the following features -//- Disabling portions of the instruction set with bits of the MISA register -//- Changing from RV64 to RV32 by writing the SXL/UXL bits of the STATUS register -// As of January 2020, virtual memory is not yet supported -// -// A component of the Wally configurable RISC-V project. -// -// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -// is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT -// OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -/////////////////////////////////////////// - -`include "wally-config.vh" - -module wallypipelinedsocbusybear ( - input logic clk, reset, - // AHB Lite Interface - // inputs from external memory - input logic [`AHBW-1:0] HRDATAEXT, - input logic HREADYEXT, HRESPEXT, - // outputs to external memory, shared with uncore memory - output logic HCLK, HRESETn, - output logic [31:0] HADDR, - output logic [`AHBW-1:0] HWDATA, - output logic HWRITE, - output logic [2:0] HSIZE, - output logic [2:0] HBURST, - output logic [3:0] HPROT, - output logic [1:0] HTRANS, - output logic HMASTLOCK, - // I/O Interface - input logic [31:0] GPIOPinsIn, - output logic [31:0] GPIOPinsOut, GPIOPinsEn, - input logic UARTSin, - output logic UARTSout, - // to instruction memory *** remove later - output logic [`XLEN-1:0] PCF, - input logic [31:0] InstrF, - input logic [`AHBW-1:0] HRDATA // from AHB mux in uncore -); - - - // Uncore signals - logic HREADY, HRESP; - logic InstrAccessFaultF, DataAccessFaultM; - logic TimerIntM, SwIntM; // from CLINT - logic ExtIntM = 0; // not yet connected - - - // for now, seem to need these to be like this - // until we get a better idea - assign HREADY = 1; - assign HRESP = 0; - assign InstrAccessFaultF = 0; - assign DataAccessFaultM = 0; - - // instantiate processor and memories - wallypipelinedhart hart(.*); - - //imem imem(.AdrF(PCF[`XLEN-1:1]), .*); // temporary until uncore memory is finished*** - //uncore uncore(.HWDATAIN(HWDATA), .*); -endmodule diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 5dc7a8c20..8409997c0 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -28,7 +28,7 @@ module testbench_busybear(); assign UARTSin = 1; // instantiate processor and memories - wallypipelinedsocbusybear dut(.*); + wallypipelinedsoc dut(.*); // initialize test From 969c09448988bfb5b0be860a162aa75258e75eee Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Sun, 28 Feb 2021 06:02:40 +0000 Subject: [PATCH 25/46] busybear: remove gpio, start adding 2nd ram --- wally-pipelined/config/busybear/wally-config.vh | 10 ++++++---- wally-pipelined/src/uncore/uncore.sv | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/wally-pipelined/config/busybear/wally-config.vh b/wally-pipelined/config/busybear/wally-config.vh index a3c5188f6..bd9dc9473 100644 --- a/wally-pipelined/config/busybear/wally-config.vh +++ b/wally-pipelined/config/busybear/wally-config.vh @@ -62,11 +62,13 @@ // Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits `define TIMBASE 64'h0000000080000000 -`define TIMRANGE 64'h000000000007FFFF +`define TIMRANGE 64'h0000000007FFFFFF +`define BOOTTIMBASE 64'h0000000000000000 //only needs to go from 0x1000 to 0x2FFF, extending to a power of 2 +`define BOOTTIMRANGE 64'h0000000000004000 `define CLINTBASE 64'h0000000002000000 -`define CLINTRANGE 64'h000000000000FFFF -`define GPIOBASE 64'h0000000010012000 -`define GPIORANGE 64'h00000000000000FF +`define CLINTRANGE 64'h000000000000BFFF +//`define GPIOBASE 64'h0000000010012000 // no GPIO in linux for now +//`define GPIORANGE 64'h00000000000000FF `define UARTBASE 64'h0000000010000000 `define UARTRANGE 64'h0000000000000007 // Bus Interface width diff --git a/wally-pipelined/src/uncore/uncore.sv b/wally-pipelined/src/uncore/uncore.sv index d899717e4..d2705d4bc 100644 --- a/wally-pipelined/src/uncore/uncore.sv +++ b/wally-pipelined/src/uncore/uncore.sv @@ -59,7 +59,7 @@ module uncore ( logic [`XLEN-1:0] HWDATA; logic [`XLEN-1:0] HREADTim, HREADCLINT, HREADGPIO, HREADUART; - logic HSELTim, HSELCLINT, HSELGPIO, PreHSELUART, HSELUART; + logic HSELBootTim, HSELTim, HSELCLINT, HSELGPIO, PreHSELUART, HSELUART; logic HRESPTim, HRESPCLINT, HRESPGPIO, HRESPUART; logic HREADYTim, HREADYCLINT, HREADYGPIO, HREADYUART; logic [1:0] MemRW; @@ -69,8 +69,10 @@ module uncore ( // AHB Address decoder adrdec timdec(HADDR, `TIMBASE, `TIMRANGE, HSELTim); + adrdec boottimdec(HADDR, `BOOTTIMBASE, `BOOTTIMRANGE, HSELBootTim); adrdec clintdec(HADDR, `CLINTBASE, `CLINTRANGE, HSELCLINT); - adrdec gpiodec(HADDR, `GPIOBASE, `GPIORANGE, HSELGPIO); + //Busybear: for now, leaving out gpio since OVPsim doesn't seem to have it + //adrdec gpiodec(HADDR, `GPIOBASE, `GPIORANGE, HSELGPIO); adrdec uartdec(HADDR, `UARTBASE, `UARTRANGE, PreHSELUART); assign HSELUART = PreHSELUART && (HSIZE == 3'b000); // only byte writes to UART are supported From 2769b147cbc1d3a3172ffe0e37d3b2ddc6bda8d4 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Sun, 28 Feb 2021 16:08:54 +0000 Subject: [PATCH 26/46] busybear: add 2nd dtim for bootram --- .../config/busybear/wally-config.vh | 20 +++++++-------- wally-pipelined/src/uncore/dtim.sv | 5 ++-- wally-pipelined/src/uncore/uncore.sv | 25 +++++++++++-------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/wally-pipelined/config/busybear/wally-config.vh b/wally-pipelined/config/busybear/wally-config.vh index bd9dc9473..e85ee73d3 100644 --- a/wally-pipelined/config/busybear/wally-config.vh +++ b/wally-pipelined/config/busybear/wally-config.vh @@ -61,16 +61,16 @@ // Peripheral memory space extends from BASE to BASE+RANGE // Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits -`define TIMBASE 64'h0000000080000000 -`define TIMRANGE 64'h0000000007FFFFFF -`define BOOTTIMBASE 64'h0000000000000000 //only needs to go from 0x1000 to 0x2FFF, extending to a power of 2 -`define BOOTTIMRANGE 64'h0000000000004000 -`define CLINTBASE 64'h0000000002000000 -`define CLINTRANGE 64'h000000000000BFFF -//`define GPIOBASE 64'h0000000010012000 // no GPIO in linux for now -//`define GPIORANGE 64'h00000000000000FF -`define UARTBASE 64'h0000000010000000 -`define UARTRANGE 64'h0000000000000007 +`define TIMBASE 32'h80000000 +`define TIMRANGE 32'h07FFFFFF +`define BOOTTIMBASE 32'h00000000 //only needs to go from 0x1000 to 0x2FFF, extending to a power of 2 +`define BOOTTIMRANGE 32'h00004000 +`define CLINTBASE 32'h02000000 +`define CLINTRANGE 32'h0000BFFF +//`define GPIOBASE 32'h10012000 // no GPIO in linux for now +//`define GPIORANGE 32'h000000FF +`define UARTBASE 32'h10000000 +`define UARTRANGE 32'h00000007 // Bus Interface width `define AHBW 64 diff --git a/wally-pipelined/src/uncore/dtim.sv b/wally-pipelined/src/uncore/dtim.sv index 4216b356c..009fb03d2 100644 --- a/wally-pipelined/src/uncore/dtim.sv +++ b/wally-pipelined/src/uncore/dtim.sv @@ -25,7 +25,7 @@ `include "wally-config.vh" -module dtim ( +module dtim #(parameter BASE=0, RANGE = 65535) ( input logic HCLK, HRESETn, input logic [1:0] MemRWtim, input logic [18:0] HADDR, @@ -35,7 +35,8 @@ module dtim ( output logic HRESPTim, HREADYTim ); - logic [`XLEN-1:0] RAM[0:65535]; + //logic [`XLEN-1:0] RAM[0:65535]; + logic [`XLEN-1:0] RAM[BASE>>(1+`XLEN/32):(RANGE-BASE)>>1+(`XLEN/32)]; logic [18:0] HWADDR; logic [`XLEN-1:0] HREADTim0; diff --git a/wally-pipelined/src/uncore/uncore.sv b/wally-pipelined/src/uncore/uncore.sv index d2705d4bc..ab66af9f1 100644 --- a/wally-pipelined/src/uncore/uncore.sv +++ b/wally-pipelined/src/uncore/uncore.sv @@ -58,12 +58,12 @@ module uncore ( ); logic [`XLEN-1:0] HWDATA; - logic [`XLEN-1:0] HREADTim, HREADCLINT, HREADGPIO, HREADUART; + logic [`XLEN-1:0] HREADBootTim, HREADTim, HREADCLINT, HREADGPIO, HREADUART; logic HSELBootTim, HSELTim, HSELCLINT, HSELGPIO, PreHSELUART, HSELUART; - logic HRESPTim, HRESPCLINT, HRESPGPIO, HRESPUART; - logic HREADYTim, HREADYCLINT, HREADYGPIO, HREADYUART; + logic HRESPBootTim, HRESPTim, HRESPCLINT, HRESPGPIO, HRESPUART; + logic HREADYBootTim, HREADYTim, HREADYCLINT, HREADYGPIO, HREADYUART; logic [1:0] MemRW; - logic [1:0] MemRWtim, MemRWclint, MemRWgpio, MemRWuart; + logic [1:0] MemRWboottim, MemRWtim, MemRWclint, MemRWgpio, MemRWuart; logic UARTIntr;// *** will need to tie INTR to an interrupt handler @@ -71,16 +71,17 @@ module uncore ( adrdec timdec(HADDR, `TIMBASE, `TIMRANGE, HSELTim); adrdec boottimdec(HADDR, `BOOTTIMBASE, `BOOTTIMRANGE, HSELBootTim); adrdec clintdec(HADDR, `CLINTBASE, `CLINTRANGE, HSELCLINT); - //Busybear: for now, leaving out gpio since OVPsim doesn't seem to have it + // Busybear: for now, leaving out gpio since OVPsim doesn't seem to have it //adrdec gpiodec(HADDR, `GPIOBASE, `GPIORANGE, HSELGPIO); adrdec uartdec(HADDR, `UARTBASE, `UARTRANGE, PreHSELUART); assign HSELUART = PreHSELUART && (HSIZE == 3'b000); // only byte writes to UART are supported // Enable read or write based on decoded address assign MemRW = {~HWRITE, HWRITED}; + assign MemRWboottim = MemRW & {2{HSELBootTim}}; assign MemRWtim = MemRW & {2{HSELTim}}; assign MemRWclint = MemRW & {2{HSELCLINT}}; - assign MemRWgpio = MemRW & {2{HSELGPIO}}; + //assign MemRWgpio = MemRW & {2{HSELGPIO}}; assign MemRWuart = MemRW & {2{HSELUART}}; /* always_ff @(posedge HCLK) begin HADDRD <= HADDR; @@ -94,11 +95,13 @@ module uncore ( subwordwrite sww(.*); // tightly integrated memory - dtim dtim(.HADDR(HADDR[18:0]), .*); + dtim #(.BASE(`TIMBASE), .RANGE(`TIMRANGE)) maindtim (.HADDR(HADDR[18:0]), .*); + dtim #(.BASE(`BOOTTIMBASE), .RANGE(`BOOTTIMRANGE)) bootdtim (.HADDR(HADDR[18:0]), .MemRWtim(MemRWboottim), + .HSELTim(HSELBootTim), .HREADTim(HREADBootTim), .HRESPTim(HRESPBootTim), .HREADYTim(HREADYBootTim), .*); // memory-mapped I/O peripherals clint clint(.HADDR(HADDR[15:0]), .*); - gpio gpio(.HADDR(HADDR[7:0]), .*); // *** may want to add GPIO interrupts + //gpio gpio(.HADDR(HADDR[7:0]), .*); // *** may want to add GPIO interrupts uart uart(.HADDR(HADDR[2:0]), .TXRDYb(), .RXRDYb(), .INTR(UARTIntr), .SIN(UARTSin), .SOUT(UARTSout), .DSRb(1'b1), .DCDb(1'b1), .CTSb(1'b0), .RIb(1'b1), .RTSb(), .DTRb(), .OUT1b(), .OUT2b(), .*); @@ -106,9 +109,9 @@ module uncore ( // mux could also include external memory // AHB Read Multiplexer assign HRDATA = ({`XLEN{HSELTim}} & HREADTim) | ({`XLEN{HSELCLINT}} & HREADCLINT) | - ({`XLEN{HSELGPIO}} & HREADGPIO) | ({`XLEN{HSELUART}} & HREADUART); - assign HRESP = HSELTim & HRESPTim | HSELCLINT & HRESPCLINT | HSELGPIO & HRESPGPIO | HSELUART & HRESPUART; - assign HREADY = HSELTim & HREADYTim | HSELCLINT & HREADYCLINT | HSELGPIO & HREADYGPIO | HSELUART & HREADYUART; + ({`XLEN{HSELBootTim}} & HREADBootTim) | ({`XLEN{HSELUART}} & HREADUART); + assign HRESP = HSELBootTim & HRESPBootTim | HSELTim & HRESPTim | HSELCLINT & HRESPCLINT | HSELGPIO & HRESPGPIO | HSELUART & HRESPUART; + assign HREADY = HSELBootTim & HREADYBootTim | HSELTim & HREADYTim | HSELCLINT & HREADYCLINT | HSELGPIO & HREADYGPIO | HSELUART & HREADYUART; // Faults assign DataAccessFaultM = ~(HSELTim | HSELCLINT | HSELGPIO | HSELUART); From 856a1079cc90e8249d12d8f4b2f70c77fe5aca90 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Sun, 28 Feb 2021 16:19:03 +0000 Subject: [PATCH 27/46] busybear: change sstatus, mstatus reset value --- wally-pipelined/src/privileged/csrsr.sv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wally-pipelined/src/privileged/csrsr.sv b/wally-pipelined/src/privileged/csrsr.sv index 05ce79583..83743c456 100644 --- a/wally-pipelined/src/privileged/csrsr.sv +++ b/wally-pipelined/src/privileged/csrsr.sv @@ -116,8 +116,8 @@ module csrsr ( STATUS_SPIE <= 0; //`S_SUPPORTED; STATUS_UPIE <= 0; // `U_SUPPORTED; STATUS_MIE <= 0; // Per Priv 3.3 - STATUS_SIE <= `S_SUPPORTED; - STATUS_UIE <= `U_SUPPORTED; + STATUS_SIE <= 0; //`S_SUPPORTED; + STATUS_UIE <= 0; //`U_SUPPORTED; end else if (~StallW) begin if (WriteMSTATUSM) begin STATUS_SUM_INT <= CSRWriteValM[18]; From 932bc0ef852956d1af785096b1864a7fa774538e Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Sun, 28 Feb 2021 16:46:53 +0000 Subject: [PATCH 28/46] busybear: check instead of providing InstrF --- wally-pipelined/regression/wally-busybear.do | 4 +- .../testbench/testbench-busybear.sv | 68 +++++++------------ 2 files changed, 27 insertions(+), 45 deletions(-) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index bf3d9d078..74f6a9d4b 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -49,11 +49,11 @@ add wave -hex /testbench_busybear/PCtext add wave -hex /testbench_busybear/pcExpected add wave -hex /testbench_busybear/dut/hart/ifu/PCF add wave -hex /testbench_busybear/dut/hart/ifu/InstrF -add wave /testbench_busybear/lastInstrF +add wave /testbench_busybear/CheckInstrF +add wave /testbench_busybear/lastCheckInstrF add wave /testbench_busybear/speculative add wave /testbench_busybear/lastPC2 add wave -divider -add wave -hex /testbench_busybear/readInstrF add wave -hex /testbench_busybear/readRAM #add wave -hex /testbench_busybear/dut/hart/priv/csr/MTVEC_REG #add wave -hex /testbench_busybear/dut/hart/priv/csr/MSTATUS_REG diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 8409997c0..7a59cc521 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -7,8 +7,7 @@ module testbench_busybear(); logic [31:0] GPIOPinsOut, GPIOPinsEn; // instantiate device to be tested - logic [`XLEN-1:0] PCF; - logic [31:0] InstrF; + logic [31:0] CheckInstrF; logic [`AHBW-1:0] HRDATA; logic [31:0] HADDR; @@ -178,10 +177,9 @@ module testbench_busybear(); logic [`XLEN-1:0] RAM[('h8000000 >> 3):0]; logic [`XLEN-1:0] bootram[('h2000 >> 3):0]; logic [`XLEN-1:0] readRAM; - logic [31:0] readInstrF; integer RAMAdr, RAMPC; assign RAMAdr = (HADDR - (HADDR > 'h2fff ? 'h80000000 : 'h1000)) >> 3; - assign RAMPC = (PCF - (PCF > 'h2fff ? 'h80000000 : 'h1000)) >> 3; + assign RAMPC = (dut.PCF - (dut.PCF > 'h2fff ? 'h80000000 : 'h1000)) >> 3; logic [63:0] readMask; assign readMask = ((1 << (8*(1 << HSIZE))) - 1) << 8 * HADDR[2:0]; @@ -220,7 +218,7 @@ module testbench_busybear(); `ERROR end - if (((readMask & HRDATA) != (readMask & readRAM)) && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin + if (((readMask & HRDATA) !== (readMask & readRAM)) && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin $display("warning %0t ps, instr %0d: HRDATA does not equal readRAM: %x, %x from address %x, %x", $time, instrs, HRDATA, readRAM, HADDR, HSIZE); warningCount += 1; `ERROR @@ -311,7 +309,7 @@ module testbench_busybear(); `CHECK_CSR2(MTVAL, `CSRM) `CHECK_CSR(MTVEC) //`CHECK_CSR2(PMPADDR0, `CSRM) - //`CHECK_CSR2(PMPCFG0, `CSRM) + //`CHECK_CSR2(PMdut.PCFG0, `CSRM) `CHECK_CSR2(SATP, `CSRS) `CHECK_CSR2(SCAUSE, `CSRS) `CHECK_CSR(SCOUNTEREN) @@ -325,9 +323,8 @@ module testbench_busybear(); logic speculative; initial begin speculative = 0; - speculative = 0; end - logic [63:0] lastInstrF, lastPC, lastPC2; + logic [63:0] lastCheckInstrF, lastPC, lastPC2; string PCtextW, PCtext2W; logic [31:0] InstrWExpected; @@ -363,27 +360,12 @@ module testbench_busybear(); end logic [31:0] InstrMask; logic forcedInstr; - always @(PCF) begin - - if (PCF >= 'h80000000 && PCF <= 'h87FFFFFF) begin - readInstrF = RAM[RAMPC] >> PCF[2:1] * 16; - if (PCF[2:1] == 2'b11) begin - readInstrF |= RAM[RAMPC+1] << 16; - end - end - - if (PCF >= 'h1000 && PCF <= 'h2FFF) begin - readInstrF = bootram[RAMPC] >> PCF[2:1] * 16; - if (PCF[2:1] == 2'b11) begin - readInstrF |= bootram[RAMPC+1] << 16; - end - end - - lastInstrF = InstrF; - lastPC <= PCF; + always @(dut.PCF) begin + lastCheckInstrF = CheckInstrF; + lastPC <= dut.PCF; lastPC2 <= lastPC; - if (speculative && ~equal(lastPC,pcExpected,3)) begin - speculative = ~equal(PCF,pcExpected,3); + if (speculative && (lastPC != pcExpected)) begin + speculative = ~equal(dut.PCF,pcExpected,3); end else begin if($feof(data_file_PC)) begin @@ -395,17 +377,17 @@ module testbench_busybear(); scan_file_PC = $fscanf(data_file_PC, "%s\n", PCtext2); PCtext = {PCtext, " ", PCtext2}; end - scan_file_PC = $fscanf(data_file_PC, "%x\n", InstrF); - if(InstrF[6:0] == 7'b1010011) begin // for now, NOP out any float instrs - InstrF = 32'b0010011; - $display("warning: NOPing out %s at PC=%0x", PCtext, PCF); + scan_file_PC = $fscanf(data_file_PC, "%x\n", CheckInstrF); + if(CheckInstrF[6:0] == 7'b1010011) begin // for now, NOP out any float instrs + CheckInstrF = 32'b0010011; + $display("warning: NOPing out %s at PC=%0x", PCtext, dut.PCF); warningCount += 1; forcedInstr = 1; end else begin - if(InstrF[28:27] != 2'b11 && InstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD - InstrF = {12'b0, InstrF[19:7], 7'b0000011}; - $display("warning: replacing AMO instr %s at PC=%0x with ld", PCtext, PCF); + if(CheckInstrF[28:27] != 2'b11 && CheckInstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD + CheckInstrF = {12'b0, CheckInstrF[19:7], 7'b0000011}; + $display("warning: replacing AMO instr %s at PC=%0x with ld", PCtext, dut.PCF); warningCount += 1; forcedInstr = 1; end @@ -422,7 +404,7 @@ module testbench_busybear(); end instrs += 1; // are we at a branch/jump? - casex (lastInstrF[31:0]) + casex (lastCheckInstrF[31:0]) 32'b00000000001000000000000001110011, // URET 32'b00010000001000000000000001110011, // SRET 32'b00110000001000000000000001110011, // MRET @@ -443,14 +425,14 @@ module testbench_busybear(); endcase //check things! - if ((~speculative) && (~equal(PCF,pcExpected,3))) begin - $display("%0t ps, instr %0d: PC does not equal PC expected: %x, %x", $time, instrs, PCF, pcExpected); + if ((~speculative) && (~equal(dut.PCF,pcExpected,3))) begin + $display("%0t ps, instr %0d: PC does not equal PC expected: %x, %x", $time, instrs, dut.PCF, pcExpected); `ERROR end - InstrMask = InstrF[1:0] == 2'b11 ? 32'hFFFFFFFF : 32'h0000FFFF; - if ((~forcedInstr) && (~speculative) && ((InstrMask & readInstrF) != (InstrMask & InstrF))) begin - $display("%0t ps, instr %0d: readInstrF does not equal InstrF: %x, %x, PC: %x", $time, instrs, readInstrF, InstrF, PCF); - warningCount += 1; + InstrMask = CheckInstrF[1:0] == 2'b11 ? 32'hFFFFFFFF : 32'h0000FFFF; + if ((~forcedInstr) && (~speculative) && ((InstrMask & dut.InstrF) !== (InstrMask & CheckInstrF))) begin + $display("%0t ps, instr %0d: InstrF does not equal CheckInstrF: %x, %x, PC: %x", $time, instrs, dut.InstrF, CheckInstrF, dut.PCF); + `ERROR end end end @@ -458,7 +440,7 @@ module testbench_busybear(); // Track names of instructions string InstrFName, InstrDName, InstrEName, InstrMName, InstrWName; logic [31:0] InstrW; - instrNameDecTB dec(InstrF, InstrFName); + instrNameDecTB dec(dut.InstrF, InstrFName); instrTrackerTB it(clk, reset, dut.hart.ieu.dp.FlushE, dut.hart.ifu.InstrD, dut.hart.ifu.InstrE, dut.hart.ifu.InstrM, InstrW, From 17715085ba8c1090681678b1931768d735b42284 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Sun, 28 Feb 2021 20:43:57 +0000 Subject: [PATCH 29/46] busybear: start preloading bootmem --- wally-pipelined/regression/wally-busybear.do | 7 +++++-- wally-pipelined/src/uncore/adrdec.sv | 3 ++- wally-pipelined/src/uncore/imem.sv | 14 +++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index 74f6a9d4b..5ff685e10 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -33,8 +33,10 @@ vlog +incdir+../config/busybear ../testbench/*.sv ../src/*/*.sv -suppress 2583 # remove +acc flag for faster sim during regressions if there is no need to access internal signals vopt +acc work.testbench_busybear -o workopt vsim workopt -suppress 8852,12070 -mem load -startaddress 0 -endaddress 1024 -filltype value -fillradix hex -filldata 0 /testbench_busybear/bootram -mem load -startaddress 0 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/bootram +mem load -startaddress 0 -endaddress 2048 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/uncore/bootdtim/RAM +mem load -startaddress 512 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/dut/uncore/bootdtim/RAM +mem load -startaddress 0 -endaddress 2048 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/imem/bootram +mem load -startaddress 512 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/dut/imem/bootram mem load -startaddress 0 -endaddress 16777216 -filltype value -fillradix hex -filldata 0 /testbench_busybear/RAM mem load -startaddress 0 -i "/courses/e190ax/busybear_boot/ram.txt" -format hex /testbench_busybear/RAM @@ -49,6 +51,7 @@ add wave -hex /testbench_busybear/PCtext add wave -hex /testbench_busybear/pcExpected add wave -hex /testbench_busybear/dut/hart/ifu/PCF add wave -hex /testbench_busybear/dut/hart/ifu/InstrF +add wave -hex /testbench_busybear/dut/InstrF add wave /testbench_busybear/CheckInstrF add wave /testbench_busybear/lastCheckInstrF add wave /testbench_busybear/speculative diff --git a/wally-pipelined/src/uncore/adrdec.sv b/wally-pipelined/src/uncore/adrdec.sv index 7e4423ec1..31e18d1e3 100644 --- a/wally-pipelined/src/uncore/adrdec.sv +++ b/wally-pipelined/src/uncore/adrdec.sv @@ -38,7 +38,8 @@ module adrdec ( // then anything address between 0x04002000 and 0x04002FFF should match (HSEL=1) assign match = (HADDR ~^ Base) | Range; - assign HSEL = &match; + //assign HSEL = &match; + assign HSEL = (HADDR >= Base) && (HADDR <= Base + Range); endmodule diff --git a/wally-pipelined/src/uncore/imem.sv b/wally-pipelined/src/uncore/imem.sv index 86d235564..be42d0afb 100644 --- a/wally-pipelined/src/uncore/imem.sv +++ b/wally-pipelined/src/uncore/imem.sv @@ -32,7 +32,8 @@ module imem ( output logic InstrAccessFaultF); /* verilator lint_off UNDRIVEN */ - logic [`XLEN-1:0] RAM[0:65535]; + logic [`XLEN-1:0] RAM[`TIMBASE>>(1+`XLEN/32):(`TIMRANGE-`TIMBASE)>>(1+`XLEN/32)]; + logic [`XLEN-1:0] bootram[`BOOTTIMBASE>>(1+`XLEN/32):(`BOOTTIMRANGE-`BOOTTIMBASE)>>(1+`XLEN/32)]; /* verilator lint_on UNDRIVEN */ logic [15:0] adrbits; logic [`XLEN-1:0] rd; @@ -43,13 +44,15 @@ module imem ( else assign adrbits = AdrF[18:3]; endgenerate - assign #2 rd = RAM[adrbits]; // word aligned + //assign #2 rd = RAM[adrbits]; // word aligned + assign #2 rd = (AdrF < (`TIMBASE >> 1)) ? bootram[adrbits] : RAM[adrbits]; // busybear: 2 memory options // hack right now for unaligned 32-bit instructions // eventually this will need to cause a stall like a cache miss // when the instruction wraps around a cache line // could be optimized to only stall when the instruction wrapping is 32 bits - assign #2 rd2 = RAM[adrbits+1][15:0]; + //assign #2 rd2 = RAM[adrbits+1][15:0]; + assign #2 rd2 = (AdrF < (`TIMBASE >> 1)) ? bootram[adrbits+1][15:0] : RAM[adrbits+1][15:0]; //busybear: 2 memory options generate if (`XLEN==32) begin assign InstrF = AdrF[1] ? {rd2[15:0], rd[31:16]} : rd; @@ -61,11 +64,12 @@ module imem ( end else begin assign InstrF = AdrF[2] ? (AdrF[1] ? {rd2[15:0], rd[63:48]} : rd[63:32]) : (AdrF[1] ? rd[47:16] : rd[31:0]); - if(`TIMBASE==0) begin + /*if(`TIMBASE==0) begin assign InstrAccessFaultF = 0; end else begin assign InstrAccessFaultF = (|AdrF[`XLEN-1:32]) | ~AdrF[31] | (|AdrF[30:16]); // memory mapped to 0x80000000-0x8000FFFF] - end + end*/ + assign InstrAccessFaultF = 0; //busybear: for now, i know we're not doing this end endgenerate endmodule From f11b3108d8ede64a277bcddd9b9746203d17f023 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Mon, 1 Mar 2021 17:45:21 +0000 Subject: [PATCH 30/46] busybear: fix bootram range --- wally-pipelined/config/busybear/wally-config.vh | 2 +- wally-pipelined/regression/wally-busybear.do | 4 ++-- wally-pipelined/src/uncore/adrdec.sv | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/wally-pipelined/config/busybear/wally-config.vh b/wally-pipelined/config/busybear/wally-config.vh index e85ee73d3..90ccc37e9 100644 --- a/wally-pipelined/config/busybear/wally-config.vh +++ b/wally-pipelined/config/busybear/wally-config.vh @@ -64,7 +64,7 @@ `define TIMBASE 32'h80000000 `define TIMRANGE 32'h07FFFFFF `define BOOTTIMBASE 32'h00000000 //only needs to go from 0x1000 to 0x2FFF, extending to a power of 2 -`define BOOTTIMRANGE 32'h00004000 +`define BOOTTIMRANGE 32'h00003FFF `define CLINTBASE 32'h02000000 `define CLINTRANGE 32'h0000BFFF //`define GPIOBASE 32'h10012000 // no GPIO in linux for now diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index 5ff685e10..4f7e42199 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -33,9 +33,9 @@ vlog +incdir+../config/busybear ../testbench/*.sv ../src/*/*.sv -suppress 2583 # remove +acc flag for faster sim during regressions if there is no need to access internal signals vopt +acc work.testbench_busybear -o workopt vsim workopt -suppress 8852,12070 -mem load -startaddress 0 -endaddress 2048 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/uncore/bootdtim/RAM +mem load -startaddress 0 -endaddress 2047 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/uncore/bootdtim/RAM mem load -startaddress 512 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/dut/uncore/bootdtim/RAM -mem load -startaddress 0 -endaddress 2048 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/imem/bootram +mem load -startaddress 0 -endaddress 2047 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/imem/bootram mem load -startaddress 512 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/dut/imem/bootram mem load -startaddress 0 -endaddress 16777216 -filltype value -fillradix hex -filldata 0 /testbench_busybear/RAM mem load -startaddress 0 -i "/courses/e190ax/busybear_boot/ram.txt" -format hex /testbench_busybear/RAM diff --git a/wally-pipelined/src/uncore/adrdec.sv b/wally-pipelined/src/uncore/adrdec.sv index 31e18d1e3..7e4423ec1 100644 --- a/wally-pipelined/src/uncore/adrdec.sv +++ b/wally-pipelined/src/uncore/adrdec.sv @@ -38,8 +38,7 @@ module adrdec ( // then anything address between 0x04002000 and 0x04002FFF should match (HSEL=1) assign match = (HADDR ~^ Base) | Range; - //assign HSEL = &match; - assign HSEL = (HADDR >= Base) && (HADDR <= Base + Range); + assign HSEL = &match; endmodule From b3247eadd262bbffc562c5016734fd14eeb4996e Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Mon, 1 Mar 2021 18:50:42 +0000 Subject: [PATCH 31/46] busybear: more adapting to new memory system --- wally-pipelined/regression/wally-busybear.do | 14 +- wally-pipelined/src/uncore/dtim.sv | 22 +-- wally-pipelined/src/uncore/uncore.sv | 10 +- .../testbench/testbench-busybear.sv | 167 ++++++++---------- 4 files changed, 99 insertions(+), 114 deletions(-) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index 4f7e42199..56d5398ae 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -37,8 +37,10 @@ mem load -startaddress 0 -endaddress 2047 -filltype value -fillradix hex -fillda mem load -startaddress 512 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/dut/uncore/bootdtim/RAM mem load -startaddress 0 -endaddress 2047 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/imem/bootram mem load -startaddress 512 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/dut/imem/bootram -mem load -startaddress 0 -endaddress 16777216 -filltype value -fillradix hex -filldata 0 /testbench_busybear/RAM -mem load -startaddress 0 -i "/courses/e190ax/busybear_boot/ram.txt" -format hex /testbench_busybear/RAM +mem load -startaddress 268435456 -endaddress 285212671 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/uncore/maindtim/RAM +mem load -startaddress 268435456 -i "/courses/e190ax/busybear_boot/ram.txt" -format hex /testbench_busybear/dut/uncore/maindtim/RAM +mem load -startaddress 268435456 -endaddress 285212671 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/imem/RAM +mem load -startaddress 268435456 -i "/courses/e190ax/busybear_boot/ram.txt" -format hex /testbench_busybear/dut/imem/RAM view wave @@ -57,7 +59,12 @@ add wave /testbench_busybear/lastCheckInstrF add wave /testbench_busybear/speculative add wave /testbench_busybear/lastPC2 add wave -divider -add wave -hex /testbench_busybear/readRAM +add wave /testbench_busybear/dut/uncore/HSELBootTim +add wave /testbench_busybear/dut/uncore/HSELTim +add wave /testbench_busybear/dut/uncore/HREADTim +add wave /testbench_busybear/dut/uncore/maindtim/HREADTim0 +add wave /testbench_busybear/dut/uncore/HREADYTim +add wave /testbench_busybear/dut/uncore/HADDR #add wave -hex /testbench_busybear/dut/hart/priv/csr/MTVEC_REG #add wave -hex /testbench_busybear/dut/hart/priv/csr/MSTATUS_REG #add wave -hex /testbench_busybear/dut/hart/priv/csr/SCOUNTEREN_REG @@ -73,6 +80,7 @@ add wave -hex /testbench_busybear/dut/hart/MemRWM[1] add wave -hex /testbench_busybear/HWDATA add wave -hex /testbench_busybear/HRDATA add wave -hex /testbench_busybear/HADDR +add wave -hex /testbench_busybear/readAdrExpected add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[1] add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[2] add wave -hex /testbench_busybear/dut/hart/ieu/dp/regf/rf[3] diff --git a/wally-pipelined/src/uncore/dtim.sv b/wally-pipelined/src/uncore/dtim.sv index 009fb03d2..cf7b39cc4 100644 --- a/wally-pipelined/src/uncore/dtim.sv +++ b/wally-pipelined/src/uncore/dtim.sv @@ -28,7 +28,7 @@ module dtim #(parameter BASE=0, RANGE = 65535) ( input logic HCLK, HRESETn, input logic [1:0] MemRWtim, - input logic [18:0] HADDR, + input logic [31:0] HADDR, input logic [`XLEN-1:0] HWDATA, input logic HSELTim, output logic [`XLEN-1:0] HREADTim, @@ -36,8 +36,8 @@ module dtim #(parameter BASE=0, RANGE = 65535) ( ); //logic [`XLEN-1:0] RAM[0:65535]; - logic [`XLEN-1:0] RAM[BASE>>(1+`XLEN/32):(RANGE-BASE)>>1+(`XLEN/32)]; - logic [18:0] HWADDR; + logic [`XLEN-1:0] RAM[BASE>>(1+`XLEN/32):(RANGE+BASE)>>1+(`XLEN/32)]; + logic [31:0] HWADDR; logic [`XLEN-1:0] HREADTim0; // logic [`XLEN-1:0] write; @@ -83,21 +83,21 @@ module dtim #(parameter BASE=0, RANGE = 65535) ( generate if (`XLEN == 64) begin // always_ff @(negedge HCLK) -// if (memwrite) RAM[HWADDR[17:3]] <= HWDATA; +// if (memwrite) RAM[HWADDR[31:3]] <= HWDATA; always_ff @(posedge HCLK) begin - //if (memwrite) RAM[HADDR[17:3]] <= HWDATA; + //if (memwrite) RAM[HADDR[31:3]] <= HWDATA; HWADDR <= HADDR; - HREADTim0 <= RAM[HADDR[17:3]]; - if (memwrite && HREADYTim) RAM[HWADDR[17:3]] <= HWDATA; + HREADTim0 <= RAM[HADDR[31:3]]; + if (memwrite && HREADYTim) RAM[HWADDR[31:3]] <= HWDATA; end end else begin // always_ff @(negedge HCLK) -// if (memwrite) RAM[HWADDR[17:2]] <= HWDATA; +// if (memwrite) RAM[HWADDR[31:2]] <= HWDATA; always_ff @(posedge HCLK) begin - //if (memwrite) RAM[HADDR[17:2]] <= HWDATA; + //if (memwrite) RAM[HADDR[31:2]] <= HWDATA; HWADDR <= HADDR; - HREADTim0 <= RAM[HADDR[17:2]]; - if (memwrite && HREADYTim) RAM[HWADDR[17:2]] <= HWDATA; + HREADTim0 <= RAM[HADDR[31:2]]; + if (memwrite && HREADYTim) RAM[HWADDR[31:2]] <= HWDATA; end end endgenerate diff --git a/wally-pipelined/src/uncore/uncore.sv b/wally-pipelined/src/uncore/uncore.sv index ab66af9f1..bcb60271a 100644 --- a/wally-pipelined/src/uncore/uncore.sv +++ b/wally-pipelined/src/uncore/uncore.sv @@ -95,8 +95,8 @@ module uncore ( subwordwrite sww(.*); // tightly integrated memory - dtim #(.BASE(`TIMBASE), .RANGE(`TIMRANGE)) maindtim (.HADDR(HADDR[18:0]), .*); - dtim #(.BASE(`BOOTTIMBASE), .RANGE(`BOOTTIMRANGE)) bootdtim (.HADDR(HADDR[18:0]), .MemRWtim(MemRWboottim), + dtim #(.BASE(`TIMBASE), .RANGE(`TIMRANGE)) maindtim (.*); + dtim #(.BASE(`BOOTTIMBASE), .RANGE(`BOOTTIMRANGE)) bootdtim (.MemRWtim(MemRWboottim), .HSELTim(HSELBootTim), .HREADTim(HREADBootTim), .HRESPTim(HRESPBootTim), .HREADYTim(HREADYBootTim), .*); // memory-mapped I/O peripherals @@ -110,11 +110,11 @@ module uncore ( // AHB Read Multiplexer assign HRDATA = ({`XLEN{HSELTim}} & HREADTim) | ({`XLEN{HSELCLINT}} & HREADCLINT) | ({`XLEN{HSELBootTim}} & HREADBootTim) | ({`XLEN{HSELUART}} & HREADUART); - assign HRESP = HSELBootTim & HRESPBootTim | HSELTim & HRESPTim | HSELCLINT & HRESPCLINT | HSELGPIO & HRESPGPIO | HSELUART & HRESPUART; - assign HREADY = HSELBootTim & HREADYBootTim | HSELTim & HREADYTim | HSELCLINT & HREADYCLINT | HSELGPIO & HREADYGPIO | HSELUART & HREADYUART; + assign HRESP = HSELBootTim & HRESPBootTim | HSELTim & HRESPTim | HSELCLINT & HRESPCLINT | HSELUART & HRESPUART; + assign HREADY = HSELBootTim & HREADYBootTim | HSELTim & HREADYTim | HSELCLINT & HREADYCLINT | HSELUART & HREADYUART; // Faults - assign DataAccessFaultM = ~(HSELTim | HSELCLINT | HSELGPIO | HSELUART); + assign DataAccessFaultM = ~(HSELTim | HSELCLINT | HSELUART); endmodule diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 7a59cc521..396388393 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -174,52 +174,27 @@ module testbench_busybear(); // In the linux boot, the processor spends the first ~5 instructions in // bootram, before jr jumps to main RAM - logic [`XLEN-1:0] RAM[('h8000000 >> 3):0]; - logic [`XLEN-1:0] bootram[('h2000 >> 3):0]; - logic [`XLEN-1:0] readRAM; - integer RAMAdr, RAMPC; - assign RAMAdr = (HADDR - (HADDR > 'h2fff ? 'h80000000 : 'h1000)) >> 3; - assign RAMPC = (dut.PCF - (dut.PCF > 'h2fff ? 'h80000000 : 'h1000)) >> 3; logic [63:0] readMask; assign readMask = ((1 << (8*(1 << HSIZE))) - 1) << 8 * HADDR[2:0]; logic [`XLEN-1:0] readAdrExpected; - always @(HWDATA or HADDR or HSIZE or HWRITE or dut.hart.MemRWM[1]) begin - - if ((HWRITE || dut.hart.MemRWM[1]) && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin - if (HWRITE) begin - RAM[RAMAdr] = (RAM[RAMAdr] & (~readMask)) | ((HWDATA << 8 * HADDR[2:0]) & readMask); // aligns write data for correct subword size - end else begin - readRAM = RAM[RAMAdr] & readMask; - end - end - - if ((HWRITE || dut.hart.MemRWM[1]) && (HADDR >= 'h1000 && HADDR <= 'h2FFF)) begin - if (HWRITE) begin - bootram[RAMAdr] = (bootram[RAMAdr] & (~readMask)) | ((HWDATA << 8 * HADDR[2:0]) & readMask); - end else begin - readRAM = bootram[RAMAdr] & readMask; - end - end - end - always @(dut.hart.MemRWM[1] or HADDR) begin - if (dut.hart.MemRWM[1]) begin + if (dut.hart.MemRWM[1] && HADDR != dut.PCF) begin if($feof(data_file_memR)) begin $display("no more memR data to read"); `ERROR end scan_file_memR = $fscanf(data_file_memR, "%x\n", readAdrExpected); scan_file_memR = $fscanf(data_file_memR, "%x\n", HRDATA); - #1; + #2; if (~equal(HADDR,readAdrExpected,4)) begin $display("%0t ps, instr %0d: HADDR does not equal readAdrExpected: %x, %x", $time, instrs, HADDR, readAdrExpected); `ERROR end - if (((readMask & HRDATA) !== (readMask & readRAM)) && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin - $display("warning %0t ps, instr %0d: HRDATA does not equal readRAM: %x, %x from address %x, %x", $time, instrs, HRDATA, readRAM, HADDR, HSIZE); + if (((readMask & HRDATA) !== (readMask & dut.HRDATA)) && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin + $display("warning %0t ps, instr %0d: HRDATA does not equal dut.HRDATA: %x, %x from address %x, %x", $time, instrs, HRDATA, dut.HRDATA, HADDR, HSIZE); warningCount += 1; `ERROR end @@ -360,79 +335,81 @@ module testbench_busybear(); end logic [31:0] InstrMask; logic forcedInstr; - always @(dut.PCF) begin - lastCheckInstrF = CheckInstrF; - lastPC <= dut.PCF; - lastPC2 <= lastPC; - if (speculative && (lastPC != pcExpected)) begin - speculative = ~equal(dut.PCF,pcExpected,3); - end - else begin - if($feof(data_file_PC)) begin - $display("no more PC data to read"); - `ERROR - end - scan_file_PC = $fscanf(data_file_PC, "%s\n", PCtext); - if (PCtext != "ret" && PCtext != "fence" && PCtext != "nop" && PCtext != "mret" && PCtext != "sfence.vma" && PCtext != "unimp") begin - scan_file_PC = $fscanf(data_file_PC, "%s\n", PCtext2); - PCtext = {PCtext, " ", PCtext2}; - end - scan_file_PC = $fscanf(data_file_PC, "%x\n", CheckInstrF); - if(CheckInstrF[6:0] == 7'b1010011) begin // for now, NOP out any float instrs - CheckInstrF = 32'b0010011; - $display("warning: NOPing out %s at PC=%0x", PCtext, dut.PCF); - warningCount += 1; - forcedInstr = 1; + always @(dut.PCF or dut.hart.ifu.InstrF) begin + if (~reset && dut.hart.ifu.InstrF !== {32{1'bx}}) begin + lastCheckInstrF = CheckInstrF; + lastPC <= dut.PCF; + lastPC2 <= lastPC; + if (speculative && (lastPC != pcExpected)) begin + speculative = ~equal(dut.PCF,pcExpected,3); end else begin - if(CheckInstrF[28:27] != 2'b11 && CheckInstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD - CheckInstrF = {12'b0, CheckInstrF[19:7], 7'b0000011}; - $display("warning: replacing AMO instr %s at PC=%0x with ld", PCtext, dut.PCF); + if($feof(data_file_PC)) begin + $display("no more PC data to read"); + `ERROR + end + scan_file_PC = $fscanf(data_file_PC, "%s\n", PCtext); + if (PCtext != "ret" && PCtext != "fence" && PCtext != "nop" && PCtext != "mret" && PCtext != "sfence.vma" && PCtext != "unimp") begin + scan_file_PC = $fscanf(data_file_PC, "%s\n", PCtext2); + PCtext = {PCtext, " ", PCtext2}; + end + scan_file_PC = $fscanf(data_file_PC, "%x\n", CheckInstrF); + if(CheckInstrF[6:0] == 7'b1010011) begin // for now, NOP out any float instrs + CheckInstrF = 32'b0010011; + $display("warning: NOPing out %s at PC=%0x", PCtext, dut.PCF); warningCount += 1; forcedInstr = 1; end else begin - forcedInstr = 0; + if(CheckInstrF[28:27] != 2'b11 && CheckInstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD + CheckInstrF = {12'b0, CheckInstrF[19:7], 7'b0000011}; + $display("warning: replacing AMO instr %s at PC=%0x with ld", PCtext, dut.PCF); + warningCount += 1; + forcedInstr = 1; + end + else begin + forcedInstr = 0; + end end - end - // then expected PC value - scan_file_PC = $fscanf(data_file_PC, "%x\n", pcExpected); - if (instrs <= 10 || (instrs <= 100 && instrs % 10 == 0) || - (instrs <= 1000 && instrs % 100 == 0) || (instrs <= 10000 && instrs % 1000 == 0) || - (instrs <= 100000 && instrs % 10000 == 0) || (instrs <= 1000000 && instrs % 100000 == 0)) begin - $display("loaded %0d instructions", instrs); - end - instrs += 1; - // are we at a branch/jump? - casex (lastCheckInstrF[31:0]) - 32'b00000000001000000000000001110011, // URET - 32'b00010000001000000000000001110011, // SRET - 32'b00110000001000000000000001110011, // MRET - 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1101111, // JAL - 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1100111, // JALR - 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1100011, // B - 32'bXXXXXXXXXXXXXXXX110XXXXXXXXXXX01, // C.BEQZ - 32'bXXXXXXXXXXXXXXXX111XXXXXXXXXXX01, // C.BNEZ - 32'bXXXXXXXXXXXXXXXX101XXXXXXXXXXX01: // C.J - speculative = 1; - 32'bXXXXXXXXXXXXXXXX1001000000000010: // C.EBREAK: - speculative = 0; // tbh don't really know what should happen here - 32'bXXXXXXXXXXXXXXXX1000XXXXX0000010, // C.JR - 32'bXXXXXXXXXXXXXXXX1001XXXXX0000010: // C.JALR //this is RV64 only so no C.JAL - speculative = 1; - default: - speculative = 0; - endcase + // then expected PC value + scan_file_PC = $fscanf(data_file_PC, "%x\n", pcExpected); + if (instrs <= 10 || (instrs <= 100 && instrs % 10 == 0) || + (instrs <= 1000 && instrs % 100 == 0) || (instrs <= 10000 && instrs % 1000 == 0) || + (instrs <= 100000 && instrs % 10000 == 0) || (instrs <= 1000000 && instrs % 100000 == 0)) begin + $display("loaded %0d instructions", instrs); + end + instrs += 1; + // are we at a branch/jump? + casex (lastCheckInstrF[31:0]) + 32'b00000000001000000000000001110011, // URET + 32'b00010000001000000000000001110011, // SRET + 32'b00110000001000000000000001110011, // MRET + 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1101111, // JAL + 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1100111, // JALR + 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1100011, // B + 32'bXXXXXXXXXXXXXXXX110XXXXXXXXXXX01, // C.BEQZ + 32'bXXXXXXXXXXXXXXXX111XXXXXXXXXXX01, // C.BNEZ + 32'bXXXXXXXXXXXXXXXX101XXXXXXXXXXX01: // C.J + speculative = 1; + 32'bXXXXXXXXXXXXXXXX1001000000000010: // C.EBREAK: + speculative = 0; // tbh don't really know what should happen here + 32'bXXXXXXXXXXXXXXXX1000XXXXX0000010, // C.JR + 32'bXXXXXXXXXXXXXXXX1001XXXXX0000010: // C.JALR //this is RV64 only so no C.JAL + speculative = 1; + default: + speculative = 0; + endcase - //check things! - if ((~speculative) && (~equal(dut.PCF,pcExpected,3))) begin - $display("%0t ps, instr %0d: PC does not equal PC expected: %x, %x", $time, instrs, dut.PCF, pcExpected); - `ERROR - end - InstrMask = CheckInstrF[1:0] == 2'b11 ? 32'hFFFFFFFF : 32'h0000FFFF; - if ((~forcedInstr) && (~speculative) && ((InstrMask & dut.InstrF) !== (InstrMask & CheckInstrF))) begin - $display("%0t ps, instr %0d: InstrF does not equal CheckInstrF: %x, %x, PC: %x", $time, instrs, dut.InstrF, CheckInstrF, dut.PCF); - `ERROR + //check things! + if ((~speculative) && (~equal(dut.PCF,pcExpected,3))) begin + $display("%0t ps, instr %0d: PC does not equal PC expected: %x, %x", $time, instrs, dut.PCF, pcExpected); + `ERROR + end + InstrMask = CheckInstrF[1:0] == 2'b11 ? 32'hFFFFFFFF : 32'h0000FFFF; + if ((~forcedInstr) && (~speculative) && ((InstrMask & dut.hart.ifu.InstrF) !== (InstrMask & CheckInstrF))) begin + $display("%0t ps, instr %0d: InstrF does not equal CheckInstrF: %x, %x, PC: %x", $time, instrs, dut.hart.ifu.InstrF, CheckInstrF, dut.PCF); + `ERROR + end end end end @@ -440,7 +417,7 @@ module testbench_busybear(); // Track names of instructions string InstrFName, InstrDName, InstrEName, InstrMName, InstrWName; logic [31:0] InstrW; - instrNameDecTB dec(dut.InstrF, InstrFName); + instrNameDecTB dec(dut.hart.ifu.InstrF, InstrFName); instrTrackerTB it(clk, reset, dut.hart.ieu.dp.FlushE, dut.hart.ifu.InstrD, dut.hart.ifu.InstrE, dut.hart.ifu.InstrM, InstrW, From b6dc0a87071e8e067976482d412d06be66372775 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Mon, 1 Mar 2021 19:08:35 +0000 Subject: [PATCH 32/46] busybear: only check pc when it actually changes --- .../testbench/testbench-busybear.sv | 134 +++++++++--------- 1 file changed, 69 insertions(+), 65 deletions(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index 396388393..eb2d01f2c 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -335,82 +335,86 @@ module testbench_busybear(); end logic [31:0] InstrMask; logic forcedInstr; + logic [63:0] lastPCF; always @(dut.PCF or dut.hart.ifu.InstrF) begin if (~reset && dut.hart.ifu.InstrF !== {32{1'bx}}) begin - lastCheckInstrF = CheckInstrF; - lastPC <= dut.PCF; - lastPC2 <= lastPC; - if (speculative && (lastPC != pcExpected)) begin - speculative = ~equal(dut.PCF,pcExpected,3); - end - else begin - if($feof(data_file_PC)) begin - $display("no more PC data to read"); - `ERROR - end - scan_file_PC = $fscanf(data_file_PC, "%s\n", PCtext); - if (PCtext != "ret" && PCtext != "fence" && PCtext != "nop" && PCtext != "mret" && PCtext != "sfence.vma" && PCtext != "unimp") begin - scan_file_PC = $fscanf(data_file_PC, "%s\n", PCtext2); - PCtext = {PCtext, " ", PCtext2}; - end - scan_file_PC = $fscanf(data_file_PC, "%x\n", CheckInstrF); - if(CheckInstrF[6:0] == 7'b1010011) begin // for now, NOP out any float instrs - CheckInstrF = 32'b0010011; - $display("warning: NOPing out %s at PC=%0x", PCtext, dut.PCF); - warningCount += 1; - forcedInstr = 1; + if (dut.PCF !== lastPCF) begin + lastCheckInstrF = CheckInstrF; + lastPC <= dut.PCF; + lastPC2 <= lastPC; + if (speculative && (lastPC != pcExpected)) begin + speculative = ~equal(dut.PCF,pcExpected,3); end else begin - if(CheckInstrF[28:27] != 2'b11 && CheckInstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD - CheckInstrF = {12'b0, CheckInstrF[19:7], 7'b0000011}; - $display("warning: replacing AMO instr %s at PC=%0x with ld", PCtext, dut.PCF); + if($feof(data_file_PC)) begin + $display("no more PC data to read"); + `ERROR + end + scan_file_PC = $fscanf(data_file_PC, "%s\n", PCtext); + if (PCtext != "ret" && PCtext != "fence" && PCtext != "nop" && PCtext != "mret" && PCtext != "sfence.vma" && PCtext != "unimp") begin + scan_file_PC = $fscanf(data_file_PC, "%s\n", PCtext2); + PCtext = {PCtext, " ", PCtext2}; + end + scan_file_PC = $fscanf(data_file_PC, "%x\n", CheckInstrF); + if(CheckInstrF[6:0] == 7'b1010011) begin // for now, NOP out any float instrs + CheckInstrF = 32'b0010011; + $display("warning: NOPing out %s at PC=%0x", PCtext, dut.PCF); warningCount += 1; forcedInstr = 1; end else begin - forcedInstr = 0; + if(CheckInstrF[28:27] != 2'b11 && CheckInstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD + CheckInstrF = {12'b0, CheckInstrF[19:7], 7'b0000011}; + $display("warning: replacing AMO instr %s at PC=%0x with ld", PCtext, dut.PCF); + warningCount += 1; + forcedInstr = 1; + end + else begin + forcedInstr = 0; + end + end + // then expected PC value + scan_file_PC = $fscanf(data_file_PC, "%x\n", pcExpected); + if (instrs <= 10 || (instrs <= 100 && instrs % 10 == 0) || + (instrs <= 1000 && instrs % 100 == 0) || (instrs <= 10000 && instrs % 1000 == 0) || + (instrs <= 100000 && instrs % 10000 == 0) || (instrs <= 1000000 && instrs % 100000 == 0)) begin + $display("loaded %0d instructions", instrs); + end + instrs += 1; + // are we at a branch/jump? + casex (lastCheckInstrF[31:0]) + 32'b00000000001000000000000001110011, // URET + 32'b00010000001000000000000001110011, // SRET + 32'b00110000001000000000000001110011, // MRET + 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1101111, // JAL + 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1100111, // JALR + 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1100011, // B + 32'bXXXXXXXXXXXXXXXX110XXXXXXXXXXX01, // C.BEQZ + 32'bXXXXXXXXXXXXXXXX111XXXXXXXXXXX01, // C.BNEZ + 32'bXXXXXXXXXXXXXXXX101XXXXXXXXXXX01: // C.J + speculative = 1; + 32'bXXXXXXXXXXXXXXXX1001000000000010: // C.EBREAK: + speculative = 0; // tbh don't really know what should happen here + 32'bXXXXXXXXXXXXXXXX1000XXXXX0000010, // C.JR + 32'bXXXXXXXXXXXXXXXX1001XXXXX0000010: // C.JALR //this is RV64 only so no C.JAL + speculative = 1; + default: + speculative = 0; + endcase + + //check things! + if ((~speculative) && (~equal(dut.PCF,pcExpected,3))) begin + $display("%0t ps, instr %0d: PC does not equal PC expected: %x, %x", $time, instrs, dut.PCF, pcExpected); + `ERROR + end + InstrMask = CheckInstrF[1:0] == 2'b11 ? 32'hFFFFFFFF : 32'h0000FFFF; + if ((~forcedInstr) && (~speculative) && ((InstrMask & dut.hart.ifu.InstrF) !== (InstrMask & CheckInstrF))) begin + $display("%0t ps, instr %0d: InstrF does not equal CheckInstrF: %x, %x, PC: %x", $time, instrs, dut.hart.ifu.InstrF, CheckInstrF, dut.PCF); + `ERROR end end - // then expected PC value - scan_file_PC = $fscanf(data_file_PC, "%x\n", pcExpected); - if (instrs <= 10 || (instrs <= 100 && instrs % 10 == 0) || - (instrs <= 1000 && instrs % 100 == 0) || (instrs <= 10000 && instrs % 1000 == 0) || - (instrs <= 100000 && instrs % 10000 == 0) || (instrs <= 1000000 && instrs % 100000 == 0)) begin - $display("loaded %0d instructions", instrs); - end - instrs += 1; - // are we at a branch/jump? - casex (lastCheckInstrF[31:0]) - 32'b00000000001000000000000001110011, // URET - 32'b00010000001000000000000001110011, // SRET - 32'b00110000001000000000000001110011, // MRET - 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1101111, // JAL - 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1100111, // JALR - 32'bXXXXXXXXXXXXXXXXXXXXXXXXX1100011, // B - 32'bXXXXXXXXXXXXXXXX110XXXXXXXXXXX01, // C.BEQZ - 32'bXXXXXXXXXXXXXXXX111XXXXXXXXXXX01, // C.BNEZ - 32'bXXXXXXXXXXXXXXXX101XXXXXXXXXXX01: // C.J - speculative = 1; - 32'bXXXXXXXXXXXXXXXX1001000000000010: // C.EBREAK: - speculative = 0; // tbh don't really know what should happen here - 32'bXXXXXXXXXXXXXXXX1000XXXXX0000010, // C.JR - 32'bXXXXXXXXXXXXXXXX1001XXXXX0000010: // C.JALR //this is RV64 only so no C.JAL - speculative = 1; - default: - speculative = 0; - endcase - - //check things! - if ((~speculative) && (~equal(dut.PCF,pcExpected,3))) begin - $display("%0t ps, instr %0d: PC does not equal PC expected: %x, %x", $time, instrs, dut.PCF, pcExpected); - `ERROR - end - InstrMask = CheckInstrF[1:0] == 2'b11 ? 32'hFFFFFFFF : 32'h0000FFFF; - if ((~forcedInstr) && (~speculative) && ((InstrMask & dut.hart.ifu.InstrF) !== (InstrMask & CheckInstrF))) begin - $display("%0t ps, instr %0d: InstrF does not equal CheckInstrF: %x, %x, PC: %x", $time, instrs, dut.hart.ifu.InstrF, CheckInstrF, dut.PCF); - `ERROR - end end + lastPCF = dut.PCF; end end From 923489fe167f2e054f3833a1ff3c19eddc8c44c0 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Mon, 1 Mar 2021 20:56:04 +0000 Subject: [PATCH 33/46] busybear: probably discovered bug in ahb code --- wally-pipelined/regression/wally-busybear.do | 10 +++++++++- wally-pipelined/src/uncore/imem.sv | 10 +++++----- wally-pipelined/testbench/testbench-busybear.sv | 12 ++++++++---- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index 56d5398ae..69de98461 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -59,12 +59,20 @@ add wave /testbench_busybear/lastCheckInstrF add wave /testbench_busybear/speculative add wave /testbench_busybear/lastPC2 add wave -divider +add wave -divider add wave /testbench_busybear/dut/uncore/HSELBootTim add wave /testbench_busybear/dut/uncore/HSELTim add wave /testbench_busybear/dut/uncore/HREADTim add wave /testbench_busybear/dut/uncore/maindtim/HREADTim0 add wave /testbench_busybear/dut/uncore/HREADYTim +add wave -divider +add wave /testbench_busybear/dut/uncore/HREADBootTim +add wave /testbench_busybear/dut/uncore/bootdtim/HREADTim0 +add wave /testbench_busybear/dut/uncore/HREADYBootTim add wave /testbench_busybear/dut/uncore/HADDR +add wave /testbench_busybear/dut/uncore/HRESP +add wave /testbench_busybear/dut/uncore/HREADY +add wave /testbench_busybear/dut/uncore/HRDATA #add wave -hex /testbench_busybear/dut/hart/priv/csr/MTVEC_REG #add wave -hex /testbench_busybear/dut/hart/priv/csr/MSTATUS_REG #add wave -hex /testbench_busybear/dut/hart/priv/csr/SCOUNTEREN_REG @@ -140,7 +148,7 @@ add wave /testbench_busybear/InstrWName #add wave -hex /testbench_busybear/dut/hart/ieu/dp/RdW #add wave -divider ##add ww -#add wave -hex -r /testbench_busybear/* +add wave -hex -r /testbench_busybear/* # #-- Set Wave Output Items #TreeUpdate [SetDefaultTree] diff --git a/wally-pipelined/src/uncore/imem.sv b/wally-pipelined/src/uncore/imem.sv index be42d0afb..2711277e7 100644 --- a/wally-pipelined/src/uncore/imem.sv +++ b/wally-pipelined/src/uncore/imem.sv @@ -32,16 +32,16 @@ module imem ( output logic InstrAccessFaultF); /* verilator lint_off UNDRIVEN */ - logic [`XLEN-1:0] RAM[`TIMBASE>>(1+`XLEN/32):(`TIMRANGE-`TIMBASE)>>(1+`XLEN/32)]; - logic [`XLEN-1:0] bootram[`BOOTTIMBASE>>(1+`XLEN/32):(`BOOTTIMRANGE-`BOOTTIMBASE)>>(1+`XLEN/32)]; + logic [`XLEN-1:0] RAM[`TIMBASE>>(1+`XLEN/32):(`TIMRANGE+`TIMBASE)>>(1+`XLEN/32)]; + logic [`XLEN-1:0] bootram[`BOOTTIMBASE>>(1+`XLEN/32):(`BOOTTIMRANGE+`BOOTTIMBASE)>>(1+`XLEN/32)]; /* verilator lint_on UNDRIVEN */ - logic [15:0] adrbits; + logic [28:0] adrbits; logic [`XLEN-1:0] rd; // logic [15:0] rd2; generate - if (`XLEN==32) assign adrbits = AdrF[17:2]; - else assign adrbits = AdrF[18:3]; + if (`XLEN==32) assign adrbits = AdrF[30:2]; + else assign adrbits = AdrF[31:3]; endgenerate //assign #2 rd = RAM[adrbits]; // word aligned diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index eb2d01f2c..db5f8aa47 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -204,9 +204,10 @@ module testbench_busybear(); logic [`XLEN-1:0] writeDataExpected, writeAdrExpected; // this might need to change - always @(HWDATA or HADDR or HSIZE or HWRITE) begin - #1; - if (HWRITE) begin + //always @(HWDATA or HADDR or HSIZE or HWRITE) begin + always @(negedge HWRITE) begin + //#1; + if ($time != 0) begin if($feof(data_file_memW)) begin $display("no more memW data to read"); `ERROR @@ -337,7 +338,9 @@ module testbench_busybear(); logic forcedInstr; logic [63:0] lastPCF; always @(dut.PCF or dut.hart.ifu.InstrF) begin - if (~reset && dut.hart.ifu.InstrF !== {32{1'bx}}) begin + if(~HWRITE) begin + #3; + if (~reset && dut.hart.ifu.InstrF[15:0] !== {16{1'bx}}) begin if (dut.PCF !== lastPCF) begin lastCheckInstrF = CheckInstrF; lastPC <= dut.PCF; @@ -416,6 +419,7 @@ module testbench_busybear(); end lastPCF = dut.PCF; end + end end // Track names of instructions From beb2beabfdfbd4b2226d5cf906e2202ee19ece8b Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Mon, 1 Mar 2021 21:01:15 +0000 Subject: [PATCH 34/46] busybear: add sim-busybear and sim-busybear-batch based on sim-wally --- wally-pipelined/regression/sim-busybear | 1 + wally-pipelined/regression/sim-busybear-batch | 1 + 2 files changed, 2 insertions(+) create mode 100755 wally-pipelined/regression/sim-busybear create mode 100755 wally-pipelined/regression/sim-busybear-batch diff --git a/wally-pipelined/regression/sim-busybear b/wally-pipelined/regression/sim-busybear new file mode 100755 index 000000000..e20344043 --- /dev/null +++ b/wally-pipelined/regression/sim-busybear @@ -0,0 +1 @@ +vsim -do wally-busybear.do diff --git a/wally-pipelined/regression/sim-busybear-batch b/wally-pipelined/regression/sim-busybear-batch new file mode 100755 index 000000000..7660eb9f6 --- /dev/null +++ b/wally-pipelined/regression/sim-busybear-batch @@ -0,0 +1 @@ +vsim -do wally-busybear.do -c From 5c456e2d7f95d74125968d022131bf0b88b21f9c Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Thu, 4 Mar 2021 20:26:41 +0000 Subject: [PATCH 35/46] busybear: comment out instraccessfaultf for imem for now --- wally-pipelined/src/uncore/imem.sv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wally-pipelined/src/uncore/imem.sv b/wally-pipelined/src/uncore/imem.sv index 239070e35..360bed398 100644 --- a/wally-pipelined/src/uncore/imem.sv +++ b/wally-pipelined/src/uncore/imem.sv @@ -60,8 +60,8 @@ module imem ( end else begin assign InstrF = AdrF[2] ? (AdrF[1] ? {rd2[15:0], rd[63:48]} : rd[63:32]) : (AdrF[1] ? rd[47:16] : rd[31:0]); - //assign InstrAccessFaultF = 0; //busybear: for now, i know we're not doing this - assign InstrAccessFaultF = |AdrF[`XLEN-1:32] | ~&({AdrF[31:1],1'b0} ~^ `TIMBASE | `TIMRANGE); + assign InstrAccessFaultF = 0; //busybear: for now, i know we're not doing this + //assign InstrAccessFaultF = |AdrF[`XLEN-1:32] | ~&({AdrF[31:1],1'b0} ~^ `TIMBASE | `TIMRANGE); end endgenerate endmodule From cfcd7d1518fada82479cbc2f5e8a6ea48db9b9e0 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Thu, 4 Mar 2021 22:11:42 +0000 Subject: [PATCH 36/46] busybear: make imperas tests work again --- wally-pipelined/regression/wally-busybear.do | 6 +- wally-pipelined/src/uncore/dtim.sv | 1 - wally-pipelined/src/uncore/imem.sv | 17 ++++- wally-pipelined/src/uncore/uncore.sv | 71 +++++++++++++++---- .../testbench/testbench-imperas.sv | 4 +- .../testbench/testbench-peripherals.sv | 4 +- 6 files changed, 78 insertions(+), 25 deletions(-) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index 69de98461..d240ef730 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -37,8 +37,8 @@ mem load -startaddress 0 -endaddress 2047 -filltype value -fillradix hex -fillda mem load -startaddress 512 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/dut/uncore/bootdtim/RAM mem load -startaddress 0 -endaddress 2047 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/imem/bootram mem load -startaddress 512 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/dut/imem/bootram -mem load -startaddress 268435456 -endaddress 285212671 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/uncore/maindtim/RAM -mem load -startaddress 268435456 -i "/courses/e190ax/busybear_boot/ram.txt" -format hex /testbench_busybear/dut/uncore/maindtim/RAM +mem load -startaddress 268435456 -endaddress 285212671 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/uncore/dtim/RAM +mem load -startaddress 268435456 -i "/courses/e190ax/busybear_boot/ram.txt" -format hex /testbench_busybear/dut/uncore/dtim/RAM mem load -startaddress 268435456 -endaddress 285212671 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/imem/RAM mem load -startaddress 268435456 -i "/courses/e190ax/busybear_boot/ram.txt" -format hex /testbench_busybear/dut/imem/RAM @@ -63,7 +63,7 @@ add wave -divider add wave /testbench_busybear/dut/uncore/HSELBootTim add wave /testbench_busybear/dut/uncore/HSELTim add wave /testbench_busybear/dut/uncore/HREADTim -add wave /testbench_busybear/dut/uncore/maindtim/HREADTim0 +add wave /testbench_busybear/dut/uncore/dtim/HREADTim0 add wave /testbench_busybear/dut/uncore/HREADYTim add wave -divider add wave /testbench_busybear/dut/uncore/HREADBootTim diff --git a/wally-pipelined/src/uncore/dtim.sv b/wally-pipelined/src/uncore/dtim.sv index cf7b39cc4..6f53c4c51 100644 --- a/wally-pipelined/src/uncore/dtim.sv +++ b/wally-pipelined/src/uncore/dtim.sv @@ -35,7 +35,6 @@ module dtim #(parameter BASE=0, RANGE = 65535) ( output logic HRESPTim, HREADYTim ); - //logic [`XLEN-1:0] RAM[0:65535]; logic [`XLEN-1:0] RAM[BASE>>(1+`XLEN/32):(RANGE+BASE)>>1+(`XLEN/32)]; logic [31:0] HWADDR; logic [`XLEN-1:0] HREADTim0; diff --git a/wally-pipelined/src/uncore/imem.sv b/wally-pipelined/src/uncore/imem.sv index 360bed398..4ce2e4666 100644 --- a/wally-pipelined/src/uncore/imem.sv +++ b/wally-pipelined/src/uncore/imem.sv @@ -33,7 +33,9 @@ module imem ( /* verilator lint_off UNDRIVEN */ logic [`XLEN-1:0] RAM[`TIMBASE>>(1+`XLEN/32):(`TIMRANGE+`TIMBASE)>>(1+`XLEN/32)]; + `ifdef BOOTTIMBASE logic [`XLEN-1:0] bootram[`BOOTTIMBASE>>(1+`XLEN/32):(`BOOTTIMRANGE+`BOOTTIMBASE)>>(1+`XLEN/32)]; + `endif /* verilator lint_on UNDRIVEN */ logic [28:0] adrbits; logic [`XLEN-1:0] rd; @@ -44,15 +46,21 @@ module imem ( else assign adrbits = AdrF[31:3]; endgenerate - //assign #2 rd = RAM[adrbits]; // word aligned + `ifndef BOOTTIMBASE + assign #2 rd = RAM[adrbits]; // word aligned + `else assign #2 rd = (AdrF < (`TIMBASE >> 1)) ? bootram[adrbits] : RAM[adrbits]; // busybear: 2 memory options + `endif // hack right now for unaligned 32-bit instructions // eventually this will need to cause a stall like a cache miss // when the instruction wraps around a cache line // could be optimized to only stall when the instruction wrapping is 32 bits - //assign #2 rd2 = RAM[adrbits+1][15:0]; + `ifndef BOOTTIMBASE + assign #2 rd2 = RAM[adrbits+1][15:0]; + `else assign #2 rd2 = (AdrF < (`TIMBASE >> 1)) ? bootram[adrbits+1][15:0] : RAM[adrbits+1][15:0]; //busybear: 2 memory options + `endif generate if (`XLEN==32) begin assign InstrF = AdrF[1] ? {rd2[15:0], rd[31:16]} : rd; @@ -60,8 +68,11 @@ module imem ( end else begin assign InstrF = AdrF[2] ? (AdrF[1] ? {rd2[15:0], rd[63:48]} : rd[63:32]) : (AdrF[1] ? rd[47:16] : rd[31:0]); + `ifndef BOOTTIMBASE + assign InstrAccessFaultF = |AdrF[`XLEN-1:32] | ~&({AdrF[31:1],1'b0} ~^ `TIMBASE | `TIMRANGE); + `else assign InstrAccessFaultF = 0; //busybear: for now, i know we're not doing this - //assign InstrAccessFaultF = |AdrF[`XLEN-1:32] | ~&({AdrF[31:1],1'b0} ~^ `TIMBASE | `TIMRANGE); + `endif end endgenerate endmodule diff --git a/wally-pipelined/src/uncore/uncore.sv b/wally-pipelined/src/uncore/uncore.sv index bcb60271a..77ed3ff5c 100644 --- a/wally-pipelined/src/uncore/uncore.sv +++ b/wally-pipelined/src/uncore/uncore.sv @@ -58,30 +58,42 @@ module uncore ( ); logic [`XLEN-1:0] HWDATA; - logic [`XLEN-1:0] HREADBootTim, HREADTim, HREADCLINT, HREADGPIO, HREADUART; - logic HSELBootTim, HSELTim, HSELCLINT, HSELGPIO, PreHSELUART, HSELUART; - logic HRESPBootTim, HRESPTim, HRESPCLINT, HRESPGPIO, HRESPUART; - logic HREADYBootTim, HREADYTim, HREADYCLINT, HREADYGPIO, HREADYUART; + logic [`XLEN-1:0] HREADTim, HREADCLINT, HREADGPIO, HREADUART; + logic HSELTim, HSELCLINT, HSELGPIO, PreHSELUART, HSELUART; + logic HRESPTim, HRESPCLINT, HRESPGPIO, HRESPUART; + logic HREADYTim, HREADYCLINT, HREADYGPIO, HREADYUART; logic [1:0] MemRW; - logic [1:0] MemRWboottim, MemRWtim, MemRWclint, MemRWgpio, MemRWuart; + logic [1:0] MemRWtim, MemRWclint, MemRWgpio, MemRWuart; + `ifdef BOOTTIMBASE + logic [`XLEN-1:0] HREADBootTim; + logic HSELBootTim, HRESPBootTim, HREADYBootTim; + logic [1:0] MemRWboottim; + `endif logic UARTIntr;// *** will need to tie INTR to an interrupt handler // AHB Address decoder adrdec timdec(HADDR, `TIMBASE, `TIMRANGE, HSELTim); + `ifdef BOOTTIMBASE adrdec boottimdec(HADDR, `BOOTTIMBASE, `BOOTTIMRANGE, HSELBootTim); + `endif adrdec clintdec(HADDR, `CLINTBASE, `CLINTRANGE, HSELCLINT); - // Busybear: for now, leaving out gpio since OVPsim doesn't seem to have it - //adrdec gpiodec(HADDR, `GPIOBASE, `GPIORANGE, HSELGPIO); + `ifdef GPIOBASE + adrdec gpiodec(HADDR, `GPIOBASE, `GPIORANGE, HSELGPIO); + `endif adrdec uartdec(HADDR, `UARTBASE, `UARTRANGE, PreHSELUART); assign HSELUART = PreHSELUART && (HSIZE == 3'b000); // only byte writes to UART are supported // Enable read or write based on decoded address assign MemRW = {~HWRITE, HWRITED}; + `ifdef BOOTTIMBASE assign MemRWboottim = MemRW & {2{HSELBootTim}}; + `endif assign MemRWtim = MemRW & {2{HSELTim}}; assign MemRWclint = MemRW & {2{HSELCLINT}}; - //assign MemRWgpio = MemRW & {2{HSELGPIO}}; + `ifdef GPIOBASE + assign MemRWgpio = MemRW & {2{HSELGPIO}}; + `endif assign MemRWuart = MemRW & {2{HSELUART}}; /* always_ff @(posedge HCLK) begin HADDRD <= HADDR; @@ -95,13 +107,17 @@ module uncore ( subwordwrite sww(.*); // tightly integrated memory - dtim #(.BASE(`TIMBASE), .RANGE(`TIMRANGE)) maindtim (.*); + dtim #(.BASE(`TIMBASE), .RANGE(`TIMRANGE)) dtim (.*); + `ifdef BOOTTIMBASE dtim #(.BASE(`BOOTTIMBASE), .RANGE(`BOOTTIMRANGE)) bootdtim (.MemRWtim(MemRWboottim), .HSELTim(HSELBootTim), .HREADTim(HREADBootTim), .HRESPTim(HRESPBootTim), .HREADYTim(HREADYBootTim), .*); + `endif // memory-mapped I/O peripherals clint clint(.HADDR(HADDR[15:0]), .*); - //gpio gpio(.HADDR(HADDR[7:0]), .*); // *** may want to add GPIO interrupts + `ifdef GPIOBASE + gpio gpio(.HADDR(HADDR[7:0]), .*); // *** may want to add GPIO interrupts + `endif uart uart(.HADDR(HADDR[2:0]), .TXRDYb(), .RXRDYb(), .INTR(UARTIntr), .SIN(UARTSin), .SOUT(UARTSout), .DSRb(1'b1), .DCDb(1'b1), .CTSb(1'b0), .RIb(1'b1), .RTSb(), .DTRb(), .OUT1b(), .OUT2b(), .*); @@ -109,12 +125,39 @@ module uncore ( // mux could also include external memory // AHB Read Multiplexer assign HRDATA = ({`XLEN{HSELTim}} & HREADTim) | ({`XLEN{HSELCLINT}} & HREADCLINT) | - ({`XLEN{HSELBootTim}} & HREADBootTim) | ({`XLEN{HSELUART}} & HREADUART); - assign HRESP = HSELBootTim & HRESPBootTim | HSELTim & HRESPTim | HSELCLINT & HRESPCLINT | HSELUART & HRESPUART; - assign HREADY = HSELBootTim & HREADYBootTim | HSELTim & HREADYTim | HSELCLINT & HREADYCLINT | HSELUART & HREADYUART; + `ifdef GPIOBASE + ({`XLEN{HSELGPIO}} & HREADGPIO) | + `endif + `ifdef BOOTTIMBASE + ({`XLEN{HSELBootTim}} & HREADBootTim) | + `endif + ({`XLEN{HSELUART}} & HREADUART); + assign HRESP = HSELTim & HRESPTim | HSELCLINT & HRESPCLINT | + `ifdef GPIOBASE + HSELGPIO & HRESPGPIO | + `endif + `ifdef BOOTTIMBASE + HSELBootTim & HRESPBootTim | + `endif + HSELUART & HRESPUART; + assign HREADY = HSELTim & HREADYTim | HSELCLINT & HREADYCLINT | + `ifdef GPIOBASE + HSELGPIO & HREADYGPIO | + `endif + `ifdef BOOTTIMBASE + HSELBootTim & HREADYBootTim | + `endif + HSELUART & HREADYUART; // Faults - assign DataAccessFaultM = ~(HSELTim | HSELCLINT | HSELUART); + assign DataAccessFaultM = ~(HSELTim | HSELCLINT | + `ifdef GPIOBASE + HSELGPIO | + `endif + `ifdef BOOTTIMBASE + HSELBootTim | + `endif + HSELUART); endmodule diff --git a/wally-pipelined/testbench/testbench-imperas.sv b/wally-pipelined/testbench/testbench-imperas.sv index 49a5263d6..182c3cc1c 100644 --- a/wally-pipelined/testbench/testbench-imperas.sv +++ b/wally-pipelined/testbench/testbench-imperas.sv @@ -407,9 +407,9 @@ string tests32i[] = { i = 0; errors = 0; if (`XLEN == 32) - testadr = tests[test+1].atohex()/4; + testadr = (`TIMBASE+tests[test+1].atohex())/4; else - testadr = tests[test+1].atohex()/8; + testadr = (`TIMBASE+tests[test+1].atohex())/8; /* verilator lint_off INFINITELOOP */ while (signature[i] !== 'bx) begin //$display("signature[%h] = %h", i, signature[i]); diff --git a/wally-pipelined/testbench/testbench-peripherals.sv b/wally-pipelined/testbench/testbench-peripherals.sv index 24180431d..ba4b94fae 100644 --- a/wally-pipelined/testbench/testbench-peripherals.sv +++ b/wally-pipelined/testbench/testbench-peripherals.sv @@ -136,9 +136,9 @@ module testbench(); i = 0; errors = 0; if (`XLEN == 32) - testadr = tests[test+1].atohex()/4; + testadr = (`TIMBASE+tests[test+1].atohex())/4; else - testadr = tests[test+1].atohex()/8; + testadr = (`TIMBASE+tests[test+1].atohex())/8; /* verilator lint_off INFINITELOOP */ while (signature[i] !== 'bx) begin //$display("signature[%h] = %h", i, signature[i]); From 7208b9bcf26cff16daf9d9d4be796325061611d9 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Fri, 5 Mar 2021 00:39:03 +0000 Subject: [PATCH 37/46] busybear: better implenetation of sim-busybear-batch --- wally-pipelined/regression/sim-busybear-batch | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wally-pipelined/regression/sim-busybear-batch b/wally-pipelined/regression/sim-busybear-batch index 7660eb9f6..2c351aade 100755 --- a/wally-pipelined/regression/sim-busybear-batch +++ b/wally-pipelined/regression/sim-busybear-batch @@ -1 +1,3 @@ -vsim -do wally-busybear.do -c +vsim -c < Date: Fri, 5 Mar 2021 00:46:32 +0000 Subject: [PATCH 38/46] busybear: make CSRs only weird for us --- wally-pipelined/config/busybear/wally-config.vh | 3 ++- wally-pipelined/src/privileged/csrm.sv | 7 +++++-- wally-pipelined/src/privileged/csrs.sv | 6 +++++- wally-pipelined/src/privileged/csrsr.sv | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/wally-pipelined/config/busybear/wally-config.vh b/wally-pipelined/config/busybear/wally-config.vh index 90ccc37e9..b01a2e30e 100644 --- a/wally-pipelined/config/busybear/wally-config.vh +++ b/wally-pipelined/config/busybear/wally-config.vh @@ -1,5 +1,5 @@ ////////////////////////////////////////// -// wally-config.vh +// busybear-config.vh // // Written: David_Harris@hmc.edu 4 January 2021 // Modified: @@ -24,6 +24,7 @@ // OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /////////////////////////////////////////// +`define BUSYBEAR // RV32 or RV64: XLEN = 32 or 64 `define XLEN 64 diff --git a/wally-pipelined/src/privileged/csrm.sv b/wally-pipelined/src/privileged/csrm.sv index 0ef268638..1050f710d 100644 --- a/wally-pipelined/src/privileged/csrm.sv +++ b/wally-pipelined/src/privileged/csrm.sv @@ -108,8 +108,7 @@ module csrm #(parameter assign WriteMCOUNTINHIBITM = CSRMWriteM && (CSRAdrM == MCOUNTINHIBIT); // CSRs - //flopenl #(`XLEN) MTVECreg(clk, reset, WriteMTVECM, CSRWriteValM, `RESET_VECTOR, MTVEC_REGW); - flopenl #(`XLEN) MTVECreg(clk, reset, WriteMTVECM, CSRWriteValM, `XLEN'b0, MTVEC_REGW); + flopenl #(`XLEN) MTVECreg(clk, reset, WriteMTVECM, CSRWriteValM, `XLEN'b0, MTVEC_REGW); //busybear: changed reset value to 0 generate if (`S_SUPPORTED | (`U_SUPPORTED & `N_SUPPORTED)) begin // DELEG registers should exist flopenl #(`XLEN) MEDELEGreg(clk, reset, WriteMEDELEGM, CSRWriteValM & MEDELEG_MASK, zero, MEDELEG_REGW); @@ -126,7 +125,11 @@ module csrm #(parameter flopenr #(`XLEN) MEPCreg(clk, reset, WriteMEPCM, NextEPCM, MEPC_REGW); flopenr #(`XLEN) MCAUSEreg(clk, reset, WriteMCAUSEM, NextCauseM, MCAUSE_REGW); flopenr #(`XLEN) MTVALreg(clk, reset, WriteMTVALM, NextMtvalM, MTVAL_REGW); + `ifndef BUSYBEAR + flopenl #(32) MCOUNTERENreg(clk, reset, WriteMCOUNTERENM, CSRWriteValM[31:0], allones, MCOUNTEREN_REGW); + `else flopenl #(32) MCOUNTERENreg(clk, reset, WriteMCOUNTERENM, {CSRWriteValM[31:2],1'b0,CSRWriteValM[0]}, 32'b0, MCOUNTEREN_REGW); + `endif flopenl #(32) MCOUNTINHIBITreg(clk, reset, WriteMCOUNTINHIBITM, CSRWriteValM[31:0], allones, MCOUNTINHIBIT_REGW); flopenr #(`XLEN) PMPADDR0reg(clk, reset, WritePMPADDR0M, CSRWriteValM, PMPADDR0_REGW); // PMPCFG registers are a pair of 64-bit in RV64 and four 32-bit in RV32 diff --git a/wally-pipelined/src/privileged/csrs.sv b/wally-pipelined/src/privileged/csrs.sv index 5b1f42058..19d533c89 100644 --- a/wally-pipelined/src/privileged/csrs.sv +++ b/wally-pipelined/src/privileged/csrs.sv @@ -75,13 +75,17 @@ module csrs #(parameter assign WriteSCOUNTERENM = CSRSWriteM && (CSRAdrM == SCOUNTEREN); // CSRs - flopenl #(`XLEN) STVECreg(clk, reset, WriteSTVECM, CSRWriteValM, zero, STVEC_REGW); + flopenl #(`XLEN) STVECreg(clk, reset, WriteSTVECM, CSRWriteValM, zero, STVEC_REGW); //busybear: change reset to 0 flopenr #(`XLEN) SSCRATCHreg(clk, reset, WriteSSCRATCHM, CSRWriteValM, SSCRATCH_REGW); flopenr #(`XLEN) SEPCreg(clk, reset, WriteSEPCM, NextEPCM, SEPC_REGW); flopenl #(`XLEN) SCAUSEreg(clk, reset, WriteSCAUSEM, NextCauseM, zero, SCAUSE_REGW); flopenr #(`XLEN) STVALreg(clk, reset, WriteSTVALM, NextMtvalM, STVAL_REGW); flopenr #(`XLEN) SATPreg(clk, reset, WriteSATPM, CSRWriteValM, SATP_REGW); + `ifndef BUSYBEAR + flopenl #(32) SCOUNTERENreg(clk, reset, WriteSCOUNTERENM, CSRWriteValM[31:0], allones, SCOUNTEREN_REGW); + `else flopenl #(32) SCOUNTERENreg(clk, reset, WriteSCOUNTERENM, {CSRWriteValM[31:2],1'b0,CSRWriteValM[0]}, 32'b0, SCOUNTEREN_REGW); + `endif if (`N_SUPPORTED) begin logic WriteSEDELEGM, WriteSIDELEGM; assign WriteSEDELEGM = CSRSWriteM && (CSRAdrM == SEDELEG); diff --git a/wally-pipelined/src/privileged/csrsr.sv b/wally-pipelined/src/privileged/csrsr.sv index 83743c456..40f77a12e 100644 --- a/wally-pipelined/src/privileged/csrsr.sv +++ b/wally-pipelined/src/privileged/csrsr.sv @@ -109,7 +109,7 @@ module csrsr ( if (reset) begin STATUS_SUM_INT <= 0; STATUS_MPRV_INT <= 0; // Per Priv 3.3 - STATUS_FS_INT <= 0; //2'b01; // initial + STATUS_FS_INT <= 0; //2'b01; // busybear: change all these reset values to 0 STATUS_MPP <= 0; //`M_MODE; STATUS_SPP <= 0; //1'b1; STATUS_MPIE <= 0; //1; From 464c1de03d8e9e5ecd8593236a129ad93e4314a8 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Fri, 5 Mar 2021 19:00:40 +0000 Subject: [PATCH 39/46] busybear: slight testbench update --- wally-pipelined/testbench/testbench-busybear.sv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv index db5f8aa47..e6ba95a13 100644 --- a/wally-pipelined/testbench/testbench-busybear.sv +++ b/wally-pipelined/testbench/testbench-busybear.sv @@ -337,7 +337,7 @@ module testbench_busybear(); logic [31:0] InstrMask; logic forcedInstr; logic [63:0] lastPCF; - always @(dut.PCF or dut.hart.ifu.InstrF) begin + always @(dut.PCF or dut.hart.ifu.InstrF or reset) begin if(~HWRITE) begin #3; if (~reset && dut.hart.ifu.InstrF[15:0] !== {16{1'bx}}) begin From 62dd9e3075d8774aa0fdb8b13fc6de88c71747e2 Mon Sep 17 00:00:00 2001 From: bbracker Date: Fri, 5 Mar 2021 14:24:22 -0500 Subject: [PATCH 40/46] first merge of ahb fix --- .../regression/wally-peripherals.do | 68 +------------------ wally-pipelined/src/uncore/clint.sv | 9 +-- wally-pipelined/src/uncore/dtim.sv | 47 +++++-------- wally-pipelined/src/uncore/gpio.sv | 7 +- wally-pipelined/src/uncore/uart.sv | 49 ++++++------- wally-pipelined/src/uncore/uartPC16550D.sv | 2 +- wally-pipelined/src/uncore/uncore.sv | 63 +++++++++-------- 7 files changed, 86 insertions(+), 159 deletions(-) diff --git a/wally-pipelined/regression/wally-peripherals.do b/wally-pipelined/regression/wally-peripherals.do index d9d9daa37..d0df00fb9 100644 --- a/wally-pipelined/regression/wally-peripherals.do +++ b/wally-pipelined/regression/wally-peripherals.do @@ -39,70 +39,4 @@ vopt +acc work.testbench -o workopt vsim workopt view wave - --- display input and output signals as hexidecimal values -# Diplays All Signals recursively -add wave /testbench/clk -add wave /testbench/reset -add wave -divider -add wave /testbench/dut/hart/ebu/IReadF -add wave /testbench/dut/hart/DataStall -add wave /testbench/dut/hart/InstrStall -add wave /testbench/dut/hart/StallF -add wave /testbench/dut/hart/StallD -add wave /testbench/dut/hart/FlushD -add wave /testbench/dut/hart/FlushE -add wave /testbench/dut/hart/FlushM -add wave /testbench/dut/hart/FlushW - -add wave -divider -add wave -hex /testbench/dut/hart/ifu/PCF -add wave -hex /testbench/dut/hart/ifu/InstrF -add wave /testbench/InstrFName -#add wave -hex /testbench/dut/hart/ifu/PCD -add wave -hex /testbench/dut/hart/ifu/InstrD -add wave /testbench/InstrDName -add wave -divider -#add wave -hex /testbench/dut/hart/ifu/PCE -#add wave -hex /testbench/dut/hart/ifu/InstrE -add wave /testbench/InstrEName -add wave -hex /testbench/dut/hart/ieu/dp/SrcAE -add wave -hex /testbench/dut/hart/ieu/dp/SrcBE -add wave -hex /testbench/dut/hart/ieu/dp/ALUResultE -add wave /testbench/dut/hart/ieu/dp/PCSrcE -add wave -divider -#add wave -hex /testbench/dut/hart/ifu/PCM -#add wave -hex /testbench/dut/hart/ifu/InstrM -add wave /testbench/InstrMName -add wave /testbench/dut/uncore/dtim/memwrite -add wave -hex /testbench/dut/uncore/HADDR -add wave -hex /testbench/dut/uncore/HWDATA -add wave -divider -add wave -hex /testbench/dut/hart/ifu/PCW -add wave /testbench/InstrWName -add wave /testbench/dut/hart/ieu/dp/RegWriteW -add wave -hex /testbench/dut/hart/ieu/dp/ResultW -add wave -hex /testbench/dut/hart/ieu/dp/RdW -add wave -divider -add wave -hex /testbench/dut/uncore/uart/u/* -add wave -divider -#add ww -add wave -hex -r /testbench/* - --- Set Wave Output Items -TreeUpdate [SetDefaultTree] -WaveRestoreZoom {0 ps} {100 ps} -configure wave -namecolwidth 250 -configure wave -valuecolwidth 120 -configure wave -justifyvalue left -configure wave -signalnamewidth 0 -configure wave -snapdistance 10 -configure wave -datasetprefix 0 -configure wave -rowmargin 4 -configure wave -childrowmargin 2 -set DefaultRadix hexadecimal - --- Run the Simulation -run 5000 -#run -all -#quit +do wally-peripherals-signals.do diff --git a/wally-pipelined/src/uncore/clint.sv b/wally-pipelined/src/uncore/clint.sv index 215ef7df0..71770323e 100644 --- a/wally-pipelined/src/uncore/clint.sv +++ b/wally-pipelined/src/uncore/clint.sv @@ -28,8 +28,9 @@ module clint ( input logic HCLK, HRESETn, - input logic [1:0] MemRWclint, - input logic [15:0] HADDR, + input logic HSELCLINT, + input logic [15:0] HADDR, + input logic HWRITE, input logic [`XLEN-1:0] HWDATA, output logic [`XLEN-1:0] HREADCLINT, output logic HRESPCLINT, HREADYCLINT, @@ -41,8 +42,8 @@ module clint ( logic [15:0] entry; logic memread, memwrite; - assign memread = MemRWclint[1]; - assign memwrite = MemRWclint[0]; + assign memread = HSELCLINT & ~HWRITE; + assign memwrite = HSELCLINT & HWRITE; assign HRESPCLINT = 0; // OK // assign HREADYCLINT = 1; // Respond immediately always_ff @(posedge HCLK) // delay response diff --git a/wally-pipelined/src/uncore/dtim.sv b/wally-pipelined/src/uncore/dtim.sv index 6f53c4c51..42ae7fbcc 100644 --- a/wally-pipelined/src/uncore/dtim.sv +++ b/wally-pipelined/src/uncore/dtim.sv @@ -27,22 +27,28 @@ module dtim #(parameter BASE=0, RANGE = 65535) ( input logic HCLK, HRESETn, - input logic [1:0] MemRWtim, - input logic [31:0] HADDR, - input logic [`XLEN-1:0] HWDATA, input logic HSELTim, + input logic [31:0] HADDR, + input logic HWRITE, + input logic [`XLEN-1:0] HWDATA, output logic [`XLEN-1:0] HREADTim, output logic HRESPTim, HREADYTim ); logic [`XLEN-1:0] RAM[BASE>>(1+`XLEN/32):(RANGE+BASE)>>1+(`XLEN/32)]; - logic [31:0] HWADDR; + logic [31:0] HWADDR, A; logic [`XLEN-1:0] HREADTim0; // logic [`XLEN-1:0] write; logic [15:0] entry; - logic memread, memwrite; - logic [3:0] busycount; + logic memread, memwrite; + logic [3:0] busycount; + + always_ff @(posedge HCLK) begin + memread <= HSELTim & ~ HWRITE; + memwrite <= HSELTim & HWRITE; + A <= HADDR; + end // busy FSM to extend READY signal always_ff @(posedge HCLK, negedge HRESETn) @@ -61,41 +67,20 @@ module dtim #(parameter BASE=0, RANGE = 65535) ( end end - /* always_ff @(posedge HCLK, negedge HRESETn) - if (~HRESETn) begin - HREADYTim <= 0; - end else begin - HREADYTim <= HSELTim; // always respond one cycle later - end */ - - - assign memread = MemRWtim[1]; - assign memwrite = MemRWtim[0]; -// always_ff @(posedge HCLK) -// memwrite <= MemRWtim[0]; // delay memwrite to write phase assign HRESPTim = 0; // OK -// assign HREADYTim = 1; // Respond immediately; *** extend this - // Model memory read and write - generate if (`XLEN == 64) begin -// always_ff @(negedge HCLK) -// if (memwrite) RAM[HWADDR[31:3]] <= HWDATA; always_ff @(posedge HCLK) begin - //if (memwrite) RAM[HADDR[31:3]] <= HWDATA; - HWADDR <= HADDR; - HREADTim0 <= RAM[HADDR[31:3]]; + HWADDR <= A; + HREADTim0 <= RAM[A[31:3]]; if (memwrite && HREADYTim) RAM[HWADDR[31:3]] <= HWDATA; end end else begin -// always_ff @(negedge HCLK) -// if (memwrite) RAM[HWADDR[31:2]] <= HWDATA; always_ff @(posedge HCLK) begin - //if (memwrite) RAM[HADDR[31:2]] <= HWDATA; - HWADDR <= HADDR; - HREADTim0 <= RAM[HADDR[31:2]]; + HWADDR <= A; + HREADTim0 <= RAM[A[31:2]]; if (memwrite && HREADYTim) RAM[HWADDR[31:2]] <= HWDATA; end end diff --git a/wally-pipelined/src/uncore/gpio.sv b/wally-pipelined/src/uncore/gpio.sv index ffea6c72e..216e30ddf 100644 --- a/wally-pipelined/src/uncore/gpio.sv +++ b/wally-pipelined/src/uncore/gpio.sv @@ -29,9 +29,10 @@ module gpio ( input logic HCLK, HRESETn, - input logic [1:0] MemRWgpio, + input logic HSELGPIO, input logic [7:0] HADDR, input logic [`XLEN-1:0] HWDATA, + input logic HWRITE, output logic [`XLEN-1:0] HREADGPIO, output logic HRESPGPIO, HREADYGPIO, input logic [31:0] GPIOPinsIn, @@ -42,8 +43,8 @@ module gpio ( logic [7:0] entry; logic memread, memwrite; - assign memread = MemRWgpio[1]; - assign memwrite = MemRWgpio[0]; + assign memread = HSELGPIO & ~HWRITE; + assign memwrite = HSELGPIO & HWRITE; assign HRESPGPIO = 0; // OK always_ff @(posedge HCLK) // delay response to data cycle HREADYGPIO <= memread | memwrite; diff --git a/wally-pipelined/src/uncore/uart.sv b/wally-pipelined/src/uncore/uart.sv index b4854981a..373674867 100644 --- a/wally-pipelined/src/uncore/uart.sv +++ b/wally-pipelined/src/uncore/uart.sv @@ -29,8 +29,9 @@ module uart ( input logic HCLK, HRESETn, - input logic [1:0] MemRWuart, - input logic [2:0] HADDR, + input logic HSELUART, + input logic [2:0] HADDR, + input logic HWRITE, input logic [`XLEN-1:0] HWDATA, output logic [`XLEN-1:0] HREADUART, output logic HRESPUART, HREADYUART, @@ -44,37 +45,37 @@ module uart ( logic [7:0] Din, Dout; // rename processor interface signals to match PC16550D and provide one-byte interface - assign MEMRb = ~MemRWuart[1]; - assign MEMWb = ~MemRWuart[0]; - assign A = HADDR[2:0]; + always_ff @(posedge HCLK) begin + MEMRb <= ~(HSELUART & ~HWRITE); + MEMWb <= ~(HSELUART & HWRITE); + A <= HADDR[2:0]; + end assign HRESPUART = 0; // OK - //assign HREADYUART = 1; // Respond immediately - always_ff @(posedge HCLK) // delay response to data cycle - HREADYUART <= ~MEMRb | ~MEMWb; + assign HREADYUART = 1; // should idle high during address phase and respond high when done; will need to be modified if UART ever needs more than 1 cycle to do something generate if (`XLEN == 64) begin - always @(posedge HCLK) begin + always_comb begin HREADUART = {Dout, Dout, Dout, Dout, Dout, Dout, Dout, Dout}; - case (HADDR) - 3'b000: Din <= HWDATA[7:0]; - 3'b001: Din <= HWDATA[15:8]; - 3'b010: Din <= HWDATA[23:16]; - 3'b011: Din <= HWDATA[31:24]; - 3'b100: Din <= HWDATA[39:32]; - 3'b101: Din <= HWDATA[47:40]; - 3'b110: Din <= HWDATA[55:48]; - 3'b111: Din <= HWDATA[63:56]; + case (A) + 3'b000: Din = HWDATA[7:0]; + 3'b001: Din = HWDATA[15:8]; + 3'b010: Din = HWDATA[23:16]; + 3'b011: Din = HWDATA[31:24]; + 3'b100: Din = HWDATA[39:32]; + 3'b101: Din = HWDATA[47:40]; + 3'b110: Din = HWDATA[55:48]; + 3'b111: Din = HWDATA[63:56]; endcase end end else begin // 32-bit - always @(posedge HCLK) begin + always_comb begin HREADUART = {Dout, Dout, Dout, Dout}; - case (HADDR[1:0]) - 2'b00: Din <= HWDATA[7:0]; - 2'b01: Din <= HWDATA[15:8]; - 2'b10: Din <= HWDATA[23:16]; - 2'b11: Din <= HWDATA[31:24]; + case (A[1:0]) + 2'b00: Din = HWDATA[7:0]; + 2'b01: Din = HWDATA[15:8]; + 2'b10: Din = HWDATA[23:16]; + 2'b11: Din = HWDATA[31:24]; endcase end end diff --git a/wally-pipelined/src/uncore/uartPC16550D.sv b/wally-pipelined/src/uncore/uartPC16550D.sv index d494e19f2..28b530751 100644 --- a/wally-pipelined/src/uncore/uartPC16550D.sv +++ b/wally-pipelined/src/uncore/uartPC16550D.sv @@ -376,7 +376,7 @@ module uartPC16550D( TXHR <= Din; txhrfull <= 1; end - $display("UART transmits: %c",Din); // for testbench + $write("%c",Din); // for testbench end if (txstate == UART_IDLE) begin // move data into tx shift register if available if (fifoenabled) begin diff --git a/wally-pipelined/src/uncore/uncore.sv b/wally-pipelined/src/uncore/uncore.sv index 77ed3ff5c..a46ca6ba3 100644 --- a/wally-pipelined/src/uncore/uncore.sv +++ b/wally-pipelined/src/uncore/uncore.sv @@ -2,7 +2,7 @@ // uncore.sv // // Written: David_Harris@hmc.edu 9 January 2021 -// Modified: +// Modified: Ben Bracker 6 Mar 2021 to better fit AMBA 3 AHB-Lite spec // // Purpose: System-on-Chip components outside the core (hart) // Memories, peripherals, external bus control @@ -59,14 +59,14 @@ module uncore ( logic [`XLEN-1:0] HWDATA; logic [`XLEN-1:0] HREADTim, HREADCLINT, HREADGPIO, HREADUART; + logic HSELTim, HSELCLINT, HSELGPIO, PreHSELUART, HSELUART; + logic HSELTimD, HSELCLINTD, HSELGPIOD, HSELUARTD; logic HRESPTim, HRESPCLINT, HRESPGPIO, HRESPUART; logic HREADYTim, HREADYCLINT, HREADYGPIO, HREADYUART; - logic [1:0] MemRW; - logic [1:0] MemRWtim, MemRWclint, MemRWgpio, MemRWuart; `ifdef BOOTTIMBASE logic [`XLEN-1:0] HREADBootTim; - logic HSELBootTim, HRESPBootTim, HREADYBootTim; + logic HSELBootTim, HSELBootTimD, HRESPBootTim, HREADYBootTim; logic [1:0] MemRWboottim; `endif logic UARTIntr;// *** will need to tie INTR to an interrupt handler @@ -95,13 +95,6 @@ module uncore ( assign MemRWgpio = MemRW & {2{HSELGPIO}}; `endif assign MemRWuart = MemRW & {2{HSELUART}}; -/* always_ff @(posedge HCLK) begin - HADDRD <= HADDR; - MemRWtim <= MemRW & {2{HSELTim}}; - MemRWclint <= MemRW & {2{HSELCLINT}}; - MemRWgpio <= MemRW & {2{HSELGPIO}}; - MemRWuart <= MemRW & {2{HSELUART}}; - end */ // subword accesses: converts HWDATAIN to HWDATA subwordwrite sww(.*); @@ -120,45 +113,57 @@ module uncore ( `endif uart uart(.HADDR(HADDR[2:0]), .TXRDYb(), .RXRDYb(), .INTR(UARTIntr), .SIN(UARTSin), .SOUT(UARTSout), .DSRb(1'b1), .DCDb(1'b1), .CTSb(1'b0), .RIb(1'b1), - .RTSb(), .DTRb(), .OUT1b(), .OUT2b(), .*); + .RTSb(), .DTRb(), .OUT1b(), .OUT2b(), .*); // mux could also include external memory // AHB Read Multiplexer - assign HRDATA = ({`XLEN{HSELTim}} & HREADTim) | ({`XLEN{HSELCLINT}} & HREADCLINT) | + assign HRDATA = ({`XLEN{HSELTimD}} & HREADTim) | ({`XLEN{HSELCLINTD}} & HREADCLINT) | `ifdef GPIOBASE - ({`XLEN{HSELGPIO}} & HREADGPIO) | + ({`XLEN{HSELGPIOD}} & HREADGPIO) | `endif `ifdef BOOTTIMBASE - ({`XLEN{HSELBootTim}} & HREADBootTim) | + ({`XLEN{HSELBootTimD}} & HREADBootTim) | `endif - ({`XLEN{HSELUART}} & HREADUART); - assign HRESP = HSELTim & HRESPTim | HSELCLINT & HRESPCLINT | + ({`XLEN{HSELUARTD}} & HREADUART); + assign HRESP = HSELTimD & HRESPTim | HSELCLINTD & HRESPCLINT | `ifdef GPIOBASE - HSELGPIO & HRESPGPIO | + HSELGPIOD & HRESPGPIO | `endif `ifdef BOOTTIMBASE - HSELBootTim & HRESPBootTim | + HSELBootTimD & HRESPBootTim | `endif - HSELUART & HRESPUART; - assign HREADY = HSELTim & HREADYTim | HSELCLINT & HREADYCLINT | + HSELUARTD & HRESPUART; + assign HREADY = HSELTimD & HREADYTim | HSELCLINTD & HREADYCLINT | `ifdef GPIOBASE - HSELGPIO & HREADYGPIO | + HSELGPIOD & HREADYGPIO | `endif `ifdef BOOTTIMBASE - HSELBootTim & HREADYBootTim | + HSELBootTimD & HREADYBootTim | `endif - HSELUART & HREADYUART; + HSELUARTD & HREADYUART; // Faults - assign DataAccessFaultM = ~(HSELTim | HSELCLINT | + assign DataAccessFaultM = ~(HSELTimD | HSELCLINTD | `ifdef GPIOBASE - HSELGPIO | + HSELGPIOD | `endif `ifdef BOOTTIMBASE - HSELBootTim | + HSELBootTimD | `endif - HSELUART); + HSELUARTD); - + + // Synchronized Address Decoder (figure 4-2 in spec) + always_ff @(posedge HCLK) begin + HSELTimD <= HSELTim; + HSELCLINTD <= HSELCLINT; + `ifdef GPIOBASE + HSELGPIOD <= HSELGPIO; + `endif + HSELUARTD <= HSELUART; + `ifdef BOOTTIMBASE + HSELBootTimD <= HSELBootTim; + `endif + end endmodule From 420c9a11c2ded0ca410556dd44dd41c6a24c08f9 Mon Sep 17 00:00:00 2001 From: bbracker Date: Fri, 5 Mar 2021 14:25:16 -0500 Subject: [PATCH 41/46] refactored sim file --- .../regression/wally-peripherals-signals.do | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 wally-pipelined/regression/wally-peripherals-signals.do diff --git a/wally-pipelined/regression/wally-peripherals-signals.do b/wally-pipelined/regression/wally-peripherals-signals.do new file mode 100644 index 000000000..3ce8e8480 --- /dev/null +++ b/wally-pipelined/regression/wally-peripherals-signals.do @@ -0,0 +1,80 @@ +# wally-peripherals-signals.do +# +# Created by Ben Bracker (bbracker@hmc.edu) on 4 Mar. 2021 +# +# I really didn't like having to relaunch and recompile an entire sim +# just because some signal names have changed, so I thought this +# would be good to factor out. + +restart -f +delete wave /* +view wave + +-- display input and output signals as hexidecimal values +# Diplays All Signals recursively +add wave /testbench/clk +add wave /testbench/reset +add wave -divider +add wave /testbench/dut/hart/DataStall +add wave /testbench/dut/hart/InstrStall +add wave /testbench/dut/hart/StallF +add wave /testbench/dut/hart/StallD +add wave /testbench/dut/hart/FlushD +add wave /testbench/dut/hart/FlushE +add wave /testbench/dut/hart/FlushM +add wave /testbench/dut/hart/FlushW + +add wave -divider +add wave -hex /testbench/dut/hart/ifu/PCF +add wave -hex /testbench/dut/hart/ifu/InstrF +add wave /testbench/InstrFName +#add wave -hex /testbench/dut/hart/ifu/PCD +add wave -hex /testbench/dut/hart/ifu/InstrD +add wave /testbench/InstrDName +add wave -divider +add wave -hex /testbench/dut/hart/ifu/PCE +add wave -hex /testbench/dut/hart/ifu/InstrE +add wave /testbench/InstrEName +add wave -hex /testbench/dut/hart/ieu/dp/SrcAE +add wave -hex /testbench/dut/hart/ieu/dp/SrcBE +add wave -hex /testbench/dut/hart/ieu/dp/ALUResultE +add wave -divider +add wave -hex /testbench/dut/hart/ifu/PCM +add wave -hex /testbench/dut/hart/ifu/InstrM +add wave /testbench/InstrMName +add wave /testbench/dut/uncore/dtim/memwrite +add wave -hex /testbench/dut/uncore/HADDR +add wave -hex /testbench/dut/uncore/HWDATA +add wave -divider +add wave -hex /testbench/dut/hart/ifu/PCW +add wave /testbench/InstrWName +add wave /testbench/dut/hart/ieu/dp/RegWriteW +add wave -hex /testbench/dut/hart/ieu/dp/ResultW +add wave -hex /testbench/dut/hart/ieu/dp/RdW +add wave -divider +add wave -hex /testbench/dut/hart/ebu/* +add wave -divider +add wave -hex /testbench/dut/uncore/uart/u/* +add wave -divider +#add ww +add wave -hex -r /testbench/* + +-- Set Wave Output Items +TreeUpdate [SetDefaultTree] +WaveRestoreZoom {0 ps} {100 ps} +configure wave -namecolwidth 250 +configure wave -valuecolwidth 120 +configure wave -justifyvalue left +configure wave -signalnamewidth 0 +configure wave -snapdistance 10 +configure wave -datasetprefix 0 +configure wave -rowmargin 4 +configure wave -childrowmargin 2 +set DefaultRadix hexadecimal + +-- Run the Simulation +#run 5000 +run -all +#quit +noview ../testbench/testbench-peripherals.sv +view wave From 2cd0f19129ca9c3caaf709ed9942bcfab610e3fc Mon Sep 17 00:00:00 2001 From: bbracker Date: Fri, 5 Mar 2021 14:27:38 -0500 Subject: [PATCH 42/46] remove deprecated mem signals --- wally-pipelined/src/uncore/uncore.sv | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/wally-pipelined/src/uncore/uncore.sv b/wally-pipelined/src/uncore/uncore.sv index a46ca6ba3..ff0111cfc 100644 --- a/wally-pipelined/src/uncore/uncore.sv +++ b/wally-pipelined/src/uncore/uncore.sv @@ -83,18 +83,6 @@ module uncore ( `endif adrdec uartdec(HADDR, `UARTBASE, `UARTRANGE, PreHSELUART); assign HSELUART = PreHSELUART && (HSIZE == 3'b000); // only byte writes to UART are supported - - // Enable read or write based on decoded address - assign MemRW = {~HWRITE, HWRITED}; - `ifdef BOOTTIMBASE - assign MemRWboottim = MemRW & {2{HSELBootTim}}; - `endif - assign MemRWtim = MemRW & {2{HSELTim}}; - assign MemRWclint = MemRW & {2{HSELCLINT}}; - `ifdef GPIOBASE - assign MemRWgpio = MemRW & {2{HSELGPIO}}; - `endif - assign MemRWuart = MemRW & {2{HSELUART}}; // subword accesses: converts HWDATAIN to HWDATA subwordwrite sww(.*); From a1223ee13b6fe0b4e4aa62a9e7f0fc68a810201d Mon Sep 17 00:00:00 2001 From: bbracker Date: Fri, 5 Mar 2021 14:36:07 -0500 Subject: [PATCH 43/46] more merging fixes --- wally-pipelined/src/uncore/uncore.sv | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wally-pipelined/src/uncore/uncore.sv b/wally-pipelined/src/uncore/uncore.sv index ff0111cfc..ae6899c47 100644 --- a/wally-pipelined/src/uncore/uncore.sv +++ b/wally-pipelined/src/uncore/uncore.sv @@ -90,8 +90,7 @@ module uncore ( // tightly integrated memory dtim #(.BASE(`TIMBASE), .RANGE(`TIMRANGE)) dtim (.*); `ifdef BOOTTIMBASE - dtim #(.BASE(`BOOTTIMBASE), .RANGE(`BOOTTIMRANGE)) bootdtim (.MemRWtim(MemRWboottim), - .HSELTim(HSELBootTim), .HREADTim(HREADBootTim), .HRESPTim(HRESPBootTim), .HREADYTim(HREADYBootTim), .*); + dtim #(.BASE(`BOOTTIMBASE), .RANGE(`BOOTTIMRANGE)) bootdtim(.HSELTim(HSELBootTim), .HREADTim(HREADBootTim), .HRESPTim(HRESPBootTim), .HREADYTim(HREADYBootTim), .*); `endif // memory-mapped I/O peripherals From 612f7a9ee467d0efcefaf921f58f127ef4eaa1f8 Mon Sep 17 00:00:00 2001 From: bbracker Date: Fri, 5 Mar 2021 15:07:34 -0500 Subject: [PATCH 44/46] added a delay to sel signals --- wally-pipelined/src/uncore/uncore.sv | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/wally-pipelined/src/uncore/uncore.sv b/wally-pipelined/src/uncore/uncore.sv index ae6899c47..c068616c9 100644 --- a/wally-pipelined/src/uncore/uncore.sv +++ b/wally-pipelined/src/uncore/uncore.sv @@ -140,17 +140,15 @@ module uncore ( HSELUARTD); - // Synchronized Address Decoder (figure 4-2 in spec) - always_ff @(posedge HCLK) begin - HSELTimD <= HSELTim; - HSELCLINTD <= HSELCLINT; - `ifdef GPIOBASE - HSELGPIOD <= HSELGPIO; - `endif - HSELUARTD <= HSELUART; - `ifdef BOOTTIMBASE - HSELBootTimD <= HSELBootTim; - `endif - end + // Address Decoder Delay (figure 4-2 in spec) + flopr #(1) hseltimreg(HCLK, ~HRESETn, HSELTim, HSELTimD); + flopr #(1) hselclintreg(HCLK, ~HRESETn, HSELCLINT, HSELCLINTD); + `ifdef GPIOBASE + flopr #(1) hselgpioreg(HCLK, ~HRESETn, HSELGPIO, HSELGPIOD); + `endif + flopr #(1) hseluartreg(HCLK, ~HRESETn, HSELUART, HSELUARTD); + `ifdef BOOTTIMBASE + flopr #(1) hselboottimreg(HCLK, ~HRESETn, HSELBootTim, HSELBootTimD); + `endif endmodule From 698190752151634736ec45a8e3d3aae6ce05b2a7 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Fri, 5 Mar 2021 20:27:01 +0000 Subject: [PATCH 45/46] fix wally-pipelined-batch.do to match wally-pipelined.do --- .../regression/wally-pipelined-batch.do | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/wally-pipelined/regression/wally-pipelined-batch.do b/wally-pipelined/regression/wally-pipelined-batch.do index 883721d26..83e50d732 100644 --- a/wally-pipelined/regression/wally-pipelined-batch.do +++ b/wally-pipelined/regression/wally-pipelined-batch.do @@ -6,13 +6,12 @@ # Go Cowboys!!!!!! # # Takes 1:10 to run RV64IC tests using gui -# 11 seconds to run batch mode -# Use this wally-pipelined.do file to run this example. +# Use this wally-pipelined-batch.do file to run this example. # Either bring up ModelSim and type the following at the "ModelSim>" prompt: -# do wally-pipelined.do ../config/rv64ic +# do wally-pipelined-batch.do # or, to run from a shell, type the following at the shell prompt: -# vsim -c -do wally-pipelined.do ../config/rv64ic +# vsim -do wally-pipelined-batch.do -c # (omit the "-c" to see the GUI while running from the shell) onbreak {resume} @@ -27,12 +26,22 @@ vlib work # suppress spurious warnngs about # "Extra checking for conflicts with always_comb done at vopt time" # because vsim will run vopt -vlog +incdir+$1 ../testbench/testbench-imperas.sv ../src/*/*.sv -suppress 2583 +# default to config/rv64ic, but allow this to be overridden at the command line. For example: +# do wally-pipelined-batch.do ../config/rv32ic +switch $argc { + 0 {vlog +incdir+../config/rv64ic ../testbench/testbench-imperas.sv ../src/*/*.sv -suppress 2583} + 1 {vlog +incdir+$1 ../testbench/testbench-imperas.sv ../src/*/*.sv -suppress 2583} +} # start and run simulation # remove +acc flag for faster sim during regressions if there is no need to access internal signals -vopt work.testbench -o workopt +vopt +acc work.testbench -o workopt vsim workopt +# load the branch predictors with known data. The value of the data is not important for function, but +# is important for perventing pessimistic x propagation. +mem load -infile twoBitPredictor.txt -format bin testbench/dut/hart/ifu/bpred/DirPredictor/memory/memory +mem load -infile BTBPredictor.txt -format bin testbench/dut/hart/ifu/bpred/TargetPredictor/memory/memory + run -all quit From d3bf36b15f7ec8d07eba74e43881270dd7ca1258 Mon Sep 17 00:00:00 2001 From: Noah Boorstin Date: Fri, 5 Mar 2021 21:01:41 +0000 Subject: [PATCH 46/46] busybear: add branch preditor loading to do file (sorry to add more loading to the do instead of less) --- wally-pipelined/regression/wally-busybear.do | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wally-pipelined/regression/wally-busybear.do b/wally-pipelined/regression/wally-busybear.do index d240ef730..3d285d08b 100644 --- a/wally-pipelined/regression/wally-busybear.do +++ b/wally-pipelined/regression/wally-busybear.do @@ -33,6 +33,11 @@ vlog +incdir+../config/busybear ../testbench/*.sv ../src/*/*.sv -suppress 2583 # remove +acc flag for faster sim during regressions if there is no need to access internal signals vopt +acc work.testbench_busybear -o workopt vsim workopt -suppress 8852,12070 +# load the branch predictors with known data. The value of the data is not important for function, but +# is important for perventing pessimistic x propagation. +mem load -infile twoBitPredictor.txt -format bin /testbench_busybear/dut/hart/ifu/bpred/DirPredictor/memory/memory +mem load -infile BTBPredictor.txt -format bin /testbench_busybear/dut/hart/ifu/bpred/TargetPredictor/memory/memory + mem load -startaddress 0 -endaddress 2047 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/uncore/bootdtim/RAM mem load -startaddress 512 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/dut/uncore/bootdtim/RAM mem load -startaddress 0 -endaddress 2047 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/imem/bootram