From c1ac153a4f68bffc2ea87f983122002b2eed57ad Mon Sep 17 00:00:00 2001 From: Rose Thompson Date: Mon, 18 Dec 2023 16:26:56 -0600 Subject: [PATCH] Closer to verilator support. --- testbench/common/DCacheFlushFSM.sv | 5 ++++- testbench/common/functionName.sv | 21 ++++++++++++++------- testbench/testbench.sv | 7 +++++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/testbench/common/DCacheFlushFSM.sv b/testbench/common/DCacheFlushFSM.sv index 983fa4932..152aaa173 100644 --- a/testbench/common/DCacheFlushFSM.sv +++ b/testbench/common/DCacheFlushFSM.sv @@ -97,7 +97,10 @@ module DCacheFlushFSM import cvw::*; #(parameter cvw_t P) // # ** Error: ../testbench/testbench.sv(483): Range must be bounded by constant expressions. // see https://verificationacademy.com/forums/systemverilog/range-must-be-bounded-constant-expressions //ShadowRAM[CacheAdr[j][i][k] >> $clog2(P.XLEN/8)] = cacheline[P.XLEN*(k+1)-1:P.XLEN*k]; - ShadowRAM[(CacheAdr[j][i][l] >> $clog2(P.XLEN/8)) + k] = CacheData[j][i][l][P.XLEN*k +: P.XLEN]; + /* verilator lint_off WIDTHTRUNC */ + // *** lint error: address trunc warning for shadowram index + ShadowRAM[(CacheAdr[j][i][l] >> $clog2(P.XLEN/8)) + {{{P.PA_BITS-32}{1'b0}}, k}] = CacheData[j][i][l][P.XLEN*k +: P.XLEN]; + /* verilator lint_on WIDTHTRUNC */ end end end diff --git a/testbench/common/functionName.sv b/testbench/common/functionName.sv index 7aebedea8..e59491621 100644 --- a/testbench/common/functionName.sv +++ b/testbench/common/functionName.sv @@ -30,7 +30,7 @@ module FunctionName import cvw::*; #(parameter cvw_t P) ( input string ProgramLabelMapFile ); - logic [P.XLEN-1:0] ProgramAddrMapMemory []; + logic [P.XLEN-1:0] ProgramAddrMapMemory [longint]; string ProgramLabelMapMemory [integer]; string FunctionName; @@ -62,7 +62,7 @@ module FunctionName import cvw::*; #(parameter cvw_t P) ( task automatic bin_search_min; input logic [P.XLEN-1:0] pc; input logic [P.XLEN-1:0] length; - ref logic [P.XLEN-1:0] array []; + ref logic [P.XLEN-1:0] array [longint]; output logic [P.XLEN-1:0] minval; output logic [P.XLEN-1:0] mid; @@ -109,7 +109,8 @@ module FunctionName import cvw::*; #(parameter cvw_t P) ( endtask // bin_search_min integer ProgramAddrMapFP, ProgramLabelMapFP; - integer ProgramAddrMapLineCount, ProgramLabelMapLineCount; + longint ProgramAddrMapLineCount; + integer ProgramLabelMapLineCount; longint ProgramAddrMapLine; string ProgramLabelMapLine; integer status; @@ -118,11 +119,17 @@ module FunctionName import cvw::*; #(parameter cvw_t P) ( // preload // initial begin always @ (negedge reset) begin + + // cannot readmemh directoy to a dynmaic array. Sad times :( + // Let's initialize a static array with FFFF_FFFF for all addresses. + // Then we can readmemh and finally copy to the dynamic array. + // clear out the old mapping between programs. ProgramAddrMapMemory.delete(); ProgramLabelMapMemory.delete(); - $readmemh(ProgramAddrMapFile, ProgramAddrMapMemory); + // Unfortunately verilator version 5.011 readmemh does not support dynamic arrays + //$readmemh(ProgramAddrMapFile, ProgramAddrMapMemory); // we need to count the number of lines in the file so we can set FunctionRadixLineCount. ProgramAddrMapLineCount = 0; @@ -131,9 +138,9 @@ module FunctionName import cvw::*; #(parameter cvw_t P) ( // read line by line to count lines if (ProgramAddrMapFP) begin while (! $feof(ProgramAddrMapFP)) begin - status = $fscanf(ProgramAddrMapFP, "%h\n", ProgramAddrMapLine); - - ProgramAddrMapLineCount = ProgramAddrMapLineCount + 1; + status = $fscanf(ProgramAddrMapFP, "%h\n", ProgramAddrMapLine); + ProgramAddrMapMemory[ProgramAddrMapLineCount] = ProgramAddrMapLine; + ProgramAddrMapLineCount = ProgramAddrMapLineCount + 1; end end else begin $display("Cannot open file %s for reading.", ProgramAddrMapFile); diff --git a/testbench/testbench.sv b/testbench/testbench.sv index f58304a25..f8a174a1b 100644 --- a/testbench/testbench.sv +++ b/testbench/testbench.sv @@ -563,8 +563,11 @@ module testbench; /* verilator lint_off INFINITELOOP */ while (signature[i] !== 'bx) begin logic [P.XLEN-1:0] sig; - if (P.DTIM_SUPPORTED) sig = testbench.dut.core.lsu.dtim.dtim.ram.RAM[testadrNoBase+i]; - else if (P.UNCORE_RAM_SUPPORTED) sig = testbench.dut.uncore.uncore.ram.ram.memory.RAM[testadrNoBase+i]; + // ************************************** + // ***** BUG BUG BUG make sure RT undoes this. + //if (P.DTIM_SUPPORTED) sig = testbench.dut.core.lsu.dtim.dtim.ram.RAM[testadrNoBase+i]; + //else if (P.UNCORE_RAM_SUPPORTED) sig = testbench.dut.uncore.uncore.ram.ram.memory.RAM[testadrNoBase+i]; + if (P.UNCORE_RAM_SUPPORTED) sig = testbench.dut.uncore.uncore.ram.ram.memory.RAM[testadrNoBase+i]; //$display("signature[%h] = %h sig = %h", i, signature[i], sig); if (signature[i] !== sig & (signature[i] !== testbench.DCacheFlushFSM.ShadowRAM[testadr+i])) begin errors = errors+1;