1 unstable release

0.1.0 Aug 11, 2019

#6 in #liberty

Download history 18/week @ 2024-04-02

57 downloads per month

MIT license

81KB
1K SLoC

liberty-parse

Liberty file format parser for Rust

Example usage

Parse libraries from a Liberty file

use liberty_parse::parse_lib;

let lib_str = r#"
library(sample) {
    cell(AND2) {
        area: 1;
    }
}
"#;

for lib in parse_lib(lib_str).unwrap() {
    println!("Library '{}' has {} cells", lib.name, lib.cells.len());
    if let Some(cell) = lib.cells.get("AND2") {
        let area = cell.simple_attributes.get("area").map_or(0.0, |v| v.float());
        println!("Cell AND2 has area: {}", area);
    } else {
        println!("Cell AND2 doesn't exist!");
    }
}

Limitations

  • Doesn't automatically parse files from include statements

  • Doesn't parse bus syntax in pin names. For example:

        pin (X[0:3]){
        }
    

lib.rs:

This crate reads Liberty format files, commonly used by EDA tools to describe library cells (including standard cells, hard IP, etc.).

Example

use liberty_parse::parse_lib;

let lib_str = r#"
library(sample) {
    cell(AND2) {
        area: 1;
    }
}
"#;

for lib in parse_lib(lib_str).unwrap() {
    println!("Library '{}' has {} cells", lib.name, lib.cells.len());
    let area = lib
        .cells
        .get("AND2")
        .and_then(|c| c.simple_attributes.get("area"))
        .map_or(-1.0, |v| v.float());
    println!("Cell AND2 has area: {}", area);
}

Dependencies

~1.5MB
~26K SLoC