# LEF/DEF and Bookshelf (OpenDB, RosettaStone) translators

Convert netlists in other formats (e.g. LEF/DEF or Bookshelf) to netlist in protocol buffer format

We implemented three different types of conversions based on [OpenDB](https://github.com/The-OpenROAD-Project/OpenROAD/tree/master/src/odb).

* **LEF/DEF -> Protocol Buffer Format** :  In this conversion, users need to provide the def file and corresponding lefs. Here is [an example](https://github.com/TILOS-AI-Institute/MacroPlacement/blob/main/CodeElements/FormatTranslators/test/LefDef2ProtocolBufferFormat/test2.py). Note that the example that we provide is the ariane design implemented in NanGate45.  The netlist and corresponding def file with placed instances are generated by [Genus iSpatial](https://github.com/TILOS-AI-Institute/MacroPlacement/tree/main/Flows/NanGate45/ariane133) flow. Here the macro placement is automatically done by the Genus and Innovus tools.

*  **Bookshelf -> Protocol Buffer Format** : In this conversion, users can directly convert a netlist in Bookshelf format to a corresponding netlist in protocol buffer format. Here is [an example](https://github.com/TILOS-AI-Institute/MacroPlacement/blob/main/CodeElements/FormatTranslators/test/Bookshelf2ProtocolBufferFormat/test1.py).
In this example, we use the *superblue19* testcase from [DAC 2012 Routability-Driven Placement Contest and Benchmark Suite](http://archive.sigda.org/dac2012/contest/dac2012_contest_benchmarks.html#head-designs).


*  **Bookshelf -> Lef/Def -> Protocol Buffer Format** :  In this conversion, users can first map a netlist in Bookshelf format to some technology node (e.g., NanGate45 or ASAP7), then convert the netlist to a corresponding netlist in protocol buffer format. Here is [an example](https://github.com/TILOS-AI-Institute/MacroPlacement/blob/main/CodeElements/FormatTranslators/test/Bookshelf2ProtocolBufferFormat/test3.py). In this example, we use the *superblue19* testcase from [DAC 2012 Routability-Driven Placement Contest and Benchmark Suite](http://archive.sigda.org/dac2012/contest/dac2012_contest_benchmarks.html#head-designs). The technology node used in this example is NanGate45.  After running the scripts, you will have both *.plc* file (netlist in protocol buffer format) and *.def*, *.lef* files (netlist and fake lefs in NanGate45).


Note that we use part of the codes from [RosettaStone](https://github.com/ABKGroup/RosettaStone), which supports the integration of academic Bookshelf benchmarks into real open-source technologies (ASAP7, NanGate45, SKY130HD, SKY130HS). (See the branch **Bookshelf -> Lef/Def -> Protocol Buffer Format**)