liberty_db/cell/items.rs
1use crate::{
2 Ctx,
3 ast::{
4 CodeFormatter, ComplexAttri, ComplexParseError, GroupComments, GroupFn, Indentation,
5 LibertySet, LibertyVec, NamedGroup, ParseScope, SimpleAttri, SimpleParseRes,
6 join_fmt,
7 },
8 common::items::WordSet,
9 expression::{LogicBooleanExpression, PowerGroundBooleanExpression, logic},
10 pin::Direction,
11 table::{CompactCcsPower, ReferenceTimeVector3D},
12};
13use core::{
14 fmt::{self, Write},
15 hash::Hash,
16 str::FromStr,
17};
18use strum::{Display, EnumString};
19/// Contains a table consisting of a single string.
20/// <a name ="reference_link" href="
21/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=199.5&end=199.6
22/// ">Reference</a>
23/// <script>
24/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
25/// </script>
26#[derive(Debug, Clone)]
27#[derive(liberty_macros::Group)]
28#[mut_set::derive::item]
29#[derive(serde::Serialize, serde::Deserialize)]
30#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
31pub struct LeakagePower<C: 'static + Ctx> {
32 #[id]
33 #[liberty(name)]
34 pub name: Vec<String>,
35 /// group comments
36 #[liberty(comments)]
37 comments: GroupComments,
38 #[liberty(extra_ctx)]
39 pub extra_ctx: C::Other,
40 /// group undefined attributes
41 #[liberty(attributes)]
42 pub attributes: crate::ast::Attributes,
43 #[id]
44 #[liberty(simple)]
45 pub power_level: Option<String>,
46 #[id]
47 #[liberty(simple)]
48 pub related_pg_pin: WordSet,
49 #[id]
50 #[liberty(simple)]
51 pub when: Option<LogicBooleanExpression>,
52 #[liberty(simple)]
53 pub value: f64,
54 #[liberty(complex)]
55 pub mode: Option<[String; 2]>,
56}
57impl<C: 'static + Ctx> GroupFn<C> for LeakagePower<C> {}
58
59#[cfg(test)]
60mod test_sort {
61 use super::*;
62 use crate::DefaultCtx;
63
64 #[test]
65 fn leakage_sort() {
66 let cell = crate::ast::test_parse::<crate::Cell<DefaultCtx>>(
67 r#"(CELL) {
68 pin(A){}
69 pin(B){}
70 pin(Y){}
71 leakage_power () {
72 related_pg_pin : VDD;
73 value : 1;
74 }
75 leakage_power () {
76 related_pg_pin : VDD;
77 when : "A*B*Y";
78 value : 2;
79 }
80 leakage_power () {
81 related_pg_pin : VDD;
82 when : "!A*B*!Y";
83 value : 3;
84 }
85 leakage_power () {
86 related_pg_pin : VDD;
87 when : "A*!B*!Y";
88 value : 4;
89 }
90 leakage_power () {
91 related_pg_pin : VDD;
92 when : "!A*!B*!Y";
93 value : 5;
94 }
95 leakage_power () {
96 related_pg_pin : VSS;
97 value : 6;
98 }
99 leakage_power () {
100 related_pg_pin : VSS;
101 when : "A*B*Y";
102 value : 7;
103 }
104 leakage_power () {
105 related_pg_pin : VSS;
106 when : "!A*B*!Y";
107 value : 8;
108 }
109 leakage_power () {
110 related_pg_pin : VSS;
111 when : "A*!B*!Y";
112 value : 9;
113 }
114 leakage_power () {
115 related_pg_pin : VSS;
116 when : "!A*!B*!Y";
117 value : 10;
118 }
119 }
120 "#,
121 );
122 assert_eq!(
123 vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
124 cell
125 .leakage_power
126 .iter()
127 .map(|leakage| leakage.value as i8)
128 .collect::<Vec<_>>()
129 );
130 }
131}
132/// The memory group is in the cell group. The memory group tags the cell as a memory
133/// cell and contains general information about the memory cell, described with these
134///
135/// attributes:
136/// + type
137/// + `address_width`
138/// + `word_width`
139/// + `column_address`
140/// + `row_address`
141///
142/// Syntax:
143/// ```text
144/// cell()
145/// memory() {
146/// type : [ram | rom ];
147/// address_width : “integer” ;
148/// word_width : “integer” ;
149/// column_address : ”integer” ;
150/// row_address : ”integer” ;
151/// }
152/// }
153/// ```
154#[derive(Debug, Clone)]
155#[derive(liberty_macros::Group)]
156#[derive(serde::Serialize, serde::Deserialize)]
157#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
158pub struct Memory<C: 'static + Ctx> {
159 #[liberty(name)]
160 pub name: Vec<String>,
161 /// group comments
162 #[liberty(comments)]
163 comments: GroupComments,
164 #[liberty(extra_ctx)]
165 pub extra_ctx: C::Other,
166 /// group undefined attributes
167 #[liberty(attributes)]
168 pub attributes: crate::ast::Attributes,
169 #[liberty(simple)]
170 pub r#type: Option<MemoryType>,
171 #[liberty(simple)]
172 pub address_width: Option<usize>,
173 #[liberty(simple)]
174 pub word_width: Option<usize>,
175 /// This attribute specifies the number or range of numbers of indexes for a column.
176 /// *Syntax*:
177 /// ```text
178 /// column_address : ”index1 [range1 index2 index3 ...]” ;
179 /// ```
180 /// Number or range of numbers of indexes. Separate the numbers in a range with a
181 /// colon.
182 ///
183 /// *Example*:
184 /// ```text
185 /// column_address : ”0:4 5” ;
186 /// ```
187 #[liberty(simple)]
188 pub column_address: Option<String>,
189 /// This attribute specifies the number or range of numbers of indexes for a row.
190 ///
191 /// *Syntax*:
192 /// ```text
193 /// row_address : ”index1 [range1 index2 index3 ...]” ;
194 /// ```
195 /// Number or range of numbers of indexes. Separate the numbers in a range with a
196 /// colon.
197 ///
198 /// *Example*:
199 /// ```text
200 /// row_address : ”6:9” ;
201 /// ```
202 /// Example 6-16 at the end of this chapter shows a RAM cell with a memory description
203 /// that includes the `column_address` and `row_address` attributes.
204 #[liberty(simple)]
205 pub row_address: Option<String>,
206}
207impl<C: 'static + Ctx> GroupFn<C> for Memory<C> {}
208#[derive(Debug, Clone, Copy, PartialEq, Display, EnumString, Hash, Eq, PartialOrd, Ord)]
209#[derive(serde::Serialize, serde::Deserialize)]
210pub enum MemoryType {
211 /// Low
212 #[strum(serialize = "ram")]
213 RAM,
214 /// High
215 #[strum(serialize = "rom")]
216 ROM,
217}
218crate::ast::impl_self_builder!(MemoryType);
219crate::ast::impl_simple!(MemoryType);
220/// Contains a table consisting of a single string.
221/// <a name ="reference_link" href="
222/// https://zao111222333.github.io/liberty-db/2020.09/user_guide.html?field=null&bgn=141.4&end=141.5
223/// ">Reference</a>
224/// <script>
225/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
226/// </script>
227#[derive(Debug, Clone)]
228#[derive(liberty_macros::Group)]
229#[mut_set::derive::item]
230#[derive(serde::Serialize, serde::Deserialize)]
231#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
232pub struct Statetable<C: 'static + Ctx> {
233 #[id]
234 #[liberty(name)]
235 pub input_nodes: Vec<String>,
236 #[id]
237 #[liberty(name)]
238 pub internal_nodes: Vec<String>,
239 /// group comments
240 #[liberty(comments)]
241 comments: GroupComments,
242 #[liberty(extra_ctx)]
243 pub extra_ctx: C::Other,
244 /// group undefined attributes
245 #[liberty(attributes)]
246 pub attributes: crate::ast::Attributes,
247 #[liberty(simple)]
248 pub table: Table,
249}
250impl<C: 'static + Ctx> GroupFn<C> for Statetable<C> {}
251
252impl<C: 'static + Ctx> NamedGroup<C> for Statetable<C> {
253 #[inline]
254 fn parse_set_name(
255 builder: &mut Self::Builder,
256 mut v: Vec<&str>,
257 ) -> Result<(), crate::ast::IdError> {
258 let l = v.len();
259 if l == 2 {
260 v.pop()
261 .map_or(Err(crate::ast::IdError::Other("Unkown pop error".into())), |var2| {
262 v.pop().map_or(
263 Err(crate::ast::IdError::Other("Unkown pop error".into())),
264 |var1| {
265 builder.input_nodes =
266 var1.split_ascii_whitespace().map(String::from).collect();
267 builder.internal_nodes =
268 var2.split_ascii_whitespace().map(String::from).collect();
269 Ok(())
270 },
271 )
272 })
273 } else {
274 Err(crate::ast::IdError::length_dismatch(2, l, v))
275 }
276 }
277 #[inline]
278 #[expect(clippy::indexing_slicing)]
279 fn fmt_name<T: Write, I: Indentation>(
280 &self,
281 f: &mut CodeFormatter<'_, T, I>,
282 ) -> fmt::Result {
283 if self.input_nodes.len() == 1 {
284 write!(f, "{}", self.input_nodes[0])?;
285 } else {
286 join_fmt(
287 self.input_nodes.iter(),
288 f,
289 |s, ff| write!(ff, "{s}"),
290 |ff| write!(ff, " "),
291 )?;
292 }
293 write!(f, ", ")?;
294 if self.internal_nodes.len() == 1 {
295 write!(f, "{}", self.internal_nodes[0])
296 } else {
297 join_fmt(
298 self.internal_nodes.iter(),
299 f,
300 |s, ff| write!(ff, "{s}"),
301 |ff| write!(ff, " "),
302 )
303 }
304 }
305}
306
307/// `StateTable` Table
308#[derive(Default, Debug, Clone)]
309#[derive(serde::Serialize, serde::Deserialize)]
310pub struct Table {
311 pub inner: Vec<TableNodeValues>,
312}
313#[derive(Default, Debug, Clone)]
314#[derive(serde::Serialize, serde::Deserialize)]
315pub struct TableNodeValues {
316 pub input_node_values: Vec<InputNodeValue>,
317 pub current_next_internal_node_values:
318 Vec<(CurrentInternalNodeValue, NextInternalNodeValue)>,
319}
320
321/// <a name ="reference_link" href="
322/// https://zao111222333.github.io/liberty-db/2020.09/user_guide.html?field=null&bgn=142.4&end=142.17
323/// ">Reference</a>
324#[derive(Debug, Clone, Copy, PartialEq, Display, EnumString, Hash, Eq, PartialOrd, Ord)]
325#[derive(serde::Serialize, serde::Deserialize)]
326pub enum InputNodeValue {
327 /// Low
328 #[strum(serialize = " L ")]
329 L,
330 /// High
331 #[strum(serialize = " H ")]
332 H,
333 /// Don't care
334 #[strum(serialize = " - ")]
335 DontCare,
336 /// Expands to both L and H
337 #[strum(serialize = "L/H")]
338 LH,
339 /// Expands to both H and L
340 #[strum(serialize = "H/L")]
341 HL,
342 /// Rising edge (from low to high)
343 #[strum(serialize = " R ")]
344 R,
345 /// Falling edge (from high to low)
346 #[strum(serialize = " F ")]
347 F,
348 /// Not rising edge
349 #[strum(serialize = "~R ")]
350 NotR,
351 /// Not falling edge
352 #[strum(serialize = "~F ")]
353 NotF,
354}
355/// <a name ="reference_link" href="
356/// https://zao111222333.github.io/liberty-db/2020.09/user_guide.html?field=null&bgn=142.4&end=142.17
357/// ">Reference</a>
358#[derive(Debug, Clone, Copy, PartialEq, Display, EnumString, Hash, Eq, PartialOrd, Ord)]
359#[derive(serde::Serialize, serde::Deserialize)]
360pub enum CurrentInternalNodeValue {
361 /// Low
362 #[strum(serialize = " L ")]
363 L,
364 /// High
365 #[strum(serialize = " H ")]
366 H,
367 /// Don't care
368 #[strum(serialize = " - ")]
369 DontCare,
370 /// Expands to both L and H
371 #[strum(serialize = "L/H")]
372 LH,
373 /// Expands to both H and L
374 #[strum(serialize = "H/L")]
375 HL,
376}
377/// <a name ="reference_link" href="
378/// https://zao111222333.github.io/liberty-db/2020.09/user_guide.html?field=null&bgn=142.18&end=142.33
379/// ">Reference</a>
380#[derive(Debug, Clone, Copy, PartialEq, Display, EnumString, Hash, Eq, PartialOrd, Ord)]
381#[derive(serde::Serialize, serde::Deserialize)]
382pub enum NextInternalNodeValue {
383 /// Low
384 #[strum(serialize = " L ")]
385 L,
386 /// High
387 #[strum(serialize = " H ")]
388 H,
389 /// Output is not specified
390 #[strum(serialize = " - ")]
391 NotSpecified,
392 /// Expands to both L and H
393 #[strum(serialize = "L/H")]
394 LH,
395 /// Expands to both H and L
396 #[strum(serialize = "H/L")]
397 HL,
398 /// Unknown
399 #[strum(serialize = " X ")]
400 X,
401 /// No event from current value. Hold.
402 /// Use only when all asynchronous inputs and clocks are inactive
403 #[strum(serialize = " N ")]
404 N,
405}
406impl fmt::Display for TableNodeValues {
407 #[inline]
408 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
409 for v in &self.input_node_values {
410 write!(f, "{v} ")?;
411 }
412 write!(f, ": ")?;
413 for (v, _) in &self.current_next_internal_node_values {
414 write!(f, "{v} ")?;
415 }
416 write!(f, ":")?;
417 for (_, v) in &self.current_next_internal_node_values {
418 write!(f, " {v}")?;
419 }
420 Ok(())
421 }
422}
423impl fmt::Display for Table {
424 #[inline]
425 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
426 fmt::Debug::fmt(&self.inner, f)
427 }
428}
429
430crate::ast::impl_self_builder!(Table);
431impl<C: 'static + Ctx> SimpleAttri<C> for Table {
432 #[inline]
433 fn is_set(&self) -> bool {
434 !self.inner.is_empty()
435 }
436 #[inline]
437 #[expect(clippy::arithmetic_side_effects)]
438 fn nom_parse<'a>(i: &'a str, scope: &mut ParseScope<'_>) -> SimpleParseRes<'a, Self> {
439 if let Ok((input, (line_num, table))) = Self::parse(i) {
440 scope.loc.line_num += line_num;
441 Ok((input, Ok(table)))
442 } else {
443 let (input, simple_multi) =
444 super::parser::simple_multi(i, &mut scope.loc.line_num)?;
445 Ok((input, Err(String::from(simple_multi))))
446 }
447 }
448 #[inline]
449 fn fmt_self<T: Write, I: Indentation>(
450 &self,
451 f: &mut CodeFormatter<'_, T, I>,
452 ) -> fmt::Result {
453 join_fmt(
454 self.inner.iter(),
455 f,
456 |i, ff| write!(ff, "{i}"),
457 |ff| {
458 write!(ff, ",\\")?;
459 ff.write_new_line_indentation()?;
460 write!(ff, " ")
461 },
462 )
463 }
464}
465
466#[cfg(test)]
467mod test_statetable {
468 use dev_utils::init_logger;
469
470 use super::*;
471 use crate::DefaultCtx;
472 #[test]
473 fn statetable_test() {
474 init_logger();
475 let statetable = crate::ast::test_parse_fmt::<Statetable<DefaultCtx>>(
476 r#"(" CLK EN SE",ENL) {
477 table : " H L L : - : L ,\
478 H L H : - : H ,\
479 H H L : - : H ,\
480 H H H : - : H ,\
481 L - - : - : N ";
482 }
483 "#,
484 r#"
485liberty_db::cell::items::Statetable ("CLK EN SE", ENL) {
486| table : " H L L : - : L ,\
487| H L H : - : H ,\
488| H H L : - : H ,\
489| H H H : - : H ,\
490| L - - : - : N ";
491}"#,
492 );
493 _ = crate::ast::test_parse_fmt::<Statetable<DefaultCtx>>(
494 r#"(" CLK EN SE",ENL) {
495 table : " H L L \
496 : - : L ,\
497 H L H : - : H ,\
498 H H L : - : H ,\
499 H H H : - : H ,\
500 L - - : - : N ";
501 }
502 "#,
503 r#"
504liberty_db::cell::items::Statetable ("CLK EN SE", ENL) {
505| table : " H L L : - : L ,\
506| H L H : - : H ,\
507| H H L : - : H ,\
508| H H H : - : H ,\
509| L - - : - : N ";
510}"#,
511 );
512 _ = crate::ast::test_parse_fmt::<Statetable<DefaultCtx>>(
513 r#"("CLK ENA SE", "IQ") { \
514 table : "L L L : - : L , \
515 L L H : - : H ,\
516 L H L : - : H ,\
517 L H H : - : H ,\
518 H - - : - : N ";
519 }
520 "#,
521 r#"
522liberty_db::cell::items::Statetable ("CLK ENA SE", IQ) {
523| table : " L L L : - : L ,\
524| L L H : - : H ,\
525| L H L : - : H ,\
526| L H H : - : H ,\
527| H - - : - : N ";
528}"#,
529 );
530 _ = crate::ast::test_parse_fmt::<Statetable<DefaultCtx>>(
531 r#"(" D CP CPN", "MQ SQ") {
532 table : " H/L R ~F : - - : H/L N,\
533 - ~R F : H/L - : N H/L,\
534 H/L R F : L - : H/L L,\
535 H/L R F : H - : H/L H,\
536 - ~R ~F : - - : N N";
537 }
538 "#,
539 r#"
540liberty_db::cell::items::Statetable ("D CP CPN", "MQ SQ") {
541| table : "H/L R ~F : - - : H/L N ,\
542| - ~R F : H/L - : N H/L,\
543| H/L R F : L - : H/L L ,\
544| H/L R F : H - : H/L H ,\
545| - ~R ~F : - - : N N ";
546}"#,
547 );
548 }
549}
550
551/// Use the `pg_pin` group to specify power and ground pins.
552///
553/// The library cells can have multiple `pg_pin` groups.
554/// A `pg_pin` group is mandatory for each cell.
555/// A cell must have at least one `primary_power` pin
556/// specified in the `pg_type` attribute and
557/// at least one `primary_ground` pin specified in the `pg_type` attribute.
558/// <a name ="reference_link" href="
559/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=209.3&end=209.6
560/// ">Reference-Definition</a>
561/// <script>
562/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
563/// </script>
564#[derive(Debug, Clone)]
565#[derive(liberty_macros::Group)]
566#[mut_set::derive::item]
567#[derive(serde::Serialize, serde::Deserialize)]
568#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
569pub struct PgPin<C: 'static + Ctx> {
570 #[liberty(name)]
571 #[id(borrow = str)]
572 pub name: String,
573 /// group comments
574 #[liberty(comments)]
575 comments: GroupComments,
576 #[liberty(extra_ctx)]
577 pub extra_ctx: C::Other,
578 /// group undefined attributes
579 #[liberty(attributes)]
580 pub attributes: crate::ast::Attributes,
581 /// <a name ="reference_link" href="
582 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html
583 /// ?field=test
584 /// &bgn
585 /// =228.22
586 /// &end
587 /// =228.22
588 /// ">Reference-Instance</a>
589 #[liberty(simple)]
590 pub direction: Option<Direction>,
591 /// Use the `voltage_name` attribute to specify an associated voltage.
592 /// This attribute is optional in the `pg_pin` group of a level-shifter cell
593 /// not powered by the switching power domains,
594 /// where the `pg_pin` group has the `std_cell_main_rail` attribute
595 /// <a name ="reference_link" href="
596 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=209.30&end=209.32
597 /// ">Reference-Definition</a>
598 #[liberty(simple)]
599 pub voltage_name: String,
600 /// Use the optional `pg_type` attribute to specify the type of power and ground pin.
601 /// The `pg_type` attribute also supports back-bias modeling.
602 /// The `pg_type` attribute can have the following values:
603 /// + `primary_power`
604 /// + `primary_ground`
605 /// + `backup_power`
606 /// + `backup_ground`
607 /// + `internal_power`
608 /// + `internal_ground`
609 /// + `pwell`
610 /// + `nwell`
611 /// + `deepnwell`
612 /// + `deeppwell`
613 ///
614 /// The `pwell` and `nwell` values specify regular wells,
615 /// and the `deeppwell` and `deepnwell` values specify isolation wells.
616 /// <a name ="reference_link" href="
617 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=210.8&end=210.13
618 /// ">Reference-Definition</a>
619 #[liberty(simple)]
620 pub pg_type: PgType,
621 /// <a name ="reference_link" href="
622 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=209.30&end=209.32
623 /// ">Reference-Definition</a>
624 #[liberty(simple)]
625 pub user_pg_type: String,
626 /// The `is_pad` attribute identifies a pad pin on
627 /// any I/O cell. You can also specify the `is_pad` attribute
628 /// on PG pins.
629 /// The valid values are `true` and `false`.
630 /// If the cell-level `pad_cell` attribute is specified on
631 /// a I/O cell, the `is_pad` attribute must be set to `true`
632 /// in either a `pg_pin` group or on a signal pin for that cell.
633 /// <a name ="reference_link" href="
634 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=111.5&end=111.8
635 /// ">Reference</a>
636 #[liberty(simple)]
637 pub is_pad: Option<bool>,
638 /// <a name ="reference_link" href="
639 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=209.30&end=209.32
640 /// ">Reference-Definition</a>
641 #[liberty(simple)]
642 pub physical_connection: String,
643 /// <a name ="reference_link" href="
644 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=209.30&end=209.32
645 /// ">Reference-Definition</a>
646 #[liberty(simple)]
647 pub related_bias_pin: String,
648 /// The `std_cell_main_rail` Boolean attribute is defined in a `primary_power`
649 /// power pin. When the attribute is set to true, the power and ground pin
650 /// is used to determine which side of the voltage boundary
651 /// the power and ground pin is connected.
652 /// <a name ="reference_link" href="
653 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=278.29&end=278.31
654 /// ">Reference-Definition</a>
655 #[liberty(simple)]
656 pub std_cell_main_rail: Option<bool>,
657 /// The `pg_function` attribute models the logical function
658 /// of a virtual or derived power and ground (PG) pin as a Boolean expression
659 /// involving the cells input signal pins, internal signal pins, PG pins.
660 /// The attribute Boolean expression is checked during library compile to
661 /// ensure that only one `pg_pin` is always active at this virtual or derived PG pin.
662 /// If more than one `pg_pin` is found to be active at the virtual or the derived
663 /// `pg_pin` output, the `read_lib` command generates an error
664 /// <a name ="reference_link" href="
665 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=266.21&end=266.26
666 /// ">Reference-Definition</a>
667 #[liberty(simple)]
668 pub pg_function: Option<PowerGroundBooleanExpression>,
669 /// The `switch_function` string attribute identifies the condition
670 /// when the attached design partition is turned off by the input `switch_pin`.
671 /// For a coarse-grain switch cell, the `switch_function` attribute can be defined
672 /// at both controlled power and ground pins (virtual VDD and virtual VSS for `pg_pin`) and
673 /// the output pins.
674 /// When the `switch_function` attribute is defined in the controlled power and ground pin,
675 /// it is used to specify the Boolean condition under which the cell switches off
676 /// (or drives an X to) the controlled design partitions, including the traditional signal
677 /// input pins only (with no related power pins to this output).
678 /// <a name ="reference_link" href="
679 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=279.5&end=279.13
680 /// ">Reference-Definition</a>
681 #[liberty(simple)]
682 pub switch_function: Option<LogicBooleanExpression>,
683}
684impl<C: 'static + Ctx> GroupFn<C> for PgPin<C> {}
685
686/// Use the `dynamic_current` group to specify a current waveform vector when the power
687/// and ground current is dependent on the logical condition of a cell. A `dynamic_current`
688/// group is defined in a cell group, as shown here:
689/// <a name ="reference_link" href="
690/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=147.3&end=147.5
691/// ">Reference</a>
692/// <script>
693/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
694/// </script>
695#[derive(Debug, Clone)]
696#[derive(liberty_macros::Group)]
697#[mut_set::derive::item]
698#[derive(serde::Serialize, serde::Deserialize)]
699#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
700pub struct DynamicCurrent<C: 'static + Ctx> {
701 #[liberty(name)]
702 #[id]
703 pub name: Option<String>,
704 /// group comments
705 #[liberty(comments)]
706 comments: GroupComments,
707 #[liberty(extra_ctx)]
708 pub extra_ctx: C::Other,
709 /// group undefined attributes
710 #[liberty(attributes)]
711 pub attributes: crate::ast::Attributes,
712 #[id]
713 #[liberty(simple)]
714 pub when: Option<LogicBooleanExpression>,
715 #[id]
716 #[liberty(simple)]
717 pub related_inputs: WordSet,
718 #[id]
719 #[liberty(simple)]
720 pub related_outputs: WordSet,
721 #[liberty(complex)]
722 pub typical_capacitances: Option<Vec<f64>>,
723 /// Use the `switching_group` group to specify a current waveform vector when the power
724 /// and ground current is dependent on pin switching conditions.
725 /// <a name ="reference_link" href="
726 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=150.18&end=150.19
727 /// ">Reference</a>
728 #[liberty(group)]
729 pub switching_group: LibertySet<SwitchingGroup<C>>,
730}
731impl<C: 'static + Ctx> GroupFn<C> for DynamicCurrent<C> {}
732
733/// Use the `switching_group` group to specify a current waveform vector when the power
734/// and ground current is dependent on pin switching conditions.
735/// <a name ="reference_link" href="
736/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=150.18&end=150.19
737/// ">Reference</a>
738/// <script>
739/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
740/// </script>
741#[derive(Debug, Clone)]
742#[derive(liberty_macros::Group)]
743#[mut_set::derive::item]
744#[derive(serde::Serialize, serde::Deserialize)]
745#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
746pub struct SwitchingGroup<C: 'static + Ctx> {
747 #[liberty(name)]
748 #[id]
749 pub name: Option<String>,
750 /// group comments
751 #[liberty(comments)]
752 comments: GroupComments,
753 #[liberty(extra_ctx)]
754 pub extra_ctx: C::Other,
755 /// group undefined attributes
756 #[liberty(attributes)]
757 pub attributes: crate::ast::Attributes,
758 /// The `input_switching_condition` attribute specifies the sense of the toggling input. If
759 /// more than one `switching_group` group is specified within the `dynamic_current` group,
760 /// you can place the attribute in any order.
761 /// The valid values are rise and fall. rise represents a rising pin and fall represents a
762 /// falling pin.
763 /// ### Syntax
764 /// `input_switching_condition (enum(rise, fall));`
765 ///
766 /// `enum(rise, fall)`
767 /// Enumerated type specifying the rise or fall condition.
768 ///
769 /// ### Example
770 /// `input_switching_condition (rise);`
771 /// <a name ="reference_link" href="
772 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=151.5&end=151.15
773 /// ">Reference</a>
774 #[id]
775 #[liberty(complex)]
776 pub input_switching_condition: Option<logic::Edge>,
777 /// Use the `output_switching_condition` attribute to specify the sense of the toggling
778 /// output. If there is more than one `switching_group` group specified within the
779 /// `dynamic_current` group, you can place the attribute in any order. The order in the list of
780 /// the `output_switching_condition` attribute is mapped to the same order of output pins in
781 /// the `related_outputs` attribute.
782 /// The valid values are rise and fall. rise represents a rising pin and fall represents a
783 /// falling pin.
784 /// ### Syntax
785 /// `output_switching_condition (enum(rise, fall));`
786 ///
787 /// `enum(rise, fall)`
788 /// Enumerated type specifying the rise or fall condition.
789 ///
790 /// ### Example
791 /// `output_switching_condition (rise, fall);`
792 /// <a name ="reference_link" href="
793 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=151.17&end=151.29
794 /// ">Reference</a>
795 #[id]
796 #[liberty(complex)]
797 pub output_switching_condition: Option<Vec<logic::Edge>>,
798 /// The `min_input_switching_count` attribute specifies the minimum number of
799 /// bits in the input bus that are switching simultaneously. The following applies to the
800 /// `min_input_switching_count` attribute:
801 /// + The count must be an integer.
802 /// + The count must be greater than 0 and less than the `max_input_switching_count`
803 /// value.
804 /// ### Syntax
805 /// ``` text
806 /// switching_group() {
807 /// min_input_switching_count : integer ;
808 /// max_input_switching_count : integer ;
809 /// ...
810 /// }
811 /// ```
812 /// ### Example
813 /// ``` text
814 /// switching_group() {
815 /// min_input_switching_count : 1 ;
816 /// max_input_switching_count : 3 ;
817 /// ...
818 /// }
819 /// ```
820 /// <a name ="reference_link" href="
821 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=152.3&end=152.22
822 /// ">Reference</a>
823 #[liberty(simple)]
824 pub min_input_switching_count: Option<usize>,
825 /// The `max_input_switching_count` attribute specifies the maximum number of
826 /// bits in the input bus that are switching simultaneously. The following applies to the
827 /// `max_input_switching_count` attribute:
828 /// + The count must be an integer.
829 /// + The count must be greater than the `min_input_switching_count` value.
830 /// + The count within a `dynamic_current` should cover the total number of input bits
831 /// specified in `related_inputs`.
832 /// ### Syntax
833 /// ``` text
834 /// switching_group() {
835 /// min_input_switching_count : integer ;
836 /// max_input_switching_count : integer ;
837 /// ...
838 /// }
839 /// ```
840 /// ### Example
841 /// ``` text
842 /// switching_group() {
843 /// min_input_switching_count : 1 ;
844 /// max_input_switching_count : 3 ;
845 /// ...
846 /// }
847 /// ```
848 /// <a name ="reference_link" href="
849 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=152.24+153.2&end=152.38+153.7
850 /// ">Reference</a>
851 #[liberty(simple)]
852 pub max_input_switching_count: Option<usize>,
853 /// Use the `pg_current` group to specify current waveform data in a vector group. If all
854 /// vectors under the group are dense, data in this group is represented as a dense table. If
855 /// all vectors under the group are sparse in cross type, data in this group is represented as a
856 /// sparse cross table. If all vectors under the group are sparse in diagonal type, data in this
857 /// group is represented as a sparse diagonal table.
858 /// ``` text
859 /// library (name) {
860 /// cell (name) {
861 /// dynamic_current () {
862 /// ...
863 /// switching_group() {
864 /// ...
865 /// pg_current () {}
866 /// ...
867 /// }
868 /// }
869 /// }
870 /// }
871 /// }
872 /// ```
873 /// Group
874 ///
875 /// `compact_ccs_power`
876 /// <a name ="reference_link" href="
877 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=153.9&end=153.28
878 /// ">Reference</a>
879 #[liberty(group)]
880 pub pg_current: LibertySet<PgCurrent<C>>,
881}
882impl<C: 'static + Ctx> GroupFn<C> for SwitchingGroup<C> {}
883
884/// Use the `pg_current` group to specify current waveform data in a vector group. If all
885/// vectors under the group are dense, data in this group is represented as a dense table. If
886/// all vectors under the group are sparse in cross type, data in this group is represented as a
887/// sparse cross table. If all vectors under the group are sparse in diagonal type, data in this
888/// group is represented as a sparse diagonal table.
889/// ``` text
890/// library (name) {
891/// cell (name) {
892/// dynamic_current () {
893/// ...
894/// switching_group() {
895/// ...
896/// pg_current () {}
897/// ...
898/// }
899/// }
900/// }
901/// }
902/// }
903/// ```
904/// Group
905///
906/// `compact_ccs_power`
907/// <a name ="reference_link" href="
908/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=153.9&end=153.28
909/// ">Reference</a>
910/// <script>
911/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
912/// </script>
913#[derive(Debug, Clone)]
914#[derive(liberty_macros::Group)]
915#[mut_set::derive::item]
916#[derive(serde::Serialize, serde::Deserialize)]
917#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
918pub struct PgCurrent<C: 'static + Ctx> {
919 #[liberty(name)]
920 #[id]
921 pub name: Option<String>,
922 /// group comments
923 #[liberty(comments)]
924 comments: GroupComments,
925 #[liberty(extra_ctx)]
926 pub extra_ctx: C::Other,
927 /// group undefined attributes
928 #[liberty(attributes)]
929 pub attributes: crate::ast::Attributes,
930 /// The `compact_ccs_power` group contains a detailed description for compact CCS
931 /// power data. The `compact_ccs_power` group includes the following optional attributes:
932 /// `base_curves_group`, `index_1`, `index_2`, `index_3` and `index_4`. The description for these
933 /// attributes in the `compact_ccs_power` group is the same as in the `compact_lut_template`
934 /// group. However, the attributes have a higher priority in the `compact_ccs_power` group.
935 /// For more information, see `compact_lut_template` Group on page 41.
936 /// The `index_output` attribute is also optional. It is used only on cross type tables. For
937 /// more information about the `index_output` attribute, see `index_output` Simple Attribute on
938 /// page 156.
939 /// ``` text
940 /// library (name) {
941 /// cell(cell_name) {
942 /// dynamic_current() {
943 /// switching_group() {
944 /// pg_current(pg_pin_name) {
945 /// compact_ccs_power (template_name) {
946 /// base_curves_group : bc_name;
947 /// index_output : pin_name;
948 /// index_1 ("float, ..., float");
949 /// index_2 ("float, ..., float");
950 /// index_3 ("float, ..., float");
951 /// index_4 ("string, ..., string");
952 /// values ("float | integer, ..., float | integer");
953 /// } /* end of compact_ccs_power */
954 /// }
955 /// }
956 /// }
957 /// }
958 /// }
959 /// ```
960 /// Complex Attributes
961 /// `base_curves_group : bc_name;`
962 /// `index_output : pin_name;`
963 /// `index_1 ("float, ..., float");`
964 /// `index_2 ("float, ..., float");`
965 /// `index_3 ("float, ..., float");`
966 /// `index_4 ("string, ..., string");`
967 /// `values ("float | integer, ..., float | integer");`
968 /// <a name ="reference_link" href="
969 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=153.30+154.2&end=153.40+154.25
970 /// ">Reference</a>
971 #[liberty(group)]
972 #[liberty(after_build = CompactCcsPower::use_compact_template)]
973 pub compact_ccs_power: LibertySet<CompactCcsPower<C>>,
974 /// Use the vector group to specify the current waveform for a power and ground pin. This
975 /// group represents a single current waveform based on specified input slew and output load.
976 /// + Data in this group is represented as a dense table, if a template with two
977 /// `total_output_net_capacitance` variables is applied to the group. If a dense table
978 /// is applied, the order of `total_output_net_capacitance` variables must map to the
979 /// order of values in the `related_outputs` attribute.
980 /// + Data in this group is represented as a sparse cross table, if the `index_output` attribute
981 /// is defined in the group.
982 /// + Data in this group is represented as a sparse diagonal table, if no
983 /// `index_output` attribute is defined in the group and a template with exact one
984 /// `total_output_net_capacitance` variable is applied to the group.
985 /// <a name ="reference_link" href="
986 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=155.14&end=155.27
987 /// ">Reference</a>
988 #[liberty(group)]
989 #[liberty(after_build = ReferenceTimeVector3D::use_current_template)]
990 pub vector: LibertyVec<ReferenceTimeVector3D<C>>,
991}
992impl<C: 'static + Ctx> GroupFn<C> for PgCurrent<C> {}
993
994/// The `intrinsic_parasitic` group specifies the state-dependent intrinsic capacitance and
995/// intrinsic resistance of a `cell`.
996/// ### Syntax
997/// ``` text
998/// library( library_name ) {
999/// ......
1000/// lu_table_template ( template_name ) {
1001/// variable_1 : pg_voltage | pg_voltage_difference;
1002/// index_1 ( "float, ..., float" );
1003/// }
1004/// cell (cell_name) {
1005/// mode_definition (mode_name) {
1006/// mode_value (mode_value) {
1007/// when : boolean_expression ;
1008/// sdf_cond : boolean_expression ;
1009/// }
1010/// }
1011/// ...
1012/// intrinsic_parasitic () {
1013/// mode (mode_name, mode_value) ;
1014/// when : boolean expression ;
1015/// intrinsic_resistance(pg_pin_name) {
1016/// related_output : output_pin_name ;
1017/// value : float ;
1018/// reference_pg_pin : pg_pin_name;
1019/// lut_values ( template_name ) {
1020/// index_1 ("float, ... float" );
1021/// values ("float, ... float" );
1022/// }
1023/// }
1024/// intrinsic_capacitance(pg_pin_name) {
1025/// value : float ;
1026/// reference_pg_pin : pg_pin_name;
1027/// lut_values ( template_name ) {
1028/// index_1 ("float, ... float" );
1029/// values ("float, ... float" );
1030/// }
1031/// }
1032/// }
1033/// }
1034/// }
1035/// ```
1036/// Simple Attributes
1037/// + when
1038/// + reference_pg_pin
1039///
1040/// Complex Attribute
1041/// + mode
1042///
1043/// Groups
1044/// + intrinsic_capacitance
1045/// + intrinsic_resistance
1046/// + `total_capacitance`
1047/// <a name ="reference_link" href="
1048/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=176.24+177.2&end=176.49+177.25
1049/// ">Reference</a>
1050/// <script>
1051/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
1052/// </script>
1053#[derive(Debug, Clone)]
1054#[derive(liberty_macros::Group)]
1055#[mut_set::derive::item]
1056#[derive(serde::Serialize, serde::Deserialize)]
1057#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
1058pub struct IntrinsicParasitic<C: 'static + Ctx> {
1059 #[liberty(name)]
1060 pub name: Option<String>,
1061 /// group comments
1062 #[liberty(comments)]
1063 comments: GroupComments,
1064 #[liberty(extra_ctx)]
1065 pub extra_ctx: C::Other,
1066 /// group undefined attributes
1067 #[liberty(attributes)]
1068 pub attributes: crate::ast::Attributes,
1069 #[id]
1070 #[liberty(simple)]
1071 pub when: Option<LogicBooleanExpression>,
1072 /// The `reference_pg_pin` attribute specifies the reference pin for the
1073 /// `intrinsic_resistance` and `intrinsic_capacitance` groups. The reference pin must
1074 /// be a valid PG pin.
1075 ///
1076 /// ### Syntax
1077 /// `reference_pg_pin : pg_pin_name ;`
1078 ///
1079 /// ### Example
1080 /// `reference_pg_pin : G1 ;`
1081 /// <a name ="reference_link" href="
1082 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=178.3&end=178.9
1083 /// ">Reference</a>
1084 #[id]
1085 #[liberty(simple)]
1086 pub reference_pg_pin: Option<String>,
1087 /// The `mode` attribute pertains to an individual `cell`. The cell is active when the `mode` attribute
1088 /// is instantiated with a name and a value. You can specify multiple instances of this attribute.
1089 /// However, specify only one instance for each `cell`.
1090 /// Define the mode attribute within an `intrinsic_parasitic` group.
1091 ///
1092 /// ### Syntax
1093 /// `mode (mode_name, mode_value) ;`
1094 ///
1095 /// ### Example
1096 /// `mode (rw, read) ;`
1097 ///
1098 /// <a name ="reference_link" href="
1099 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=178.11&end=178.18
1100 /// ">Reference</a>
1101 #[liberty(complex)]
1102 pub mode: Option<[String; 2]>,
1103 /// Use this group to specify the intrinsic capacitance of a `cell`.
1104 /// ### Syntax
1105 /// ``` text
1106 /// intrinsic_parasitic () {
1107 /// intrinsic_capacitance (pg_pin_name) {
1108 /// value : float ;
1109 /// reference_pg_pin : pg_pin_name;
1110 /// lut_values ( template_name ) {
1111 /// index_1 ("float, ... float" );
1112 /// values ("float, ... float" );
1113 /// }
1114 /// }
1115 /// }
1116 /// ```
1117 /// The `pg_pin_name` specifies a power and ground pin where the capacitance is derived.
1118 /// You can have more than one `intrinsic_capacitance` group. You can place these
1119 /// groups in any order within an `intrinsic_parasitic` group.
1120 /// <a name ="reference_link" href="
1121 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=178.20&end=178.34
1122 /// ">Reference</a>
1123 #[liberty(group)]
1124 pub intrinsic_capacitance: LibertySet<IntrinsicCapacitance<C>>,
1125 /// Use this group to specify the intrinsic resistance between a power pin and an output pin of
1126 /// a cell.
1127 ///
1128 /// ### Syntax
1129 /// ``` text
1130 /// intrinsic_parasitic () {
1131 /// intrinsic_resistance (pg_pin_name) {
1132 /// related_output : output_pin_name ;
1133 /// value : float ;
1134 /// reference_pg_pin : pg_pin_name;
1135 /// lut_values ( template_name ) {
1136 /// index_1 ("float, ... float" );
1137 /// values ("float, ... float" );
1138 /// }
1139 /// }
1140 /// }
1141 /// ```
1142 /// The `pg_pin_name` specifies a power or ground pin. You can place the
1143 /// `intrinsic_resistance` groups in any order within an `intrinsic_parasitic` group. If
1144 /// some of the `intrinsic_resistance` group is not defined, the value of resistance defaults
1145 /// to +infinity. The channel connection between the power and ground pins and the output
1146 /// pin is defined as a closed channel if the resistance value is greater than 1 megaohm.
1147 /// Otherwise, the channel is opened. The `intrinsic_resistance` group is not required if
1148 /// the channel is closed.
1149 ///
1150 /// Simple Attributes
1151 /// + `related_output`
1152 /// + `value`
1153 /// + `reference_pg_pin`
1154 /// Group
1155 /// + `lut_values`
1156 /// <a name ="reference_link" href="
1157 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=180.10&end=180.36
1158 /// ">Reference</a>
1159 #[liberty(group)]
1160 pub intrinsic_resistance: LibertySet<IntrinsicResistance<C>>,
1161 /// The `total_capacitance` group specifies the macro cell’s total capacitance on a power
1162 /// or ground net within the `intrinsic_parasitic` group. The following applies to the
1163 /// `total_capacitance` group:
1164 /// + The `total_capacitance` group can be placed in any order if there is more than one
1165 /// `total_capacitance` group within an `intrinsic_parasitic` group.
1166 /// + The total capacitance parasitics modeling in macro cells is not state dependent, which
1167 /// means that there is no state condition specified in `intrinsic_parasitic`.
1168 ///
1169 /// ### Syntax
1170 /// ``` text
1171 /// cell (cell_name) {
1172 /// ...
1173 /// intrinsic_parasitic () {
1174 /// total_capacitance (pg_pin_name) {
1175 /// value : float ;
1176 /// }
1177 /// ...
1178 /// }
1179 /// ...
1180 /// }
1181 /// ```
1182 ///
1183 /// ### Example
1184 /// ``` text
1185 /// cell (my_cell) {
1186 /// ...
1187 /// intrinsic_parasitic () {
1188 /// total_capacitance (VDD) {
1189 /// value : 0.2 ;
1190 /// }
1191 /// ...
1192 /// }
1193 /// ...
1194 /// }
1195 /// ```
1196 /// <a name ="reference_link" href="
1197 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=182.12&end=182.42
1198 /// ">Reference</a>
1199 #[liberty(group)]
1200 pub total_capacitance: LibertySet<PgPinWithValue<C>>,
1201}
1202impl<C: 'static + Ctx> GroupFn<C> for IntrinsicParasitic<C> {}
1203
1204/// Use this group to specify the intrinsic capacitance of a `cell`.
1205/// ### Syntax
1206/// ``` text
1207/// intrinsic_parasitic () {
1208/// intrinsic_capacitance (pg_pin_name) {
1209/// value : float ;
1210/// reference_pg_pin : pg_pin_name;
1211/// lut_values ( template_name ) {
1212/// index_1 ("float, ... float" );
1213/// values ("float, ... float" );
1214/// }
1215/// }
1216/// }
1217/// ```
1218/// The `pg_pin_name` specifies a power and ground pin where the capacitance is derived.
1219/// You can have more than one `intrinsic_capacitance` group. You can place these
1220/// groups in any order within an `intrinsic_parasitic` group.
1221/// <a name ="reference_link" href="
1222/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=178.20&end=178.34
1223/// ">Reference</a>
1224/// <script>
1225/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
1226/// </script>
1227#[derive(Debug, Clone)]
1228#[derive(liberty_macros::Group)]
1229#[mut_set::derive::item]
1230#[derive(serde::Serialize, serde::Deserialize)]
1231#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
1232pub struct IntrinsicCapacitance<C: 'static + Ctx> {
1233 #[liberty(name)]
1234 pub name: Option<String>,
1235 /// group comments
1236 #[liberty(comments)]
1237 comments: GroupComments,
1238 #[liberty(extra_ctx)]
1239 pub extra_ctx: C::Other,
1240 /// group undefined attributes
1241 #[liberty(attributes)]
1242 pub attributes: crate::ast::Attributes,
1243 /// The `value` attribute specifies the value of the intrinsic capacitance.
1244 /// By default, the intrinsic capacitance value is zero.
1245 /// <a name ="reference_link" href="
1246 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=179.8&end=179.9
1247 /// ">Reference</a>
1248 #[id(into_hash_ord_fn = crate::common::f64_into_hash_ord_fn)]
1249 #[liberty(simple)]
1250 pub value: f64,
1251 /// The `reference_pg_pin` attribute specifies the reference pin for the
1252 /// `intrinsic_resistance` and `intrinsic_capacitance` groups. The reference pin must
1253 /// be a valid PG pin.
1254 /// ### Syntax
1255 /// `reference_pg_pin : pg_pin_name ;`
1256 ///
1257 /// ### Example
1258 /// `reference_pg_pin : G1 ;`
1259 /// <a name ="reference_link" href="
1260 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=179.15&end=179.21
1261 /// ">Reference</a>
1262 #[id]
1263 #[liberty(simple)]
1264 pub reference_pg_pin: Option<String>,
1265 /// Voltage-dependent intrinsic parasitics are modeled by lookup tables. A lookup table
1266 /// consists of intrinsic parasitic values for different values of VDD. To use these lookup
1267 /// tables, define the `lut_values` group. You can add the `lut_values` group to both the
1268 /// `intrinsic_resistance` and `intrinsic_capacitance` groups. The `lut_values` group
1269 /// uses the `variable_1` variable, which is defined within the `lu_table_template` group,
1270 /// at the library level. The valid values of the `variable_1` variable are `pg_voltage` and
1271 /// `pg_voltage_difference`.
1272 ///
1273 /// ### Syntax
1274 /// ``` text
1275 /// lut_values ( template_name ) {
1276 /// index_1 ("float, ... float" );
1277 /// values ("float, ... float" );
1278 /// }
1279 /// ```
1280 ///
1281 /// ### Example
1282 /// ``` text
1283 /// lut_values ( test_voltage ) {
1284 /// index_1 ( "0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0" );
1285 /// values ( "0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0" );
1286 /// }
1287 /// ```
1288 /// <a name ="reference_link" href="
1289 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=179.23+180.2&end=179.34+180.8
1290 /// ">Reference</a>
1291 #[liberty(group)]
1292 pub lut_values: Option<LutValues<C>>,
1293}
1294impl<C: 'static + Ctx> GroupFn<C> for IntrinsicCapacitance<C> {}
1295
1296/// Use this group to specify the intrinsic resistance between a power pin and an output pin of
1297/// a cell.
1298///
1299/// ### Syntax
1300/// ``` text
1301/// intrinsic_parasitic () {
1302/// intrinsic_resistance (pg_pin_name) {
1303/// related_output : output_pin_name ;
1304/// value : float ;
1305/// reference_pg_pin : pg_pin_name;
1306/// lut_values ( template_name ) {
1307/// index_1 ("float, ... float" );
1308/// values ("float, ... float" );
1309/// }
1310/// }
1311/// }
1312/// ```
1313/// The `pg_pin_name` specifies a power or ground pin. You can place the
1314/// `intrinsic_resistance` groups in any order within an `intrinsic_parasitic` group. If
1315/// some of the `intrinsic_resistance` group is not defined, the value of resistance defaults
1316/// to +infinity. The channel connection between the power and ground pins and the output
1317/// pin is defined as a closed channel if the resistance value is greater than 1 megaohm.
1318/// Otherwise, the channel is opened. The `intrinsic_resistance` group is not required if
1319/// the channel is closed.
1320///
1321/// Simple Attributes
1322/// + `related_output`
1323/// + `value`
1324/// + `reference_pg_pin`
1325/// Group
1326/// + `lut_values`
1327/// <a name ="reference_link" href="
1328/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=180.10&end=180.36
1329/// ">Reference</a>
1330/// <script>
1331/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
1332/// </script>
1333#[derive(Debug, Clone)]
1334#[derive(liberty_macros::Group)]
1335#[mut_set::derive::item]
1336#[derive(serde::Serialize, serde::Deserialize)]
1337#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
1338pub struct IntrinsicResistance<C: 'static + Ctx> {
1339 #[liberty(name)]
1340 pub name: Option<String>,
1341 /// group comments
1342 #[liberty(comments)]
1343 comments: GroupComments,
1344 #[liberty(extra_ctx)]
1345 pub extra_ctx: C::Other,
1346 /// group undefined attributes
1347 #[liberty(attributes)]
1348 pub attributes: crate::ast::Attributes,
1349 /// Specifies the value of the intrinsic resistance. If this attribute is not defined, the value of
1350 /// the intrinsic resistance defaults to +infinity.
1351 /// <a name ="reference_link" href="
1352 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=181.9&end=181.10
1353 /// ">Reference</a>
1354 #[liberty(simple)]
1355 #[liberty(default = f64::INFINITY)]
1356 pub value: f64,
1357 /// Use this attribute to specify the output pin.
1358 /// ### Syntax
1359 /// ``` text
1360 /// related_output : output_pin_name ;
1361 /// ``` text
1362 ///
1363 /// `output_pin_name`
1364 /// The name of the output pin.
1365 /// ### Example
1366 /// `related_output : "A & B" ;`
1367 /// <a name ="reference_link" href="
1368 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=179.15&end=179.21
1369 /// ">Reference</a>
1370 #[id]
1371 #[liberty(simple)]
1372 pub related_output: Option<String>,
1373 /// The `reference_pg_pin` attribute specifies the reference pin for the
1374 /// `intrinsic_resistance` and `intrinsic_capacitance` groups. The reference pin must
1375 /// be a valid PG pin.
1376 /// ### Syntax
1377 /// `reference_pg_pin : pg_pin_name ;`
1378 ///
1379 /// ### Example
1380 /// `reference_pg_pin : G1 ;`
1381 /// <a name ="reference_link" href="
1382 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=179.15&end=179.21
1383 /// ">Reference</a>
1384 #[id]
1385 #[liberty(simple)]
1386 pub reference_pg_pin: Option<String>,
1387 /// Voltage-dependent intrinsic parasitics are modeled by lookup tables. A lookup table
1388 /// consists of intrinsic parasitic values for different values of VDD. To use these lookup
1389 /// tables, define the `lut_values` group. You can add the `lut_values` group to both the
1390 /// `intrinsic_resistance` and `intrinsic_capacitance` groups. The `lut_values` group
1391 /// uses the `variable_1` variable, which is defined within the `lu_table_template` group,
1392 /// at the library level. The valid values of the `variable_1` variable are `pg_voltage` and
1393 /// `pg_voltage_difference`.
1394 ///
1395 /// ### Syntax
1396 /// ``` text
1397 /// lut_values ( template_name ) {
1398 /// index_1 ("float, ... float" );
1399 /// values ("float, ... float" );
1400 /// }
1401 /// ```
1402 ///
1403 /// ### Example
1404 /// ``` text
1405 /// lut_values ( test_voltage ) {
1406 /// index_1 ( "0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0" );
1407 /// values ( "0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0" );
1408 /// }
1409 /// ```
1410 /// <a name ="reference_link" href="
1411 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=179.23+180.2&end=179.34+180.8
1412 /// ">Reference</a>
1413 #[liberty(group)]
1414 pub lut_values: Option<LutValues<C>>,
1415}
1416impl<C: 'static + Ctx> GroupFn<C> for IntrinsicResistance<C> {}
1417
1418/// The `total_capacitance` group specifies the macro cell’s total capacitance on a power
1419/// or ground net within the `intrinsic_parasitic` group. The following applies to the
1420/// `total_capacitance` group:
1421/// + The `total_capacitance` group can be placed in any order if there is more than one
1422/// `total_capacitance` group within an `intrinsic_parasitic` group.
1423/// + The total capacitance parasitics modeling in macro cells is not state dependent, which
1424/// means that there is no state condition specified in `intrinsic_parasitic`.
1425///
1426/// ### Syntax
1427/// ``` text
1428/// cell (cell_name) {
1429/// ...
1430/// intrinsic_parasitic () {
1431/// total_capacitance (pg_pin_name) {
1432/// value : float ;
1433/// }
1434/// ...
1435/// }
1436/// ...
1437/// }
1438/// ```
1439///
1440/// ### Example
1441/// ``` text
1442/// cell (my_cell) {
1443/// ...
1444/// intrinsic_parasitic () {
1445/// total_capacitance (VDD) {
1446/// value : 0.2 ;
1447/// }
1448/// ...
1449/// }
1450/// ...
1451/// }
1452/// ```
1453/// <a name ="reference_link" href="
1454/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=182.12&end=182.42
1455/// ">Reference</a>
1456/// <script>
1457/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
1458/// </script>
1459#[derive(Debug, Clone)]
1460#[derive(liberty_macros::Group)]
1461#[mut_set::derive::item]
1462#[derive(serde::Serialize, serde::Deserialize)]
1463#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
1464pub struct PgPinWithValue<C: 'static + Ctx> {
1465 #[id]
1466 #[liberty(name)]
1467 pg_pin_name: Option<String>,
1468 /// group comments
1469 #[liberty(comments)]
1470 comments: GroupComments,
1471 #[liberty(extra_ctx)]
1472 pub extra_ctx: C::Other,
1473 /// group undefined attributes
1474 #[liberty(attributes)]
1475 pub attributes: crate::ast::Attributes,
1476 #[liberty(simple)]
1477 pub value: f64,
1478}
1479impl<C: 'static + Ctx> GroupFn<C> for PgPinWithValue<C> {}
1480
1481/// The `gate_leakage` group specifies the cell’s gate leakage current on input or inout pins
1482/// within the `leakage_current` group in a cell. The following applies to `gate_leakage`
1483///
1484/// groups:
1485/// + Groups can be placed in any order if there is more than one `gate_leakage` group
1486/// within a `leakage_current` group.
1487/// + The leakage current of a cell is characterized with opened outputs, which means that
1488/// modeling cell outputs do not drive any other cells. Outputs are assumed to have zero
1489/// static current during the measurement.
1490/// + A missing `gate_leakage` group is allowed for certain pins.
1491/// + Current conservation is applicable if it can be applied to higher error tolerance.
1492/// ### Syntax
1493/// `gate_leakage (input_pin_name)`
1494///
1495/// ### Example
1496/// ``` text
1497/// cell (my_cell) {
1498/// ...
1499/// leakage_current {
1500/// ...
1501/// }
1502/// ...
1503/// gate_leakage (A) {
1504/// input_low_value : -0.5 ;
1505/// input_high_value : 0.6 ;
1506/// }
1507/// }
1508/// ```
1509/// Simple Attributes
1510/// + `input_low_value`
1511/// + `input_high_value`
1512/// <a name ="reference_link" href="
1513/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=197.9&end=197.38
1514/// ">Reference</a>
1515/// <script>
1516/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
1517/// </script>
1518#[derive(Debug, Clone)]
1519#[derive(liberty_macros::Group)]
1520#[mut_set::derive::item]
1521#[derive(serde::Serialize, serde::Deserialize)]
1522#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
1523pub struct GateLeakage<C: 'static + Ctx> {
1524 #[id]
1525 #[liberty(name)]
1526 input_pin_name: Option<String>,
1527 /// group comments
1528 #[liberty(comments)]
1529 comments: GroupComments,
1530 #[liberty(extra_ctx)]
1531 pub extra_ctx: C::Other,
1532 /// group undefined attributes
1533 #[liberty(attributes)]
1534 pub attributes: crate::ast::Attributes,
1535 /// The `input_low_value` attribute specifies gate leakage current on an input or inout pin
1536 /// when the pin is in a low state condition.
1537 /// The following applies to the `input_low_value` attribute:
1538 /// + A negative floating-point number value is required.
1539 /// + The gate leakage current flow is measured from the power pin of a cell to the ground
1540 /// pin of its driver cell.
1541 /// + The input pin is pulled up to low.
1542 /// + The `input_low_value` attribute is not required for a `gate_leakage` group.
1543 /// <a name ="reference_link" href="
1544 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=198.3&end=198.22
1545 /// ">Reference</a>
1546 #[liberty(simple)]
1547 pub input_low_value: Option<f64>,
1548 /// The `input_high_value` attribute specifies gate leakage current on an input or inout pin
1549 /// when the pin is in a high state condition.
1550 /// + The gate leakage current flow is measured from the power pin of its driver cell to the
1551 /// ground pin of the cell itself.
1552 /// + A positive floating-point number value is required.
1553 /// + The input pin is pulled up to high.
1554 /// + The `input_high_value` attribute is not required for a `gate_leakage` group.
1555 /// <a name ="reference_link" href="
1556 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=198.24&end=198.38
1557 /// ">Reference</a>
1558 #[liberty(simple)]
1559 pub input_high_value: Option<f64>,
1560}
1561impl<C: 'static + Ctx> GroupFn<C> for GateLeakage<C> {}
1562
1563/// A `leakage_current` group is defined within a cell group or a model group to specify
1564/// leakage current values that are dependent on the state of the cell.
1565///
1566/// ### Syntax
1567/// ``` text
1568/// library (name) {
1569/// cell(cell_name) {
1570/// ...
1571/// leakage_current() {
1572/// when : boolean expression;
1573/// pg_current(pg_pin_name) {
1574/// value : float;
1575/// }
1576/// ...
1577/// }
1578/// }
1579/// ```
1580/// Simple Attributes
1581/// + when
1582/// + value
1583///
1584/// Complex Attribute
1585/// + mode
1586///
1587/// Group
1588/// + pg_current
1589/// <a name ="reference_link" href="
1590/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=194.49+195.2&end=194.50+195.20
1591/// ">Reference</a>
1592/// <script>
1593/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
1594/// </script>
1595#[derive(Debug, Clone)]
1596#[derive(liberty_macros::Group)]
1597#[mut_set::derive::item]
1598#[derive(serde::Serialize, serde::Deserialize)]
1599#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
1600pub struct LeakageCurrent<C: 'static + Ctx> {
1601 #[liberty(name)]
1602 pub name: Option<String>,
1603 /// group comments
1604 #[liberty(comments)]
1605 comments: GroupComments,
1606 #[liberty(extra_ctx)]
1607 pub extra_ctx: C::Other,
1608 /// group undefined attributes
1609 #[liberty(attributes)]
1610 pub attributes: crate::ast::Attributes,
1611 #[id]
1612 #[liberty(simple)]
1613 pub when: Option<LogicBooleanExpression>,
1614 /// When a cell has a single power and ground pin, omit the `pg_current` group and specify
1615 /// the leakage current value. Otherwise, specify the value in the `pg_current` group. Current
1616 /// conservation is applied for each `leakage_current` group. The value attribute specifies
1617 /// the absolute value of leakage current on a single power and ground pin.
1618 /// <a name ="reference_link" href="
1619 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=195.34+196.2&end=195.35+196.9
1620 /// ">Reference</a>
1621 #[liberty(simple)]
1622 pub value: Option<f64>,
1623 /// The `mode` attribute pertains to an individual `cell`. The cell is active when the `mode` attribute
1624 /// is instantiated with a name and a value. You can specify multiple instances of this attribute.
1625 /// However, specify only one instance for each `cell`.
1626 /// Define the mode attribute within an `intrinsic_parasitic` group.
1627 ///
1628 /// ### Syntax
1629 /// `mode (mode_name, mode_value) ;`
1630 ///
1631 /// ### Example
1632 /// `mode (rw, read) ;`
1633 ///
1634 /// <a name ="reference_link" href="
1635 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=178.11&end=178.18
1636 /// ">Reference</a>
1637 #[liberty(complex)]
1638 pub mode: Option<[String; 2]>,
1639 /// Use this group to specify a power or ground pin where leakage current is to be measured.
1640 ///
1641 /// ### Syntax
1642 /// ``` text
1643 /// cell(cell_name) {
1644 /// ...
1645 /// leakage_current() {
1646 /// when : boolean expression;
1647 /// pg_current(pg_pin_name) {
1648 /// value : float;
1649 /// }
1650 /// }
1651 /// }
1652 /// ```
1653 /// `pg_pin_name`
1654 ///
1655 /// Specifies the power or ground pin where the leakage current is to be measured.
1656 /// Simple Attribute
1657 ///
1658 /// `value`
1659 ///
1660 /// Use this attribute in the `pg_current` group to specify the leakage current value when a cell
1661 /// has multiple power and ground pins. The leakage current is measured toward a cell. For
1662 /// power pins, the current is positive if it is dragged into a cell. For ground pins, the current
1663 /// is negative, indicating that current flows out of a cell. If all power and ground pins are
1664 /// specified within a `leakage_current` group, the sum of the leakage currents should be
1665 /// zero.
1666 /// <a name ="reference_link" href="
1667 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=196.17&end=196.36
1668 /// ">Reference</a>
1669 #[liberty(group)]
1670 pub pg_current: LibertySet<PgPinWithValue<C>>,
1671 /// The `gate_leakage` group specifies the cell’s gate leakage current on input or inout pins
1672 /// within the `leakage_current` group in a cell. The following applies to `gate_leakage`
1673 ///
1674 /// groups:
1675 /// + Groups can be placed in any order if there is more than one `gate_leakage` group
1676 /// within a `leakage_current` group.
1677 /// + The leakage current of a cell is characterized with opened outputs, which means that
1678 /// modeling cell outputs do not drive any other cells. Outputs are assumed to have zero
1679 /// static current during the measurement.
1680 /// + A missing `gate_leakage` group is allowed for certain pins.
1681 /// + Current conservation is applicable if it can be applied to higher error tolerance.
1682 /// ### Syntax
1683 /// `gate_leakage (input_pin_name)`
1684 ///
1685 /// ### Example
1686 /// ``` text
1687 /// cell (my_cell) {
1688 /// ...
1689 /// leakage_current {
1690 /// ...
1691 /// }
1692 /// ...
1693 /// gate_leakage (A) {
1694 /// input_low_value : -0.5 ;
1695 /// input_high_value : 0.6 ;
1696 /// }
1697 /// }
1698 /// ```
1699 /// Simple Attributes
1700 /// + `input_low_value`
1701 /// + `input_high_value`
1702 /// <a name ="reference_link" href="
1703 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=197.9&end=197.38
1704 /// ">Reference</a>
1705 #[liberty(group)]
1706 pub gate_leakage: LibertySet<GateLeakage<C>>,
1707}
1708impl<C: 'static + Ctx> GroupFn<C> for LeakageCurrent<C> {}
1709
1710/// Voltage-dependent intrinsic parasitics are modeled by lookup tables. A lookup table
1711/// consists of intrinsic parasitic values for different values of VDD. To use these lookup
1712/// tables, define the `lut_values` group. You can add the `lut_values` group to both the
1713/// `intrinsic_resistance` and `intrinsic_capacitance` groups. The `lut_values` group
1714/// uses the `variable_1` variable, which is defined within the `lu_table_template` group,
1715/// at the library level. The valid values of the `variable_1` variable are `pg_voltage` and
1716/// `pg_voltage_difference`.
1717///
1718/// ### Syntax
1719/// ``` text
1720/// lut_values ( template_name ) {
1721/// index_1 ("float, ... float" );
1722/// values ("float, ... float" );
1723/// }
1724/// ```
1725///
1726/// ### Example
1727/// ``` text
1728/// lut_values ( test_voltage ) {
1729/// index_1 ( "0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0" );
1730/// values ( "0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0" );
1731/// }
1732/// ```
1733/// <a name ="reference_link" href="
1734/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=179.23+180.2&end=179.34+180.8
1735/// ">Reference</a>
1736/// <script>
1737/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
1738/// </script>
1739#[derive(Debug, Clone)]
1740#[derive(liberty_macros::Group)]
1741#[derive(serde::Serialize, serde::Deserialize)]
1742#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
1743pub struct LutValues<C: 'static + Ctx> {
1744 #[liberty(name)]
1745 pub name: Option<String>,
1746 /// group comments
1747 #[liberty(comments)]
1748 comments: GroupComments,
1749 #[liberty(extra_ctx)]
1750 pub extra_ctx: C::Other,
1751 /// group undefined attributes
1752 #[liberty(attributes)]
1753 pub attributes: crate::ast::Attributes,
1754 #[liberty(complex)]
1755 pub index_1: Vec<f64>,
1756 #[liberty(complex)]
1757 pub values: Vec<f64>,
1758}
1759impl<C: 'static + Ctx> GroupFn<C> for LutValues<C> {}
1760
1761/// Use the optional `pg_type` attribute to specify the type of power and ground pin.
1762/// The `pg_type` attribute also supports back-bias modeling.
1763/// The `pg_type` attribute can have the following values:
1764/// + `primary_power`
1765/// + `primary_ground`
1766/// + `backup_power`
1767/// + `backup_ground`
1768/// + `internal_power`
1769/// + `internal_ground`
1770/// + `pwell`
1771/// + `nwell`
1772/// + `deepnwell`
1773/// + `deeppwell`
1774///
1775/// The `pwell` and `nwell` values specify regular wells,
1776/// and the `deeppwell` and `deepnwell` values specify isolation wells.
1777/// <a name ="reference_link" href="
1778/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=210.8&end=210.13
1779/// ">Reference-Definition</a>
1780#[derive(Debug, Clone, Copy)]
1781#[derive(Hash, PartialEq, Eq)]
1782#[derive(Ord, PartialOrd, Default)]
1783#[derive(strum::EnumString, strum::EnumIter, strum::Display, strum::IntoStaticStr)]
1784#[derive(serde::Serialize, serde::Deserialize)]
1785pub enum PgType {
1786 /// `primary_power`
1787 #[strum(serialize = "primary_power")]
1788 PrimaryPower,
1789 /// `primary_ground`
1790 #[strum(serialize = "primary_ground")]
1791 PrimaryGround,
1792 /// `backup_power`
1793 #[strum(serialize = "backup_power")]
1794 BackupPower,
1795 /// `backup_ground`
1796 #[strum(serialize = "backup_ground")]
1797 #[default]
1798 BackupGround,
1799 /// `internal_power`
1800 #[strum(serialize = "internal_power")]
1801 InternalPower,
1802 /// `internal_ground`
1803 #[strum(serialize = "internal_ground")]
1804 InternalGround,
1805 /// `pwell`
1806 #[strum(serialize = "pwell")]
1807 Pwell,
1808 /// `nwell`
1809 #[strum(serialize = "nwell")]
1810 Nwell,
1811 /// `deepnwell`
1812 #[strum(serialize = "deepnwell")]
1813 DeepNwell,
1814 /// `deeppwell`
1815 #[strum(serialize = "deeppwell")]
1816 DeepPwell,
1817}
1818crate::ast::impl_self_builder!(PgType);
1819crate::ast::impl_simple!(PgType);
1820
1821/// The `switch_cell_type` cell-level attribute specifies
1822/// the type of the switch cell for direct inference.
1823///
1824/// ### Syntax:
1825/// ``` text
1826/// switch_cell_type : coarse_grain | fine_grain;
1827/// ``` text
1828/// <a name ="reference_link" href="
1829/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=210.8&end=210.13
1830/// ">Reference-Definition</a>
1831#[derive(Debug, Clone, Copy)]
1832#[derive(Hash, PartialEq, Eq)]
1833#[derive(Ord, PartialOrd)]
1834#[derive(strum::EnumString, strum::EnumIter, strum::Display)]
1835#[derive(serde::Serialize, serde::Deserialize)]
1836pub enum SwitchCellType {
1837 /// `coarse_grain`
1838 #[strum(serialize = "coarse_grain")]
1839 CoarseGrain,
1840 /// `fine_grain`
1841 #[strum(serialize = "fine_grain")]
1842 FineGrain,
1843}
1844crate::ast::impl_self_builder!(SwitchCellType);
1845crate::ast::impl_simple!(SwitchCellType);
1846
1847/// interprets a combination timing arc between the clock pin and the output pin as a rising edge arc or as a falling edge arc
1848///
1849/// Valid values are `rising_edge_clock_cell` and `falling_edge_clock_cell`.
1850/// <a name ="reference_link" href="
1851/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=109.29+109.36&end=109.30+109.37
1852/// ">Reference</a>
1853#[derive(Debug, Clone, Copy)]
1854#[derive(Hash, PartialEq, Eq)]
1855#[derive(Ord, PartialOrd)]
1856#[derive(strum::EnumString, strum::EnumIter, strum::Display)]
1857#[derive(serde::Serialize, serde::Deserialize)]
1858pub enum FpgaCellType {
1859 /// `rising_edge_clock_cell`
1860 #[strum(serialize = "rising_edge_clock_cell")]
1861 RisingEdgeClockCell,
1862 /// `falling_edge_clock_cell`
1863 #[strum(serialize = "falling_edge_clock_cell")]
1864 FallingEdgeClockCell,
1865}
1866crate::ast::impl_self_builder!(FpgaCellType);
1867crate::ast::impl_simple!(FpgaCellType);
1868
1869/// The `level_shifter_type` attribute specifies the
1870/// voltage conversion type that is supported.
1871/// Valid values are:
1872///
1873/// + `LH`: Low to High
1874/// + `HL`: High to Low
1875/// + `HL_LH`: High to Low and Low to High
1876///
1877/// The `level_shifter_type` attribute is optional
1878/// <a name ="reference_link" href="
1879/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=115.9&end=115.17
1880/// ">Reference</a>
1881#[expect(non_camel_case_types)]
1882#[derive(Debug, Clone, Copy)]
1883#[derive(Hash, PartialEq, Eq)]
1884#[derive(Ord, PartialOrd)]
1885#[derive(strum::EnumString, strum::EnumIter, strum::Display)]
1886#[derive(serde::Serialize, serde::Deserialize)]
1887pub enum LevelShifterType {
1888 /// `LH`: Low to High
1889 #[strum(serialize = "LH")]
1890 LH,
1891 /// `HL`: High to Low
1892 #[strum(serialize = "HL")]
1893 HL,
1894 /// `HL_LH`: High to Low and Low to High
1895 #[strum(serialize = "HL_LH")]
1896 HL_LH,
1897}
1898crate::ast::impl_self_builder!(LevelShifterType);
1899crate::ast::impl_simple!(LevelShifterType);
1900
1901/// You can use the `clock_gating_integrated_cell` attribute to enter specific
1902/// values that determine which integrated cell functionality the clock-gating tool uses.
1903///
1904/// ### Syntax:
1905/// ```text
1906/// clock_gating_integrated_cell:generic|value_id;
1907/// ``` text
1908/// <a name ="reference_link" href="
1909/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=103.19&end=103.24
1910/// ">Reference</a>
1911#[derive(Debug, Clone)]
1912#[derive(Hash, PartialEq, Eq)]
1913#[derive(Ord, PartialOrd)]
1914#[derive(serde::Serialize, serde::Deserialize)]
1915pub enum ClockGatingIntegratedCell {
1916 ContainlatchNegedge,
1917 RegisterslatchPosedgePostcontrol,
1918 LatchlatchNegedgePrecontrol,
1919 LatchnonePosedgeControlObs,
1920 /// by accessing the state tables and state functions of the library cell pins
1921 Generic(String),
1922}
1923impl FromStr for ClockGatingIntegratedCell {
1924 type Err = ();
1925 #[inline]
1926 fn from_str(s: &str) -> Result<Self, Self::Err> {
1927 match s {
1928 "containlatch_negedge" => Ok(Self::ContainlatchNegedge),
1929 "registerslatch_posedge_postcontrol" => Ok(Self::RegisterslatchPosedgePostcontrol),
1930 "latchlatch_negedge_precontrol" => Ok(Self::LatchlatchNegedgePrecontrol),
1931 "latchnone_posedge_control_obs" => Ok(Self::LatchnonePosedgeControlObs),
1932 _ => Ok(Self::Generic(s.into())),
1933 }
1934 }
1935}
1936
1937impl fmt::Display for ClockGatingIntegratedCell {
1938 #[inline]
1939 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1940 match self {
1941 Self::ContainlatchNegedge => write!(f, "containlatch_negedge"),
1942 Self::RegisterslatchPosedgePostcontrol => {
1943 write!(f, "registerslatch_posedge_postcontrol")
1944 }
1945 Self::LatchlatchNegedgePrecontrol => write!(f, "latchlatch_negedge_precontrol"),
1946 Self::LatchnonePosedgeControlObs => write!(f, "latchnone_posedge_control_obs"),
1947 Self::Generic(s) => write!(f, "{s}"),
1948 }
1949 }
1950}
1951crate::ast::impl_self_builder!(ClockGatingIntegratedCell);
1952crate::ast::impl_simple!(ClockGatingIntegratedCell);
1953
1954/// Use the `pin_opposite` attribute to describe functionally opposite (logically inverse) groups
1955/// of input or output pins.
1956/// ### Syntax
1957///
1958/// ``` text
1959/// pin_opposite ("name_list1", "name_list2") ;
1960/// ``` text
1961///
1962/// + `name_list1`: A `name_list` of output pins requires the supplied output values to be opposite.
1963/// + `name_list2`: A `name_list` of input pins requires the supplied input values to be opposite.
1964///
1965/// In the following example, pins IP and OP are logically inverse.
1966/// ``` text
1967/// pin_opposite ("IP", "OP") ;
1968/// ``` text
1969/// The `pin_opposite` attribute also incorporates the functionality of the `pin_equal` complex
1970/// attribute.
1971///
1972/// In the following example, Q1, Q2, and Q3 are equal; QB1 and QB2 are equal; and the pins
1973/// in the first group are opposite of the pins in the second group.
1974/// ``` text
1975/// pin_opposite ("Q1 Q2 Q3", "QB1 QB2") ;
1976/// ``` text
1977/// <a name ="reference_link" href="
1978/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=124.9&end=124.22
1979/// ">Reference</a>
1980#[derive(Debug, Clone)]
1981#[derive(Hash, PartialEq, Eq)]
1982#[derive(Ord, PartialOrd)]
1983#[derive(serde::Serialize, serde::Deserialize)]
1984pub struct PinOpposite {
1985 pub name_list1: WordSet,
1986 pub name_list2: WordSet,
1987}
1988crate::ast::impl_self_builder!(PinOpposite);
1989impl<C: 'static + Ctx> ComplexAttri<C> for PinOpposite {
1990 #[inline]
1991 fn parse<'a, I: Iterator<Item = &'a &'a str>>(
1992 mut iter: I,
1993 _scope: &mut ParseScope<'_>,
1994 ) -> Result<Self, ComplexParseError> {
1995 let name_list1: WordSet = match iter.next() {
1996 Some(&s) => match s.parse() {
1997 Ok(f) => f,
1998 Err(_) => return Err(ComplexParseError::Other),
1999 },
2000 None => return Err(ComplexParseError::LengthDismatch),
2001 };
2002 let name_list2: WordSet = match iter.next() {
2003 Some(&s) => match s.parse() {
2004 Ok(f) => f,
2005 Err(_) => return Err(ComplexParseError::Other),
2006 },
2007 None => return Err(ComplexParseError::LengthDismatch),
2008 };
2009 if iter.next().is_some() {
2010 Err(ComplexParseError::LengthDismatch)
2011 } else {
2012 Ok(Self { name_list1, name_list2 })
2013 }
2014 }
2015 #[inline]
2016 fn fmt_self<T: Write, I: Indentation>(
2017 &self,
2018 f: &mut CodeFormatter<'_, T, I>,
2019 ) -> fmt::Result {
2020 write!(f, "{}, {}", self.name_list1, self.name_list2)
2021 }
2022}
2023
2024/// The `retention_condition` group includes attributes that specify the conditions for the
2025/// retention cell to hold its state during the retention mode.
2026/// <a name ="reference_link" href="
2027/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=215.18&end=215.23
2028/// ">Reference</a>
2029/// <script>
2030/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
2031/// </script>
2032#[derive(Debug, Clone)]
2033#[derive(liberty_macros::Group)]
2034#[derive(serde::Serialize, serde::Deserialize)]
2035#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
2036pub struct RetentionCondition<C: 'static + Ctx> {
2037 /// group comments
2038 #[liberty(comments)]
2039 comments: GroupComments,
2040 #[liberty(extra_ctx)]
2041 pub extra_ctx: C::Other,
2042 /// group undefined attributes
2043 #[liberty(attributes)]
2044 pub attributes: crate::ast::Attributes,
2045 /// The `power_down_function` attribute specifies the Boolean condition for the retention
2046 /// cell to be powered down, that is, the primary power to the cell is shut down. When this
2047 /// Boolean condition evaluates to true, it triggers the evaluation of the control input conditions
2048 /// specified by the `required_condition` attribute.
2049 /// <a name ="reference_link" href="
2050 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=215.27&end=215.33
2051 /// ">Reference</a>
2052 #[liberty(simple)]
2053 pub power_down_function: Option<PowerGroundBooleanExpression>,
2054 /// The `required_condition` attribute specifies the control input conditions during the
2055 /// retention mode. These conditions are checked when the primary power to the retention
2056 /// cell is shut down. If these conditions are not met, the cell is considered to be in an illegal
2057 /// state.
2058 ///
2059 /// Note:
2060 ///
2061 /// Within the `retention_condition` group, the `power_down_function` attribute
2062 /// by itself does not specify the retention mode of the cell. The conditions specified
2063 /// by the `required_condition` attribute ensure that the retention control pin is in
2064 /// the correct state when the primary power to the cell is shut down.
2065 /// <a name ="reference_link" href="
2066 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=216.4&end=216.17
2067 /// ">Reference</a>
2068 #[liberty(simple)]
2069 pub required_condition: Option<LogicBooleanExpression>,
2070}
2071impl<C: 'static + Ctx> GroupFn<C> for RetentionCondition<C> {}
2072
2073/// The `preset_condition` group is a group of attributes for a condition check on the normal
2074/// mode preset expression.
2075///
2076/// If preset is asserted during the restore operation, it needs to extend beyond the restore
2077/// operation time period so that the flip-flop content can be successfully overwritten.
2078/// Therefore, trailing-edge condition checks on preset pins might be needed.
2079/// <a name ="reference_link" href="
2080/// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=214.23&end=214.27
2081/// ">Reference</a>
2082/// <script>
2083/// IFRAME('https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html');
2084/// </script>
2085#[derive(Debug, Clone)]
2086#[derive(liberty_macros::Group)]
2087#[derive(serde::Serialize, serde::Deserialize)]
2088#[serde(bound = "C::Other: serde::Serialize + serde::de::DeserializeOwned")]
2089pub struct RresetCondition<C: 'static + Ctx> {
2090 /// group comments
2091 #[liberty(comments)]
2092 comments: GroupComments,
2093 #[liberty(extra_ctx)]
2094 pub extra_ctx: C::Other,
2095 /// group undefined attributes
2096 #[liberty(attributes)]
2097 pub attributes: crate::ast::Attributes,
2098 /// The `input` attribute should be identical to the `preset` attribute in the `ff` group and defines
2099 /// how the asynchronous preset control is asserted.
2100 /// <a name ="reference_link" href="
2101 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=215.5&end=215.7
2102 /// ">Reference</a>
2103 #[liberty(simple)]
2104 pub input: Option<LogicBooleanExpression>,
2105 /// The `required_condition` attribute specifies the condition that the input attribute is
2106 /// required to be and is evaluated at the positive edge of the `clocked_on` attribute in the
2107 /// `clock_condition` group. If the expression evaluates to false, the cell is in an illegal
2108 /// state.
2109 /// <a name ="reference_link" href="
2110 /// https://zao111222333.github.io/liberty-db/2020.09/reference_manual.html?field=null&bgn=215.10&end=215.13
2111 /// ">Reference</a>
2112 #[liberty(simple)]
2113 pub required_condition: Option<LogicBooleanExpression>,
2114}
2115impl<C: 'static + Ctx> GroupFn<C> for RresetCondition<C> {}