Skip to content

Commit 966ed00

Browse files
committed
use a single 'external' argument instead of 'use_external' and 'impls'
1 parent b4ff5bf commit 966ed00

2 files changed

Lines changed: 33 additions & 29 deletions

File tree

vunit/builtins.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ def _add_files(self, pattern):
6969

7070
self._vunit_lib.add_source_file(file_name)
7171

72-
def _add_data_types(self, use_external=None, impls=None):
72+
def _add_data_types(self, external=None):
7373
"""
7474
Add data types packages
7575
76-
:param use_external: list of a single Boolean, to select whether to enable external models for string.
77-
:param impls: optional list of lists containing alternative implementations for external models.
76+
:param external: list of a single Boolean, to select whether to enable external models for string.
77+
Optionally a list of paths containing alternative implementations for external
78+
models can be provided.
7879
"""
7980
self._add_files(join(VHDL_PATH, "data_types", "src", "types", "*.vhd"))
8081
self._add_files(join(VHDL_PATH, "data_types", "src", "*.vhd"))
@@ -84,12 +85,13 @@ def _add_data_types(self, use_external=None, impls=None):
8485
use_ext = [False]
8586
files = [None]
8687

87-
if use_external is not None:
88-
for ind, val in enumerate(use_external):
89-
use_ext[ind] = val
90-
if impls is not None:
91-
for ind, val in enumerate(impls):
92-
files[ind] = val
88+
if external is not None:
89+
for ind, val in enumerate(external):
90+
if isinstance(val, bool):
91+
use_ext[ind] = val
92+
else:
93+
use_ext[ind] = True
94+
files[ind] = val
9395

9496
for val in use_ext:
9597
if val and simulator_check(lambda simclass: not simclass.supports_vhpi()):
@@ -209,14 +211,15 @@ def add_verilog_builtins(self):
209211
"""
210212
self._vunit_lib.add_source_files(join(VERILOG_PATH, "vunit_pkg.sv"))
211213

212-
def add_vhdl_builtins(self, use_external=None, impls=None):
214+
def add_vhdl_builtins(self, external=None):
213215
"""
214216
Add vunit VHDL builtin libraries
215217
216-
:param use_external: list of a single Boolean, to select whether to enable external models for string.
217-
:param impls: optional list of lists containing alternative implementations for external models.
218+
:param external: list of a single Boolean, to select whether to enable external models for string.
219+
Optionally a list of paths containing alternative implementations for external
220+
models can be provided.
218221
"""
219-
self._add_data_types(use_external=use_external, impls=impls)
222+
self._add_data_types(external=external)
220223
self._add_files(join(VHDL_PATH, "*.vhd"))
221224
for path in ("core", "logging", "string_ops", "check", "dictionary", "run", "path"):
222225
self._add_files(join(VHDL_PATH, path, "src", "*.vhd"))

vunit/ui.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,17 @@ class VUnit(object): # pylint: disable=too-many-instance-attributes, too-many-p
290290
"""
291291

292292
@classmethod
293-
def from_argv(cls, argv=None, compile_builtins=True, vhdl_standard=None, use_external=None, impls=None):
293+
def from_argv(cls, argv=None, compile_builtins=True, vhdl_standard=None, external=None):
294294
"""
295295
Create VUnit instance from command line arguments.
296296
297297
:param argv: Use explicit argv instead of actual command line argument
298298
:param compile_builtins: Do not compile builtins. Used for VUnit internal testing.
299299
:param vhdl_standard: The VHDL standard used to compile files into this library,
300300
if None the VUNIT_VHDL_STANDARD environment variable is used
301-
:param use_external: list of a single Boolean, to select whether to enable external models for string.
302-
:param impls: optional list of lists containing alternative implementations for external models
301+
:param external: list of a single Boolean, to select whether to enable external models for string.
302+
Optionally a list of paths containing alternative implementations for external
303+
models can be provided.
303304
:returns: A :class:`.VUnit` object instance
304305
305306
:example:
@@ -315,12 +316,11 @@ def from_argv(cls, argv=None, compile_builtins=True, vhdl_standard=None, use_ext
315316
args,
316317
compile_builtins=compile_builtins,
317318
vhdl_standard=vhdl_standard,
318-
use_external=use_external,
319-
impls=impls
319+
external=external
320320
)
321321

322322
@classmethod
323-
def from_args(cls, args, compile_builtins=True, vhdl_standard=None, use_external=None, impls=None):
323+
def from_args(cls, args, compile_builtins=True, vhdl_standard=None, external=None):
324324
"""
325325
Create VUnit instance from args namespace.
326326
Intended for users who adds custom command line options.
@@ -331,20 +331,20 @@ def from_args(cls, args, compile_builtins=True, vhdl_standard=None, use_external
331331
:param compile_builtins: Do not compile builtins. Used for VUnit internal testing.
332332
:param vhdl_standard: The VHDL standard used to compile files into this library,
333333
if None the VUNIT_VHDL_STANDARD environment variable is used
334-
:param use_external: list of a single Boolean, to select whether to enable external models for string.
335-
:param impls: optional list of lists containing alternative implementations for external models
334+
:param external: list of a single Boolean, to select whether to enable external models for string.
335+
Optionally a list of paths containing alternative implementations for external
336+
models can be provided.
336337
:returns: A :class:`.VUnit` object instance
337338
338339
"""
339340
return cls(
340341
args,
341342
compile_builtins=compile_builtins,
342343
vhdl_standard=vhdl_standard,
343-
use_external=use_external,
344-
impls=impls
344+
external=external
345345
)
346346

347-
def __init__(self, args, compile_builtins=True, vhdl_standard=None, use_external=None, impls=None):
347+
def __init__(self, args, compile_builtins=True, vhdl_standard=None, external=None):
348348
self._args = args
349349
self._configure_logging(args.log_level)
350350
self._output_path = abspath(args.output_path)
@@ -393,7 +393,7 @@ def test_filter(name, attribute_names):
393393
self._builtins = Builtins(self, self._vhdl_standard, simulator_class)
394394
self._compile_builtins = compile_builtins
395395
if compile_builtins:
396-
self.add_builtins(use_external=use_external, impls=impls)
396+
self.add_builtins(external=external)
397397

398398
def _create_database(self):
399399
"""
@@ -1076,14 +1076,15 @@ def _run_test(self, test_cases, report):
10761076
no_color=self._args.no_color)
10771077
runner.run(test_cases)
10781078

1079-
def add_builtins(self, use_external=None, impls=None):
1079+
def add_builtins(self, external=None):
10801080
"""
10811081
Add vunit VHDL builtin libraries
10821082
1083-
:param use_external: list of a single Boolean, to select whether to enable external models for string.
1084-
:param impls: optional list of lists containing alternative implementations for external models.
1083+
:param external: list of a single Boolean, to select whether to enable external models for string.
1084+
Optionally a list of paths containing alternative implementations for external
1085+
models can be provided.
10851086
"""
1086-
self._builtins.add_vhdl_builtins(use_external=use_external, impls=impls)
1087+
self._builtins.add_vhdl_builtins(external=external)
10871088

10881089
def add_com(self):
10891090
"""

0 commit comments

Comments
 (0)