diff --git a/testbench/testbench.sv b/testbench/testbench.sv index be2df5a59..29b5207a0 100644 --- a/testbench/testbench.sv +++ b/testbench/testbench.sv @@ -388,11 +388,10 @@ module testbench; end end - // *** 06 January 2024 RT: may have to uncomment this block for vcs/verilator integer adrindex; if (P.UNCORE_RAM_SUPPORTED) always @(posedge clk) - if (ResetMem) // program memory is sometimes reset + if (ResetMem) // program memory is sometimes reset (e.g. for CoreMark, which needs zeroed memory) for (adrindex=0; adrindex<(P.UNCORE_RAM_RANGE>>1+(P.XLEN/32)); adrindex = adrindex+1) dut.uncore.uncore.ram.ram.memory.RAM[adrindex] = '0; @@ -442,6 +441,15 @@ module testbench; clk = 1; # 5; clk = 0; # 5; end + /* + // Print key info each cycle for debugging + always @(posedge clk) begin + #2; + $display("PCM: %x InstrM: %x (%5s) WriteDataM: %x IEUResultM: %x", + dut.core.PCM, dut.core.InstrM, InstrMName, dut.core.WriteDataM, dut.core.ieu.dp.IEUResultM); + end + */ + //////////////////////////////////////////////////////////////////////////////// // Support logic //////////////////////////////////////////////////////////////////////////////// @@ -504,6 +512,9 @@ module testbench; input logic riscofTest; input integer begin_signature_addr; output integer errors; + int fd, code; + string line; + int siglines, sigentries; localparam SIGNATURESIZE = 5000000; integer i; @@ -512,41 +523,48 @@ module testbench; string signame; logic [P.XLEN-1:0] testadr, testadrNoBase; - // for tests with no self checking mechanism, read .signature.output file and compare to check for errors - // clear signature to prevent contamination from previous tests - for(i=0; i 1) begin // skip blank lines + if ($sscanf(line, "%x", sig32[siglines])) siglines = siglines + 1; // increment if line is not blank + end end + $fclose(fd); end + // Check valid number of lines were read + if (siglines == 0) begin + errors = 1; + $display("Error: empty test file %s", signame); + end else if (P.XLEN == 64 & (siglines % 2)) begin + errors = 1; + $display("Error: RV64 signature has odd number of lines %s", signame); + end else errors = 0; + + // copy lines into signature, converting to XLEN if necessary + sigentries = (P.XLEN == 32) ? siglines : siglines/2; // number of signature entries + for (i=0; i