Skip to main content

在 Sphinx 中从 Verilog 生成图表。

项目描述

派皮 PyPI 版本 文档 构建状态 编解码器

Sphinx 扩展从 HDL 代码生成各种类型的图表,支持 Verilog、nMigen 和 RTLIL。

sphinxcontrib-hdl-diagrams 是一个 Sphinx 扩展,可以更轻松地从 HDL 源文件编写漂亮的文档。它主要使用Yosys读取源文件并生成图表。

查看文档以获取示例。

安装

需要 Python 3.5+。

pip install sphinxcontrib-hdl-diagrams

或者,

python3 -m pip install sphinxcontrib-hdl-diagrams

狮身人面像集成

在您的 conf.py 中,添加以下行。

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

非 Python 依赖项

这些依赖项可以安装在您的系统上,也可以使用 conda environment.yml文件安装;

conda XXXX

必需的

默认情况下,verilog-diagram使用 PyPI 中提供的yowasp-yosys包。可以通过运行pip install -r requirements.txt来安装它。但是,您也可以使用安装在系统上的 Yosys,或者使用 Sphinx conf.py文件中的verilog_diagram_yosys变量指向特定的 Yosys 二进制文件:

要使用系统中可用的 Yosys,请使用以下设置:

verilog_diagram_yosys = "system"

如果要指向特定的 Yosys 二进制文件,请提供程序的路径:

verilog_diagram_yosys = "<path-to-Yosys>"

可选的

用法

hdl图

hdl-diagram RST 指令可用于从 Verilog 代码生成图表并将其包含在您的文档中。查看示例以了解如何使用它。

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

选项

:type: - HDL 图表类型;

  • yosys-blackbox - Yosys 呈现的网表。

  • yosys-aig -在直接在 Yosys 中生成图像之前,通过aigmap运行 Verilog 文件

  • netlistsvg - 使用netlistsvg渲染输出

:module: - 要绘制的模块。

:flatten: - 在生成图像之前使用 Yosys flatten命令。

例子

这是一个 4 位进位链的示意图。

4位进位链

无执照

此扩展还提供了no-license指令,可用于包含文件中的代码块,但省略文件顶部的许可标头。它的行为类似于literalinclude指令,但是lines选项被覆盖以仅显示许可证头之后的行。

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

例子

下面是literalincludeno-license指令之间的比较。

.. 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

执照

阿帕奇 2.0

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

sphinxcontrib-verilog-diagrams-0.1.0.tar.gz (3.6 kB 查看哈希)

已上传 source

内置分布

sphinxcontrib_verilog_diagrams-0.1.0-py3-none-any.whl (3.9 kB 查看哈希

已上传 py3