Skip to content

A fully defined liberty data structure, efficient parser & formatter

Notifications You must be signed in to change notification settings

zao111222333/liberty-db

 
 

Repository files navigation

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.8"

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

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 --bench dev

TODO

  • CI:

    • only do comparsion after tag new version
    • fast regression self in build.yml
  • Other:

    • BDD use ArcStr
    • Linked Group
    • like IndexMap, only sort once and store
    • bitcode support
  • Reconstruction:

    • parser to GroupBuilder, e.g., use Vec to store GroupSet, no comment attribute
    • build/link GroupBuilder to Group, providing parent's scope, e.g.
      • all Pin name set to build BDD
      • supper group like timing::TimingTableLookUp
      • check all rules
  • Parse:

    • Only Vec<NotNan<f64>> and Value complex attributes need quotes vector, use fast_float2::parse_partial
    • Fix error when make_golden
      • intrinsic_parasitic group
      • leakage_current group
      • dynamic_current group
    • async
    • stream input
  • Finished

    • user define
    • remove GroupWapper, ComplexWapper, SimpleWapper. At leaset remove it in parser and formatter
    • fix missing newline at endding
    • recursive parse boolean expression
    • macros
    • format to liberty
    • support multi-line \
    • support comment
    • Use MutSet to store GroupMap

About

A fully defined liberty data structure, efficient parser & formatter

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages