mirror of
				https://github.com/openhwgroup/cvw
				synced 2025-02-11 06:05:49 +00:00 
			
		
		
		
	Testbench automatically creates memfile, label, addr files if they are out of date or missing
This commit is contained in:
		
							parent
							
								
									9b120bb3aa
								
							
						
					
					
						commit
						8645441d00
					
				
							
								
								
									
										12
									
								
								testbench/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								testbench/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					# Makefile for testbench to create .memfile, .objdump.addr, and .objdump.lab from an ELF
 | 
				
			||||||
 | 
					# David_Harris@hmc.edu 3 July 2024
 | 
				
			||||||
 | 
					# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%.elf.memfile: %.elf
 | 
				
			||||||
 | 
						riscv64-unknown-elf-elf2hex --bit-width 64 --input $< --output $@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%.elf.objdump.addr: %.elf.objdump
 | 
				
			||||||
 | 
						extractFunctionRadix.sh $<
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%.elf.objdump: %.elf
 | 
				
			||||||
 | 
						riscv64-unknown-elf-objdump -S -D $< > $@
 | 
				
			||||||
@ -54,11 +54,14 @@ module testbench;
 | 
				
			|||||||
  `ifdef VERILATOR
 | 
					  `ifdef VERILATOR
 | 
				
			||||||
      import "DPI-C" function string getenvval(input string env_name);
 | 
					      import "DPI-C" function string getenvval(input string env_name);
 | 
				
			||||||
      string       RISCV_DIR = getenvval("RISCV"); // "/opt/riscv";
 | 
					      string       RISCV_DIR = getenvval("RISCV"); // "/opt/riscv";
 | 
				
			||||||
 | 
					      string       WALLY_DIR = getenvval("WALLY"); // ~/cvw typical
 | 
				
			||||||
  `elsif VCS
 | 
					  `elsif VCS
 | 
				
			||||||
      import "DPI-C" function string getenv(input string env_name);
 | 
					      import "DPI-C" function string getenv(input string env_name);
 | 
				
			||||||
      string       RISCV_DIR = getenv("RISCV"); // "/opt/riscv";
 | 
					      string       RISCV_DIR = getenv("RISCV"); // "/opt/riscv";
 | 
				
			||||||
 | 
					      string       WALLY_DIR = getenv("WALLY"); 
 | 
				
			||||||
  `else
 | 
					  `else
 | 
				
			||||||
      string       RISCV_DIR = "$RISCV"; // "/opt/riscv";
 | 
					      string       RISCV_DIR = "$RISCV"; // "/opt/riscv";
 | 
				
			||||||
 | 
					      string       WALLY_DIR = "$WALLY";
 | 
				
			||||||
  `endif
 | 
					  `endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  `include "parameter-defs.vh"
 | 
					  `include "parameter-defs.vh"
 | 
				
			||||||
@ -382,7 +385,7 @@ module testbench;
 | 
				
			|||||||
      // declare memory labels that interest us, the updateProgramAddrLabelArray task will find 
 | 
					      // declare memory labels that interest us, the updateProgramAddrLabelArray task will find 
 | 
				
			||||||
      // the addr of each label and fill the array. To expand, add more elements to this array 
 | 
					      // the addr of each label and fill the array. To expand, add more elements to this array 
 | 
				
			||||||
      // and initialize them to zero (also initilaize them to zero at the start of the next test)
 | 
					      // and initialize them to zero (also initilaize them to zero at the start of the next test)
 | 
				
			||||||
      updateProgramAddrLabelArray(ProgramAddrMapFile, ProgramLabelMapFile, ProgramAddrLabelArray);
 | 
					      updateProgramAddrLabelArray(ProgramAddrMapFile, ProgramLabelMapFile, memfilename, WALLY_DIR, ProgramAddrLabelArray);
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
`ifdef VERILATOR // this macro is defined when verilator is used
 | 
					`ifdef VERILATOR // this macro is defined when verilator is used
 | 
				
			||||||
  // Simulator Verilator has an issue that the validate logic below slows runtime 110x if it is 
 | 
					  // Simulator Verilator has an issue that the validate logic below slows runtime 110x if it is 
 | 
				
			||||||
@ -931,10 +934,15 @@ endmodule
 | 
				
			|||||||
task automatic updateProgramAddrLabelArray;
 | 
					task automatic updateProgramAddrLabelArray;
 | 
				
			||||||
  /* verilator lint_off WIDTHTRUNC */
 | 
					  /* verilator lint_off WIDTHTRUNC */
 | 
				
			||||||
  /* verilator lint_off WIDTHEXPAND */
 | 
					  /* verilator lint_off WIDTHEXPAND */
 | 
				
			||||||
  input string ProgramAddrMapFile, ProgramLabelMapFile;
 | 
					  input string ProgramAddrMapFile, ProgramLabelMapFile, memfilename, WALLY_DIR;
 | 
				
			||||||
  inout  integer ProgramAddrLabelArray [string];
 | 
					  inout  integer ProgramAddrLabelArray [string];
 | 
				
			||||||
  // Gets the memory location of begin_signature
 | 
					  // Gets the memory location of begin_signature
 | 
				
			||||||
  integer ProgramLabelMapFP, ProgramAddrMapFP;
 | 
					  integer ProgramLabelMapFP, ProgramAddrMapFP;
 | 
				
			||||||
 | 
					  string cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // if memfile, label, or addr files are out of date or don't exist, generate them
 | 
				
			||||||
 | 
					  cmd = {"make -f ", WALLY_DIR, "/testbench/Makefile ", memfilename, " ", ProgramAddrMapFile};
 | 
				
			||||||
 | 
					  $system(cmd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ProgramLabelMapFP = $fopen(ProgramLabelMapFile, "r");
 | 
					  ProgramLabelMapFP = $fopen(ProgramLabelMapFile, "r");
 | 
				
			||||||
  ProgramAddrMapFP = $fopen(ProgramAddrMapFile, "r");
 | 
					  ProgramAddrMapFP = $fopen(ProgramAddrMapFile, "r");
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user