首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Yosys -用verilog制作电子原理图

Yosys -用verilog制作电子原理图
EN

Stack Overflow用户
提问于 2021-06-10 14:56:53
回答 1查看 1.2K关注 0票数 0

我知道如何使用yosys从verilog .v文件编译.dot文件,以便以图形方式检查verilog设计。我在我的制作文件中使用了这样的目标:

代码语言:javascript
复制
dot:
    yosys \
        -p "read_verilog -sv -formal $(file_main).v" \
        -p "hierarchy -check -top $(module_top)" \
        -p "proc" \
        -p "show -prefix $(file_main) -notitle -colors 2 -width -format dot"
    xdot $(file_main).dot

但有个问题。在用‘`xdot编译并打开.dot文件之后,一切看起来都更像软件流程图,但我希望它看起来更像电子原理图。目前是否有办法做到这一点?

我知道yosis也可以从verilog .v文件中创建.blif文件。我通常是这样做的:

代码语言:javascript
复制
yosys \
    -p "synth_ice40 -top $(module_top) -blif $(file_main).blif" \
    $(file_main).v

具有.blif扩展名的文件实际上是一个netlist文件(来源)!那么有什么程序可以预演它们吗?或者是解析它们的解析器,这样我就可以以某种方式预览它们的原理图了?

NETLISTSVG

有人建议使用工具网表,这是没有积极开发的,它有一个不好的缺点。它不接受inout类型。因此,如果我使用这个makefile目标:

代码语言:javascript
复制
svg:
    yosys \
        -p "read_verilog -sv -formal $(file_main).v" \
        -p "hierarchy -check -top $(module_top)" \
        -p "proc" \
        -p "write_json $(file_main).json"
    netlistsvg -o $(file_main).svg $(file_main).json

Yosys工作出色,并生成.json netlist文件:

代码语言:javascript
复制
        "d": {
          "direction": "input",
          "bits": [ 2 ]
        },
        "c": {
          "direction": "input",
          "bits": [ 3 ]
        },
        "r": {
          "direction": "input",
          "bits": [ 4 ]
        },
        "q": {
          "direction": "inout",
          "bits": [ 5 ]
        }
      },
      "cells": {
        "$and$d_flip_flop_rizing_clr.v:25$1": {
          "hide_name": 1,
          "type": "$and",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "B_SIGNED": "00000000000000000000000000000000",
            "B_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:25.17-25.22"
          },
          "port_directions": {
            "A": "input",
            "B": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 6 ],
            "B": [ 7 ],
            "Y": [ 8 ]
          }
        },
        "$and$d_flip_flop_rizing_clr.v:26$2": {
          "hide_name": 1,
          "type": "$and",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "B_SIGNED": "00000000000000000000000000000000",
            "B_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:26.17-26.22"
          },
          "port_directions": {
            "A": "input",
            "B": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 9 ],
            "B": [ 6 ],
            "Y": [ 10 ]
          }
        },
        "$and$d_flip_flop_rizing_clr.v:28$4": {
          "hide_name": 1,
          "type": "$and",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "B_SIGNED": "00000000000000000000000000000000",
            "B_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:28.17-28.25"
          },
          "port_directions": {
            "A": "input",
            "B": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 11 ],
            "B": [ 9 ],
            "Y": [ 12 ]
          }
        },
        "$and$d_flip_flop_rizing_clr.v:30$6": {
          "hide_name": 1,
          "type": "$and",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "B_SIGNED": "00000000000000000000000000000000",
            "B_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:30.17-30.22"
          },
          "port_directions": {
            "A": "input",
            "B": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 13 ],
            "B": [ 14 ],
            "Y": [ 15 ]
          }
        },
        "$and$d_flip_flop_rizing_clr.v:31$7": {
          "hide_name": 1,
          "type": "$and",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "B_SIGNED": "00000000000000000000000000000000",
            "B_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:31.17-31.25"
          },
          "port_directions": {
            "A": "input",
            "B": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 15 ],
            "B": [ 2 ],
            "Y": [ 16 ]
          }
        },
        "$and$d_flip_flop_rizing_clr.v:34$10": {
          "hide_name": 1,
          "type": "$and",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "B_SIGNED": "00000000000000000000000000000000",
            "B_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:34.17-34.22"
          },
          "port_directions": {
            "A": "input",
            "B": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 13 ],
            "B": [ 14 ],
            "Y": [ 17 ]
          }
        },
        "$and$d_flip_flop_rizing_clr.v:35$11": {
          "hide_name": 1,
          "type": "$and",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "B_SIGNED": "00000000000000000000000000000000",
            "B_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:35.17-35.25"
          },
          "port_directions": {
            "A": "input",
            "B": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 17 ],
            "B": [ 5 ],
            "Y": [ 18 ]
          }
        },
        "$and$d_flip_flop_rizing_clr.v:37$13": {
          "hide_name": 1,
          "type": "$and",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "B_SIGNED": "00000000000000000000000000000000",
            "B_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:37.17-37.22"
          },
          "port_directions": {
            "A": "input",
            "B": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 19 ],
            "B": [ 14 ],
            "Y": [ 20 ]
          }
        },
        "$and$d_flip_flop_rizing_clr.v:38$14": {
          "hide_name": 1,
          "type": "$and",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "B_SIGNED": "00000000000000000000000000000000",
            "B_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:38.17-38.25"
          },
          "port_directions": {
            "A": "input",
            "B": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 20 ],
            "B": [ 3 ],
            "Y": [ 21 ]
          }
        },
        "$and$d_flip_flop_rizing_clr.v:41$17": {
          "hide_name": 1,
          "type": "$and",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "B_SIGNED": "00000000000000000000000000000000",
            "B_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:41.17-41.22"
          },
          "port_directions": {
            "A": "input",
            "B": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 6 ],
            "B": [ 3 ],
            "Y": [ 11 ]
          }
        },
        "$not$d_flip_flop_rizing_clr.v:27$3": {
          "hide_name": 1,
          "type": "$not",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:27.17-27.23"
          },
          "port_directions": {
            "A": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 8 ],
            "Y": [ 5 ]
          }
        },
        "$not$d_flip_flop_rizing_clr.v:29$5": {
          "hide_name": 1,
          "type": "$not",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:29.14-29.20"
          },
          "port_directions": {
            "A": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 12 ],
            "Y": [ 13 ]
          }
        },
        "$not$d_flip_flop_rizing_clr.v:32$8": {
          "hide_name": 1,
          "type": "$not",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:32.14-32.20"
          },
          "port_directions": {
            "A": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 16 ],
            "Y": [ 9 ]
          }
        },
        "$not$d_flip_flop_rizing_clr.v:33$9": {
          "hide_name": 1,
          "type": "$not",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:33.14-33.17"
          },
          "port_directions": {
            "A": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 4 ],
            "Y": [ 14 ]
          }
        },
        "$not$d_flip_flop_rizing_clr.v:36$12": {
          "hide_name": 1,
          "type": "$not",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:36.14-36.20"
          },
          "port_directions": {
            "A": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 18 ],
            "Y": [ 7 ]
          }
        },
        "$not$d_flip_flop_rizing_clr.v:39$15": {
          "hide_name": 1,
          "type": "$not",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:39.14-39.20"
          },
          "port_directions": {
            "A": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 21 ],
            "Y": [ 6 ]
          }
        },
        "$not$d_flip_flop_rizing_clr.v:40$16": {
          "hide_name": 1,
          "type": "$not",
          "parameters": {
            "A_SIGNED": "00000000000000000000000000000000",
            "A_WIDTH": "00000000000000000000000000000001",
            "Y_WIDTH": "00000000000000000000000000000001"
          },
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:40.14-40.20"
          },
          "port_directions": {
            "A": "input",
            "Y": "output"
          },
          "connections": {
            "A": [ 10 ],
            "Y": [ 19 ]
          }
        }
      },
      "netnames": {
        "$and$d_flip_flop_rizing_clr.v:25$1_Y": {
          "hide_name": 1,
          "bits": [ 8 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:25.17-25.22"
          }
        },
        "$and$d_flip_flop_rizing_clr.v:26$2_Y": {
          "hide_name": 1,
          "bits": [ 10 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:26.17-26.22"
          }
        },
        "$and$d_flip_flop_rizing_clr.v:28$4_Y": {
          "hide_name": 1,
          "bits": [ 12 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:28.17-28.25"
          }
        },
        "$and$d_flip_flop_rizing_clr.v:30$6_Y": {
          "hide_name": 1,
          "bits": [ 15 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:30.17-30.22"
          }
        },
        "$and$d_flip_flop_rizing_clr.v:31$7_Y": {
          "hide_name": 1,
          "bits": [ 16 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:31.17-31.25"
          }
        },
        "$and$d_flip_flop_rizing_clr.v:34$10_Y": {
          "hide_name": 1,
          "bits": [ 17 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:34.17-34.22"
          }
        },
        "$and$d_flip_flop_rizing_clr.v:35$11_Y": {
          "hide_name": 1,
          "bits": [ 18 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:35.17-35.25"
          }
        },
        "$and$d_flip_flop_rizing_clr.v:37$13_Y": {
          "hide_name": 1,
          "bits": [ 20 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:37.17-37.22"
          }
        },
        "$and$d_flip_flop_rizing_clr.v:38$14_Y": {
          "hide_name": 1,
          "bits": [ 21 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:38.17-38.25"
          }
        },
        "$and$d_flip_flop_rizing_clr.v:41$17_Y": {
          "hide_name": 1,
          "bits": [ 11 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:41.17-41.22"
          }
        },
        "$not$d_flip_flop_rizing_clr.v:27$3_Y": {
          "hide_name": 1,
          "bits": [ 5 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:27.17-27.23"
          }
        },
        "$not$d_flip_flop_rizing_clr.v:29$5_Y": {
          "hide_name": 1,
          "bits": [ 13 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:29.14-29.20"
          }
        },
        "$not$d_flip_flop_rizing_clr.v:32$8_Y": {
          "hide_name": 1,
          "bits": [ 9 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:32.14-32.20"
          }
        },
        "$not$d_flip_flop_rizing_clr.v:33$9_Y": {
          "hide_name": 1,
          "bits": [ 14 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:33.14-33.17"
          }
        },
        "$not$d_flip_flop_rizing_clr.v:36$12_Y": {
          "hide_name": 1,
          "bits": [ 7 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:36.14-36.20"
          }
        },
        "$not$d_flip_flop_rizing_clr.v:39$15_Y": {
          "hide_name": 1,
          "bits": [ 6 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:39.14-39.20"
          }
        },
        "$not$d_flip_flop_rizing_clr.v:40$16_Y": {
          "hide_name": 1,
          "bits": [ 19 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:40.14-40.20"
          }
        },
        "_00_": {
          "hide_name": 0,
          "bits": [ 5 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:4.8-4.12"
          }
        },
        "_01_": {
          "hide_name": 0,
          "bits": [ 12 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:5.8-5.12"
          }
        },
        "_02_": {
          "hide_name": 0,
          "bits": [ 15 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:6.8-6.12"
          }
        },
        "_03_": {
          "hide_name": 0,
          "bits": [ 16 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:7.8-7.12"
          }
        },
        "_04_": {
          "hide_name": 0,
          "bits": [ 17 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:8.8-8.12"
          }
        },
        "_05_": {
          "hide_name": 0,
          "bits": [ 18 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:9.8-9.12"
          }
        },
        "_06_": {
          "hide_name": 0,
          "bits": [ 20 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:10.8-10.12"
          }
        },
        "_07_": {
          "hide_name": 0,
          "bits": [ 21 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:11.8-11.12"
          }
        },
        "_08_": {
          "hide_name": 0,
          "bits": [ 11 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:12.8-12.12"
          }
        },
        "_09_": {
          "hide_name": 0,
          "bits": [ 8 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:13.8-13.12"
          }
        },
        "_10_": {
          "hide_name": 0,
          "bits": [ 10 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:14.8-14.12"
          }
        },
        "c": {
          "hide_name": 0,
          "bits": [ 3 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:15.9-15.10"
          }
        },
        "d": {
          "hide_name": 0,
          "bits": [ 2 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:16.9-16.10"
          }
        },
        "e": {
          "hide_name": 0,
          "bits": [ 14 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:17.8-17.9"
          }
        },
        "f": {
          "hide_name": 0,
          "bits": [ 19 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:18.8-18.9"
          }
        },
        "g": {
          "hide_name": 0,
          "bits": [ 6 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:19.8-19.9"
          }
        },
        "h": {
          "hide_name": 0,
          "bits": [ 13 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:20.8-20.9"
          }
        },
        "i": {
          "hide_name": 0,
          "bits": [ 9 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:21.8-21.9"
          }
        },
        "j": {
          "hide_name": 0,
          "bits": [ 7 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:22.8-22.9"
          }
        },
        "q": {
          "hide_name": 0,
          "bits": [ 5 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:23.9-23.10"
          }
        },
        "r": {
          "hide_name": 0,
          "bits": [ 4 ],
          "attributes": {
            "src": "d_flip_flop_rizing_clr.v:24.9-24.10"
          }
        }
      }
    }
  }
}

但是,netlistsvg命令失败时有一个错误:

代码语言:javascript
复制
netlistsvg -o d_flip_flop_rizing_clr.svg d_flip_flop_rizing_clr.json
/usr/local/lib/node_modules/netlistsvg/bin/netlistsvg.js:55
            throw Error(JSON.stringify(ajv.errors, null, 2));
            ^

Error: [
  {
    "keyword": "enum",
    "dataPath": "/modules/d_flip_flop_rizing_clr/ports/q/direction",
    "schemaPath": "#/properties/modules/additionalProperties/properties/ports/additionalProperties/properties/direction/enum",
    "params": {
      "allowedValues": [
        "input",
        "output"
      ]
    },
    "message": "should be equal to one of the allowed values"
  }
]
    at /usr/local/lib/node_modules/netlistsvg/bin/netlistsvg.js:55:19
    at /usr/local/lib/node_modules/netlistsvg/bin/netlistsvg.js:41:17
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)
make: *** [makefile:152: svg] Error 1

而且它还在抱怨inout类型。非常不完整..。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-22 12:01:13

您可能想看看NetlistSVG。它可以从Yosys创建的JSON netlist中绘制一个示意图。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67923728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档