f4pga / ideas

Random ideas and interesting ideas for things we hope to eventually do.
86 stars 9 forks source link

Create Python library for parsing / producing BLIF (and eBLIF) files #18

Open mithro opened 6 years ago

mithro commented 6 years ago

Create a Python library for parsing / producing BLIF (and eBLIF) files

BLIF is the preferred method of design entry for many designers. The Berkeley Logic Interchange Format (BLIF) is a simple file format for exchanging sequential logic between programs.

eBLIF is an extension of the BLIF format to add features needed for using BLIF as part of an FPGA PnR flow created by Clifford Wolf. The best format is the Verilog to Routing docs here.

BLIF is used by Yosys, Arachne-pnr and Verilog to Routing.

There might be a starting library here.

Expected results

A Python library published on PyPi which makes it easy to read and write BLIF files.

Knowledge Prerequisites

nturley commented 6 years ago

I can work on this. I'm a little busy at the moment so my progress would be steady but slow.

Do we have a corpus of BLIF files to test against?

mithro commented 6 years ago

@nturley

We don't really have a good corpus but some sources of BLIF files are;

You can also easily generate them with Yosys and the write_blif command.

GitHub
verilog-to-routing/vtr-verilog-to-routing
vtr-verilog-to-routing - Verilog to Routing -- Open Source CAD Flow for FPGA Research
GitHub
cseed/arachne-pnr
arachne-pnr - Place and route tool for FPGAs
mx-shift commented 6 years ago

I've been making BLIFs to exercise different parts of the grammar for my Rust BLIF parser at https://github.com/gaffe-logic/blif/tree/master/examples . Feel free to use them.

nturley commented 6 years ago

any objections to a parser generator like antlr4? The grammar would then be reusable for other languages.

mithro commented 6 years ago

@nturley Only requirement is we need a pure Python library. Looks like antlr4 might support that? https://github.com/antlr/antlr4/blob/master/doc/python-target.md

GitHub
antlr/antlr4
antlr4 - ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
mx-shift commented 6 years ago

I started on a new BLIF parser using GitHub's recently released Tree Sitter incremental parser framework.

JohnDMcMaster commented 6 years ago

Nice! Not sure where our BLIF roadmap is, but we'll take a look if we start poking around there