Skip to content

Commit 0dc7223

Browse files
Add documentation on using GHDL/VHDL
1 parent d30138d commit 0dc7223

File tree

6 files changed

+141
-4
lines changed

6 files changed

+141
-4
lines changed

README.rst

Lines changed: 20 additions & 1 deletion
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
@@ -106,6 +106,25 @@ 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 is prebuilt into Yosys,
115+
add this configuration option to let Yosys know::
116+
117+
hdl_diagram_ghdl = "prebuilt"
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.
127+
109128
Usage
110129
-----
111130

docs/code/vhdl/alu.vhdl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
library IEEE;
2+
use IEEE.std_logic_1164.all;
3+
use IEEE.numeric_std.all;
4+
5+
entity top is
6+
port(
7+
a : in unsigned(3 downto 0);
8+
b : in unsigned(3 downto 0);
9+
s : in unsigned(1 downto 0);
10+
y : out unsigned(3 downto 0)
11+
);
12+
end top;
13+
14+
architecture rtl of top is
15+
16+
begin
17+
18+
y <= a when s="00" else
19+
b when s="01" else
20+
"0000" when s="10" else
21+
a + b when s="11" else (others => '0');
22+
23+
end;

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
'sphinxcontrib_hdl_diagrams',
5959
]
6060

61+
# Uncomment for YosysHQ/fpga-toolchain
62+
# hdl_diagram_yosys = "system"
63+
# hdl_diagram_ghdl = "prebuilt"
64+
6165
# Add any paths that contain templates here, relative to this directory.
6266
templates_path = ['_templates']
6367

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: top
38+
39+
Result
40+
******
41+
42+
.. hdl-diagram:: ../code/vhdl/alu.vhdl
43+
:type: yosys-bb
44+
:module: top
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: top
60+
61+
Result
62+
******
63+
64+
.. hdl-diagram:: ../code/vhdl/alu.vhdl
65+
:type: yosys-aig
66+
:module: top
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: top
82+
83+
84+
Result
85+
******
86+
87+
.. hdl-diagram:: ../code/vhdl/alu.vhdl
88+
:type: netlistsvg
89+
:module: top

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ 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.
@@ -56,6 +56,7 @@ 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)
5960

6061
Usage
6162
-----

0 commit comments

Comments
 (0)