Skip to content

Commit

Permalink
Adds --gui flag. Closes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
kraigher committed Feb 12, 2015
1 parent 40bfda4 commit 0bcfe8f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
4 changes: 3 additions & 1 deletion user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ cases.
```shell
> python run.py -h
usage: run.py [-h] [-l] [--compile] [--clean] [-o OUTPUT_PATH] [-x XUNIT_XML]
[-v] [--no-color] [--log-level {info,error,warning,debug}]
[-v] [--no-color] [--gui]
[--log-level {info,error,warning,debug}]
[tests [tests ...]]

VUnit command line tool.
Expand All @@ -53,6 +54,7 @@ optional arguments:
-v, --verbose Print test output immediately and not only when
failure
--no-color Do not color output
--gui Open test case(s) in simulator gui
--log-level {info,error,warning,debug}
```
Expand Down
29 changes: 23 additions & 6 deletions vunit/modelsim_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@
from vunit.exceptions import CompileError

class ModelSimInterface:
def __init__(self, modelsim_ini="modelsim.ini", persistent=False):
def __init__(self, modelsim_ini="modelsim.ini", persistent=False, gui=False):
self._modelsim_ini = modelsim_ini

# Workarround for Microsemi 10.3a which does not
# respect MODELSIM environment variable when set within .do script
# Microsemi bug reference id: dvt64978
os.environ["MODELSIM"] = self._modelsim_ini

self._create_modelsim_ini()
self._vsim_process = None
self._gui = gui
assert not (persistent and gui)

if persistent:
self._create_vsim_process()
Expand Down Expand Up @@ -230,11 +238,18 @@ def _create_user_script(self, common_file_name):
tcl += "vunit_help\n"
return tcl

def _run_batch_file(self, batch_file_name):
def _run_batch_file(self, batch_file_name, gui=False):
try:
proc = Process(['vsim', '-quiet', '-c',
"-l", join(dirname(batch_file_name), "transcript"),
'-do', "do %s" % fix_path(batch_file_name)])
args = ['vsim', '-quiet',
"-l", join(dirname(batch_file_name), "transcript"),
'-do', "do %s" % fix_path(batch_file_name)]

if gui:
args.append('-gui')
else:
args.append('-c')

proc = Process(args)
proc.consume_output()
except Process.NonZeroExitCode:
return False
Expand Down Expand Up @@ -289,7 +304,9 @@ def simulate(self, output_path, library_name, entity_name, architecture_name=Non
write_file(user_file_name, user_do)
write_file(batch_file_name, batch_do)

if self._vsim_process is None:
if self._gui:
success = self._run_batch_file(user_file_name, gui=True)
elif self._vsim_process is None:
success = self._run_batch_file(batch_file_name)
else:
success = self._run_persistent(common_file_name, load_only)
Expand Down
14 changes: 11 additions & 3 deletions vunit/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def test_filter(name):
log_level=args.log_level,
test_filter=test_filter,
list_only=args.list,
compile_only=args.compile)
compile_only=args.compile,
gui=args.gui)

@classmethod
def _create_argument_parser(cls):
Expand Down Expand Up @@ -95,6 +96,10 @@ def _create_argument_parser(cls):
default=False,
help='Do not color output')

parser.add_argument('--gui', action='store_true',
default=False,
help='Open test case(s) in simulator gui')

parser.add_argument('--log-level',
default="warning",
choices=["info", "error", "warning", "debug"])
Expand All @@ -114,7 +119,8 @@ def __init__(self,
elaborate_only=False,
vhdl_standard='2008',
compile_builtins=True,
persistent_sim=True):
persistent_sim=True,
gui=False):

self._project = Project()

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

self._tb_filter = tb_filter
self._persistent_sim = persistent_sim
self._gui = gui
self._configuration = TestConfiguration()
self._internal_preprocessors = []
self._external_preprocessors = []
Expand Down Expand Up @@ -319,7 +326,8 @@ def _create_output_path(self):
def _create_simulator_if(self):
return ModelSimInterface(
join(self._output_path, "modelsim.ini"),
persistent=self._persistent_sim)
persistent=self._persistent_sim and not self._gui,
gui=self._gui)

@property
def _preprocessed_path(self):
Expand Down

0 comments on commit 0bcfe8f

Please sign in to comment.