Skip to content

Commit 1279d49

Browse files
committed
Write runner_cfg to file.
1 parent c302329 commit 1279d49

File tree

7 files changed

+34
-13
lines changed

7 files changed

+34
-13
lines changed

tests/acceptance/artificial/vhdl/tb_reading_runner_cfg_from_file.vhd

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,9 @@ end entity;
1616
architecture tb of tb_reading_runner_cfg_from_file is
1717
begin
1818
test_runner : process
19-
file runner_cfg_fptr : text;
20-
variable runner_cfg_line : line;
2119
begin
22-
file_open(runner_cfg_fptr, "runner.cfg", write_mode);
23-
write(
24-
runner_cfg_line,
25-
string'("active python runner : true,enabled_test_cases : ,output path : " &
26-
replace(output_path(runner_cfg), ":", "::") & ",tb path : " &
27-
replace(tb_path(runner_cfg), ":", "::") & ",use_color : true")
28-
);
29-
writeline(runner_cfg_fptr, runner_cfg_line);
30-
file_close(runner_cfg_fptr);
31-
3220
test_runner_setup(runner, null_runner_cfg);
21+
3322
check_true(active_python_runner(null_runner_cfg));
3423
check(output_path(null_runner_cfg) /= "");
3524
check(enabled_test_cases(null_runner_cfg) /= "__all__");

vunit/sim_if/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ def simulate(self, output_path, test_suite_name, config, elaborate_only):
215215
Simulate
216216
"""
217217

218+
def get_simulator_output_path(self, output_path):
219+
"Get current working directory for simulation"
220+
218221
def setup_library_mapping(self, project):
219222
"""
220223
Implemented by specific simulators

vunit/sim_if/activehdl.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ def _create_gui_script(self, common_file_name, config):
375375
for library in self._libraries:
376376
tcl += f"vmap {library.name!s} {fix_path(library.directory)!s}\n"
377377

378+
tcl += "global sim_working_folder\n"
379+
tcl += f"set sim_working_folder {fix_path(str(Path(common_file_name).parent / 'gui'))}\n"
380+
378381
tcl += "vunit_load\n"
379382

380383
init_file = config.sim_options.get(self.name + ".init_file.gui", None)
@@ -428,11 +431,23 @@ def simulate(self, output_path, test_suite_name, config, elaborate_only):
428431

429432
if self._gui:
430433
gui_path = str(script_path / "gui")
431-
renew_path(gui_path)
434+
if (script_path / "gui" / "runner.cfg").exists():
435+
runner_cfg = (script_path / "gui" / "runner.cfg").read_text()
436+
renew_path(gui_path)
437+
(script_path / "gui" / "runner.cfg").write_text(runner_cfg)
438+
else:
439+
renew_path(gui_path)
440+
432441
return self._run_batch_file(str(gui_file_name), gui=True, cwd=gui_path)
433442

434443
return self._run_batch_file(str(batch_file_name), gui=False, cwd=str(Path(self._library_cfg).parent))
435444

445+
def get_simulator_output_path(self, output_path):
446+
if self._gui:
447+
return Path(output_path) / self.name / "gui"
448+
449+
return Path(self._library_cfg).parent
450+
436451

437452
@total_ordering
438453
class Version(object):

vunit/sim_if/ghdl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ def simulate(self, output_path, test_suite_name, config, elaborate_only): # pyl
363363

364364
return status
365365

366+
def get_simulator_output_path(self, output_path):
367+
return Path(".")
368+
366369
def _compile_source_file(self, source_file, printer):
367370
"""
368371
Runs parent command for compilation, and moves any .gcno files to the compilation output

vunit/sim_if/incisive.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ def simulate(self, output_path, test_suite_name, config, elaborate_only=False):
347347
return False
348348
return True
349349

350+
def get_simulator_output_path(self, output_path):
351+
return Path(output_path) / self.name
352+
350353
def _hdlvar_args(self):
351354
"""
352355
Return hdlvar argument if available

vunit/sim_if/vsim_simulator_mixin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,9 @@ def simulate(self, output_path, test_suite_name, config, elaborate_only):
331331

332332
return self._run_batch_file(str(batch_file_name))
333333

334+
def get_simulator_output_path(self, output_path):
335+
return Path(self._sim_cfg_file_name).parent
336+
334337

335338
def fix_path(path):
336339
"""

vunit/test/suites.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ def _simulate(self, output_path):
231231
"tb path": config.tb_path.replace("\\", "/") + "/",
232232
}
233233

234+
# TODO: remove file after?
235+
simulator_output_path = self._simulator_if.get_simulator_output_path(output_path) / "runner.cfg"
236+
simulator_output_path.parent.mkdir(parents=True, exist_ok=True)
237+
simulator_output_path.write_text(encode_dict(runner_cfg))
238+
234239
# @TODO Warn if runner cfg already set?
235240
config.generics["runner_cfg"] = encode_dict(runner_cfg)
236241

0 commit comments

Comments
 (0)