|
14 | 14 | from vunit.exceptions import CompileError |
15 | 15 |
|
16 | 16 | class ModelSimInterface: |
17 | | - def __init__(self, modelsim_ini="modelsim.ini", persistent=False): |
| 17 | + def __init__(self, modelsim_ini="modelsim.ini", persistent=False, gui=False): |
18 | 18 | 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 | + |
19 | 25 | self._create_modelsim_ini() |
20 | 26 | self._vsim_process = None |
| 27 | + self._gui = gui |
| 28 | + assert not (persistent and gui) |
21 | 29 |
|
22 | 30 | if persistent: |
23 | 31 | self._create_vsim_process() |
@@ -230,11 +238,18 @@ def _create_user_script(self, common_file_name): |
230 | 238 | tcl += "vunit_help\n" |
231 | 239 | return tcl |
232 | 240 |
|
233 | | - def _run_batch_file(self, batch_file_name): |
| 241 | + def _run_batch_file(self, batch_file_name, gui=False): |
234 | 242 | 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) |
238 | 253 | proc.consume_output() |
239 | 254 | except Process.NonZeroExitCode: |
240 | 255 | return False |
@@ -289,7 +304,9 @@ def simulate(self, output_path, library_name, entity_name, architecture_name=Non |
289 | 304 | write_file(user_file_name, user_do) |
290 | 305 | write_file(batch_file_name, batch_do) |
291 | 306 |
|
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: |
293 | 310 | success = self._run_batch_file(batch_file_name) |
294 | 311 | else: |
295 | 312 | success = self._run_persistent(common_file_name, load_only) |
|
0 commit comments