Skip to content

Commit ddc28de

Browse files
committed
Added support for log location based on VHDL-2019 call paths.
1 parent bae5d38 commit ddc28de

22 files changed

+3986
-3216
lines changed

docs/logging/user_guide.rst

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,19 +300,31 @@ counted to get statistics on disabled log messages.
300300
disable(get_logger("memory_ip:timing_check"), warning);
301301
302302
303-
Log Location Preprocessing
304-
--------------------------
303+
Log Location
304+
------------
305+
306+
For simulators supporting VHDL-2019 VUnit adds file name
307+
and line number location information to all log entries. Currently
308+
only Riviera-PRO supports VHDL-2019 and it restricts the feature
309+
to **debug compiled files**. You can compile all files or just the ones
310+
using logging. For example,
311+
312+
.. code-block:: python
305313
306-
The optional VUnit location preprocessor can be used to add file name
307-
and line number location information to all log calls. This
308-
functionality is enabled from the ``run.py`` file like this:
314+
testbenches = lib.get_source_files("*tb*")
315+
testbenches.set_compile_option("rivierapro.vcom_flags", ["-dbg"])
316+
317+
318+
For earlier VHDL standards there is an optional location preprocessor that can
319+
be used to serve the same purpose. The preprocessor is enabled from
320+
the ``run.py`` file like this:
309321

310322
.. code-block:: python
311323
312324
ui = VUnit.from_argv()
313325
ui.enable_location_preprocessing()
314326
315-
and will change the output to something like this.
327+
Regardless of method the location information is appended to the end of the log entry:
316328

317329
.. code-block:: console
318330
@@ -322,8 +334,25 @@ and will change the output to something like this.
322334
If you've placed your log call(s) in a convenience procedure you most
323335
likely want the location of the calls to that procedure to be in the
324336
output and not the location of the log call in the definition of the
325-
convenience procedure. You can do that by adding the ``line_num`` and
326-
``file_name`` parameters to the **end** of the parameter list for that
337+
convenience procedure. For VHDL-2019 you can use the ``path_offset``
338+
parameter to specify a number of steps earlier in the call stack. For
339+
example,
340+
341+
.. code-block:: vhdl
342+
343+
procedure my_convenience_procedure(
344+
<my parameters>) is
345+
begin
346+
<some code>
347+
info("Some message", path_offset => 1);
348+
<some code>
349+
end procedure my_convenience_procedure;
350+
351+
When ``path_offset`` is set to 1 the location of the caller to
352+
``my_convenience_procedure`` will be used in the log output.
353+
354+
With earlier VHDL standard you can add the ``line_num`` and
355+
``file_name`` parameters to the **end** of the parameter list for the
327356
convenience procedure
328357

329358
.. code-block:: vhdl

tests/unit/test_vhdl_standard.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,27 @@ def test_and_later():
4848
VHDL.STD_2008,
4949
VHDL.STD_2019,
5050
}
51+
assert VHDL.STD_2002.and_later == {
52+
VHDL.STD_2002,
53+
VHDL.STD_2008,
54+
VHDL.STD_2019,
55+
}
5156
assert VHDL.STD_2008.and_later == {VHDL.STD_2008, VHDL.STD_2019}
5257
assert VHDL.STD_2019.and_later == {VHDL.STD_2019}
5358

5459

60+
def test_and_earlier():
61+
assert VHDL.STD_2019.and_earlier == {
62+
VHDL.STD_1993,
63+
VHDL.STD_2002,
64+
VHDL.STD_2008,
65+
VHDL.STD_2019,
66+
}
67+
assert VHDL.STD_2008.and_earlier == {VHDL.STD_1993, VHDL.STD_2002, VHDL.STD_2008}
68+
assert VHDL.STD_2002.and_earlier == {VHDL.STD_1993, VHDL.STD_2002}
69+
assert VHDL.STD_1993.and_earlier == {VHDL.STD_1993}
70+
71+
5572
def test_supports_context():
5673
assert not VHDL.STD_2002.supports_context
5774
assert VHDL.STD_2008.supports_context

vunit/builtins.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def _add_files(self, pattern=None, allow_empty=True):
6060
standard_name = str(standard)
6161
if standard_name + "p" in base_file_name:
6262
standards.update(standard.and_later)
63+
elif standard_name + "m" in base_file_name:
64+
standards.update(standard.and_earlier)
6365
elif standard_name in base_file_name:
6466
standards.add(standard)
6567

0 commit comments

Comments
 (0)