Skip to content

Commit

Permalink
New attributes for ccs and lvf format (#16)
Browse files Browse the repository at this point in the history
* fix ccs format unsupported attributes

* fix lvf unsupported attributes

* fix lvf fmt bug when mismatch

* bump version to `0.9.3`
  • Loading branch information
zao111222333 authored Feb 5, 2025
1 parent 966e1b6 commit 8814b22
Show file tree
Hide file tree
Showing 11 changed files with 485 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// "rust-analyzer.check.command": "clippy",
// "rust-analyzer.check.extraArgs": [], // "--all-features"
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.cargo.features": ["py"],
// "rust-analyzer.cargo.features": ["py"],
// vscode-lldb need glibc 2.28
// "rust-analyzer.debug.engine": "vadimcn.vscode-lldb",
// "lldb.launch.initCommands": ["settings set target.disable-aslr false"],
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
members = ["macros", "dev", "dev/utils", "dev/include/liberty2json"]

[workspace.package]
version = "0.9.2"
version = "0.9.3"
license = "MIT"
edition = "2021"
authors = ["Junzhuo <[email protected]>"]
Expand Down
8 changes: 8 additions & 0 deletions examples/1_parse_fmt_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::{
fs::{read_to_string, File},
io::{BufWriter, Write},
path::Path,
time::Instant,
};

// cargo run /path/to/xxx.lib
Expand All @@ -15,13 +16,20 @@ fn main() {

let input_lib = Path::new(&args[1]);
log::info!("Parsing [file] {} ...", input_lib.display());
let now = Instant::now();
let library =
Library::<DefaultCtx>::parse_lib(read_to_string(input_lib).unwrap().as_str())
.unwrap();
let elapsed_parse = now.elapsed();
let out_file_name =
format!("example1_{}", input_lib.file_name().unwrap().to_str().unwrap());
log::info!("Output to [file] {} ...", out_file_name);
let out_file = File::create(out_file_name).unwrap();
let mut writer = BufWriter::new(out_file);
let now = Instant::now();
write!(&mut writer, "{}", library).unwrap();
let elapsed_write = now.elapsed();
log::info!("DONE");
log::info!("parse: {elapsed_parse:?}");
log::info!("write: {elapsed_write:?}");
}
4 changes: 2 additions & 2 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ pub(crate) enum ComplexParseError {
/// `ParseIntError`
#[error("{0}")]
Int(#[from] lexical_core::Error),
/// title length mismatch
#[error("title length mismatch")]
/// complex length mismatch
#[error("complex length mismatch")]
LengthDismatch,
/// other error
#[error("other")]
Expand Down
19 changes: 19 additions & 0 deletions src/ccsn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,25 @@ pub struct ReceiverCapacitance<C: Ctx> {
#[serde(serialize_with = "GroupSet::<TableLookUpMultiSegment<C>>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<TableLookUpMultiSegment<C>>::deserialize_with")]
pub receiver_capacitance_rise: GroupSet<TableLookUpMultiSegment<C>>,
/// In referenced CCS noise modeling, the `active_input_ccb` attribute lists the active or
/// switching input_ccb groups of the input pin that do not propagate the noise in the timing
/// arc or the receiver capacitance load.
/// You can also specify this attribute in the `receiver_capacitance` group of the input pin.
///
/// Syntax
/// ``` text
/// active_input_ccb(input_ccb_name1[ , input_ccb_name2, ...]);
/// ```
/// Example
/// ``` text
/// active_input_ccb("A", "B");
/// ```
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=339.2&end=339.6
/// ">Reference-Instance</a>
#[size = 24]
#[liberty(complex)]
pub active_input_ccb: Vec<String>,
#[size = 336]
#[liberty(group)]
pub receiver_capacitance1_fall: Option<TableLookUp<C>>,
Expand Down
10 changes: 5 additions & 5 deletions src/common/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
};
use core::fmt::Write;

use super::table::TableLookUp;
use super::table::TableLookUp2D;

#[derive(Debug, Clone)]
#[derive(liberty_macros::Group)]
Expand All @@ -33,10 +33,10 @@ pub(crate) struct Timing<C: Ctx> {
#[liberty(simple(type = Option))]
t2: Option<TimingType>,
#[liberty(supergroup(
cell_fall: Option<TableLookUp<C>>,
ocv_mean_shift_cell_fall: Option<TableLookUp<C>>,
ocv_std_dev_cell_fall: Option<TableLookUp<C>>,
ocv_skewness_cell_fall: Option<TableLookUp<C>>,
cell_fall: Option<TableLookUp2D<C>>,
ocv_mean_shift_cell_fall: Option<TableLookUp2D<C>>,
ocv_std_dev_cell_fall: Option<TableLookUp2D<C>>,
ocv_skewness_cell_fall: Option<TableLookUp2D<C>>,
))]
pub cell_fall: Option<TimingTableLookUp<C>>,
}
Expand Down
42 changes: 42 additions & 0 deletions src/common/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,48 @@ impl SimpleAttri for VariableType {
}
}

/// Specify the optional `sigma_type` attribute to define the type of arrival time listed in the
/// `ocv_sigma_cell_rise`, `ocv_sigma_cell_fall`, `ocv_sigma_rise_transition`, and
/// `ocv_sigma_fall_transition` group lookup tables. The values are `early`, `late`, and
/// `early_and_late`. The default is `early_and_late`.
///
/// You can specify the `sigma_type` attribute in the `ocv_sigma_cell_rise` and
/// `ocv_sigma_cell_fall` groups.
///
/// Syntax
/// ``` text
/// sigma_type: early | late | early_and_late;
/// ```
/// Example
/// ``` text
/// sigma_type: early;
/// ```
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=357.15&end=357.24
/// ">Reference-Definition</a>
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
#[derive(Display, EnumString)]
#[derive(serde::Serialize, serde::Deserialize)]
pub enum SigmaType {
#[strum(serialize = "early")]
Early,
#[strum(serialize = "late")]
Late,
#[default]
#[strum(serialize = "early_and_late")]
EarlyAndLate,
}
crate::ast::impl_self_builder!(SigmaType);
impl SimpleAttri for SigmaType {
#[inline]
fn nom_parse<'a>(
i: &'a str,
scope: &mut ParseScope,
) -> crate::ast::SimpleParseRes<'a, Self> {
crate::ast::nom_parse_from_str(i, scope)
}
}

/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2007.03/_user_guide.html
/// ?field=test
Expand Down
60 changes: 60 additions & 0 deletions src/common/table.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::items::SigmaType;
use crate::{
ast::{
self, Attributes, ComplexAttri, ComplexParseError, GroupComments, GroupFn, GroupSet,
Expand Down Expand Up @@ -723,6 +724,64 @@ pub struct TableLookUp3D<C: Ctx> {
pub values: Values,
}

/// Specify the optional `sigma_type` attribute to define the type of arrival time listed in the
/// `ocv_sigma_cell_rise`, `ocv_sigma_cell_fall`, `ocv_sigma_rise_transition`, and
/// `ocv_sigma_fall_transition` group lookup tables.
#[mut_set::derive::item(sort)]
#[derive(Debug, Clone)]
#[derive(liberty_macros::Group)]
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(bound = "C::Table: serde::Serialize + serde::de::DeserializeOwned")]
pub struct OcvSigmaTable<C: Ctx> {
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!", with_ref = false)]
name: Option<String>,
/// group comments
#[size = 32]
#[liberty(comments)]
comments: GroupComments,
#[size = 0]
#[liberty(extra_ctx)]
pub extra_ctx: C::Table,
/// group undefined attributes
#[size = 40]
#[liberty(attributes)]
pub attributes: Attributes,
/// Specify the optional `sigma_type` attribute to define the type of arrival time listed in the
/// `ocv_sigma_cell_rise`, `ocv_sigma_cell_fall`, `ocv_sigma_rise_transition`, and
/// `ocv_sigma_fall_transition` group lookup tables. The values are `early`, `late`, and
/// `early_and_late`. The default is `early_and_late`.
///
/// You can specify the `sigma_type` attribute in the `ocv_sigma_cell_rise` and
/// `ocv_sigma_cell_fall` groups.
///
/// Syntax
/// ``` text
/// sigma_type: early | late | early_and_late;
/// ```
/// Example
/// ``` text
/// sigma_type: early;
/// ```
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=357.15&end=357.24
/// ">Reference-Definition</a>
#[size = 1]
#[liberty(simple)]
#[id]
pub sigma_type: SigmaType,
#[size = 24]
#[liberty(complex)]
pub index_1: Vec<f64>,
#[size = 24]
#[liberty(complex)]
pub index_2: Vec<f64>,
#[size = 40]
#[liberty(complex)]
pub values: Values,
}

#[mut_set::derive::item(sort)]
#[derive(Debug, Clone)]
#[derive(liberty_macros::Group)]
Expand Down Expand Up @@ -834,6 +893,7 @@ impl<C: Ctx> GroupFn for TableLookUp<C> {}
impl<C: Ctx> GroupFn for TableLookUpMultiSegment<C> {}
impl<C: Ctx> GroupFn for TableLookUp2D<C> {}
impl<C: Ctx> GroupFn for TableLookUp3D<C> {}
impl<C: Ctx> GroupFn for OcvSigmaTable<C> {}
impl<C: Ctx> GroupFn for DriverWaveform<C> {}
impl<C: Ctx> GroupFn for Vector3D<C> {}
impl<C: Ctx> GroupFn for Vector4D<C> {}
Expand Down
48 changes: 48 additions & 0 deletions src/library/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,54 @@ pub struct Library<C: Ctx> {
#[size = 16]
#[liberty(simple(type = Option))]
pub nom_voltage: Option<f64>,
/// The `receiver_capacitance_rise_threshold_pct` attribute specifies the points that
/// separate the voltage rise segments in the multi-segment receiver capacitance model.
///
/// Specify the points as percentage of the rail voltage between 0.0 and 100.0.
///
/// Specify monotonically increasing values with the
/// `receiver_capacitance_rise_threshold_pct` attribute.
///
/// Syntax
/// ``` text
/// receiver_capacitance_rise_threshold_pct ("float, float,...");
/// ```
/// Example
/// ``` text
/// receiver_capacitance_rise_threshold_pct ("0, 30, 50, 60, 70, 80, 100");
/// ```
/// In this example, six segments are defined and the first segment is from zero percent to 30
/// percent of the rail voltage.
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=38.18&end=38.28
/// ">Reference</a>
#[size = 24]
#[liberty(complex)]
pub receiver_capacitance_rise_threshold_pct: Vec<f64>,
/// The `receiver_capacitance_fall_threshold_pct` attribute specifies the points that
/// separate the voltage fall segments in the multi-segment receiver capacitance model.
///
/// Specify each point as a percentage of the rail voltage between 0.0 and 100.0.
///
/// Specify monotonically decreasing values with the
/// `receiver_capacitance_fall_threshold_pct` attribute.
///
/// Syntax
/// ``` text
/// receiver_capacitance_fall_threshold_pct ("float, float,...");
/// ```
/// Example
/// ``` text
/// receiver_capacitance_fall_threshold_pct ("100, 80, 70, 60, 50, 30, 0");
/// ```
/// In this example, six segments are defined and the first segment is from 100 percent to 80
/// percent of the rail voltage.
/// <a name ="reference_link" href="
/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=38.6&end=38.16
/// ">Reference</a>
#[size = 24]
#[liberty(complex)]
pub receiver_capacitance_fall_threshold_pct: Vec<f64>,
/// Use this group to define operating conditions;
/// that is, `process`, `voltage`, and `temperature`.
/// You define an `operating_conditions` group at the library-level, as shown here:
Expand Down
Loading

0 comments on commit 8814b22

Please sign in to comment.