Loading

优化数字前端工作流的小脚本v2.0

挖了个新坑,在github上开了个项目:https://github.com/sasasatori/APBRST/tree/main

APBRST: 基于Pyverilog的RTL到文档翻译工具

作者: sasasatori, 联系方式: 2861704773@qq.com

序言

APBRST旨在帮助Verilog RTL开发者自动且轻松地从Verilog代码生成原始文档,以加速代码理解和文档编写的过程。未来可能还支持SystemVerilog的翻译或从文档生成原始RTL代码。该工具基于开源项目Pyverilog,使用Python编写。

许可证

Apache许可证2.0 (http://www.apache.org/licenses/LICENSE-2.0)

安装

要求与Pyverilog相同

  • Python3: 3.7或更高版本
  • Icarus Verilog: 10.1或更高版本
sudo apt install iverilog  
  • Jinja2: 2.10或更高版本
  • PLY: 3.4或更高版本
pip3 install jinja2 ply  

安装Pyverilog后即可直接使用APBRST

现在可以通过setup.py脚本安装Pyverilog:

python3 setup.py install  

使用方法

可以直接运行APBRST:

python3 verilog2spec.py ./verilog/<filename>.v  

示例Verilog文件存放在/verilog目录中,包括cmsdk_ahb_gpio.vfifo.v

运行结果示例:

User@System:~/<path>/APBRST$ python3 verilog2spec.py ./verilog/cmsdk_ahb_gpio.v  
Generating LALR tables  
WARNING: 183 shift/reduce conflicts  

-------------------------generate module tree-------------------------  

cmsdk_ahb_gpio (top)  
├── u_ahb_to_gpio: cmsdk_ahb_to_iop  
└── u_iop_gpio: cmsdk_iop_gpio  

-------------------------generate param table-------------------------  

| Parameter | Default Value | Function |  
| :-------: | :-----------: | :------: |  
| ALTERNATE_FUNC_MASK |    16'h0000   |          |  
| ALTERNATE_FUNC_DEFAULT |    16'h0000   |          |  
| BE        |       0       |          |  

-------------------------generate port table-------------------------  

|     Port     | Width | Direction | Function |  
| :----------: | :---: | :-------: | :------: |  
|     HCLK    |   1   |   Input   |          |  
|   HRESETn   |   1   |   Input   |          |  
|     FCLK    |   1   |   Input   |          |  
|     HSEL    |   1   |   Input   |          |  
|    HREADY   |   1   |   Input   |          |  
|    HTRANS   |   2   |   Input   |          |  
|    HSIZE    |   3   |   Input   |          |  
|    HWRITE   |   1   |   Input   |          |  
|    HADDR    |   12  |   Input   |          |  
|    HWDATA   |   32  |   Input   |          |  
|  ECOREVNUM  |   4   |   Input   |          |  
|    PORTIN   |   16  |   Input   |          |  
|  HREADYOUT  |   1   |   Output  |          |  
|    HRESP    |   1   |   Output  |          |  
|    HRDATA   |   32  |   Output  |          |  
|   PORTOUT   |   16  |   Output  |          |  
|    PORTEN   |   16  |   Output  |          |  
|   PORTFUNC  |   16  |   Output  |          |  
|   GPIOINT   |   16  |   Output  |          |  
|   COMBINT   |   1   |   Output  |          |  
User@System:~/<path>/APBRST$ python3 verilog2spec.py ./verilog/fifo.v  
Generating LALR tables  
WARNING: 183 shift/reduce conflicts  

-------------------------generate module tree-------------------------  

fifo (top)  

-------------------------generate param table-------------------------  

| Parameter | Default Value | Function |  
| :-------: | :-----------: | :------: |  


-------------------------generate port table-------------------------  

|     Port     | Width | Direction | Function |  
| :----------: | :---: | :-------: | :------: |  
|     clk     |   1   |   Input   |          |  
|     srst    |   1   |   Input   |          |  
|    wr_en    |   1   |   Input   |          |  
|    rd_en    |   1   |   Input   |          |  
|     din     |   32  |   Input   |          |  
|     dout    |   32  |   Output  |          |  
|    empty    |   1   |   Output  |          |  
|     full    |   1   |   Output  |          |  

待办事项

posted @ 2025-04-24 20:00  sasasatori  阅读(308)  评论(1)    收藏  举报