#eda #liberty #parser

liberty-db

A fully defined liberty data structure, efficient parser & formatter

72 releases (9 breaking)

Uses new Rust 2024

0.10.1 Mar 12, 2025
0.9.6 Mar 11, 2025
0.8.1 Dec 31, 2024
0.7.3 Nov 28, 2024
0.1.1 Dec 16, 2022

#105 in Database interfaces

Download history 251/week @ 2024-11-28 232/week @ 2024-12-05 205/week @ 2024-12-12 121/week @ 2024-12-19 338/week @ 2024-12-26 180/week @ 2025-01-02 2/week @ 2025-01-09 108/week @ 2025-01-16 2/week @ 2025-01-23 370/week @ 2025-01-30 173/week @ 2025-02-06 157/week @ 2025-02-13 171/week @ 2025-02-20 20/week @ 2025-02-27 260/week @ 2025-03-06 152/week @ 2025-03-13

615 downloads per month

MIT license

1MB
18K SLoC

liberty-db

pipeline pipeline License liberty-db Docs Benchmark codecov

Highlight Features

Usage

This library is implemented in Rust, with document.

[dependencies]
liberty_db = "0.10"

One basic demo here:

use liberty_db::{DefaultCtx, Library};
use std::{
  fs::File,
  io::{BufWriter, Write},
};
static TEMPLATE: &str = r#"
library(demo) {
  time_unit : "1ps";
  voltage_unit : "10mV";
  current_unit : "1uA";
  operating_conditions ( typical ) {
      process : 1;
      voltage : 1.1;
  }
  lu_table_template(delay_template_4x5) {
    variable_1 : total_output_net_capacitance;
    variable_2 : input_net_transition;
    index_1 ("1000.0, 1001.0, 1002.0, 1003.0");
    index_2 ("1000.0, 1001.0, 1002.0, 1003.0, 1004.0");
  }
  cell (DFF) {
    pin (D) {}
    pin (CK) {}
    pin (Q) {}
  }
}"#;
fn main(){
  let mut library = Library::<DefaultCtx>::parse_lib(TEMPLATE).unwrap();
  // modify library
  library.cell.get_mut("DFF").map(|cell_dff| {
    cell_dff
      .pin
      .get_mut("CK".into())
      .map(|pin_ck| pin_ck.clock = Some(true))
  });
  // print library
  println!("{library}");
  // write library
  let out_file = File::create("demo.lib").unwrap();
  let mut writer = BufWriter::new(out_file);
  write!(&mut writer, "{}", library).unwrap();
}

See more examples, and run them if you clone this repo:

# example0
cargo run --example 0_parse_fmt
# example1
cargo run --example 1_parse_fmt_file -- dev/tech/cases/ocv.lib
# example2
cargo run --example 2_prune_lib -- dev/tech/cases/ocv.lib
# example3
cargo run --example 3_lookup_timing

Or you can download the releases/latest/examples.zip, then

cd ./examples_x86_64-unknown-linux-musl
# example0
./0_parse_fmt
# example1
./1_parse_fmt_file dev/tech/cases/ocv.lib
# example2
./2_prune_lib dev/tech/cases/ocv.lib
# example3
./3_lookup_timing

Benchmark

Basic information as follow, see latest benchmark summary.

Project Comparison

ProjectLangVersionType SupportBoolean
Expression
Comment
AllPartlyAST only
liberty-dbrustlatestcurrent version
si2dr_libertyC1.0Synopsys's version at 2005, many attributes are not supported
OpenTimerC++172STA tool's liberty component
liberty-iorust0.0.4
libertyparserust0.3.0
liberty2jsonrust0.1.0

Dev

Run unit-test and regression.

cargo test --release

Run benchmark, it will takes 40mins.

cargo bench --package dev --bench benchmark --features bench

TODO

  • Parse: use nom_locate
  • Parse: check all rules
  • Parse: Linked Group
  • Parse: async
  • CI: only do comparsion after tag new version
  • MISC: bitcode support

Dependencies

~5.5–8MB
~152K SLoC