use crate::{
ast::{Attributes, GroupComments, GroupFn, GroupSet},
ccsn::{CCSNStage, ReceiverCapacitance},
common::items::{NameList, WordSet},
expression::{logic, BooleanExpression},
internal_power::InternalPower,
timing::Timing,
ArcStr, NotNan,
};
mod bundle;
mod items;
pub use bundle::*;
pub use items::*;
#[mut_set::derive::item(sort)]
#[derive(Debug, Default, Clone)]
#[derive(liberty_macros::Group)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Pin {
#[id]
#[size = 48]
#[liberty(name)]
pub name: NameList,
#[size = 2376]
#[liberty(comments)]
pub comments: GroupComments<Self>,
#[size = 48]
#[liberty(attributes)]
pub attributes: Attributes,
#[size = 8]
#[liberty(simple(type = Option))]
pub driver_waveform_rise: Option<ArcStr>,
#[size = 8]
#[liberty(simple(type = Option))]
pub driver_waveform_fall: Option<ArcStr>,
#[size = 8]
#[liberty(simple)]
pub related_ground_pin: ArcStr,
#[size = 2]
#[liberty(complex(type = Option))]
pub retention_pin: Option<RetentionPin>,
#[size = 8]
#[liberty(simple)]
pub related_power_pin: ArcStr,
#[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<BooleanExpression>,
#[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 = 48]
#[liberty(simple)]
pub antenna_diode_related_ground_pins: WordSet,
#[size = 48]
#[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<NotNan<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<ArcStr>,
#[size = 48]
#[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<NotNan<f64>>,
#[size = 1]
#[liberty(simple(type = Option))]
pub driver_type: Option<DriverType>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fall_capacitance: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fall_current_slope_after_threshold: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fall_current_slope_before_threshold: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fall_time_after_threshold: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fall_time_before_threshold: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub fanout_load: Option<NotNan<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 = 48]
#[liberty(simple)]
pub input_map: WordSet,
#[size = 8]
#[liberty(simple(type = Option))]
pub input_signal_level: Option<ArcStr>,
#[size = 8]
#[liberty(simple(type = Option))]
pub input_voltage: Option<ArcStr>,
#[size = 8]
#[liberty(simple(type = Option))]
pub internal_node: Option<ArcStr>,
#[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<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub max_fanout: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub max_input_delta_overdrive_high: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub max_input_delta_underdrive_high: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub max_transition: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_capacitance: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_fanout: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_period: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_pulse_width_high: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_pulse_width_low: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub min_transition: Option<NotNan<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<ArcStr>,
#[size = 16]
#[liberty(simple(type = Option))]
pub output_signal_level_high: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub output_signal_level_low: Option<NotNan<f64>>,
#[size = 8]
#[liberty(simple(type = Option))]
pub output_voltage: Option<ArcStr>,
#[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<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub pulling_resistance: Option<NotNan<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<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub rise_current_slope_after_threshold: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub rise_current_slope_before_threshold: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub rise_time_after_threshold: Option<NotNan<f64>>,
#[size = 16]
#[liberty(simple(type = Option))]
pub rise_time_before_threshold: Option<NotNan<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<(NotNan<f64>, NotNan<f64>)>,
#[size = 24]
#[liberty(complex(type = Option))]
pub rise_capacitance_range: Option<(NotNan<f64>, NotNan<f64>)>,
#[size = 48]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<InternalPower>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<InternalPower>::deserialize_with")]
pub internal_power: GroupSet<InternalPower>,
pub tlatch: (),
#[size = 48]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<Timing>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<Timing>::deserialize_with")]
pub timing: GroupSet<Timing>,
#[size = 48]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<ReceiverCapacitance>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<ReceiverCapacitance>::deserialize_with")]
pub receiver_capacitance: GroupSet<ReceiverCapacitance>,
#[size = 48]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<CCSNStage>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<CCSNStage>::deserialize_with")]
pub input_ccb: GroupSet<CCSNStage>,
#[size = 48]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<CCSNStage>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<CCSNStage>::deserialize_with")]
pub output_ccb: GroupSet<CCSNStage>,
#[size = 48]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<CCSNStage>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<CCSNStage>::deserialize_with")]
pub ccsn_first_stage: GroupSet<CCSNStage>,
#[size = 48]
#[liberty(group(type = Set))]
#[serde(serialize_with = "GroupSet::<CCSNStage>::serialize_with")]
#[serde(deserialize_with = "GroupSet::<CCSNStage>::deserialize_with")]
pub ccsn_last_stage: GroupSet<CCSNStage>,
}
impl GroupFn for Pin {}
#[cfg(test)]
mod test {
#[test]
fn pin_name_list() {
let cell = crate::ast::test_parse_fmt::<crate::Cell>(
r#"(test_cell){
pin (A) {}
pin (B,C,D,E) {}
}"#,
r#"
liberty_db::cell::Cell (test_cell) {
| pin (A) {
| }
| pin (B, C, D, E) {
| }
}"#,
);
}
}