Skip to content

Commit

Permalink
ui: split 'add_builtins' into 'add_vhdl_builtins' and 'add_verilog_bu…
Browse files Browse the repository at this point in the history
…iltins'
  • Loading branch information
umarcor committed Oct 21, 2021
1 parent 38a4534 commit 9536061
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
3 changes: 1 addition & 2 deletions docs/data_types/external_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ List of types that are currently in the external VHDL API:
* **string_ptr**, and **byte_vector_ptr** as an alias (:ref:`External string API <ext_string_pkg>`)
* **integer_vector_ptr** (:ref:`External integer vector API <ext_integer_vector_pkg>`)

.. important:: By default, bodies of the external API functions/procedures include forced failure assertions. Hence, using ``mode/=internal`` without providing a *bridge* to a foreign language will make tests fail. Bridges must be provided through `vu.add_builtins(external=<Options>)`, where `<Options>` defaults to ``{"string": False, "integer_vector": False}``. Each field should contain a list of VHDL files to replace the *dummy* default. See `VUnit/cosim <https://github.com/VUnit/cosim>`_ for reference implementations of bridges and examples.
.. important:: By default, bodies of the external API functions/procedures include forced failure assertions. Hence, using ``mode/=internal`` without providing a *bridge* to a foreign language will make tests fail. Bridges must be provided through `vu.add_vhdl_builtins(external=<Options>)`, where `<Options>` defaults to ``{"string": False, "integer_vector": False}``. Each field should contain a list of VHDL files to replace the *dummy* default. See `VUnit/cosim <https://github.com/VUnit/cosim>`_ for reference implementations of bridges and examples.

.. toctree::
:hidden:

ext_string
ext_integer_vector

16 changes: 11 additions & 5 deletions vunit/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ def test_filter(name, attribute_names):

self._builtins = Builtins(self, self._vhdl_standard, simulator_class)
if compile_builtins:
self.add_builtins()
self.add_vhdl_builtins()
builtins_deprecation_note = (
"'compile_builtins' (which defaults to 'True') is deprecated "
"and it will be removed in future releases; "
"preserve the functionality using "
"'compile_builtins=False' and 'VU.add_builtins'"
"'compile_builtins=False' and 'VU.add_vhdl_builtins'"
)
warn(builtins_deprecation_note, Warning)

Expand Down Expand Up @@ -934,17 +934,23 @@ def _run_test(self, test_cases, report):
)
runner.run(test_cases)

def add_builtins(self, external=None):
def add_verilog_builtins(self):
"""
Add vunit VHDL builtin libraries
Add VUnit Verilog builtin libraries
"""
self._builtins.add_verilog_builtins()

def add_vhdl_builtins(self, external=None):
"""
Add VUnit VHDL builtin libraries
:param external: struct to provide bridges for the external VHDL API.
:example:
.. code-block:: python
VU.add_builtins(external={
VU.add_vhdl_builtins(external={
'string': ['path/to/custom/file'],
'integer': ['path/to/custom/file']}
)
Expand Down
8 changes: 6 additions & 2 deletions vunit/verilog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@
"""

from vunit.ui import VUnit as VUnitVHDL
from warnings import warn


class VUnit(VUnitVHDL):
"""
VUnit Verilog interface
"""

def add_builtins(self, external=None): # pylint: disable=arguments-differ
# This is a temporary workaround to avoid breaking the scripts of current verilog users
def add_vhdl_builtins(self): # pylint: disable=arguments-differ
"""
Add vunit Verilog builtin libraries
"""
self._builtins.add_verilog_builtins()
builtins_deprecation_note = (
"class 'verilog' is deprecated and it will be removed in future releases"
"class 'verilog' is deprecated and it will be removed in future releases; "
"preserve the functionality using the default vunit class, along with "
"'compile_builtins=False' and 'VU.add_verilog_builtins'"
)
warn(builtins_deprecation_note, Warning)
4 changes: 3 additions & 1 deletion vunit/verilog/check/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
# Copyright (c) 2014-2021, Lars Asplund lars.anders.asplund@gmail.com

from pathlib import Path
from vunit.verilog import VUnit
from vunit import VUnit


ROOT = Path(__file__).parent

VU = VUnit.from_argv()
VU.add_verilog_builtins()

VU.add_library("lib").add_source_files(ROOT / "test" / "*.sv")
VU.set_sim_option("modelsim.vsim_flags.gui", ["-novopt"])

Expand Down

0 comments on commit 9536061

Please sign in to comment.