#graphviz #dot #yosys
Вопрос:
Я знаю, как использовать yosys
компиляцию .dot
файла из .v
файла verilog, чтобы графически проверить дизайн verilog. Я использую такую цель в своих файлах создания:
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
Но есть одна проблема. После .dot
того, как файл скомпилирован и открыт с помощью `xdot, все больше похоже на блок-схемы программного обеспечения, но я бы хотел, чтобы он больше походил на схемы электроники. Есть ли в настоящее время способ достичь этого?
Я знаю, что yosis
это также может создавать .blif
файлы из .v
файлов verilog. Обычно я делаю это так в своих файлах создания:
yosys
-p "synth_ice40 -top $(module_top) -blif $(file_main).blif"
$(file_main).v
Файлы с .blif
расширением на самом деле являются файлами сетевого списка (источник)! Итак, есть ли какая-нибудь программа, которая может каким-то образом просмотреть их? Или, может быть, анализатор, который может анализировать их, чтобы я мог как-то просмотреть их схемы?
NETLISTSVG
Было предложено использовать инструмент netlistsvg, который активно не разрабатывается и имеет неприятный недостаток. Он не принимает тип inout
. Так что, если я использую эту makefile
цель:
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
файл сетевого списка:
"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
эта команда завершается ошибкой:
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
на тип. Очень неполный…
Ответ №1:
Возможно, вам захочется взглянуть на NetlistSVG. Он может нарисовать схему из сетевого списка JSON, созданного Yosys.
Комментарии:
1. Это действительно похоже на то, что можно было бы использовать!
2. К сожалению, инструмент немного неполон. Он не поддерживает
inout
направление, необходимое для HDL. Я добавил объяснение к своему вопросу.3. Я вручную установил версию программы для разработки, и она работает — позже они реализовали
inout
: github.com/nturley/netlistsvg/pull/102