Tests: Fix driver for --iv etc

This commit is contained in:
Wilson Snyder 2024-10-06 04:49:53 -04:00
parent bdd37e40fe
commit d52822781c

View File

@ -1343,6 +1343,7 @@ class VlTest:
'fails': False, 'fails': False,
'run_env': '', 'run_env': '',
'tee': True, 'tee': True,
'use_libvpi': False
} }
param.update(vars(self)) param.update(vars(self))
param.update(kwargs) param.update(kwargs)
@ -1366,115 +1367,118 @@ class VlTest:
run_env = run_env + ' ' run_env = run_env + ' '
if param['atsim']: if param['atsim']:
self.run( cmd = [
logfile=self.obj_dir + "/atsim_sim.log", "echo q | " + run_env + self.obj_dir + "/athdl_sv",
fails=param['fails'], ' '.join(param['atsim_run_flags']), ' '.join(param['all_run_flags'])
cmd=[ ]
"echo q | " + run_env + self.obj_dir + "/athdl_sv", self.run(cmd=cmd,
' '.join(param['atsim_run_flags']), check_finished=param['check_finished'],
' '.join(param['all_run_flags']), entering=param['entering'],
], expect_filename=param.get('atsim_run_expect_filename', None),
*param, fails=param['fails'],
expect_filename=param['atsim_run_expect_filename'], logfile=param.get('logfile', self.obj_dir + "/atsim_sim.log"),
) tee=param['tee'])
elif param['ghdl']: elif param['ghdl']:
self.run( cmd = [
logfile=self.obj_dir + "/ghdl_sim.log", run_env + self.obj_dir + "/simghdl", ' '.join(param['ghdl_run_flags']),
fails=param['fails'], ' '.join(param['all_run_flags'])
cmd=[ ]
run_env + self.obj_dir + "/simghdl", self.run(cmd=cmd,
' '.join(param['ghdl_run_flags']), check_finished=param['check_finished'],
' '.join(param['all_run_flags']), entering=param['entering'],
], expect_filename=param.get('ghdl_run_expect_filename', None),
*param, fails=param['fails'],
expect_filename=param['ghdl_run_expect_filename'], logfile=param.get('logfile', self.obj_dir + "/ghdl_sim.log"),
) tee=param['tee'])
elif param['iv']: elif param['iv']:
cmd = [ cmd = [
run_env + self.obj_dir + "/simiv", run_env + self.obj_dir + "/simiv", ' '.join(param['iv_run_flags']),
' '.join(param['iv_run_flags']), ' '.join(param['all_run_flags'])
' '.join(param['all_run_flags']),
] ]
if param['use_libvpi']: if param['use_libvpi']:
# Don't enter command line on $stop, include vpi # Don't enter command line on $stop, include vpi
cmd += ["vvp -n -m " + self.obj_dir + "/libvpi.so"] cmd += ["vvp -n -m " + self.obj_dir + "/libvpi.so"]
self.run( self.run(cmd=cmd,
logfile=self.obj_dir + "/iv_sim.log", check_finished=param['check_finished'],
fails=param['fails'], entering=param['entering'],
cmd=cmd, expect_filename=param.get('iv_run_expect_filename', None),
*param, fails=param['fails'],
expect_filename=param['iv_run_expect_filename'], logfile=param.get('logfile', self.obj_dir + "/vlt_sim.log"),
) tee=param['tee'])
elif param['ms']: elif param['ms']:
pli_opt = "" pli_opt = ""
if param['use_libvpi']: if param['use_libvpi']:
pli_opt = "-pli " + self.obj_dir + "/libvpi.so" pli_opt = "-pli " + self.obj_dir + "/libvpi.so"
self.run( cmd = [
logfile=self.obj_dir + "/ms_sim.log", "echo q | " + run_env + VtOs.getenv_def('VERILATOR_MODELSIM', "vsim"),
fails=param['fails'], ' '.join(param['ms_run_flags']), ' '.join(param['all_run_flags']), pli_opt,
cmd=[ (" top")
"echo q | " + run_env + VtOs.getenv_def('VERILATOR_MODELSIM', "vsim"), ]
' '.join(param['ms_run_flags']), ' '.join(param['all_run_flags']), pli_opt, self.run(cmd=cmd,
(" top") check_finished=param['check_finished'],
], entering=param['entering'],
*param, expect_filename=param.get('ms_run_expect_filename', None),
expect_filename=param['ms_expect_filename'], fails=param['fails'],
) logfile=param.get('logfile', self.obj_dir + "/ms_sim.log"),
tee=param['tee'])
elif param['nc']: elif param['nc']:
self.run( cmd = [
logfile=self.obj_dir + "/nc_sim.log", "echo q | " + run_env + VtOs.getenv_def('VERILATOR_NCVERILOG', "ncverilog"),
fails=param['fails'], ' '.join(param['nc_run_flags']), ' '.join(param['all_run_flags'])
cmd=[ ]
"echo q | " + run_env + VtOs.getenv_def('VERILATOR_NCVERILOG', "ncverilog"), self.run(cmd=cmd,
' '.join(param['nc_run_flags']), check_finished=param['check_finished'],
' '.join(param['all_run_flags']), entering=param['entering'],
], expect_filename=param.get('nc_run_expect_filename', None),
*param, fails=param['fails'],
expect_filename=param['nc_run_expect_filename'], logfile=param.get('logfile', self.obj_dir + "/nc_sim.log"),
) tee=param['tee'])
elif param['vcs']: elif param['vcs']:
# my $fh = IO::File->new(">simv.key") or die "%Error: $! simv.key," # my $fh = IO::File->new(">simv.key") or die "%Error: $! simv.key,"
# fh.print("quit\n"); fh.close() # fh.print("quit\n"); fh.close()
self.run( cmd = [
logfile=self.obj_dir + "/vcs_sim.log", "echo q | " + run_env + "./simv", ' '.join(param['vcs_run_flags']),
cmd=[ ' '.join(param['all_run_flags'])
"echo q | " + run_env + "./simv", ]
' '.join(param['vcs_run_flags']), self.run(cmd=cmd,
' '.join(param['all_run_flags']), check_finished=param['check_finished'],
], entering=param['entering'],
*param, expect_filename=param.get('vcs_run_expect_filename', None),
expect_filename=param['vcs_run_expect_filename'], fails=param['fails'],
) logfile=param.get('logfile', self.obj_dir + "/vcs_sim.log"),
tee=param['tee'])
elif param['xrun']: elif param['xrun']:
pli_opt = "" pli_opt = ""
if param['use_libvpi']: if param['use_libvpi']:
pli_opt = "-loadvpi " + self.obj_dir + "/libvpi.so:vpi_compat_bootstrap" pli_opt = "-loadvpi " + self.obj_dir + "/libvpi.so:vpi_compat_bootstrap"
self.run( cmd = [
logfile=self.obj_dir + "/xrun_sim.log", "echo q | " + run_env + VtOs.getenv_def('VERILATOR_XRUN', "xrun"),
fails=param['fails'], ' '.join(param['xrun_run_flags']),
cmd=[ ' '.join(param['xrun_flags2']),
"echo q | " + run_env + VtOs.getenv_def('VERILATOR_XRUN', "xrun"), ' '.join(param['all_run_flags']),
' '.join(param['xrun_run_flags']), pli_opt,
' '.join(param['xrun_flags2']), param['top_filename'],
' '.join(param['all_run_flags']), ]
pli_opt, self.run(cmd=cmd,
param['top_filename'], check_finished=param['check_finished'],
], entering=param['entering'],
*param, expect_filename=param.get('xrun_run_expect_filename', None),
expect_filename=param['xrun_run_expect_filename'], fails=param['fails'],
) logfile=param.get('logfile', self.obj_dir + "/xrun_sim.log"),
tee=param['tee'])
elif param['xsim']: elif param['xsim']:
self.run( cmd = [
logfile=self.obj_dir + "/xsim_sim.log", run_env + VtOs.getenv_def('VERILATOR_XELAB', "xelab"),
fails=param['fails'], ' '.join(param['xsim_run_flags']), ' '.join(param['xsim_run_flags2']),
cmd=[ ' '.join(param['all_run_flags']), (" " + self.name + ".top")
run_env + VtOs.getenv_def('VERILATOR_XELAB', "xelab"), ]
' '.join(param['xsim_run_flags']), ' '.join(param['xsim_run_flags2']), self.run(cmd=cmd,
' '.join(param['all_run_flags']), (" " + self.name + ".top") check_finished=param['check_finished'],
], entering=param['entering'],
*param, expect_filename=param.get('xsim_run_expect_filename', None),
expect_filename=param['xsim_expect_filename'], fails=param['fails'],
) logfile=param.get('logfile', self.obj_dir + "/xsim_sim.log"),
tee=param['tee'])
elif param['vlt_all']: elif param['vlt_all']:
if not param['executable']: if not param['executable']:
param['executable'] = self.obj_dir + "/" + param['vm_prefix'] param['executable'] = self.obj_dir + "/" + param['vm_prefix']
@ -1483,13 +1487,13 @@ class VlTest:
debugger = VtOs.getenv_def('VERILATOR_GDB', "gdb") + " " debugger = VtOs.getenv_def('VERILATOR_GDB', "gdb") + " "
elif Args.rrsim: elif Args.rrsim:
debugger = "rr record " debugger = "rr record "
cmd = [
(run_env + debugger + param['executable'] + (" -ex 'run " if Args.gdbsim else "")),
*param['all_run_flags'],
("'" if Args.gdbsim else ""),
]
self.run( self.run(
cmd=[ cmd=cmd,
(run_env + debugger + param['executable'] +
(" -ex 'run " if Args.gdbsim else "")),
*param['all_run_flags'],
("'" if Args.gdbsim else ""),
],
aslr_off=param['aslr_off'], # Disable address space layour randomization aslr_off=param['aslr_off'], # Disable address space layour randomization
check_finished=param['check_finished'], # Check for All Finished check_finished=param['check_finished'], # Check for All Finished
entering=param['entering'], # Print entering directory information entering=param['entering'], # Print entering directory information
@ -2072,7 +2076,7 @@ class VlTest:
def _make_top_v(self) -> None: def _make_top_v(self) -> None:
self._read_inputs_v() self._read_inputs_v()
with open(self.top_shell_filename(), 'w', encoding="utf8") as fh: with open(self.top_shell_filename, 'w', encoding="utf8") as fh:
fh.write("module top;\n") fh.write("module top;\n")
for inp in sorted(self._inputs.keys()): for inp in sorted(self._inputs.keys()):
fh.write(" reg " + inp + ";\n") fh.write(" reg " + inp + ";\n")
@ -2107,7 +2111,7 @@ class VlTest:
fh.write(" fastclk = 1;\n") fh.write(" fastclk = 1;\n")
if 'clk' in self._inputs: if 'clk' in self._inputs:
fh.write(" clk = 1;\n") fh.write(" clk = 1;\n")
fh.write(" while (" + time + " < " + self.sim_time + ") begin\n") fh.write(" while ($time < " + str(self.sim_time) + ") begin\n")
for i in range(6): for i in range(6):
fh.write(" #1;\n") fh.write(" #1;\n")
if 'fastclk' in self._inputs: if 'fastclk' in self._inputs: