use crate::{
ast::{
Attributes, ComplexAttri, ComplexParseError, GroupComments, GroupFn, GroupSet,
ParseScope, SimpleAttri,
},
ArcStr, NotNan,
};
use core::fmt::{self, Write};
use super::parse_f64;
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct TableLookUpMultiSegment {
#[liberty(name)]
#[size = 8]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 168]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[id]
#[size = 8]
#[liberty(simple)]
segment: usize,
#[size = 24]
#[liberty(complex)]
pub index_1: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_2: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_3: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_4: Vec<NotNan<f64>>,
#[size = 40]
#[liberty(complex)]
pub values: Values,
}
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct DriverWaveform {
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
pub name: Option<ArcStr>,
#[size = 8]
#[liberty(simple(type = Option))]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
pub driver_waveform_name: Option<ArcStr>,
#[size = 168]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 24]
#[liberty(complex)]
pub index_1: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_2: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_3: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_4: Vec<NotNan<f64>>,
#[size = 40]
#[liberty(complex)]
pub values: Values,
}
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct TableLookUp2D {
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 96]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 24]
#[liberty(complex)]
pub index_1: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_2: Vec<NotNan<f64>>,
#[size = 40]
#[liberty(complex)]
pub values: Values,
}
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct CompactLutTemplate {
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 192]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 8]
#[liberty(simple(type = Option))]
pub base_curves_group: Option<ArcStr>,
#[size = 1]
#[liberty(simple(type = Option))]
pub variable_1: Option<VariableTypeCompactLutTemplateIndex12>,
#[size = 24]
#[liberty(complex)]
pub index_1: Vec<NotNan<f64>>,
#[size = 1]
#[liberty(simple(type = Option))]
pub variable_2: Option<VariableTypeCompactLutTemplateIndex12>,
#[size = 24]
#[liberty(complex)]
pub index_2: Vec<NotNan<f64>>,
#[size = 1]
#[liberty(simple(type = Option))]
pub variable_3: Option<VariableTypeCompactLutTemplateIndex3>,
#[size = 24]
#[liberty(complex)]
pub index_3: Vec<ArcStr>,
}
impl GroupFn for CompactLutTemplate {}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(strum_macros::Display, strum_macros::EnumString)]
#[derive(serde::Serialize, serde::Deserialize)]
pub enum VariableTypeCompactLutTemplateIndex12 {
#[strum(serialize = "input_net_transition")]
InputNetTransition,
#[strum(serialize = "total_output_net_capacitance")]
TotalOutputNetCapacitance,
}
impl SimpleAttri for VariableTypeCompactLutTemplateIndex12 {
#[inline]
fn nom_parse<'a>(
i: &'a str,
scope: &mut ParseScope,
) -> crate::ast::SimpleParseRes<'a, Self> {
crate::ast::nom_parse_from_str(i, scope)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(strum_macros::Display, strum_macros::EnumString)]
#[derive(serde::Serialize, serde::Deserialize)]
pub enum VariableTypeCompactLutTemplateIndex3 {
#[strum(serialize = "curve_parameters")]
CurveParameters,
}
impl SimpleAttri for VariableTypeCompactLutTemplateIndex3 {
#[inline]
fn nom_parse<'a>(
i: &'a str,
scope: &mut ParseScope,
) -> crate::ast::SimpleParseRes<'a, Self> {
crate::ast::nom_parse_from_str(i, scope)
}
}
#[mut_set::derive::item(sort)]
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Vector3D {
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 120]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[id]
#[size = 8]
#[liberty(complex)]
pub index_1: NotNan<f64>,
#[id]
#[size = 8]
#[liberty(complex)]
pub index_2: NotNan<f64>,
#[size = 24]
#[liberty(complex)]
pub index_3: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub values: Vec<NotNan<f64>>,
}
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct ReferenceTimeVector3D {
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 144]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[id]
#[size = 8]
#[liberty(simple)]
pub reference_time: NotNan<f64>,
#[id]
#[size = 8]
#[liberty(complex)]
pub index_1: NotNan<f64>,
#[id]
#[size = 8]
#[liberty(complex)]
pub index_2: NotNan<f64>,
#[size = 24]
#[liberty(complex)]
pub index_3: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub values: Vec<NotNan<f64>>,
}
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Vector4D {
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 144]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[id]
#[size = 8]
#[liberty(complex)]
pub index_1: NotNan<f64>,
#[id]
#[size = 8]
#[liberty(complex)]
pub index_2: NotNan<f64>,
#[id]
#[size = 8]
#[liberty(complex)]
pub index_3: NotNan<f64>,
#[size = 24]
#[liberty(complex)]
pub index_4: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub values: Vec<NotNan<f64>>,
}
#[mut_set::derive::item(sort)]
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Vector3DGrpup {
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 24]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 48]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<Vector3D>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<Vector3D>::deserialize_with")]
pub vector: GroupSet<Vector3D>,
}
#[mut_set::derive::item(sort)]
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct ReferenceTimeVector3DGrpup {
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 24]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 48]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<ReferenceTimeVector3D>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<ReferenceTimeVector3D>::deserialize_with")]
pub vector: GroupSet<ReferenceTimeVector3D>,
}
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Vector4DGrpup {
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 24]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 48]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<Vector4D>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<Vector4D>::deserialize_with")]
pub vector: GroupSet<Vector4D>,
}
impl GroupFn for Vector3DGrpup {}
impl GroupFn for Vector4DGrpup {}
impl GroupFn for ReferenceTimeVector3D {}
impl GroupFn for ReferenceTimeVector3DGrpup {}
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct TableLookUp3D {
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 120]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 24]
#[liberty(complex)]
pub index_1: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_2: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_3: Vec<NotNan<f64>>,
#[size = 40]
#[liberty(complex)]
pub values: Values,
}
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct TableLookUp1D {
unit: (),
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 72]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 24]
#[liberty(complex)]
pub index_1: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub values: Vec<NotNan<f64>>,
}
impl GroupFn for TableLookUp1D {}
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct CompactCcsTable {
unit: (),
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 72]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 8]
#[liberty(simple)]
pub base_curves_group: ArcStr,
#[size = 40]
#[liberty(complex)]
pub values: Values,
}
impl GroupFn for CompactCcsTable {}
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct TableLookUp {
unit: (),
#[size = 8]
#[liberty(name)]
#[id(borrow = "Option<&str>", check_fn = "mut_set::borrow_option!")]
name: Option<ArcStr>,
#[size = 144]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 24]
#[liberty(complex)]
pub index_1: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_2: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_3: Vec<NotNan<f64>>,
#[size = 24]
#[liberty(complex)]
pub index_4: Vec<NotNan<f64>>,
#[size = 40]
#[liberty(complex)]
pub values: Values,
}
impl GroupFn for TableLookUp {}
impl GroupFn for TableLookUpMultiSegment {}
impl GroupFn for TableLookUp2D {}
impl GroupFn for TableLookUp3D {}
impl GroupFn for DriverWaveform {}
impl GroupFn for Vector3D {}
impl GroupFn for Vector4D {}
#[derive(Debug, Default, Clone)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Values {
pub size1: usize,
pub size2: usize,
pub inner: Vec<NotNan<f64>>,
}
impl ComplexAttri for Values {
#[inline]
#[expect(clippy::arithmetic_side_effects)]
fn parse<'a, I: Iterator<Item = &'a Vec<&'a str>>>(
iter: I,
_scope: &mut ParseScope,
) -> Result<Self, ComplexParseError> {
let mut size1 = 0;
let mut size2 = 0;
let mut table_len_mismatch = false;
let inner = iter
.flat_map(|v| {
size2 += 1;
let l = v.len();
#[expect(clippy::else_if_without_else)]
if l != 0 {
if size1 == 0 {
size1 = l;
} else if size1 != l {
table_len_mismatch = true;
}
}
v.iter().map(parse_f64)
})
.collect::<Result<Vec<NotNan<f64>>, _>>()?;
if table_len_mismatch {
Err(ComplexParseError::LengthDismatch)
} else {
Ok(Self { size1, size2, inner })
}
}
#[inline]
fn is_set(&self) -> bool {
!self.inner.is_empty()
}
#[inline]
fn fmt_self<T: Write, I: crate::ast::Indentation>(
&self,
f: &mut crate::ast::CodeFormatter<'_, T, I>,
) -> fmt::Result {
let indent = f.indentation();
let mut iter = self.inner.chunks(self.size1);
if let Some(v) = iter.next() {
crate::ast::join_fmt(
v.iter(),
f,
|float, ff| ff.write_float(float.into_inner()),
", ",
)?;
}
while let Some(v) = iter.next() {
write!(f, ", \\\n{indent}")?;
crate::ast::join_fmt(
v.iter(),
f,
|float, ff| ff.write_float(float.into_inner()),
", ",
)?;
}
Ok(())
}
}
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[mut_set::derive::item(sort)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct TableTemple {
#[size = 8]
#[liberty(name)]
#[id(borrow = "&str")]
pub name: ArcStr,
#[size = 216]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 2]
#[liberty(simple(type = Option))]
pub variable_1: Option<Variable>,
#[size = 2]
#[liberty(simple(type = Option))]
pub variable_2: Option<Variable>,
#[size = 2]
#[liberty(simple(type = Option))]
pub variable_3: Option<Variable>,
#[size = 2]
#[liberty(simple(type = Option))]
pub variable_4: Option<Variable>,
#[size = 24]
#[liberty(complex(type = Option))]
pub index_1: Option<Vec<NotNan<f64>>>,
#[size = 24]
#[liberty(complex(type = Option))]
pub index_2: Option<Vec<NotNan<f64>>>,
#[size = 24]
#[liberty(complex(type = Option))]
pub index_3: Option<Vec<NotNan<f64>>>,
#[size = 24]
#[liberty(complex(type = Option))]
pub index_4: Option<Vec<NotNan<f64>>>,
}
impl GroupFn for TableTemple {}
#[derive(Debug, Clone, Copy)]
#[derive(Hash, PartialEq, Eq)]
#[derive(Ord, PartialOrd)]
#[derive(serde::Serialize, serde::Deserialize)]
pub enum Variable {
Time(TimeVariable),
Voltage(VoltageVariable),
Capacitance(CapacitanceVariable),
RcProduct,
Length(LengthVariable),
Scalar(ScalarVariable),
}
impl SimpleAttri for Variable {
#[inline]
fn nom_parse<'a>(
i: &'a str,
scope: &mut ParseScope,
) -> crate::ast::SimpleParseRes<'a, Self> {
crate::ast::nom_parse_from_str(i, scope)
}
}
impl core::str::FromStr for Variable {
type Err = strum::ParseError;
#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"input_voltage" => Self::Voltage(VoltageVariable::InputVoltage),
"output_voltage" => Self::Voltage(VoltageVariable::OutputVoltage),
"input_noise_height" => Self::Voltage(VoltageVariable::InputNoiseHeight),
"input_transition_time" => Self::Time(TimeVariable::InputTransitionTime),
"input_net_transition" => Self::Time(TimeVariable::InputNetTransition),
"constrained_pin_transition" => Self::Time(TimeVariable::ConstrainedPinTransition),
"related_pin_transition" => Self::Time(TimeVariable::RelatedPinTransition),
"driver_slew" => Self::Time(TimeVariable::DriverSlew),
"output_transition" => Self::Time(TimeVariable::OutputTransition),
"output_pin_transition" => Self::Time(TimeVariable::OutputPinTransition),
"connect_delay" => Self::Time(TimeVariable::ConnectDelay),
"input_noise_width" => Self::Time(TimeVariable::InputNoiseWidth),
"time" => Self::Time(TimeVariable::Time),
"total_output_net_capacitance" => {
Self::Capacitance(CapacitanceVariable::TotalOutputNetCapacitance)
}
"output_net_wire_cap" => Self::Capacitance(CapacitanceVariable::OutputNetWireCap),
"output_net_pin_cap" => Self::Capacitance(CapacitanceVariable::OutputNetPinCap),
"related_out_total_output_net_capaci" => {
Self::Capacitance(CapacitanceVariable::RelatedOutTotalOutputNetCapacitance)
}
"related_out_output_net_wire_cap" => {
Self::Capacitance(CapacitanceVariable::RelatedOutOutputNetWireCap)
}
"related_out_output_net_pin_cap" => {
Self::Capacitance(CapacitanceVariable::RelatedOutOutputNetPinCap)
}
"fanout_pin_capacitance" => {
Self::Capacitance(CapacitanceVariable::FanoutPinCapacitance)
}
"output_net_length" => Self::Length(LengthVariable::OutputNetLength),
"related_out_output_net_length" => {
Self::Length(LengthVariable::RelatedOutOutputNetLength)
}
"fanout_number" => Self::Scalar(ScalarVariable::FanoutNumber),
"normalized_voltage" => Self::Scalar(ScalarVariable::NormalizedVoltage),
"rc_product" => Self::RcProduct,
_ => {
return Err(strum::ParseError::VariantNotFound);
}
})
}
}
impl fmt::Display for Variable {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Time(v) => v.fmt(f),
Self::Voltage(v) => v.fmt(f),
Self::Capacitance(v) => v.fmt(f),
Self::Length(v) => v.fmt(f),
Self::Scalar(v) => v.fmt(f),
Self::RcProduct => write!(f, "rc_product"),
}
}
}
#[derive(Debug, Clone, Copy)]
#[derive(Hash, PartialEq, Eq)]
#[derive(Ord, PartialOrd)]
#[derive(strum_macros::EnumString, strum_macros::EnumIter, strum_macros::Display)]
#[derive(serde::Serialize, serde::Deserialize)]
pub enum TimeVariable {
#[strum(serialize = "input_transition_time")]
InputTransitionTime,
#[strum(serialize = "input_net_transition")]
InputNetTransition,
#[strum(serialize = "constrained_pin_transition")]
ConstrainedPinTransition,
#[strum(serialize = "related_pin_transition")]
RelatedPinTransition,
#[strum(serialize = "driver_slew")]
DriverSlew,
#[strum(serialize = "output_transition")]
OutputTransition,
#[strum(serialize = "output_pin_transition")]
OutputPinTransition,
#[strum(serialize = "connect_delay")]
ConnectDelay,
#[strum(serialize = "input_noise_width")]
InputNoiseWidth,
#[strum(serialize = "time")]
Time,
}
#[derive(Debug, Clone, Copy)]
#[derive(Hash, PartialEq, Eq)]
#[derive(Ord, PartialOrd)]
#[derive(strum_macros::EnumString, strum_macros::EnumIter, strum_macros::Display)]
#[derive(serde::Serialize, serde::Deserialize)]
pub enum VoltageVariable {
#[strum(serialize = "input_voltage")]
InputVoltage,
#[strum(serialize = "output_voltage")]
OutputVoltage,
#[strum(serialize = "input_noise_height")]
InputNoiseHeight,
}
#[derive(Debug, Clone, Copy)]
#[derive(Hash, PartialEq, Eq)]
#[derive(Ord, PartialOrd)]
#[derive(strum_macros::EnumString, strum_macros::EnumIter, strum_macros::Display)]
#[derive(serde::Serialize, serde::Deserialize)]
pub enum CapacitanceVariable {
#[strum(serialize = "total_output_net_capacitance")]
TotalOutputNetCapacitance,
#[strum(serialize = "output_net_wire_cap")]
OutputNetWireCap,
#[strum(serialize = "output_net_pin_cap")]
OutputNetPinCap,
#[strum(serialize = "related_out_total_output_net_capaci")]
RelatedOutTotalOutputNetCapacitance,
#[strum(serialize = "related_out_output_net_wire_cap")]
RelatedOutOutputNetWireCap,
#[strum(serialize = "related_out_output_net_pin_cap")]
RelatedOutOutputNetPinCap,
#[strum(serialize = "fanout_pin_capacitance")]
FanoutPinCapacitance,
}
#[derive(Debug, Clone, Copy)]
#[derive(Hash, PartialEq, Eq)]
#[derive(Ord, PartialOrd)]
#[derive(strum_macros::EnumString, strum_macros::EnumIter, strum_macros::Display)]
#[derive(serde::Serialize, serde::Deserialize)]
pub enum LengthVariable {
#[strum(serialize = "output_net_length")]
OutputNetLength,
#[strum(serialize = "related_out_output_net_length")]
RelatedOutOutputNetLength,
}
#[derive(Debug, Clone, Copy)]
#[derive(Hash, PartialEq, Eq)]
#[derive(Ord, PartialOrd)]
#[derive(strum_macros::EnumString, strum_macros::EnumIter, strum_macros::Display)]
#[derive(serde::Serialize, serde::Deserialize)]
pub enum ScalarVariable {
#[strum(serialize = "fanout_number")]
FanoutNumber,
#[strum(serialize = "normalized_voltage")]
NormalizedVoltage,
}
#[cfg(test)]
mod test {
use crate::ast::test_parse_fmt;
#[test]
fn table() {
let table = test_parse_fmt::<super::TableLookUp>(
r#" ("CCS_RCV_TEMPLATE_0") {
index_1("0.0186051, 0.0372112, 0.0744591");
index_2("0.1000000, 0.2500000, 0.5000000");
values("5.4283814e-01, 5.4289214e-01, 5.4298464e-01", \
"6.0907950e-01, 6.0906120e-01, 6.0903281e-01,", \
"6.2226570e-01, 6.2225652e-01, 6.2212002e-01,");
}
"#,
r#"
liberty_db::common::table::TableLookUp (CCS_RCV_TEMPLATE_0) {
| index_1 ("0.0186051, 0.0372112, 0.0744591");
| index_2 ("0.1, 0.25, 0.5");
| values ("0.54283814, 0.54289214, 0.54298464", \
| | "0.6090795, 0.6090612, 0.60903281", \
| | "0.6222657, 0.62225652, 0.62212002");
}"#,
);
}
#[test]
fn compact_ccs_table() {
let table = test_parse_fmt::<super::CompactCcsTable>(
r#" ("c_ccs_pwr_template_6") {
values("-0.0119931,-101.1912245,", \
"-0.0119953,-101.1912245,", \
"-0.0119957,-101.1912245,", \
"-0.0119957,-101.1912245,", \
"-0.0119957,-101.1912245,", \
"-0.0119953,-101.1912245,", \
"-0.0119953,-101.1912245,", \
"-0.7696603,-101.1912245,");
}
"#,
r#"
liberty_db::common::table::CompactCcsTable (c_ccs_pwr_template_6) {
| values ("-0.0119931, -101.1912245", \
| | "-0.0119953, -101.1912245", \
| | "-0.0119957, -101.1912245", \
| | "-0.0119957, -101.1912245", \
| | "-0.0119957, -101.1912245", \
| | "-0.0119953, -101.1912245", \
| | "-0.0119953, -101.1912245", \
| | "-0.7696603, -101.1912245");
}"#,
);
}
}