Skip to content

Commit 722efd5

Browse files
umarcoreine
authored andcommitted
doc: add vhpidirect/index, vpi/index and vhpi/index
1 parent 5c36855 commit 722efd5

File tree

5 files changed

+83
-25
lines changed

5 files changed

+83
-25
lines changed

doc/index.rst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,32 @@ who are new to either `GHDL` or `VHDL` to first read the :ref:`USING:QuickStart`
2727
Three main approaches are used to co-simulate (co-execute) VHDL sources along with software applications written in a
2828
language other than VHDL (typically C/C++/SystemC):
2929

30-
* Verilog Procedural Interface (VPI), also known as Program Language Interface (PLI) 2.0.
30+
* `Verilog Procedural Interface <https://en.wikipedia.org/wiki/Verilog_Procedural_Interface>`_ (VPI), also known as
31+
Program Language Interface (PLI) 2.0.
3132

32-
* VHDL Procedural Interface (VHPI), or specific implementations, such as Foreign Language Interface (FLI).
33+
* `VHDL Programming Interface <https://ieeexplore.ieee.org/document/4299594>`_ (VHPI), or specific implementations,
34+
such as Foreign Language Interface (FLI).
3335

3436
* Generation of C/C++ models/sources through a transpiler.
3537

3638
VPI and VHPI are complex APIs which allow to inspect the hierarchy, set callbacks and/or assign signals. Because
3739
provided features are similar, GHDL supports VPI only. Furthermore, as an easier to use alternative, GHDL features a
38-
custom coexecution procedure named VHPIDIRECT, similar to SystemVerilog's Direct Programming Interface (DPI).
39-
As of today, generation of C++/SystemC models à la Verilator is not supported. However, a *vhdlator*/*ghdlator* might
40-
be available in the future.
40+
custom coexecution procedure named VHPIDIRECT, similar to SystemVerilog's DPI (`Direct Programming Interface <https://en.wikipedia.org/wiki/SystemVerilog_DPI>`_).
41+
As of today, generation of C++/SystemC models à la `Verilator <https://www.veripool.org/wiki/verilator>`_ is not
42+
supported. However, a *vhdlator*/*ghdlator* might be available in the future.
43+
44+
:ref:`VHPIDIRECT <COSIM:VHPIDIRECT:Intro>` is easier to use than :ref:`VPI <COSIM:VPI:Intro>`/:ref:`VHPI <COSIM:VHPI:Intro>`
45+
because, as the name suggests, it is a direct interface. However, on the one hand VHPIDIRECT requires modification of
46+
VHDL sources, which might not be possible or desirable in certain contexts. On the other hand, VPI/VHPI allow use cases
47+
which are not yet possible with VHPIDIRECT, such as controlling execution time steps. It is suggested to read the quick
48+
start examples of both interfacing mechanisms, in order to get a feel of the differences.
49+
4150

4251
.. toctree::
4352
:caption: VHPIDIRECT
53+
:hidden:
4454

55+
vhpidirect/index
4556
vhpidirect/declarations
4657
vhpidirect/wrapping
4758
vhpidirect/linking
@@ -50,28 +61,17 @@ be available in the future.
5061
vhpidirect/examples/index
5162
vhpidirect/mistakes
5263

53-
Interfacing with foreign languages through VHPIDIRECT is possible on any platform.
54-
You can define a subprogram in a foreign language (such as `C` or
55-
`Ada`) and import it into a VHDL design.
56-
57-
.. NOTE::
58-
GHDL supports different backends, and not all of them generate binary artifacts. Precisely, ``mcode`` is an in-memory
59-
backend. Hence, the examples need to be built/executed with either LLVM or GCC backends. A few of them, the ones that
60-
do not require linking object files, can be used with mcode.
61-
62-
.. ATTENTION::
63-
As a consequence of the runtime copyright, you are not allowed to distribute an
64-
executable produced by GHDL without allowing access to the VHDL sources. See
65-
:ref:`INTRO:Copyrights`.
66-
67-
.. TIP::
68-
See :ghdlsharp:`1053` for on-going work with regard to VHPIDIRECT.
6964

7065
.. toctree::
7166
:caption: VPI
67+
:hidden:
7268

69+
vpi/index
7370
vpi/examples/index
7471

75-
See :ref:`VPI_build_commands`.
7672

77-
TBC
73+
.. toctree::
74+
:caption: VPHI
75+
:hidden:
76+
77+
vhpi/index

doc/vhpi/index.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.. program:: ghdl
2+
3+
.. _COSIM:VHPI:Intro:
4+
5+
Introduction
6+
============
7+
8+
.. ATTENTION::
9+
Since VPI and VHPI provide very similar features, and because VPI is already supported in GHDL, VHPI is not available (yet).
10+
Hence, the information in this section is provided for completeness only.
11+
12+
VHDL Programming Interface (VHPI) was introduced in 2007, as an ammendment to IEEE Std 1076-2002: `1076c-2007 - IEEE Standard VHDL Language Reference Manual - Procedural Language Application Interface <https://ieeexplore.ieee.org/document/4299594>`_.
13+
In the 2009, the programming interface was published as part of `1076-2008 - IEEE Standard VHDL Language Reference Manual <https://ieeexplore.ieee.org/document/4772740>`_.
14+
The latest version was published in 2019: `1076-2019 - IEEE Standard for VHDL Language Reference Manual <https://ieeexplore.ieee.org/document/8938196>`_.
15+
16+
Some vendors support C programming interfaces similar to VHPI. For example, Mentor Graphics' ModelSim/QuestaSim supports a
17+
Foreign Language Interface (FLI) that provides functions to have procedural access to information within the simulator, ``vsim``. These allow to traverse the hierarchy, get/set values and control a simulation run. See `Using ModelSim Foreign Language Interface for c – VHDL CoSimulation and for Simulator Control on Linux x86 Platform <https://opencores.org/usercontent/doc/1380917197>`_ and `github.com/andrepool/fli <https://github.com/andrepool/fli>`_.

doc/vhpidirect/examples/shared.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. program:: ghdl
22
.. _COSIM:VHPIDIRECT:Examples:shared:
33

4-
Shared
5-
######
4+
Shared libs and dynamic loading
5+
###############################
66

77
.. IMPORTANT::
88
As explained in :ref:`COSIM:VHPIDIRECT:Dynamic:loading_a_simulation`, in order to load binaries/libraries dynamically,

doc/vhpidirect/index.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. program:: ghdl
2+
3+
.. _COSIM:VHPIDIRECT:Intro:
4+
5+
Introduction
6+
============
7+
8+
Interfacing with foreign languages through VHPIDIRECT is possible on any platform. You can reuse or define a subprogram
9+
in a foreign language (such as `C` or `Ada`) and import it into a VHDL design.
10+
11+
.. NOTE::
12+
GHDL supports different backends, and not all of them generate binary artifacts. Precisely, ``mcode`` is an in-memory
13+
backend. Hence, the examples need to be built/executed with either LLVM or GCC backends. A few of them, the ones that
14+
do not require linking object files, can be used with mcode.
15+
16+
.. ATTENTION::
17+
As a consequence of the runtime copyright, you are not allowed to distribute an
18+
executable produced by GHDL without allowing access to the VHDL sources. See
19+
:ref:`INTRO:Copyrights`.
20+
21+
.. TIP::
22+
See :ghdlsharp:`1053` for on-going work with regard to VHPIDIRECT.

doc/vpi/index.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. program:: ghdl
2+
.. _COSIM:VPI:Intro:
3+
4+
Introduction
5+
============
6+
7+
Verilog Procedural Interface (VPI) is part of the IEEE Std 1364: `1364-2005 - IEEE Standard for Verilog Hardware Description Language <https://ieeexplore.ieee.org/document/1620780>`_.
8+
It allows Verilog code to invoke C functions, and C functions to invoke Verilog system tasks. VPI is sometimes referred to
9+
as PLI 2, because it replaced the deprecated Program Language Interface (PLI).
10+
11+
VPI provides advanced features, at the cost of having to learn the API. Since this is the user and reference manual for GHDL,
12+
an introduction to VPI is not included. Thus, the reader should have at least a basic knowledge of the interface. A good knowledge of the reference manual.
13+
14+
Unlike VHPIDIRECT, which allows and requires the user to define a custom API between VHDL and C, VPI is itself a pre-defined
15+
API. Hence, all VPI modules need to include a standard header file, ``vpi_user.h``. At the same time, VPI modules need to be
16+
built as shared libraries, and they are dynamically loaded at runtime. This is similar to example :ref:`COSIM:VHPIDIRECT:Examples:shared:shlib`.
17+
However, when using VPI, VHDL sources are agnostic to the existence of C sources.
18+
19+
Information about GHDL's commands related to VPI is available at :ref:`VPI_build_commands` and :option:`--vpi`.

0 commit comments

Comments
 (0)