Got the directory mode wsim working!

This commit is contained in:
Rose Thompson 2024-06-01 10:56:37 -05:00
parent 224b8469ab
commit 2382677f8f

112
bin/wsim
View File

@ -14,52 +14,7 @@
import argparse import argparse
import os import os
# Parse arguments def LaunchSim(ElfFile):
parser = argparse.ArgumentParser()
parser.add_argument("config", help="Configuration file")
parser.add_argument("testsuite", help="Test suite or ELF file")
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")
parser.add_argument("--gui", "-g", help="Simulate with GUI", action="store_true")
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="")
parser.add_argument("--vcd", "-v", help="Generate testbench.vcd", action="store_true")
parser.add_argument("--lockstep", "-l", help="Run ImperasDV lock, step, and compare.", action="store_true")
parser.add_argument("--locksteplog", "-b", help="Retired instruction number to be begin logging.", default=0)
parser.add_argument("--covlog", "-d", help="Log coverage after n instructions.", default=0)
args = parser.parse_args()
print("Config=" + args.config + " tests=" + args.testsuite + " sim=" + args.sim + " gui=" + str(args.gui) + " args='" + args.args + "'")
ElfFile=""
if(os.path.isfile(args.testsuite)):
ElfFile = "+ElfFile=" + args.testsuite
args.testsuite = "none"
# Validate arguments
if (args.gui):
if args.sim not in ["questa", "vcs"]:
print("GUI option only supported for Questa and VCS")
exit(1)
if (args.coverage):
if args.sim not in ["questa", "vcs"]:
print("Coverage option only available for Questa and VCS")
exit(1)
if (args.vcd):
args.args += " -DMAKEVCD=1"
# create the output sub-directories.
WALLY = os.environ.get('WALLY')
regressionDir = WALLY + '/sim/'
for d in ["logs", "wkdir", "cov"]:
try:
os.mkdir(regressionDir+args.sim+"/"+d)
except:
pass
# Launch selected simulator # Launch selected simulator
cd = "cd $WALLY/sim/" +args.sim cd = "cd $WALLY/sim/" +args.sim
# ugh. can't have more than 9 arguments passed to vsim. why? I'll have to remove --lockstep when running # ugh. can't have more than 9 arguments passed to vsim. why? I'll have to remove --lockstep when running
@ -119,3 +74,68 @@ elif (args.sim == "vcs"):
cmd = cd + "; ./run_vcs " + args.config + " " + args.testsuite + " " + args.args cmd = cd + "; ./run_vcs " + args.config + " " + args.testsuite + " " + args.args
print(cmd) print(cmd)
os.system(cmd) os.system(cmd)
# Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument("config", help="Configuration file")
parser.add_argument("testsuite", help="Test suite or ELF file")
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")
parser.add_argument("--gui", "-g", help="Simulate with GUI", action="store_true")
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="")
parser.add_argument("--vcd", "-v", help="Generate testbench.vcd", action="store_true")
parser.add_argument("--lockstep", "-l", help="Run ImperasDV lock, step, and compare.", action="store_true")
parser.add_argument("--locksteplog", "-b", help="Retired instruction number to be begin logging.", default=0)
parser.add_argument("--covlog", "-d", help="Log coverage after n instructions.", default=0)
parser.add_argument("--elfext", "-e", help="When searching for elf files only includes ones which end in this extension", default=".elf")
args = parser.parse_args()
print("Config=" + args.config + " tests=" + args.testsuite + " sim=" + args.sim + " gui=" + str(args.gui) + " args='" + args.args + "'")
ElfFile=""
DirectorMode = 0
ElfList = []
if(os.path.isfile(args.testsuite)):
ElfFile = "+ElfFile=" + args.testsuite
args.testsuite = "none"
ElfList.append("+ElfFile=" + args.testsuite)
elif(os.path.isdir(args.testsuite)):
DirectorMode = 1
for dirpath, dirnames, filenames in os.walk(args.testsuite):
for file in filenames:
if file.endswith(args.elfext):
ElfList.append("+ElfFile=" + os.path.join(dirpath, file))
args.testsuite = "none"
print(ElfList)
# Validate arguments
if (args.gui):
if args.sim not in ["questa", "vcs"]:
print("GUI option only supported for Questa and VCS")
exit(1)
if (args.coverage):
if args.sim not in ["questa", "vcs"]:
print("Coverage option only available for Questa and VCS")
exit(1)
if (args.vcd):
args.args += " -DMAKEVCD=1"
# create the output sub-directories.
WALLY = os.environ.get('WALLY')
regressionDir = WALLY + '/sim/'
for d in ["logs", "wkdir", "cov"]:
try:
os.mkdir(regressionDir+args.sim+"/"+d)
except:
pass
if(DirectorMode):
for ElfFile in ElfList:
LaunchSim(ElfFile)
else:
LaunchSim(ElfFile)