diff --git a/testbench/testbench.sv b/testbench/testbench.sv index 1de54a670..542ddc874 100644 --- a/testbench/testbench.sv +++ b/testbench/testbench.sv @@ -182,8 +182,7 @@ module testbench; logic ResetCntRst; - string signame, memfilename, pathname, objdumpfilename, adrstr, outputfile; - integer outputFilePointer; + string signame, memfilename, pathname; integer begin_signature_addr; assign ResetThreshold = 3'd5; @@ -214,7 +213,6 @@ module testbench; STATE_TESTBENCH_RESET: begin NextState = STATE_INIT_TEST; test = 1; - ResetMem = 1; // only need to reset the memories once. Assumes the tests don't write xs to memory. reset_ext = 1; end STATE_INIT_TEST: begin @@ -258,6 +256,8 @@ module testbench; STATE_RESET_MEMORIES: begin NextState = STATE_LOAD_MEMORIES; reset_ext = 1; + // this initialization is very expensive, only do it for coremark. + if (TEST == "coremark") ResetMem = 1; end STATE_LOAD_MEMORIES: begin NextState = STATE_RESET_TEST; @@ -295,6 +295,11 @@ module testbench; end STATE_VALIDATE: begin NextState = STATE_INIT_TEST; + if (TEST == "coremark") + if (dut.core.priv.priv.EcallFaultM) begin + $display("Benchmark: coremark is done."); + $stop; + end if (!begin_signature_addr) $display("begin_signature addr not found in %s", ProgramLabelMapFile); else begin @@ -350,20 +355,22 @@ module testbench; //////////////////////////////////////////////////////////////////////////////// // load memories with program image //////////////////////////////////////////////////////////////////////////////// - always @(posedge LoadMem) begin - if (P.FPGA) begin - string romfilename, sdcfilename; - romfilename = {"../tests/custom/fpga-test-sdc/bin/fpga-test-sdc.memfile"}; - sdcfilename = {"../testbench/sdc/ramdisk2.hex"}; - $readmemh(romfilename, dut.uncore.uncore.bootrom.bootrom.memory.ROM); - $readmemh(sdcfilename, sdcard.sdcard.FLASHmem); - // shorten sdc timers for simulation - dut.uncore.uncore.sdc.SDC.LimitTimers = 1; - end - else if (P.IROM_SUPPORTED) $readmemh(memfilename, dut.core.ifu.irom.irom.rom.ROM); - else if (P.BUS_SUPPORTED) $readmemh(memfilename, dut.uncore.uncore.ram.ram.memory.RAM); - if (P.DTIM_SUPPORTED) $readmemh(memfilename, dut.core.lsu.dtim.dtim.ram.RAM); - $display("Read memfile %s", memfilename); + always @(posedge clk) begin + if (LoadMem) begin + if (P.FPGA) begin + string romfilename, sdcfilename; + romfilename = {"../tests/custom/fpga-test-sdc/bin/fpga-test-sdc.memfile"}; + sdcfilename = {"../testbench/sdc/ramdisk2.hex"}; + $readmemh(romfilename, dut.uncore.uncore.bootrom.bootrom.memory.ROM); + $readmemh(sdcfilename, sdcard.sdcard.FLASHmem); + // shorten sdc timers for simulation + dut.uncore.uncore.sdc.SDC.LimitTimers = 1; + end + else if (P.IROM_SUPPORTED) $readmemh(memfilename, dut.core.ifu.irom.irom.rom.ROM); + else if (P.BUS_SUPPORTED) $readmemh(memfilename, dut.uncore.uncore.ram.ram.memory.RAM); + if (P.DTIM_SUPPORTED) $readmemh(memfilename, dut.core.lsu.dtim.dtim.ram.RAM); + $display("Read memfile %s", memfilename); + end end @@ -382,8 +389,6 @@ module testbench; logic HREADY; logic HSELEXT; - logic InitializingMemories; - integer ResetCountOld, ResetThresholdOld; logic InReset; logic BeginSample; @@ -428,70 +433,6 @@ module testbench; dut.core.ifu.InstrM, InstrW, InstrFName, InstrDName, InstrEName, InstrMName, InstrWName); - // initialize tests - localparam MemStartAddr = 0; - localparam MemEndAddr = P.UNCORE_RAM_RANGE>>1+(P.XLEN/32); - - initial - begin - ResetCountOld = 0; - ResetThresholdOld = 2; - InReset = 1; - //test = 1; - //totalerrors = 0; - testadr = 0; - testadrNoBase = 0; - // riscof tests have a different signature, tests[0] == "1" refers to RiscvArchTests - // and tests[0] == "2" refers to WallyRiscvArchTests - //riscofTest = tests[0] == "1" | tests[0] == "2"; - // fill memory with defined values to reduce Xs in simulation - // Quick note the memory will need to be initialized. The C library does not - // guarantee the initialized reads. For example a strcmp can read 6 byte - // strings, but uses a load double to read them in. If the last 2 bytes are - // not initialized the compare results in an 'x' which propagates through - // the design. -/* -----\/----- EXCLUDED -----\/----- - if (TEST == "coremark") - for (i=MemStartAddr; i