From 9ee4a2b408d69167675758f2c6fc2a84079a3686 Mon Sep 17 00:00:00 2001 From: Jordan Carlin Date: Sat, 30 Nov 2024 23:04:13 -0800 Subject: [PATCH 1/2] Support Elffiles on all simulators --- bin/wsim | 11 ++++------- sim/vcs/run_vcs | 5 ++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/bin/wsim b/bin/wsim index 56abd9567..4e03b0d95 100755 --- a/bin/wsim +++ b/bin/wsim @@ -64,6 +64,9 @@ if(args.testsuite.endswith('.elf') and args.elf == ""): # No --elf argument; che print("ELF file not found: " + args.testsuite) exit(1) +if (ElfFile != ""): + args.args += " " + ElfFile + 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) @@ -143,8 +146,6 @@ if (args.tb == "testbench_fp" and args.sim != "questa"): if (args.sim == "questa"): if (args.gui) and (args.tb == "testbench"): args.params += "DEBUG=1" - if (ElfFile != ""): - args.args += " " + ElfFile if (args.args != ""): args.args = " --args \\\"" + args.args + "\\\"" if (args.params != ""): @@ -162,7 +163,6 @@ elif (args.sim == "verilator"): print(f"Running Verilator on {args.config} {args.testsuite}") os.system(f"/usr/bin/make -C {regressionDir}/verilator WALLYCONF={args.config} TEST={args.testsuite} TESTBENCH={args.tb} PLUS_ARGS=\"{args.args}\" PARAM_ARGS=\"{args.params}\"") elif (args.sim == "vcs"): - print("wsim params: " + args.params) print(f"Running VCS on " + args.config + " " + args.testsuite) # if (args.gui): # flags += " --gui" @@ -174,9 +174,6 @@ elif (args.sim == "vcs"): vcsparams = "" else: vcsparams = " --params \"" + args.params + "\" " - print("VCS params: " + vcsparams) - if (ElfFile != ""): - ElfFile = " --elffile " + ElfFile - cmd = cd + "; " + prefix + " ./run_vcs " + args.config + " " + args.testsuite + " " + " --tb " + args.tb + " " + vcsargs + vcsparams + ElfFile + " " + flags + cmd = cd + "; " + prefix + " ./run_vcs " + args.config + " " + args.testsuite + " " + " --tb " + args.tb + " " + vcsargs + vcsparams + " " + flags print(cmd) os.system(cmd) diff --git a/sim/vcs/run_vcs b/sim/vcs/run_vcs index 02eccc59b..1234ac4c8 100755 --- a/sim/vcs/run_vcs +++ b/sim/vcs/run_vcs @@ -24,7 +24,6 @@ parser = argparse.ArgumentParser() parser.add_argument("config", help="Configuration file") parser.add_argument("testsuite", help="Test suite (or none, when running a single ELF file) ") parser.add_argument("--tb", "-t", help="Testbench", choices=["testbench", "testbench_fp"], default="testbench") -parser.add_argument("--elffile", "-e", help="ELF file name", default="") parser.add_argument("--coverage", "-c", help="Code & Functional Coverage", action="store_true") parser.add_argument("--fcov", "-f", help="Code & Functional Coverage", action="store_true") parser.add_argument("--args", "-a", help="Optional arguments passed to simulator via $value$plusargs", default="") @@ -33,7 +32,7 @@ parser.add_argument("--lockstep", "-l", help="Run ImperasDV lock, step, and comp # GUI not yet implemented #parser.add_argument("--gui", "-g", help="Simulate with GUI", action="store_true") args = parser.parse_args() -print("run_vcs Config=" + args.config + " tests=" + args.testsuite + " elffile=" + args.elffile + " lockstep=" + str(args.lockstep) + " args='" + args.args + "'") +print("run_vcs Config=" + args.config + " tests=" + args.testsuite + " lockstep=" + str(args.lockstep) + " args='" + args.args + "' params='" + args.params + "'") cfgdir = "$WALLY/config" srcdir = "$WALLY/src" @@ -88,7 +87,7 @@ PARAM_OVERRIDES=" -parameters " + wkdir + "/param_overrides.txt " OUTPUT="sim_out" VCS_CMD="vcs +lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU,noSTASKW_CO,noSTASKW_CO1,noSTASKW_RMCOF -suppress +warn -sverilog +vc -Mupdate -line -full64 -lca -ntb_opts sensitive_dyn " + "-top " + args.tb + PARAM_OVERRIDES + INCLUDE_PATH # Disabled Debug flags; add them back for a GUI mode -debug_access+all+reverse -kdb +vcs+vcdpluson VCS = VCS_CMD + " -Mdir=" + wkdir + " " + srcdir + "/cvw.sv " + LOCKSTEP_OPTIONS + " " + COV_OPTIONS + " " + RTL_FILES + " -o " + wkdir + "/" + OUTPUT + " -work " + wkdir + " -Mlib=" + wkdir + " -l " + logdir + "/" + args.config + "_" + args.testsuite + ".log" -SIMV_CMD= wkdir + "/" + OUTPUT + " +TEST=" + args.testsuite + " " + args.elffile + " " + args.args + " -no_save " + LOCKSTEP_SIMV +SIMV_CMD= wkdir + "/" + OUTPUT + " +TEST=" + args.testsuite + " " + args.args + " -no_save " + LOCKSTEP_SIMV # Run simulation print("Executing: " + str(VCS) ) From cd90e81c76095135f7d298d7b0d4f2f7c23a64fc Mon Sep 17 00:00:00 2001 From: Jordan Carlin Date: Sat, 30 Nov 2024 23:43:51 -0800 Subject: [PATCH 2/2] wsim cleanup --- bin/wsim | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/bin/wsim b/bin/wsim index 4e03b0d95..907ff9105 100755 --- a/bin/wsim +++ b/bin/wsim @@ -72,10 +72,12 @@ if(args.lockstep and not args.testsuite.endswith('.elf') and not args.testsuite exit(1) # Validate arguments -if (args.gui or args.ccov or args.fcov or args.lockstep or args.lockstepverbose): - if args.sim not in ["questa", "vcs"]: - print("Option only supported for Questa and VCS") - exit(1) +if (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) if (args.vcd): args.args += " -DMAKEVCD=1" @@ -91,14 +93,10 @@ if(int(args.locksteplog) >= 1): EnableLog = 1 else: EnableLog = 0 prefix = "" if (args.lockstep or args.lockstepverbose or args.fcov): - if (args.sim == "questa" or args.sim == "vcs"): - imperasicPath = os.path.join(WALLY, "config", args.config, "imperas.ic") - if not os.path.isfile(imperasicPath): # If config is a derivative, look for imperas.ic in derivative configs - imperasicPath = os.path.join(WALLY, "config", "deriv", args.config, "imperas.ic") - prefix = "IMPERAS_TOOLS=" + imperasicPath -# Force Questa to use 64-bit mode, sometimes it defaults to 32-bit even on 64-bit machines -if (args.sim == "questa"): - prefix = "MTI_VCO_MODE=64 " + prefix + imperasicPath = os.path.join(WALLY, "config", args.config, "imperas.ic") + if not os.path.isfile(imperasicPath): # If config is a derivative, look for imperas.ic in derivative configs + imperasicPath = os.path.join(WALLY, "config", "deriv", args.config, "imperas.ic") + prefix = "IMPERAS_TOOLS=" + imperasicPath if (args.lockstep or args.lockstepverbose): if(args.locksteplog != 0): ImperasPlusArgs = " +IDV_TRACE2LOG=" + str(EnableLog) + " +IDV_TRACE2LOG_AFTER=" + str(args.locksteplog) @@ -137,13 +135,10 @@ for d in ["logs", "wkdir", "cov", "ucdb", "fcov", "fcov_ucdb"]: cd = "cd $WALLY/sim/" +args.sim -# check for unsupported sims -if (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) - # per-simulator launch if (args.sim == "questa"): + # Force Questa to use 64-bit mode, sometimes it defaults to 32-bit even on 64-bit machines + prefix = "MTI_VCO_MODE=64 " + prefix if (args.gui) and (args.tb == "testbench"): args.params += "DEBUG=1" if (args.args != ""): @@ -159,7 +154,6 @@ if (args.sim == "questa"): print("Running Questa with command: " + cmd) os.system(cmd) elif (args.sim == "verilator"): - # PWD=${WALLY}/sim CONFIG=rv64gc TESTSUITE=arch64i print(f"Running Verilator on {args.config} {args.testsuite}") os.system(f"/usr/bin/make -C {regressionDir}/verilator WALLYCONF={args.config} TEST={args.testsuite} TESTBENCH={args.tb} PLUS_ARGS=\"{args.args}\" PARAM_ARGS=\"{args.params}\"") elif (args.sim == "vcs"):