Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

Pyverilog

> 编程语言
Open source

Python-based Hardware Design Processing Toolkit for Verilog HDL

798 stars0 likes0 views
WebsiteGitHub

About

Python-based Hardware Design Processing Toolkit for Verilog HDL

Pyverilog

Python-based Hardware Design Processing Toolkit for Verilog HDL

Copyright 2013, Shinya Takamaeda-Yamazaki and Contributors

License

Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)

Publication

If you use Pyverilog in your research, please cite the following paper.

  • Shinya Takamaeda-Yamazaki: Pyverilog: A Python-based Hardware Design Processing Toolkit for Verilog HDL, 11th International Symposium on Applied Reconfigurable Computing (ARC 2015) (Poster), Lecture Notes in Computer Science, Vol.9040/2015, pp.451-460, April 2015. Paper
@inproceedings{Takamaeda:2015:ARC:Pyverilog,
title={Pyverilog: A Python-Based Hardware Design Processing Toolkit for Verilog HDL},
author={Takamaeda-Yamazaki, Shinya},
booktitle={Applied Reconfigurable Computing},
month={Apr},
year={2015},
pages={451-460},
volume={9040},
series={Lecture Notes in Computer Science},
publisher={Springer International Publishing},
doi={10.1007/978-3-319-16214-0_42},
url={http://dx.doi.org/10.1007/978-3-319-16214-0_42},
}

What's Pyverilog?

Pyverilog is an open-source hardware design processing toolkit for Verilog HDL. All source codes are written in Python.

Pyverilog includes (1) code parser, (2) dataflow analyzer, (3) control-flow analyzer and (4) code generator. You can create your own design analyzer, code translator and code generator of Verilog HDL based on this toolkit.

Contribute to Pyverilog

Pyverilog project always welcomes questions, bug reports, feature proposals, and pull requests on GitHub.

for questions, bug reports, and feature proposals

Please leave your comment on the issue tracker on GitHub.

for pull requests

Please check "CONTRIBUTORS.md" for the contributors who provided pull requests.

Pyverilog uses pytest for the integration testing. When you send a pull request, please include a testing example with pytest. To write a testing code, please refer the existing testing examples in "tests" directory.

If the pull request code passes all the tests successfully and has no obvious problem, it will be merged to the develop branch by the main committers.

Installation

Requirements

  • Python3: 3.7 or later
  • Icarus Verilog: 10.1 or later
bash
sudo apt install iverilog
  • Jinja2: 2.10 or later
  • PLY: 3.4 or later
pip3 install jinja2 ply

Optional installation for testing

These are required for automatic testing of tests. We recommend to install these testing library to verify experimental features.

  • pytest: 3.8.1 or later
  • pytest-pythonpath: 0.7.3 or later
pip3 install pytest pytest-pythonpath

Optional installation for visualization

These are required for graph visualization by dataflow/graphgen.py and controlflow/controlflow_analyzer.py.

  • Graphviz: 2.38.0 or later
  • Pygraphviz: 1.3.1 or later
bash
sudo apt install graphviz
pip3 install pygraphviz

Install

Now you can install Pyverilog using setup.py script:

python3 setup.py install

Tools

This software includes various tools for Verilog HDL design.

  • vparser: Code parser to generate AST (Abstract Syntax Tree) from source codes of Verilog HDL.
  • dataflow: Dataflow analyzer with an optimizer to remove redundant expressions and some dataflow handling tools.
  • controlflow: Control-flow analyzer with condition analyzer that identify when a signal is activated.
  • ast_code_generator: Verilog HDL code generator from AST.

Getting Started

First, please prepare a Verilog HDL source file as below. The file name is 'test.v'. This sample design adds the input value internally whtn the enable signal is asserted. Then is outputs its partial value to the LED.

verilog
module top
  (
   input CLK, 
   input RST,
   input enable,
   input [31:0] value,
   output [7:0] led
  );
  reg [31:0] count;
  reg [7:0] state;
  assign led = count[23:16];
  always @(posedge CLK) begin
    if(RST) begin
      count 'd0)--> 1
1 --None--> 2
2 --None--> 0
Loop
(0, 1, 2)

You got also a png file (top_state.png), if you did not append "--nograph". The picture shows that the graphical structure of the state machine.

Code generator

Finally, let's try code generation. Please prepare a Python script as below. The file name is 'test.py'. A Verilog HDL code is represented by using the AST classes defined in 'vparser.ast'.

…

Please type the command as below at the same directory with Pyverilog.

python3 test.py

Then Verilog HDL code generated from the AST instances is displayed.

verilog
module top #
(
  parameter DATAWID = 32
)
(
  input CLK,
  input RST,
  output [7:0] led
);

  reg [DATAWID-1:0] count;
  assign led = count[DATAWID-1:DATAWID-8];

  always @(posedge CLK) begin
    if(RST) begin
      count <= 0;
    end else begin
      count <= count + 1;
    end
  end

endmodule

Related Project and Site

Veriloggen

  • A Mixed-Paradigm Hardware Construction Framework

NNgen

  • A Fully-Customizable Hardware Synthesis Compiler for Deep Neural Network

IPgen

  • IP-core package generator for AXI4/Avalon

PyCoRAM

  • Python-based Portable IP-core Synthesis Framework for FPGA-based Computing

flipSyrup

  • Cycle-Accurate Hardware Simulation Framework on Abstract FPGA Platforms

Pyverilog_toolbox

  • Pyverilog_toolbox is Pyverilog-based verification/design tool, which is developed by Fukatani-san and uses Pyverilog as a fundamental library. Thanks for your contribution!

shtaxxx.hatenablog.com

  • Blog entry for introduction and examples of Pyverilog (in Japansese)

Issues· 82 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Pythoncode-generatorcompilercontrol-flow-analyzerdataflow-analyzer

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言