ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Rewrite the xml parser in vpr to be based on DTD and auto generated.

Open mithro opened this issue 7 years ago • 7 comments

Currently the xml parser in vpr is hand coded.

It would be good to rip it out and replace it with a auto-generated xml parser based around a DTD which defines the file format.

Create a XML definition using DTD, XSD or Relax-NG -- unsure the best format... See;

  • https://www.tutorialspoint.com/xsd/index.htm
  • http://www.relaxng.org/tutorial-20011203.html

Existing XML file formats in order of importance;

  • "rr_graph.xml" format - http://vtr-verilog-to-routing.readthedocs.io/en/latest/vpr/file_formats.html#routing-resource-graph-file-format-xml
  • "Packed netlist" format - http://vtr-verilog-to-routing.readthedocs.io/en/latest/vpr/file_formats.html#packed-netlist-format-net
  • "FPGA architecture description" - http://vtr-verilog-to-routing.readthedocs.io/en/latest/arch/index.html

New XML file formats needing to be created;

  • placement file format - http://vtr-verilog-to-routing.readthedocs.io/en/latest/vpr/file_formats.html#placement-file-format-place
  • route file file format - http://vtr-verilog-to-routing.readthedocs.io/en/latest/vpr/file_formats.html#routing-file-format-route

The idea is eventually to auto-generate parser / code structures from the definitions; IE see --

  • http://www.davekuhlman.org/generateDS.html
  • https://www.liquid-technologies.com/xml-schema-to-cpp
  • https://www.codalogic.com/lmx/?xmlfwd-xml2cppcom
  • https://www.codesynthesis.com/products/xsd/
  • https://www.genivia.com/doc/databinding/html/index.html

mithro avatar Dec 30 '17 00:12 mithro

I created schemas for the packed netlist and routing resource formats here: https://gist.github.com/Laksen/dc3fdf65a7eb6bb1186c46381215ac55

They don't match the examples 100% as the examples contain some undocumented values, but that should be easy to change

Gist
VPR XML Schemas

Laksen avatar Jul 15 '18 12:07 Laksen

I updated some types to use xs:double instead of xs:decimal to allow scientific notation. Also a preliminary version of the architecture description has been added. There might be a few bits missing, but with the files I could find they almost passed validation.

There were some inconsistencies like default_* names in <fc> attributes where I chose the values from the documentation

https://gist.github.com/Laksen/cf67f1103e5c539bb44cd183d617aee8

Gist
GitHub is where people build software. More than 28 million people use GitHub to discover, fork, and contribute to over 85 million projects.

Laksen avatar Jul 15 '18 14:07 Laksen

@Laksen this is awesome! Do you want to send them as a pull request in the https://github.com/SymbiFlow/symbiflow-arch-defs repo? The common/xml directory would be the right place.

GitHub
symbiflow-arch-defs - FOSS architecture definitions of FPGA hardware useful for doing PnR device generation.

mithro avatar Jul 15 '18 14:07 mithro

@Laksen has added a schema for the existing XML formats in the pull request here -> https://github.com/SymbiFlow/symbiflow-arch-defs/pull/195 - Thank you so much.

The next steps would be; a) Figuring out the best way to generate Python and C++ code from the schemas. b) Designing a new XML format (and appropriate schema) for the placement and route formats from VtR. c) Using the XML schema's for automatic validation of the files.

mithro avatar Jul 16 '18 21:07 mithro

https://www.codesynthesis.com/products/xsd/ looks pretty good but is under a GPL license and we really want to keep things open. The alternative is probably to follow an example shown at this page https://blind.guru/bmmlcxx.html and use Python + Jinja2 templates to create C++ code.

W3C XML Schema to C++ data binding compiler is an open-source, cross-platform XML Data Binding implementation for C++

mithro avatar Sep 19 '18 00:09 mithro

The best example I have found is https://github.com/mlang/xsdcxx-musicxml

GitHub
Contribute to mlang/xsdcxx-musicxml development by creating an account on GitHub.

mithro avatar Sep 19 '18 00:09 mithro