From 775881f123047fc0e3782c3e0e74dcd7ea427c71 Mon Sep 17 00:00:00 2001 From: Jordan Carlin Date: Sun, 1 Dec 2024 14:17:07 -0800 Subject: [PATCH] Make testsuite parameter to wsim optional if passing the --elf flag --- bin/wsim | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/bin/wsim b/bin/wsim index 44d9152f5..c13216a6f 100755 --- a/bin/wsim +++ b/bin/wsim @@ -20,7 +20,7 @@ WALLY = os.environ.get('WALLY') def parseArgs(): parser = argparse.ArgumentParser() parser.add_argument("config", help="Configuration file") - parser.add_argument("testsuite", help="Test suite or path to .elf file") + parser.add_argument("testsuite", nargs="?", help="Test suite or path to .elf file") parser.add_argument("--elf", "-e", help="ELF File name; use if name does not end in .elf", default="") parser.add_argument("--sim", "-s", help="Simulator", choices=["questa", "verilator", "vcs"], default="questa") parser.add_argument("--tb", "-t", help="Testbench", choices=["testbench", "testbench_fp"], default="testbench") @@ -37,6 +37,20 @@ def parseArgs(): parser.add_argument("--rvvi", "-r", help="Simulate rvvi hardware interface and ethernet.", action="store_true") return parser.parse_args() +def validateArgs(args): + if not args.testsuite and not args.elf: + print("Error: Missing test suite or ELF file") + exit(1) + if(args.lockstep and not args.testsuite.endswith('.elf') and not args.testsuite == "buildroot"): + print(f"Invalid Options. Cannot run a testsuite, {args.testsuite} with lockstep. Must run a single elf.") + exit(1) + elif (args.gui or args.ccov or args.fcov or args.lockstep or args.lockstepverbose) and args.sim not in ["questa", "vcs"]: + print("Option only supported for Questa and VCS") + exit(1) + elif (args.tb == "testbench_fp" and args.sim != "questa"): + print("Error: testbench_fp presently only supported by Questa, not VCS or Verilator, because of a touchy testbench") + exit(1) + def elfFileCheck(args): ElfFile = "" if os.path.isfile(args.elf): @@ -62,17 +76,6 @@ def elfFileCheck(args): exit(1) return ElfFile -def validateArgs(args): - if(args.lockstep and not args.testsuite.endswith('.elf') and not args.testsuite == "buildroot"): - print(f"Invalid Options. Cannot run a testsuite, {args.testsuite} with lockstep. Must run a single elf.") - exit(1) - elif (args.gui or args.ccov or args.fcov or args.lockstep or args.lockstepverbose) and args.sim not in ["questa", "vcs"]: - print("Option only supported for Questa and VCS") - exit(1) - elif (args.tb == "testbench_fp" and args.sim != "questa"): - print("Error: testbench_fp presently only supported by Questa, not VCS or Verilator, because of a touchy testbench") - exit(1) - def prepSim(args, ElfFile): flags = "" if args.vcd: @@ -169,9 +172,9 @@ def runVCS(args, flags, prefix): if __name__ == "__main__": args = parseArgs() + validateArgs(args) print(f"Config={args.config} tests={args.testsuite} sim={args.sim} gui={args.gui} args='{args.args} params='{args.params}'") ElfFile = elfFileCheck(args) - validateArgs(args) flags, prefix = prepSim(args, ElfFile) createDirs(args) exit(runSim(args, flags, prefix))