1use reda_lib_macro::model;
2use crate::lib_enum;
3
4use super::{LibDontFault, LibExpr};
5
6#[model]
7#[derive(Debug, Clone, Default)]
8pub struct LibPin {
9 pub name: String,
10
11 pub alive_during_power_up: Option<bool>,
13 pub always_on: Option<bool>,
14
15 pub antenna_diode_type: Option<LibAntennaDiodeType>,
16 pub antenna_diode_related_ground_pins: Option<String>,
17 pub antenna_diode_related_power_pins: Option<String>,
18
19 pub bit_width: Option<usize>,
20
21 pub capacitance: Option<f64>,
22 pub fall_capacitance: Option<f64>,
23 pub fanout_load: Option<f64>,
24 pub drive_current: Option<f64>,
25 pub fall_current_slope_after_threshold: Option<f64>,
26 pub fall_current_slope_before_threshold: Option<f64>,
27 pub fall_time_after_threshold: Option<f64>,
28 pub fall_time_before_threshold: Option<f64>,
29
30 pub max_capacitance: Option<f64>,
31 pub min_capacitance: Option<f64>,
32 pub max_fanout: Option<f64>,
33 pub min_fanout: Option<f64>,
34 pub max_transition: Option<f64>,
35 pub min_transition: Option<f64>,
36 pub min_period: Option<f64>,
37 pub min_pulse_width_high: Option<f64>,
38 pub min_pulse_width_low: Option<f64>,
39 pub max_input_delta_overdrive_high: Option<f64>,
40 pub max_input_delta_underdrive_high: Option<f64>,
41
42 pub clamp_0_function: Option<String>,
43 pub clamp_1_function: Option<String>,
44 pub clamp_latch_function: Option<String>,
45 pub clamp_z_function: Option<String>,
46 pub function: Option<LibExpr>,
47 pub illegal_clamp_condition: Option<String>,
48 pub complementary_pin: Option<String>,
49 pub nextstate_type: Option<LibNextStateType>,
50
51 pub clock: Option<bool>,
52 pub clock_gate_clock_pin: Option<bool>,
53 pub clock_gate_enable_pin: Option<bool>,
54 pub clock_gate_test_pin: Option<bool>,
55 pub clock_gate_obs_pin: Option<bool>,
56 pub clock_gate_out_pin: Option<bool>,
57 pub clock_isolation_cell_clock_pin: Option<bool>,
58
59 pub direction: LibPinDirection,
60 pub driver_type: Option<LibDriverType>,
61 pub output_signal_level: Option<String>,
62 pub output_signal_level_high: Option<f64>,
63 pub output_signal_level_low: Option<f64>,
64 pub output_voltage: Option<String>,
65 pub input_signal_level: Option<String>,
66 pub input_voltage: Option<String>,
67
68 pub has_builtin_pad: Option<bool>,
69 pub hysteresis: Option<bool>,
70 pub is_pad: Option<bool>,
71 pub is_unconnected: Option<bool>,
72 pub multicell_pad_pin: Option<bool>,
73 pub inverted_output: Option<bool>,
74
75 pub connection_class: Option<String>,
76 pub fault_model: Option<String>,
77 pub dont_fault: Option<LibDontFault>,
78 pub internal_node: Option<String>,
79 pub input_map: Option<String>,
80
81 pub pin_func_type: Option<LibPinFuncType>,
82 pub primary_output: Option<bool>,
83 pub pulling_current: Option<f64>,
84 pub pulling_resistance: Option<f64>,
85 pub restore_action: Option<LibAction>,
86 pub restore_edge_type: Option<LibRestoreEdgeType>,
87 pub rise_capacitance: Option<f64>,
88 pub rise_current_slope_after_threshold: Option<f64>,
89 pub rise_current_slope_before_threshold: Option<f64>,
90 pub rise_time_after_threshold: Option<f64>,
91 pub rise_time_before_threshold: Option<f64>,
92 pub save_action: Option<LibAction>,
93 pub signal_type: Option<LibSignalType>,
94 pub slew_control: Option<LibSlewControl>,
95 pub state_function: Option<LibExpr>,
96 pub test_output_only: Option<bool>,
97 pub three_state: Option<LibExpr>,
98 pub x_function: Option<LibExpr>,
99
100 pub fall_capacitance_range: Option<[f64; 2]>,
102 pub rise_capacitance_range: Option<[f64; 2]>,
103
104 pub timings: Vec<LibTiming>,
106}
107
108#[model]
109#[derive(Debug, Clone)]
110pub struct LibTiming {
111 pub related_pin: String,
112 pub timing_sense: Option<LibTimingSense>,
113 pub timing_type: Option<LibTimingType>,
114
115 pub cell_fall: Option<LibLuTable>,
116 pub cell_rise: Option<LibLuTable>,
117 pub fall_transition: Option<LibLuTable>,
118 pub rise_transition: Option<LibLuTable>,
119
120 pub fall_constraint: Option<LibLuTable>,
121 pub rise_constraint: Option<LibLuTable>,
122}
123
124#[model]
125#[derive(Debug, Clone)]
126pub struct LibInternalPower {
127 pub related_pin: String,
128 pub fall_power: LibLuTable,
129 pub rise_power: LibLuTable,
130}
131
132#[model]
133#[derive(Debug, Clone)]
134pub struct LibLuTable {
135 pub template_name: String,
136 pub index_1: Option<Vec<f64>>,
137 pub index_2: Option<Vec<f64>>,
138 pub index_3: Option<Vec<f64>>,
139 pub values: Vec<Vec<f64>>,
140}
141
142lib_enum!(LibTimingSense, positive_unate, negative_unate, non_unate);
143
144lib_enum!(LibTimingType,
145 combinational, combinational_rise,
146 combinational_fall, three_state_disable,
147 three_state_disable_rise, three_state_disable_fall,
148 three_state_enable, three_state_enable_rise,
149 three_state_enable_fall,rising_edge, falling_edge,
150 preset, clear, hold_rising, hold_falling,
151 setup_rising, setup_falling, recovery_rising,
152 recovery_falling, skew_rising, skew_falling,
153 removal_rising, removal_falling, min_pulse_width,
154 minimum_period, max_clock_tree_path,
155 min_clock_tree_path,non_seq_setup_rising,
156 non_seq_setup_falling, non_seq_hold_rising,
157 non_seq_hold_falling, nochange_high_high,
158 nochange_high_low,
159 nochange_low_high,
160 nochange_low_low);
161
162lib_enum!(LibPinDirection, input, output, inout, internal);
163
164lib_enum!(LibAntennaDiodeType, power, ground, power_and_ground);
165
166lib_enum!(LibDriverType,
167 pull_up,
168 pull_down,
169 open_drain,
170 open_source,
171 bus_hold,
172 resistive,
173 resistive0,
174 resistive1,
175);
176
177lib_enum!(LibNextStateType,
178 data,
179 preset,
180 clear,
181 load,
182 scan_in,
183 scan_enable,
184);
185
186lib_enum!(LibAction, l, h, r, f);
187
188lib_enum!(LibRestoreEdgeType, edge_trigger, leading, trailing);
189
190lib_enum!(LibSlewControl, low, medium, high, none);
191
192lib_enum!(LibSignalType,
193 test_scan_in,
194 test_scan_in_inverted,
195 test_scan_out,
196 test_scan_out_inverted,
197 test_scan_enable,
198 test_scan_enable_inverted,
199 test_scan_clock,
200 test_scan_clock_a,
201 test_scan_clock_b,
202 test_clock,
203);
204
205lib_enum!(LibPinFuncType,
206 clock_enable,
207 active_high,
208 active_low,
209 active_rising,
210 active_falling,
211);
212
213impl LibPin {
214 pub fn new<S: Into<String>>(name: S) -> Self {
215 Self {
216 name: name.into(),
217 ..Default::default()
218 }
219 }
220}