Skip to content

Commit 10e9a98

Browse files
Add configuration page and documentation on VHDL/GHDL support
Signed-off-by: Michael Riegert <michael@eowyn.net>
1 parent cb701d3 commit 10e9a98

File tree

6 files changed

+248
-12
lines changed

6 files changed

+248
-12
lines changed

README.rst

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ sphinxcontrib-hdl-diagrams
3030
----
3131

3232
Sphinx Extension which generates various types of diagrams from HDL code, supporting Verilog,
33-
nMigen and RTLIL.
33+
nMigen, RTLIL, and VHDL.
3434

3535
`sphinxcontrib-hdl-diagrams <https://github.com/SymbiFlow/sphinxcontrib-hdl-diagrams>`_
3636
is a Sphinx extension to make it easier to write nice documentation from
@@ -84,19 +84,19 @@ Required
8484
.. |yosys| replace:: ``yosys``
8585
.. _yosys: https://github.com/YosysHQ/yosys
8686

87-
By default, ``verilog-diagram`` uses the ``yowasp-yosys`` package provided in PyPI.
87+
By default, ``hdl-diagram`` uses the ``yowasp-yosys`` package provided in PyPI.
8888
It can be installed by running ``pip install -r requirements.txt``.
8989
However, you could also use Yosys that is installed on your system,
90-
or point to the specific Yosys binary using ``verilog_diagram_yosys`` variable
90+
or point to the specific Yosys binary using ``hdl_diagram_yosys`` variable
9191
in the Sphinx ``conf.py`` file:
9292

9393
To use Yosys that is available in your system, use the following setting::
9494

95-
verilog_diagram_yosys = "system"
95+
hdl_diagram_yosys = "system"
9696

9797
If you want to point to the specific Yosys binary, provide the path to the program::
9898

99-
verilog_diagram_yosys = "<path-to-Yosys>"
99+
hdl_diagram_yosys = "<path-to-Yosys>"
100100

101101
Optional
102102
~~~~~~~~
@@ -106,6 +106,27 @@ Optional
106106
.. |netlistsvg| replace:: ``netlistsvg``
107107
.. _netlistsvg: https://github.com/nturley/netlistsvg
108108

109+
* |ghdl|_
110+
111+
.. |ghdl| replace:: ``ghdl``
112+
.. _ghdl: https://github.com/ghdl/ghdl
113+
114+
GHDL and ghdl-yosys-plugin are required for VHDL support. If ghdl-yosys-plugin is built into Yosys,
115+
add this configuration option to let Yosys know::
116+
117+
hdl_diagram_ghdl = "built-in"
118+
119+
Otherwise, to load GHDL as a runtime module, set this configuration option to::
120+
121+
hdl_diagram_ghdl = "module"
122+
123+
Which will pass ``-m ghdl`` to Yosys when calling it. Similarly, setting this to the path of a
124+
ghdl-yosys-plugin shared library will also work.
125+
126+
Unfortunately, at this time GHDL and ghdl-yosys-plugin aren't supported by YoWASP. However, we'd
127+
love to have it available. Are you aware of some proof-of-concept linking WASM compiled from both
128+
C++ and Ada? Do you want to give it a try? Let us know!
129+
109130
Usage
110131
-----
111132

docs/code/vhdl/alu.vhdl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--
2+
-- Copyright (C) 2020 The SymbiFlow Authors.
3+
--
4+
-- Licensed under the Apache License, Version 2.0 (the "License");
5+
-- you may not use this file except in compliance with the License.
6+
-- You may obtain a copy of the License at
7+
--
8+
-- https://www.apache.org/licenses/LICENSE-2.0
9+
--
10+
-- Unless required by applicable law or agreed to in writing, software
11+
-- distributed under the License is distributed on an "AS IS" BASIS,
12+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
-- See the License for the specific language governing permissions and
14+
-- limitations under the License.
15+
--
16+
-- SPDX-License-Identifier: Apache-2.0
17+
18+
library IEEE;
19+
use IEEE.std_logic_1164.all;
20+
use IEEE.numeric_std.all;
21+
22+
entity alu is
23+
port(
24+
a : in unsigned(3 downto 0);
25+
b : in unsigned(3 downto 0);
26+
s : in unsigned(1 downto 0);
27+
y : out unsigned(3 downto 0)
28+
);
29+
end alu;
30+
31+
architecture rtl of alu is
32+
33+
begin
34+
35+
y <= a when s="00" else
36+
b when s="01" else
37+
"0000" when s="10" else
38+
a + b when s="11" else (others => '0');
39+
40+
end;

docs/configuration/index.rst

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
Configuration
2+
=============
3+
4+
This is the list of possible configurations that go in ``conf.py``.
5+
6+
Yosys
7+
+++++
8+
9+
``hdl_diagram_yosys`` tells the program what version or binary of Yosys to use.
10+
By default it is set to ``YoWASP``. Setting it to ``system``, the program will
11+
use Yosys available in the current PATH. It can also contain the path to a specific
12+
Yosys binary.::
13+
14+
hdl_diagram_yosys = "yowasp" # default
15+
16+
hdl_diagram_yosys = "system" # use yosys from PATH
17+
18+
hdl_diagram_yosys = "<path-to-Yosys>" # use specific yosys binary
19+
20+
21+
netlistsvg
22+
++++++++++
23+
24+
netlistsvg can take various skin files for use when creating diagrams. It is
25+
set to ``default`` by default, using the built-in netlistsvg skin.::
26+
27+
hdl_diagram_skin = "<path-to-skin>"
28+
29+
30+
Output format
31+
+++++++++++++
32+
33+
The output format for the generated diagrams can either be set to ``svg`` or ``png``.::
34+
35+
hdl_diagram_output_format = "svg"
36+
37+
hdl_diagram_output_format = "png"
38+
39+
40+
GHDL
41+
++++
42+
43+
ghdl-yosys-plugin can either be built into Yosys or loaded at runtime. If it is built into Yosys,
44+
then set this configuration option to ``built-in``. If it is loaded at runtime, then this can
45+
either be set to ``module`` if the shared library is located at ``YOSYS_PREFIX/share/yosys/plugins/
46+
ghdl.so``, or as a path to the ``ghdl.so`` shared library. ::
47+
48+
hdl_diagram_ghdl = "built-in" # default, if ghdl-yosys-plugin is built into Yosys
49+
50+
hdl_diagram_ghdl = "module" # passes `-m ghdl` to Yosys
51+
52+
hdl_diagram_ghdl = "<path-to-GHDL-shared-library>" # path to specific ghdl.so,
53+
# passes `-m '<path>'` to Yosys
54+
55+
The VHDL standard used for GHDL can be set globally using this configuration option.::
56+
57+
hdl_diagram_ghdl_std = "08" # default, for VHDL 2008
58+
59+
hdl_diagram_ghdl_std = "97" # for VHDL 1993
60+
61+
Common Errors
62+
+++++++++++++
63+
64+
.. code-block::
65+
66+
ERROR:
67+
This version of Yosys cannot load plugins at runtime.
68+
Some plugins may have been included at build time.
69+
Use option `-H' to see the available built-in and plugin commands.
70+
71+
This error signifies that the current version of Yosys cannot load plugins
72+
at runtime, and so all plugins must be prebuit. For VHDL, ``hdl_diagram_ghdl``
73+
must be set to ``built-in``.
74+
75+
.. code-block::
76+
77+
ERROR: Can't guess frontend for input file `' (missing -f option)!
78+
79+
This error signifies that the version of Yosys being used cannot figure out
80+
how to interpret the input file. For VHDL, this signifies that either GHDL
81+
isn't being loaded properly, or that the current version of Yosys isn't compatible
82+
with GHDL.

docs/examples/alu-vhdl.rst

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
4 bit ALU in VHDL
2+
=================
3+
4+
VHDL Code
5+
+++++++++
6+
7+
RST Directive
8+
*************
9+
10+
.. code-block:: rst
11+
:linenos:
12+
13+
.. no-license:: ../code/vhdl/alu.vhdl
14+
:language: vhdl
15+
:linenos:
16+
17+
18+
Result
19+
******
20+
21+
.. no-license:: ../code/vhdl/alu.vhdl
22+
:language: vhdl
23+
:linenos:
24+
25+
Yosys BlackBox Diagram
26+
++++++++++++++++++++++
27+
28+
RST Directive
29+
*************
30+
31+
.. code-block:: rst
32+
:linenos:
33+
:emphasize-lines: 2
34+
35+
.. hdl-diagram:: ../code/vhdl/alu.vhdl
36+
:type: yosys-bb
37+
:module: alu
38+
39+
Result
40+
******
41+
42+
.. hdl-diagram:: ../code/vhdl/alu.vhdl
43+
:type: yosys-bb
44+
:module: alu
45+
46+
47+
Yosys AIG Diagram
48+
+++++++++++++++++
49+
50+
RST Directive
51+
*************
52+
53+
.. code-block:: rst
54+
:linenos:
55+
:emphasize-lines: 2
56+
57+
.. hdl-diagram:: ../code/vhdl/alu.vhdl
58+
:type: yosys-aig
59+
:module: alu
60+
61+
Result
62+
******
63+
64+
.. hdl-diagram:: ../code/vhdl/alu.vhdl
65+
:type: yosys-aig
66+
:module: alu
67+
68+
69+
NetlistSVG Diagram
70+
++++++++++++++++++
71+
72+
RST Directive
73+
*************
74+
75+
.. code-block:: rst
76+
:linenos:
77+
:emphasize-lines: 2
78+
79+
.. hdl-diagram:: ../code/vhdl/alu.vhdl
80+
:type: netlistsvg
81+
:module: alu
82+
83+
84+
Result
85+
******
86+
87+
.. hdl-diagram:: ../code/vhdl/alu.vhdl
88+
:type: netlistsvg
89+
:module: alu

docs/examples/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Examples
44
.. toctree::
55
:maxdepth: 1
66
:glob:
7-
7+
88
comb-full-adder
9-
carry4
9+
carry4
10+
alu-vhdl

docs/index.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ Sphinx HDL Diagrams
33

44
sphinx-hdl-diagrams is an extension to Sphinx to make it easier to write
55
nice documentation from HDL source files, in the form of Verilog, nMigen,
6-
or RTLIL code.
6+
RTLIL, or VHDL code.
77

88
You use the |hdl-diagram|_ RST directive to generate various styles of
99
diagrams from HDL code.
1010

11-
Most of the time there will be a license header at the top of source code,
12-
which we might not want to show in the documentation.
13-
This extension also provides the |no-license|_ RST directive which works exactly
11+
Most of the time there will be a license header at the top of source code,
12+
which we might not want to show in the documentation.
13+
This extension also provides the |no-license|_ RST directive which works exactly
1414
like the `.. literalinclude` directive, but the `lines` option is overridden
1515
to only show the lines after the license header.
1616

@@ -56,6 +56,8 @@ conda `environment.yml <https://github.com/SymbiFlow/sphinxcontrib-hdl-diagrams/
5656

5757
- `yosys <https://github.com/YosysHQ/yosys>`_ (required)
5858
- `netlistsvg <https://github.com/nturley/netlistsvg>`_ (optional)
59+
- `GHDL <https://github.com/ghdl/ghdl>`_ (required for VHDL)
60+
- `ghdl-yosys-plugin <https://github.com/ghdl/ghdl-yosys-plugin>`_ (required for VHDL)
5961

6062
Usage
6163
-----
@@ -106,6 +108,7 @@ So, refer to `literalinclude` for the available options.
106108
:maxdepth: 1
107109
:glob:
108110
:hidden:
109-
111+
112+
configuration/index
110113
directives/index
111114
examples/index

0 commit comments

Comments
 (0)