|
| 1 | +sphinxcontrib-verilog-diagrams |
| 2 | +============================== |
| 3 | + |
| 4 | + |
| 5 | +.. image:: https://img.shields.io/pypi/v/sphinxcontrib-verilog-diagrams.svg |
| 6 | + :target: https://pypi.python.org/pypi/sphinxcontrib-verilog-diagrams |
| 7 | + :alt: PyPI |
| 8 | + |
| 9 | + |
| 10 | +.. image:: https://img.shields.io/pypi/pyversions/sphinxcontrib-verilog-diagrams.svg |
| 11 | + :target: https://pypi.python.org/pypi/sphinxcontrib-verilog-diagrams |
| 12 | + :alt: PyPI version |
| 13 | + |
| 14 | + |
| 15 | +.. image:: https://readthedocs.org/projects/sphinxcontrib-verilog-diagrams/badge |
| 16 | + :target: https://sphinxcontrib-verilog-diagrams.readthedocs.io/en/latest/ |
| 17 | + :alt: Documentation |
| 18 | + |
| 19 | + |
| 20 | +.. image:: https://travis-ci.com/SymbiFlow/sphinxcontrib-verilog-diagrams.svg?branch=master |
| 21 | + :target: https://travis-ci.com/SymbiFlow/sphinxcontrib-verilog-diagrams |
| 22 | + :alt: Build Status |
| 23 | + |
| 24 | + |
| 25 | +.. image:: https://codecov.io/gh/SymbiFlow/sphinxcontrib-verilog-diagrams/branch/master/graph/badge.svg |
| 26 | + :target: https://codecov.io/gh/SymbiFlow/sphinxcontrib-verilog-diagrams |
| 27 | + :alt: codecov |
| 28 | + |
| 29 | + |
| 30 | +---- |
| 31 | + |
| 32 | +Sphinx Extension which generates various types of diagrams from Verilog code. |
| 33 | + |
| 34 | +`sphinxcontrib-verilog-diagrams <https://github.com/SymbiFlow/sphinxcontrib-verilog-diagrams>`_ |
| 35 | +is a Sphinx extension to make it easier to write nice documentation from |
| 36 | +Verilog files. It primarily uses `Yosys <https://github.com/YosysHQ/yosys>`_ to do the Verilog reading. |
| 37 | + |
| 38 | +Check out the `documentation <https://sphinxcontrib-verilog-diagrams.readthedocs.io/en/latest>`_ for examples. |
| 39 | + |
| 40 | +Installation |
| 41 | +------------ |
| 42 | + |
| 43 | +Python 3.5+ is required. |
| 44 | + |
| 45 | +.. code-block:: |
| 46 | +
|
| 47 | + pip install sphinxcontrib-verilog-diagrams |
| 48 | +
|
| 49 | +Or, |
| 50 | + |
| 51 | +.. code-block:: |
| 52 | +
|
| 53 | + python3 -m pip install sphinxcontrib-verilog-diagrams |
| 54 | +
|
| 55 | +Sphinx Integration |
| 56 | +^^^^^^^^^^^^^^^^^^ |
| 57 | + |
| 58 | +In your conf.py, add the following lines. |
| 59 | + |
| 60 | +.. code-block:: python |
| 61 | +
|
| 62 | + extensions = [ |
| 63 | + ..., |
| 64 | + 'sphinxcontrib_verilog_diagrams', |
| 65 | + ] |
| 66 | +
|
| 67 | +Non-Python Dependencies |
| 68 | +^^^^^^^^^^^^^^^^^^^^^^^ |
| 69 | + |
| 70 | +These dependencies can be either installed on your system or install using the |
| 71 | +conda ``environment.yml`` file with; |
| 72 | + |
| 73 | +.. code-block:: bash |
| 74 | +
|
| 75 | + conda XXXX |
| 76 | +
|
| 77 | +Required |
| 78 | +~~~~~~~~ |
| 79 | + |
| 80 | +* |yosys|_ |
| 81 | +.. |yosys| replace:: `yosys` |
| 82 | +.. _yosys: https://github.com/YosysHQ/yosys |
| 83 | + |
| 84 | +Optional |
| 85 | +~~~~~~~~ |
| 86 | + |
| 87 | +* |netlistsvg|_ |
| 88 | +.. |netlistsvg| replace:: `netlistsvg` |
| 89 | +.. _netlistsvg: https://github.com/nturley/netlistsvg |
| 90 | + |
| 91 | +Usage |
| 92 | +----- |
| 93 | + |
| 94 | +``verilog-diagram`` |
| 95 | +^^^^^^^^^^^^^^^^^^^ |
| 96 | + |
| 97 | +The ``verilog-diagram`` RST directive can be used to generate a diagram from Verilog code and include it in your documentation. |
| 98 | +Check out the `examples <https://sphinxcontrib-verilog-diagrams.readthedocs.io/en/latest/>`_ to see how to use it. |
| 99 | + |
| 100 | +.. code-block:: rst |
| 101 | +
|
| 102 | +
|
| 103 | + .. verilog-diagram:: file.v |
| 104 | + :type: XXXXX |
| 105 | + :module: XXXX |
| 106 | + :flatten: |
| 107 | +
|
| 108 | +Options |
| 109 | +~~~~~~~ |
| 110 | + |
| 111 | +``:type:`` - Verilog Diagram Types; |
| 112 | + |
| 113 | + |
| 114 | +* ``yosys-blackbox`` - Netlist rendered by Yosys. |
| 115 | +* ``yosys-aig`` - Verilog file run through ``aigmap`` before image is generated directly in Yosys. |
| 116 | +* ``netlistsvg`` - Render output with `netlistsvg <https://github.com/nturley/netlistsvg>`_ |
| 117 | + |
| 118 | +``:module:`` - Which module to diagram. |
| 119 | + |
| 120 | +``:flatten:`` - Use the Yosys ``flatten`` command before generating the image. |
| 121 | + |
| 122 | +Example |
| 123 | +~~~~~~~ |
| 124 | + |
| 125 | +Here is a diagram of a 4-bit carry chain. |
| 126 | + |
| 127 | + |
| 128 | +.. image:: ./carry4-flatten.svg |
| 129 | + :target: ./carry4-flatten.svg |
| 130 | + :alt: 4-bit carry chain |
| 131 | + |
| 132 | + |
| 133 | +``no-license`` |
| 134 | +^^^^^^^^^^^^^^ |
| 135 | + |
| 136 | +This extension also provides the ``no-license`` directive which can be used to include code blocks from a file, but omitting the license header |
| 137 | +at the top of the file. It behaves like the ``literalinclude`` directive, but the ``lines`` option is overridden to only show the lines after the license header. |
| 138 | + |
| 139 | +.. code-block:: rst |
| 140 | +
|
| 141 | +
|
| 142 | + .. no-license:: verilog/dff.v |
| 143 | + :language: verilog |
| 144 | + :linenos: |
| 145 | + :caption: verilog/dff.v |
| 146 | +
|
| 147 | +Example |
| 148 | +~~~~~~~ |
| 149 | + |
| 150 | +Here is a comparison between the ``literalinclude`` and ``no-license`` directives. |
| 151 | + |
| 152 | +.. code-block:: rst |
| 153 | +
|
| 154 | + .. literalinclude:: verilog/dff.v |
| 155 | + :language: verilog |
| 156 | + :caption: verilog/dff.v |
| 157 | +
|
| 158 | +.. code-block:: verilog |
| 159 | +
|
| 160 | + /* |
| 161 | + * Copyright (C) 2020 The SymbiFlow Authors. |
| 162 | + * |
| 163 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 164 | + * you may not use this file except in compliance with the License. |
| 165 | + * You may obtain a copy of the License at |
| 166 | + * |
| 167 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 168 | + * |
| 169 | + * Unless required by applicable law or agreed to in writing, software |
| 170 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 171 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 172 | + * See the License for the specific language governing permissions and |
| 173 | + * limitations under the License. |
| 174 | + * |
| 175 | + * SPDX-License-Identifier: Apache-2.0 |
| 176 | + */ |
| 177 | +
|
| 178 | + // Single flip-flip test. |
| 179 | + module top(input clk, input di, output do); |
| 180 | + always @( posedge clk ) |
| 181 | + do <= di; |
| 182 | + endmodule // top |
| 183 | +
|
| 184 | +.. code-block:: rst |
| 185 | +
|
| 186 | + .. no-license:: verilog/dff.v |
| 187 | + :language: verilog |
| 188 | + :caption: verilog/dff.v |
| 189 | +
|
| 190 | +.. code-block:: verilog |
| 191 | +
|
| 192 | + // Single flip-flip test. |
| 193 | + module top(input clk, input di, output do); |
| 194 | + always @( posedge clk ) |
| 195 | + do <= di; |
| 196 | + endmodule // top |
| 197 | +
|
| 198 | +Licence |
| 199 | +------- |
| 200 | + |
| 201 | +`Apache 2.0 <LICENSE>`_ |
0 commit comments