mirror of
				https://github.com/openhwgroup/cvw
				synced 2025-02-11 06:05:49 +00:00 
			
		
		
		
	added support for embench post processing to testbench.sv
This commit is contained in:
		
							parent
							
								
									ee7070c5b6
								
							
						
					
					
						commit
						d28b4cf602
					
				@ -128,7 +128,8 @@ logic [3:0] dummy;
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  string signame, memfilename, pathname, objdumpfilename, adrstr;
 | 
					  string signame, memfilename, pathname, objdumpfilename, adrstr, outputfile;
 | 
				
			||||||
 | 
					  integer outputFilePointer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  logic [31:0] GPIOPinsIn, GPIOPinsOut, GPIOPinsEn;
 | 
					  logic [31:0] GPIOPinsIn, GPIOPinsOut, GPIOPinsEn;
 | 
				
			||||||
  logic UARTSin, UARTSout;
 | 
					  logic UARTSin, UARTSout;
 | 
				
			||||||
@ -213,70 +214,88 @@ logic [3:0] dummy;
 | 
				
			|||||||
          $display("Benchmark: coremark is done.");
 | 
					          $display("Benchmark: coremark is done.");
 | 
				
			||||||
          $stop;
 | 
					          $stop;
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					      // Termination condition (i.e. we finished running current test) 
 | 
				
			||||||
      if (DCacheFlushDone) begin
 | 
					      if (DCacheFlushDone) begin
 | 
				
			||||||
 
 | 
					        // Gets the memory location of begin_signature
 | 
				
			||||||
        #600; // give time for instructions in pipeline to finish
 | 
					 | 
				
			||||||
        // clear signature to prevent contamination from previous tests
 | 
					 | 
				
			||||||
        for(i=0; i<SIGNATURESIZE; i=i+1) begin
 | 
					 | 
				
			||||||
          sig32[i] = 'bx;
 | 
					 | 
				
			||||||
        end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // read signature, reformat in 64 bits if necessary
 | 
					 | 
				
			||||||
        signame = {pathname, tests[test], ".signature.output"};
 | 
					 | 
				
			||||||
        $readmemh(signame, sig32);
 | 
					 | 
				
			||||||
        i = 0;
 | 
					 | 
				
			||||||
        while (i < SIGNATURESIZE) begin
 | 
					 | 
				
			||||||
          if (`XLEN == 32) begin
 | 
					 | 
				
			||||||
            signature[i] = sig32[i];
 | 
					 | 
				
			||||||
            i = i+1;
 | 
					 | 
				
			||||||
          end else begin
 | 
					 | 
				
			||||||
            signature[i/2] = {sig32[i+1], sig32[i]};
 | 
					 | 
				
			||||||
            i = i + 2;
 | 
					 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
          if (i >= 4 & sig32[i-4] === 'bx) begin
 | 
					 | 
				
			||||||
            if (i == 4) begin
 | 
					 | 
				
			||||||
              i = SIGNATURESIZE+1; // flag empty file
 | 
					 | 
				
			||||||
              $display("  Error: empty test file");
 | 
					 | 
				
			||||||
            end else i = SIGNATURESIZE; // skip over the rest of the x's for efficiency
 | 
					 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
        end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Check errors
 | 
					 | 
				
			||||||
        errors = (i == SIGNATURESIZE+1); // error if file is empty
 | 
					 | 
				
			||||||
        i = 0;
 | 
					 | 
				
			||||||
        testadr = (`RAM_BASE+tests[test+1].atohex())/(`XLEN/8);
 | 
					        testadr = (`RAM_BASE+tests[test+1].atohex())/(`XLEN/8);
 | 
				
			||||||
        testadrNoBase = (tests[test+1].atohex())/(`XLEN/8);
 | 
					        testadrNoBase = (tests[test+1].atohex())/(`XLEN/8);
 | 
				
			||||||
        /* verilator lint_off INFINITELOOP */
 | 
					        #600; // give time for instructions in pipeline to finish
 | 
				
			||||||
        while (signature[i] !== 'bx) begin
 | 
					        if (TEST == "embench") begin
 | 
				
			||||||
          logic [`XLEN-1:0] sig;
 | 
					          // Writes contents of begin_signature to .sim.output file
 | 
				
			||||||
          if (`DMEM == `MEM_TIM) sig = dut.core.lsu.dtim.dtim.ram.memory.RAM[testadrNoBase+i];
 | 
					          // this contains instret and cycles for start and end of test run, used by embench python speed script to calculate embench speed score
 | 
				
			||||||
          else                   sig = dut.uncore.ram.ram.memory.RAM[testadrNoBase+i];
 | 
					          // also begin_signature contains the results of the self checking mechanism, which will be read by the python script for error checking
 | 
				
			||||||
          //$display("signature[%h] = %h sig = %h", i, signature[i], sig);
 | 
					          $display("Embench Benchmark: %s is done.", tests[test]);
 | 
				
			||||||
          if (signature[i] !== sig &
 | 
					          outputfile = {pathname, tests[test], ".sim.output"};
 | 
				
			||||||
          //if (signature[i] !== dut.core.lsu.dtim.ram.memory.RAM[testadr+i] &
 | 
					          outputFilePointer = $fopen(outputfile);
 | 
				
			||||||
	      (signature[i] !== DCacheFlushFSM.ShadowRAM[testadr+i])) begin  // ***i+1?
 | 
					          i = 0;
 | 
				
			||||||
            if ((signature[i] !== '0 | signature[i+4] !== 'x)) begin
 | 
					          while ($unsigned(i) < $unsigned(5'd5)) begin
 | 
				
			||||||
              // if (signature[i+4] !== 'bx | (signature[i] !== 32'hFFFFFFFF & signature[i] !== 32'h00000000)) begin
 | 
					            $fdisplayh(outputFilePointer, DCacheFlushFSM.ShadowRAM[testadr+i]);
 | 
				
			||||||
              // report errors unless they are garbage at the end of the sim
 | 
					            i = i + 1;
 | 
				
			||||||
              // kind of hacky test for garbage right now
 | 
					          end
 | 
				
			||||||
              $display("sig4 = %h ne %b", signature[i+4], signature[i+4] !== 'bx);
 | 
					          $fclose(outputFilePointer);
 | 
				
			||||||
              errors = errors+1;
 | 
					          $display("Embench Benchmark: created output file: %s", outputfile);
 | 
				
			||||||
              $display("  Error on test %s result %d: adr = %h sim (D$) %h sim (DMEM) = %h, signature = %h", 
 | 
					        end else begin 
 | 
				
			||||||
                    tests[test], i, (testadr+i)*(`XLEN/8), DCacheFlushFSM.ShadowRAM[testadr+i], sig, signature[i]);
 | 
					          // for tests with no self checking mechanism, read .signature.output file and compare to check for errors
 | 
				
			||||||
                    //   tests[test], i, (testadr+i)*(`XLEN/8), DCacheFlushFSM.ShadowRAM[testadr+i], dut.core.lsu.dtim.ram.memory.RAM[testadr+i], signature[i]);
 | 
					          // clear signature to prevent contamination from previous tests
 | 
				
			||||||
              $stop;//***debug
 | 
					          for(i=0; i<SIGNATURESIZE; i=i+1) begin
 | 
				
			||||||
 | 
					            sig32[i] = 'bx;
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					          // read signature, reformat in 64 bits if necessary
 | 
				
			||||||
 | 
					          signame = {pathname, tests[test], ".signature.output"};
 | 
				
			||||||
 | 
					          $readmemh(signame, sig32);
 | 
				
			||||||
 | 
					          i = 0;
 | 
				
			||||||
 | 
					          while (i < SIGNATURESIZE) begin
 | 
				
			||||||
 | 
					            if (`XLEN == 32) begin
 | 
				
			||||||
 | 
					              signature[i] = sig32[i];
 | 
				
			||||||
 | 
					              i = i+1;
 | 
				
			||||||
 | 
					            end else begin
 | 
				
			||||||
 | 
					              signature[i/2] = {sig32[i+1], sig32[i]};
 | 
				
			||||||
 | 
					              i = i + 2;
 | 
				
			||||||
 | 
					            end
 | 
				
			||||||
 | 
					            if (i >= 4 & sig32[i-4] === 'bx) begin
 | 
				
			||||||
 | 
					              if (i == 4) begin
 | 
				
			||||||
 | 
					                i = SIGNATURESIZE+1; // flag empty file
 | 
				
			||||||
 | 
					                $display("  Error: empty test file");
 | 
				
			||||||
 | 
					              end else i = SIGNATURESIZE; // skip over the rest of the x's for efficiency
 | 
				
			||||||
            end
 | 
					            end
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
          i = i + 1;
 | 
					
 | 
				
			||||||
        end
 | 
					          // Check errors
 | 
				
			||||||
        /* verilator lint_on INFINITELOOP */
 | 
					          errors = (i == SIGNATURESIZE+1); // error if file is empty
 | 
				
			||||||
        if (errors == 0) begin
 | 
					          i = 0;
 | 
				
			||||||
          $display("%s succeeded.  Brilliant!!!", tests[test]);
 | 
					          /* verilator lint_off INFINITELOOP */
 | 
				
			||||||
        end
 | 
					          while (signature[i] !== 'bx) begin
 | 
				
			||||||
        else begin
 | 
					            logic [`XLEN-1:0] sig;
 | 
				
			||||||
          $display("%s failed with %d errors. :(", tests[test], errors);
 | 
					            if (`DMEM == `MEM_TIM) sig = dut.core.lsu.dtim.dtim.ram.memory.RAM[testadrNoBase+i];
 | 
				
			||||||
          totalerrors = totalerrors+1;
 | 
					            else                   sig = dut.uncore.ram.ram.memory.RAM[testadrNoBase+i];
 | 
				
			||||||
 | 
					            //$display("signature[%h] = %h sig = %h", i, signature[i], sig);
 | 
				
			||||||
 | 
					            if (signature[i] !== sig &
 | 
				
			||||||
 | 
					            //if (signature[i] !== dut.core.lsu.dtim.ram.memory.RAM[testadr+i] &
 | 
				
			||||||
 | 
					            (signature[i] !== DCacheFlushFSM.ShadowRAM[testadr+i])) begin  // ***i+1?
 | 
				
			||||||
 | 
					              if ((signature[i] !== '0 | signature[i+4] !== 'x)) begin
 | 
				
			||||||
 | 
					                // if (signature[i+4] !== 'bx | (signature[i] !== 32'hFFFFFFFF & signature[i] !== 32'h00000000)) begin
 | 
				
			||||||
 | 
					                // report errors unless they are garbage at the end of the sim
 | 
				
			||||||
 | 
					                // kind of hacky test for garbage right now
 | 
				
			||||||
 | 
					                $display("sig4 = %h ne %b", signature[i+4], signature[i+4] !== 'bx);
 | 
				
			||||||
 | 
					                errors = errors+1;
 | 
				
			||||||
 | 
					                $display("  Error on test %s result %d: adr = %h sim (D$) %h sim (DMEM) = %h, signature = %h", 
 | 
				
			||||||
 | 
					                      tests[test], i, (testadr+i)*(`XLEN/8), DCacheFlushFSM.ShadowRAM[testadr+i], sig, signature[i]);
 | 
				
			||||||
 | 
					                      //   tests[test], i, (testadr+i)*(`XLEN/8), DCacheFlushFSM.ShadowRAM[testadr+i], dut.core.lsu.dtim.ram.memory.RAM[testadr+i], signature[i]);
 | 
				
			||||||
 | 
					                $stop;//***debug
 | 
				
			||||||
 | 
					              end
 | 
				
			||||||
 | 
					            end
 | 
				
			||||||
 | 
					            i = i + 1;
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					          /* verilator lint_on INFINITELOOP */
 | 
				
			||||||
 | 
					          if (errors == 0) begin
 | 
				
			||||||
 | 
					            $display("%s succeeded.  Brilliant!!!", tests[test]);
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					          else begin
 | 
				
			||||||
 | 
					            $display("%s failed with %d errors. :(", tests[test], errors);
 | 
				
			||||||
 | 
					            totalerrors = totalerrors+1;
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					        // move onto the next test, check to see if we're done
 | 
				
			||||||
        test = test + 2;
 | 
					        test = test + 2;
 | 
				
			||||||
        if (test == tests.size()) begin
 | 
					        if (test == tests.size()) begin
 | 
				
			||||||
          if (totalerrors == 0) $display("SUCCESS! All tests ran without failures.");
 | 
					          if (totalerrors == 0) $display("SUCCESS! All tests ran without failures.");
 | 
				
			||||||
@ -284,6 +303,7 @@ logic [3:0] dummy;
 | 
				
			|||||||
          $stop;
 | 
					          $stop;
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
        else begin
 | 
					        else begin
 | 
				
			||||||
 | 
					            // If there are still additional tests to run, read in information for the next test
 | 
				
			||||||
            //pathname = tvpaths[tests[0]];
 | 
					            //pathname = tvpaths[tests[0]];
 | 
				
			||||||
            memfilename = {pathname, tests[test], ".elf.memfile"};
 | 
					            memfilename = {pathname, tests[test], ".elf.memfile"};
 | 
				
			||||||
            //$readmemh(memfilename, dut.uncore.ram.ram.memory.RAM);
 | 
					            //$readmemh(memfilename, dut.uncore.ram.ram.memory.RAM);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user