use crate::{
ast::{Attributes, GroupComments, GroupFn, GroupSet},
ccsn::{CCSNStage, ReceiverCapacitance},
common::{
char_config::CharConfig,
items::{NameList, WordSet},
},
expression::{logic, BooleanExpression, PowerGroundBooleanExpression},
internal_power::InternalPower,
timing::Timing,
Ctx,
};
mod bundle;
mod items;
pub use bundle::*;
pub use items::*;
#[mut_set::derive::item(sort)]
#[derive(Debug, Clone)]
#[derive(liberty_macros::Group)]
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(bound = "C::Pin: serde::Serialize + serde::de::DeserializeOwned")]
pub struct Pin<C: Ctx> {
#[id(
borrow = "crate::common::items::RefNameList<'_>",
check_fn = "NameList::as_ref",
with_ref = false
)]
#[size = 48]
#[liberty(name)]
pub name: NameList,
#[size = 32]
#[liberty(comments)]
comments: GroupComments,
#[size = 0]
#[liberty(extra_ctx)]
pub extra_ctx: C::Pin,
#[size = 40]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 8]
#[liberty(simple(type = Option))]
pub driver_waveform_rise: Option<String>,
#[size = 8]
#[liberty(simple(type = Option))]
pub driver_waveform_fall: Option<String>,
#[size = 8]
#[liberty(simple)]
pub related_ground_pin: String,
#[size = 2]
#[liberty(complex(type = Option))]
pub retention_pin: Option<RetentionPin>,
#[size = 8]
#[liberty(simple)]
pub related_power_pin: String,
#[size = 1]
#[liberty(simple(type = Option))]
pub alive_during_partial_power_down: Option<bool>,
#[size = 32]
#[liberty(simple(type = Option))]
pub power_down_function: Option<PowerGroundBooleanExpression>,
#[size = 1]
#[liberty(simple(type = Option))]
pub alive_during_power_up: Option<bool>,
#[size = 1]
#[liberty(simple(type = Option))]
pub always_on: Option<bool>,
#[size = 1]
#[liberty(simple(type = Option))]
pub antenna_diode_type: Option<AntennaDiodeType>,
#[size = 64]
#[liberty(simple)]
pub antenna_diode_related_ground_pins: WordSet,
#[size = 64]
#[liberty(simple)]
pub antenna_diode_related_power_pins: WordSet,
#[size = 16]
#[liberty(simple(type = Option))]
pub bit_width: Option<usize>,
#[size = 16]
#[liberty(simple(type = Option))]
pub capacitance: Option<f64>,
#[size = 32]
#[liberty(simple(type = Option))]
pub clamp_0_function: Option<BooleanExpression>,
#[size = 32]
#[liberty(simple(type = Option))]
pub clamp_1_function: Option<BooleanExpression>,
#[size = 32]
#[liberty(simple(type = Option))]
pub clamp_latch_function: Option<BooleanExpression>,
#[size = 32]
#[liberty(simple(type = Option))]
pub clamp_z_function: Option<BooleanExpression>,
#[size = 1]
#[liberty(simple(type = Option))]
pub clock: Option<bool>,
#[size = 1]
#[liberty(simple(type = Option))]
pub clock_gate_clock_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type = Option))]
pub clock_gate_enable_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type = Option))]
pub clock_gate_test_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type = Option))]
pub clock_gate_obs_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type = Option))]
pub clock_gate_out_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type = Option))]
pub clock_isolation_cell_clock_pin: Option<bool>,
#[size = 8]
#[liberty(simple(type = Option))]
pub complementary_pin: Option<String>,
#[size = 64]
#[liberty(simple)]
pub connection_class: WordSet,
#[size = 1]
#[liberty(simple(type = Option))]
pub direction: Option<Direction>,
#[size = 1]
#[liberty(simple(type = Option))]
pub dont_fault: Option<DontFault>,
#[size = 16]
#[liberty(simple(type = Option))]
pub drive_current: Option<f64>,
#[size = 1]
#[liberty(simple(type = Option))]
pub driver_type: Option<DriverType>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fall_capacitance: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fall_current_slope_after_threshold: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fall_current_slope_before_threshold: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fall_time_after_threshold: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fall_time_before_threshold: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fanout_load: Option<f64>,
#[size = 2]
#[liberty(simple(type = Option))]
pub fault_model: Option<TwoValue>,
#[size = 32]
#[liberty(simple(type = Option))]
pub function: Option<BooleanExpression>,
#[size = 32]
#[liberty(simple(type = Option))]
pub has_builtin_pad: Option<BooleanExpression>,
#[size = 1]
#[liberty(simple(type = Option))]
pub hysteresis: Option<bool>,
#[size = 32]
#[liberty(simple(type = Option))]
pub illegal_clamp_condition: Option<BooleanExpression>,
#[size = 64]
#[liberty(simple)]
pub input_map: WordSet,
#[size = 8]
#[liberty(simple(type = Option))]
pub input_signal_level: Option<String>,
#[size = 8]
#[liberty(simple(type = Option))]
pub input_voltage: Option<String>,
#[size = 8]
#[liberty(simple(type = Option))]
pub internal_node: Option<String>,
#[size = 1]
#[liberty(simple(type = Option))]
pub inverted_output: Option<bool>,
#[size = 1]
#[liberty(simple(type = Option))]
pub is_pad: Option<bool>,
#[size = 1]
#[liberty(simple(type=Option))]
pub is_pll_reference_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type=Option))]
pub is_pll_feedback_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type=Option))]
pub is_pll_output_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type=Option))]
pub is_unbuffered: Option<bool>,
#[size = 1]
#[liberty(simple(type = Option))]
pub is_unconnected: Option<bool>,
#[size = 1]
#[liberty(simple(type=Option))]
pub isolation_cell_data_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type=Option))]
pub isolation_cell_enable_pin: Option<bool>,
#[size = 32]
#[liberty(simple(type=Option))]
pub isolation_enable_condition: Option<BooleanExpression>,
#[size = 1]
#[liberty(simple(type=Option))]
pub level_shifter_data_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type=Option))]
pub level_shifter_enable_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type=Option))]
pub map_to_logic: Option<OneZero>,
#[size = 16]
#[liberty(simple(type = Option))]
pub max_capacitance: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub max_fanout: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub max_input_delta_overdrive_high: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub max_input_delta_underdrive_high: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub max_transition: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_capacitance: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_fanout: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_period: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_pulse_width_high: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_pulse_width_low: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_transition: Option<f64>,
#[size = 1]
#[liberty(simple(type = Option))]
pub multicell_pad_pin: Option<bool>,
#[size = 1]
#[liberty(simple(type = Option))]
pub nextstate_type: Option<NextstateType>,
#[size = 8]
#[liberty(simple(type = Option))]
pub output_signal_level: Option<String>,
#[size = 16]
#[liberty(simple(type = Option))]
pub output_signal_level_high: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub output_signal_level_low: Option<f64>,
#[size = 8]
#[liberty(simple(type = Option))]
pub output_voltage: Option<String>,
#[size = 1]
#[liberty(simple(type = Option))]
pub pin_func_type: Option<PinFuncType>,
#[size = 1]
#[liberty(simple(type = Option))]
pub prefer_tied: Option<OneZero>,
#[size = 1]
#[liberty(simple(type = Option))]
pub primary_output: Option<bool>,
#[size = 16]
#[liberty(simple(type = Option))]
pub pulling_current: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub pulling_resistance: Option<f64>,
#[size = 2]
#[liberty(simple(type = Option))]
pub restore_action: Option<logic::Normal>,
#[size = 1]
#[liberty(simple(type = Option))]
pub restore_edge_type: Option<RestoreEdgeType>,
#[size = 16]
#[liberty(simple(type = Option))]
pub rise_capacitance: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub rise_current_slope_after_threshold: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub rise_current_slope_before_threshold: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub rise_time_after_threshold: Option<f64>,
#[size = 16]
#[liberty(simple(type = Option))]
pub rise_time_before_threshold: Option<f64>,
#[size = 2]
#[liberty(simple(type = Option))]
pub save_action: Option<logic::Normal>,
#[size = 1]
#[liberty(simple(type = Option))]
pub signal_type: Option<SignalType>,
#[size = 1]
#[liberty(simple(type = Option))]
pub slew_control: Option<SlewControl>,
#[size = 32]
#[liberty(simple(type = Option))]
pub state_function: Option<BooleanExpression>,
#[size = 1]
#[liberty(simple(type = Option))]
pub test_output_only: Option<bool>,
#[size = 32]
#[liberty(simple(type = Option))]
pub three_state: Option<BooleanExpression>,
#[size = 32]
#[liberty(simple(type = Option))]
pub x_function: Option<BooleanExpression>,
#[size = 1]
#[liberty(simple(type = Option))]
pub switch_pin: Option<bool>,
#[size = 24]
#[liberty(complex(type = Option))]
pub fall_capacitance_range: Option<(f64, f64)>,
#[size = 24]
#[liberty(complex(type = Option))]
pub rise_capacitance_range: Option<(f64, f64)>,
#[size = 1312]
#[liberty(group)]
pub char_config: Option<CharConfig<C>>,
#[size = 88]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<InternalPower<C>>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<InternalPower<C>>::deserialize_with")]
pub internal_power: GroupSet<InternalPower<C>>,
#[size = 88]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<TLatch<C>>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<TLatch<C>>::deserialize_with")]
pub tlatch: GroupSet<TLatch<C>>,
#[size = 88]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<Timing<C>>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<Timing<C>>::deserialize_with")]
pub timing: GroupSet<Timing<C>>,
#[size = 88]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<ReceiverCapacitance<C>>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<ReceiverCapacitance<C>>::deserialize_with")]
pub receiver_capacitance: GroupSet<ReceiverCapacitance<C>>,
#[size = 88]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<CCSNStage<C>>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<CCSNStage<C>>::deserialize_with")]
pub input_ccb: GroupSet<CCSNStage<C>>,
#[size = 88]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<CCSNStage<C>>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<CCSNStage<C>>::deserialize_with")]
pub output_ccb: GroupSet<CCSNStage<C>>,
#[size = 88]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<CCSNStage<C>>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<CCSNStage<C>>::deserialize_with")]
pub ccsn_first_stage: GroupSet<CCSNStage<C>>,
#[size = 88]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<CCSNStage<C>>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<CCSNStage<C>>::deserialize_with")]
pub ccsn_last_stage: GroupSet<CCSNStage<C>>,
}
impl<C: Ctx> GroupFn for Pin<C> {}
#[cfg(test)]
mod test {
use crate::DefaultCtx;
#[test]
fn pin_name_list() {
let cell = crate::ast::test_parse_fmt::<crate::Cell<DefaultCtx>>(
r#"(test_cell){
pin (A) {}
pin (B,C,D,E) {}
}"#,
r#"
liberty_db::cell::Cell (test_cell) {
| pin (A) {
| }
| pin (B, C, D, E) {
| }
}"#,
);
}
}