forked from Github_Repos/cvw
		
	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 | ||||
| 
 | ||||
|   string signame, memfilename, pathname, objdumpfilename, adrstr; | ||||
|   string signame, memfilename, pathname, objdumpfilename, adrstr, outputfile; | ||||
|   integer outputFilePointer; | ||||
| 
 | ||||
|   logic [31:0] GPIOPinsIn, GPIOPinsOut, GPIOPinsEn; | ||||
|   logic UARTSin, UARTSout; | ||||
| @ -213,70 +214,88 @@ logic [3:0] dummy; | ||||
|           $display("Benchmark: coremark is done."); | ||||
|           $stop; | ||||
|         end | ||||
|       // Termination condition (i.e. we finished running current test) 
 | ||||
|       if (DCacheFlushDone) begin | ||||
|   | ||||
|         #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; | ||||
|         // Gets the memory location of begin_signature
 | ||||
|         testadr = (`RAM_BASE+tests[test+1].atohex())/(`XLEN/8); | ||||
|         testadrNoBase = (tests[test+1].atohex())/(`XLEN/8); | ||||
|         /* verilator lint_off INFINITELOOP */ | ||||
|         while (signature[i] !== 'bx) begin | ||||
|           logic [`XLEN-1:0] sig; | ||||
|           if (`DMEM == `MEM_TIM) sig = dut.core.lsu.dtim.dtim.ram.memory.RAM[testadrNoBase+i]; | ||||
|           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
 | ||||
|         #600; // give time for instructions in pipeline to finish
 | ||||
|         if (TEST == "embench") begin | ||||
|           // Writes contents of begin_signature to .sim.output file
 | ||||
|           // this contains instret and cycles for start and end of test run, used by embench python speed script to calculate embench speed score
 | ||||
|           // also begin_signature contains the results of the self checking mechanism, which will be read by the python script for error checking
 | ||||
|           $display("Embench Benchmark: %s is done.", tests[test]); | ||||
|           outputfile = {pathname, tests[test], ".sim.output"}; | ||||
|           outputFilePointer = $fopen(outputfile); | ||||
|           i = 0; | ||||
|           while ($unsigned(i) < $unsigned(5'd5)) begin | ||||
|             $fdisplayh(outputFilePointer, DCacheFlushFSM.ShadowRAM[testadr+i]); | ||||
|             i = i + 1; | ||||
|           end | ||||
|           $fclose(outputFilePointer); | ||||
|           $display("Embench Benchmark: created output file: %s", outputfile); | ||||
|         end else begin  | ||||
|           // 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<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 | ||||
|           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; | ||||
| 
 | ||||
|           // Check errors
 | ||||
|           errors = (i == SIGNATURESIZE+1); // error if file is empty
 | ||||
|           i = 0; | ||||
|           /* verilator lint_off INFINITELOOP */ | ||||
|           while (signature[i] !== 'bx) begin | ||||
|             logic [`XLEN-1:0] sig; | ||||
|             if (`DMEM == `MEM_TIM) sig = dut.core.lsu.dtim.dtim.ram.memory.RAM[testadrNoBase+i]; | ||||
|             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 | ||||
|         // move onto the next test, check to see if we're done
 | ||||
|         test = test + 2; | ||||
|         if (test == tests.size()) begin | ||||
|           if (totalerrors == 0) $display("SUCCESS! All tests ran without failures."); | ||||
| @ -284,6 +303,7 @@ logic [3:0] dummy; | ||||
|           $stop; | ||||
|         end | ||||
|         else begin | ||||
|             // If there are still additional tests to run, read in information for the next test
 | ||||
|             //pathname = tvpaths[tests[0]];
 | ||||
|             memfilename = {pathname, tests[test], ".elf.memfile"}; | ||||
|             //$readmemh(memfilename, dut.uncore.ram.ram.memory.RAM);
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user