4
votes

I want to parse Verilog gate level code and store the data in a data structure (ex. graph).

Then I want to do something on the gates in C/C++ and output a corresponding Verilog file.

(I would like to build one program which input and output are Verilog gate level code)

(input.v => myProgram => output.v)

If there is any library or open source code to do so?

I found that it can be done by Flex and Bison but I have no idea how to use Flex and Bison.

3

3 Answers

1
votes

There was a similar question a few days ago about doing this in ruby, in which I pointed to my Verilog parser gem. Not sure if it is robust enough for you though, would love feedback, bug reports, feature requests.

There are perl verilog parsers out there but I have not used any of them directly and avoid perl, hopefully others can add info about other parsers.

1
votes

I have used Verilog-Perl successfully to parse Verilog code. It is well-maintained: it even supports the recent SystemVerilog extensions.

1
votes

Yosys (https://github.com/cliffordwolf/yosys) is a framework for Verilog Synthesis written in C++. Yosys is still under construction but if you only want to read and write gate-level netlists it can do what you need..

PS: A reference manual (that also covers the C++ APIs) is on the way. I've written ~100 pages already, but can't publish it before I've finished my BSc. thesis (another month or so).