lef21 0.2.0

Library Exchange Format (LEF) Integrated Circuit Layout Parser & Writer
Documentation

Lef21 Library Exchange Format (LEF) Parser & Writer

Library Exchange Format (LEF) is an ASCII-based format for integrated circuit (IC) layout and technology.

LEF is near-ubiquitously used IC-industry-wide for two related purposes:

  • LEF design libraries, primarily comprised of LEF macros, provide the physical abstract view of circuit designs.
  • Such abstract-views are commonly the target for layout-synthesis programs ("place and route").
  • They include a circuit's pin locations and requirements for physical blockages ("obstructions"), among other metadata, typically without including the circuit's internal implementation.
  • LEF technology descriptions ("tech-lef") provide a concise description of design-rules for assembling such cells, as commonly performed by layout-synthesis software.

Lef21 includes comprehensive support for parsing and writing LEF design libraries, primarily stored as its [LefLibrary] and [LefMacro] types. A select subset of tech-lef features are also supported, particularly those which blur the lines between technology and library data.

Usage

Creating a [LefLibrary] from file solely requires a call to the [LefLibrary::open] method:

use lef21::LefLibrary;
let lib = LefLibrary::open("mylib.lef")?;

Each [LefLibrary] is a short tree of macro-definitions, which are in turn primarily comprised of pin-definitions and obstructions. This [LefLibrary] tree is of the form:

  • [LefLibrary]
  • Library Metadata
  • Macro Definitions, stored as Vec<[LefMacro]>
  • Macro Metadata
  • Blockages / Obstructions, stored as Vec<[LefLayerGeometries]>
  • Pin Definitions, stored as Vec<[LefPin]>
  • Pin Metadata
  • Port Definitions, stored as Vec<[LefPort]>

All fields of all layers in the [LefLibrary] tree are publicly accessible and modifiable.

Lef21 libraries can be saved to file with their [LefLibrary::save] method:

lib.save("yourlib.lef")?;

Or converted to in-memory LEF-format [String]s via [LefLibrary::to_string]:

let s = lib.to_string()?;
println!({}, s);

Serialization

[LefLibrary], all underlying data structures, and all Lef21's other primary data stores are serde serializable, and can be straightforwardly converted to and from any serde-compatible format. Examples:

let lib = lef21::LefLibrary::new();
let json = serde_json::to_string(&lib);
let yaml = serde_yaml::to_string(&lib);
let toml = toml::to_string(&lib);

Lef21 includes built-in support for a subset of serde-formats via its [SerializationFormat] enumeration, and support for directly reading and writing files in each format via its accompanying [SerdeFile] trait. Example using [SerializationFormat::Yaml]:

use lef21::SerializationFormat::Yaml;
let lib = lef21::LefLibrary::new();

// Write to YAML-format file
Yaml.save(&lib, "mylib.lef.yaml")?;
// And read back from file
let lib2: lef21::LefLibrary = Yaml.open("mylib.lef.yaml")?;  

Background

Lef21 is a subset of the larger Layout21 library, and is primarily used as an import and export layer. Lef21 correspondingly uses the LEF format's concepts, idioms, and terminology (e.g. "macro" vs. "cell") throughout. Its LEF data structures are nonetheless designed for direct manipulation, for example in programmatically modifying existing LEF content.

LEF is frequently paired with the DEF ASCII-based format for specifying circuit's internal physical implementations. More common industry usage pairs LEF with GDSII's binary implementation format, which dramatically reduces data-sizes for large circuits. DEF is not supported by Lef21. GDSII is supported by the related gds21 crate.

License

Lef21 and Layout21 are published under a permissive BSD license.

The LEF format was originally designed by Tangent Systems, later acquired by Cadence Design Systems. Lef21 holds no relationship to either entity, nor any authority or ownership over the format. Countless LEF-format design descriptions are freely available as open-source software. Their examples serve as the basis for Lef21.