Refactor Elf eile handling for better Breker compatibility

This commit is contained in:
Jordan Carlin 2024-12-19 12:51:51 -08:00
parent 53b5c9557a
commit 2818bdbaa8
No known key found for this signature in database

View File

@ -57,13 +57,13 @@ def validateArgs(args):
def elfFileCheck(args): def elfFileCheck(args):
ElfFile = "" ElfFile = ""
if os.path.isfile(args.elf): if os.path.isfile(args.elf):
ElfFile = f"+ElfFile={os.path.abspath(args.elf)}" ElfFile = os.path.abspath(args.elf)
elif args.elf: elif args.elf:
print(f"ELF file not found: {args.elf}") print(f"ELF file not found: {args.elf}")
sys.exit(1) sys.exit(1)
elif args.testsuite.endswith('.elf'): # No --elf argument; check if testsuite has a .elf extension and use that instead elif args.testsuite.endswith('.elf'): # No --elf argument; check if testsuite has a .elf extension and use that instead
if os.path.isfile(args.testsuite): if os.path.isfile(args.testsuite):
ElfFile = f"+ElfFile={os.path.abspath(args.testsuite)}" ElfFile = os.path.abspath(args.testsuite)
# extract the elf name from the path to be the test suite # extract the elf name from the path to be the test suite
fields = args.testsuite.rsplit('/', 3) fields = args.testsuite.rsplit('/', 3)
# if the name is just ref.elf in a deep path (riscv-arch-test/wally-riscv-arch-test), then use the directory name as the test suite to make it unique; otherwise work directory will have duplicates. # if the name is just ref.elf in a deep path (riscv-arch-test/wally-riscv-arch-test), then use the directory name as the test suite to make it unique; otherwise work directory will have duplicates.
@ -94,7 +94,7 @@ def prepSim(args, ElfFile):
if args.tb == "testbench_fp": if args.tb == "testbench_fp":
paramsList.append(f'TEST="{args.testsuite}"') paramsList.append(f'TEST="{args.testsuite}"')
if ElfFile: if ElfFile:
argsList.append(f"{ElfFile}") argsList.append(f"+ElfFile={ElfFile}")
if args.gui and args.tb == "testbench": if args.gui and args.tb == "testbench":
paramsList.append("DEBUG=1") paramsList.append("DEBUG=1")
if args.ccov: if args.ccov:
@ -110,11 +110,11 @@ def prepSim(args, ElfFile):
if args.lockstep or args.lockstepverbose or args.fcov: if args.lockstep or args.lockstepverbose or args.fcov:
prefix = lockstepSetup(args) prefix = lockstepSetup(args)
defineList.append("+define+USE_IMPERAS_DV") defineList.append("+define+USE_IMPERAS_DV")
if "breker" in ElfFile: if args.config == "breker":
ElfFileNoExtension = os.path.splitext(args.testsuite)[0] ElfFileNoExtension = os.path.splitext(ElfFile)[0]
flagsList.append("--breker") flagsList.append("--breker")
defineList.append("+define+USE_TREK_DV") defineList.append("+define+USE_TREK_DV")
argsList.append(f"+TREK_TBX_FILE={WALLY}/tests/breker/work/{ElfFileNoExtension}/{ElfFileNoExtension}.tbx") argsList.append(f"+TREK_TBX_FILE={ElfFileNoExtension}.tbx")
# Combine into a single string # Combine into a single string
args.args += " ".join(argsList) args.args += " ".join(argsList)
args.params += " ".join(paramsList) args.params += " ".join(paramsList)