Skip to content

Commit 0bcfe8f

Browse files
committed
Adds --gui flag. Closes #16
1 parent 40bfda4 commit 0bcfe8f

3 files changed

Lines changed: 37 additions & 10 deletions

File tree

user_guide.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ cases.
3333
```shell
3434
> python run.py -h
3535
usage: run.py [-h] [-l] [--compile] [--clean] [-o OUTPUT_PATH] [-x XUNIT_XML]
36-
[-v] [--no-color] [--log-level {info,error,warning,debug}]
36+
[-v] [--no-color] [--gui]
37+
[--log-level {info,error,warning,debug}]
3738
[tests [tests ...]]
3839

3940
VUnit command line tool.
@@ -53,6 +54,7 @@ optional arguments:
5354
-v, --verbose Print test output immediately and not only when
5455
failure
5556
--no-color Do not color output
57+
--gui Open test case(s) in simulator gui
5658
--log-level {info,error,warning,debug}
5759
```
5860

vunit/modelsim_interface.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@
1414
from vunit.exceptions import CompileError
1515

1616
class ModelSimInterface:
17-
def __init__(self, modelsim_ini="modelsim.ini", persistent=False):
17+
def __init__(self, modelsim_ini="modelsim.ini", persistent=False, gui=False):
1818
self._modelsim_ini = modelsim_ini
19+
20+
# Workarround for Microsemi 10.3a which does not
21+
# respect MODELSIM environment variable when set within .do script
22+
# Microsemi bug reference id: dvt64978
23+
os.environ["MODELSIM"] = self._modelsim_ini
24+
1925
self._create_modelsim_ini()
2026
self._vsim_process = None
27+
self._gui = gui
28+
assert not (persistent and gui)
2129

2230
if persistent:
2331
self._create_vsim_process()
@@ -230,11 +238,18 @@ def _create_user_script(self, common_file_name):
230238
tcl += "vunit_help\n"
231239
return tcl
232240

233-
def _run_batch_file(self, batch_file_name):
241+
def _run_batch_file(self, batch_file_name, gui=False):
234242
try:
235-
proc = Process(['vsim', '-quiet', '-c',
236-
"-l", join(dirname(batch_file_name), "transcript"),
237-
'-do', "do %s" % fix_path(batch_file_name)])
243+
args = ['vsim', '-quiet',
244+
"-l", join(dirname(batch_file_name), "transcript"),
245+
'-do', "do %s" % fix_path(batch_file_name)]
246+
247+
if gui:
248+
args.append('-gui')
249+
else:
250+
args.append('-c')
251+
252+
proc = Process(args)
238253
proc.consume_output()
239254
except Process.NonZeroExitCode:
240255
return False
@@ -289,7 +304,9 @@ def simulate(self, output_path, library_name, entity_name, architecture_name=Non
289304
write_file(user_file_name, user_do)
290305
write_file(batch_file_name, batch_do)
291306

292-
if self._vsim_process is None:
307+
if self._gui:
308+
success = self._run_batch_file(user_file_name, gui=True)
309+
elif self._vsim_process is None:
293310
success = self._run_batch_file(batch_file_name)
294311
else:
295312
success = self._run_persistent(common_file_name, load_only)

vunit/ui.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def test_filter(name):
5757
log_level=args.log_level,
5858
test_filter=test_filter,
5959
list_only=args.list,
60-
compile_only=args.compile)
60+
compile_only=args.compile,
61+
gui=args.gui)
6162

6263
@classmethod
6364
def _create_argument_parser(cls):
@@ -95,6 +96,10 @@ def _create_argument_parser(cls):
9596
default=False,
9697
help='Do not color output')
9798

99+
parser.add_argument('--gui', action='store_true',
100+
default=False,
101+
help='Open test case(s) in simulator gui')
102+
98103
parser.add_argument('--log-level',
99104
default="warning",
100105
choices=["info", "error", "warning", "debug"])
@@ -114,7 +119,8 @@ def __init__(self,
114119
elaborate_only=False,
115120
vhdl_standard='2008',
116121
compile_builtins=True,
117-
persistent_sim=True):
122+
persistent_sim=True,
123+
gui=False):
118124

119125
self._project = Project()
120126

@@ -140,6 +146,7 @@ def __init__(self,
140146

141147
self._tb_filter = tb_filter
142148
self._persistent_sim = persistent_sim
149+
self._gui = gui
143150
self._configuration = TestConfiguration()
144151
self._internal_preprocessors = []
145152
self._external_preprocessors = []
@@ -319,7 +326,8 @@ def _create_output_path(self):
319326
def _create_simulator_if(self):
320327
return ModelSimInterface(
321328
join(self._output_path, "modelsim.ini"),
322-
persistent=self._persistent_sim)
329+
persistent=self._persistent_sim and not self._gui,
330+
gui=self._gui)
323331

324332
@property
325333
def _preprocessed_path(self):

0 commit comments

Comments
 (0)