Skip to content

Commit

Permalink
use a single 'external' argument instead of 'use_external' and 'impls'
Browse files Browse the repository at this point in the history
  • Loading branch information
umarcor committed Jun 4, 2019
1 parent 70292d0 commit 17fecdb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
29 changes: 16 additions & 13 deletions vunit/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ def _add_files(self, pattern):

self._vunit_lib.add_source_file(file_name)

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

if use_external is not None:
for ind, val in enumerate(use_external):
use_ext[ind] = val
if impls is not None:
for ind, val in enumerate(impls):
files[ind] = val
if external is not None:
for ind, val in enumerate(external):
if isinstance(val, bool):
use_ext[ind] = val
else:
use_ext[ind] = True
files[ind] = val

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

def add_vhdl_builtins(self, use_external=None, impls=None):
def add_vhdl_builtins(self, external=None):
"""
Add vunit VHDL builtin libraries
:param use_external: list of a single Boolean, to select whether to enable external models for string.
:param impls: optional list of lists containing alternative implementations for external models.
:param external: list of a single Boolean, to select whether to enable external models for string.
Optionally a list of paths containing alternative implementations for external
models can be provided.
"""
self._add_data_types(use_external=use_external, impls=impls)
self._add_data_types(external=external)
self._add_files(join(VHDL_PATH, "*.vhd"))
for path in ("core", "logging", "string_ops", "check", "dictionary", "run", "path"):
self._add_files(join(VHDL_PATH, path, "src", "*.vhd"))
Expand Down
33 changes: 17 additions & 16 deletions vunit/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,17 @@ class VUnit(object): # pylint: disable=too-many-instance-attributes, too-many-p
"""

@classmethod
def from_argv(cls, argv=None, compile_builtins=True, vhdl_standard=None, use_external=None, impls=None):
def from_argv(cls, argv=None, compile_builtins=True, vhdl_standard=None, external=None):
"""
Create VUnit instance from command line arguments.
:param argv: Use explicit argv instead of actual command line argument
:param compile_builtins: Do not compile builtins. Used for VUnit internal testing.
:param vhdl_standard: The VHDL standard used to compile files into this library,
if None the VUNIT_VHDL_STANDARD environment variable is used
:param use_external: list of a single Boolean, to select whether to enable external models for string.
:param impls: optional list of lists containing alternative implementations for external models
:param external: list of a single Boolean, to select whether to enable external models for string.
Optionally a list of paths containing alternative implementations for external
models can be provided.
:returns: A :class:`.VUnit` object instance
:example:
Expand All @@ -315,12 +316,11 @@ def from_argv(cls, argv=None, compile_builtins=True, vhdl_standard=None, use_ext
args,
compile_builtins=compile_builtins,
vhdl_standard=vhdl_standard,
use_external=use_external,
impls=impls
external=external
)

@classmethod
def from_args(cls, args, compile_builtins=True, vhdl_standard=None, use_external=None, impls=None):
def from_args(cls, args, compile_builtins=True, vhdl_standard=None, external=None):
"""
Create VUnit instance from args namespace.
Intended for users who adds custom command line options.
Expand All @@ -331,20 +331,20 @@ def from_args(cls, args, compile_builtins=True, vhdl_standard=None, use_external
:param compile_builtins: Do not compile builtins. Used for VUnit internal testing.
:param vhdl_standard: The VHDL standard used to compile files into this library,
if None the VUNIT_VHDL_STANDARD environment variable is used
:param use_external: list of a single Boolean, to select whether to enable external models for string.
:param impls: optional list of lists containing alternative implementations for external models
:param external: list of a single Boolean, to select whether to enable external models for string.
Optionally a list of paths containing alternative implementations for external
models can be provided.
:returns: A :class:`.VUnit` object instance
"""
return cls(
args,
compile_builtins=compile_builtins,
vhdl_standard=vhdl_standard,
use_external=use_external,
impls=impls
external=external
)

def __init__(self, args, compile_builtins=True, vhdl_standard=None, use_external=None, impls=None):
def __init__(self, args, compile_builtins=True, vhdl_standard=None, external=None):
self._args = args
self._configure_logging(args.log_level)
self._output_path = abspath(args.output_path)
Expand Down Expand Up @@ -393,7 +393,7 @@ def test_filter(name, attribute_names):
self._builtins = Builtins(self, self._vhdl_standard, simulator_class)
self._compile_builtins = compile_builtins
if compile_builtins:
self.add_builtins(use_external=use_external, impls=impls)
self.add_builtins(external=external)

def _create_database(self):
"""
Expand Down Expand Up @@ -1076,14 +1076,15 @@ def _run_test(self, test_cases, report):
no_color=self._args.no_color)
runner.run(test_cases)

def add_builtins(self, use_external=None, impls=None):
def add_builtins(self, external=None):
"""
Add vunit VHDL builtin libraries
:param use_external: list of a single Boolean, to select whether to enable external models for string.
:param impls: optional list of lists containing alternative implementations for external models.
:param external: list of a single Boolean, to select whether to enable external models for string.
Optionally a list of paths containing alternative implementations for external
models can be provided.
"""
self._builtins.add_vhdl_builtins(use_external=use_external, impls=impls)
self._builtins.add_vhdl_builtins(external=external)

def add_com(self):
"""
Expand Down

0 comments on commit 17fecdb

Please sign in to comment.