Skip to main content

Generate diagrams from HDL in Sphinx.

Project description

PyPI PyPI version Documentation Build Status codecov

Sphinx Extension which generates various types of diagrams from HDL code, supporting Verilog, nMigen and RTLIL.

sphinxcontrib-hdl-diagrams is a Sphinx extension to make it easier to write nice documentation from HDL source files. It primarily uses Yosys to read the source files and generate the diagrams.

Check out the documentation for examples.

Installation

Python 3.5+ is required.

pip install sphinxcontrib-hdl-diagrams

Or,

python3 -m pip install sphinxcontrib-hdl-diagrams

Sphinx Integration

In your conf.py, add the following lines.

extensions = [
    ...,
    'sphinxcontrib_hdl_diagrams',
]

Non-Python Dependencies

These dependencies can be either installed on your system or install using the conda environment.yml file with;

conda XXXX

Required

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

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

verilog_diagram_yosys = "system"

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

verilog_diagram_yosys = "<path-to-Yosys>"

Optional

Usage

hdl-diagram

The hdl-diagram RST directive can be used to generate a diagram from Verilog code and include it in your documentation. Check out the examples to see how to use it.

.. hdl-diagram:: file.v
   :type: XXXXX
   :module: XXXX
   :skin: XXXX
   :yosys_script: XXXX
   :flatten:

Options

:type: - HDL Diagram Types;

  • yosys-blackbox - Netlist rendered by Yosys.

  • yosys-aig - Verilog file run through aigmap before image is generated directly in Yosys.

  • netlistsvg - Render output with netlistsvg

:module: - Which module to diagram.

:flatten: - Use the Yosys flatten command before generating the image.

Example

Here is a diagram of a 4-bit carry chain.

4-bit carry chain

no-license

This extension also provides the no-license directive which can be used to include code blocks from a file, but omitting the license header 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.

.. no-license:: verilog/dff.v
   :language: verilog
   :linenos:
   :caption: verilog/dff.v

Example

Here is a comparison between the literalinclude and no-license directives.

.. literalinclude:: verilog/dff.v
   :language: verilog
   :caption: verilog/dff.v
/*
 * Copyright (C) 2020  The SymbiFlow Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

// Single flip-flip test.
module top(input clk, input di, output do);
  always @( posedge clk )
    do <= di;
endmodule // top
.. no-license:: verilog/dff.v
   :language: verilog
   :caption: verilog/dff.v
// Single flip-flip test.
module top(input clk, input di, output do);
  always @( posedge clk )
    do <= di;
endmodule // top

Licence

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinxcontrib-hdl-diagrams-0.0.post131.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file sphinxcontrib-hdl-diagrams-0.0.post131.tar.gz.

File metadata

  • Download URL: sphinxcontrib-hdl-diagrams-0.0.post131.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.5.2

File hashes

Hashes for sphinxcontrib-hdl-diagrams-0.0.post131.tar.gz
Algorithm Hash digest
SHA256 f05f467d91c90b879090ef04f80481cca171d7a8cc909bfa6eef3ed2d6687cf1
MD5 f886d8e46223516d233e1403ab780545
BLAKE2b-256 32717bd7451d588c7542d4688ae9570ce29044b875236b0b42390ba2102bca41

See more details on using hashes here.

File details

Details for the file sphinxcontrib_hdl_diagrams-0.0.post131-py3-none-any.whl.

File metadata

  • Download URL: sphinxcontrib_hdl_diagrams-0.0.post131-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.5.2

File hashes

Hashes for sphinxcontrib_hdl_diagrams-0.0.post131-py3-none-any.whl
Algorithm Hash digest
SHA256 d030617dab2e84d0bc9aa53aea8ababb2824fe69761383f0c5ab580256f047fa
MD5 651b45daea87ebdd48bfa157e8929cd4
BLAKE2b-256 d64f3e114fd7beacd1dc66981add16036d7dbd060bbbca6f1494c6279d48d26c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page