1use crate::*;
2
3#[tracable_parser]
6#[packrat_parser]
7pub(crate) fn gate_instantiation(s: Span) -> IResult<Span, GateInstantiation> {
8 alt((
9 gate_instantiation_cmos,
10 gate_instantiation_enable,
11 gate_instantiation_mos,
12 gate_instantiation_n_input,
13 gate_instantiation_n_output,
14 gate_instantiation_pass_en,
15 gate_instantiation_pass,
16 gate_instantiation_pulldown,
17 gate_instantiation_pullup,
18 ))(s)
19}
20
21#[tracable_parser]
22#[packrat_parser]
23pub(crate) fn gate_instantiation_cmos(s: Span) -> IResult<Span, GateInstantiation> {
24 let (s, a) = cmos_switchtype(s)?;
25 let (s, b) = opt(delay3)(s)?;
26 let (s, c) = list(symbol(","), cmos_switch_instance)(s)?;
27 let (s, d) = symbol(";")(s)?;
28 Ok((
29 s,
30 GateInstantiation::Cmos(Box::new(GateInstantiationCmos {
31 nodes: (a, b, c, d),
32 })),
33 ))
34}
35
36#[tracable_parser]
37#[packrat_parser]
38pub(crate) fn gate_instantiation_enable(s: Span) -> IResult<Span, GateInstantiation> {
39 let (s, a) = enable_gatetype(s)?;
40 let (s, b) = opt(drive_strength)(s)?;
41 let (s, c) = opt(delay3)(s)?;
42 let (s, d) = list(symbol(","), enable_gate_instance)(s)?;
43 let (s, e) = symbol(";")(s)?;
44 Ok((
45 s,
46 GateInstantiation::Enable(Box::new(GateInstantiationEnable {
47 nodes: (a, b, c, d, e),
48 })),
49 ))
50}
51
52#[tracable_parser]
53#[packrat_parser]
54pub(crate) fn gate_instantiation_mos(s: Span) -> IResult<Span, GateInstantiation> {
55 let (s, a) = mos_switchtype(s)?;
56 let (s, b) = opt(delay3)(s)?;
57 let (s, c) = list(symbol(","), mos_switch_instance)(s)?;
58 let (s, d) = symbol(";")(s)?;
59 Ok((
60 s,
61 GateInstantiation::Mos(Box::new(GateInstantiationMos {
62 nodes: (a, b, c, d),
63 })),
64 ))
65}
66
67#[tracable_parser]
68#[packrat_parser]
69pub(crate) fn gate_instantiation_n_input(s: Span) -> IResult<Span, GateInstantiation> {
70 let (s, a) = n_input_gatetype(s)?;
71 let (s, b) = opt(drive_strength)(s)?;
72 let (s, c) = opt(delay2)(s)?;
73 let (s, d) = list(symbol(","), n_input_gate_instance)(s)?;
74 let (s, e) = symbol(";")(s)?;
75 Ok((
76 s,
77 GateInstantiation::NInput(Box::new(GateInstantiationNInput {
78 nodes: (a, b, c, d, e),
79 })),
80 ))
81}
82
83#[tracable_parser]
84#[packrat_parser]
85pub(crate) fn gate_instantiation_n_output(s: Span) -> IResult<Span, GateInstantiation> {
86 let (s, a) = n_output_gatetype(s)?;
87 let (s, b) = opt(drive_strength)(s)?;
88 let (s, c) = opt(delay2)(s)?;
89 let (s, d) = list(symbol(","), n_output_gate_instance)(s)?;
90 let (s, e) = symbol(";")(s)?;
91 Ok((
92 s,
93 GateInstantiation::NOutput(Box::new(GateInstantiationNOutput {
94 nodes: (a, b, c, d, e),
95 })),
96 ))
97}
98
99#[tracable_parser]
100#[packrat_parser]
101pub(crate) fn gate_instantiation_pass_en(s: Span) -> IResult<Span, GateInstantiation> {
102 let (s, a) = pass_en_switchtype(s)?;
103 let (s, b) = opt(delay2)(s)?;
104 let (s, c) = list(symbol(","), pass_enable_switch_instance)(s)?;
105 let (s, d) = symbol(";")(s)?;
106 Ok((
107 s,
108 GateInstantiation::PassEn(Box::new(GateInstantiationPassEn {
109 nodes: (a, b, c, d),
110 })),
111 ))
112}
113
114#[tracable_parser]
115#[packrat_parser]
116pub(crate) fn gate_instantiation_pass(s: Span) -> IResult<Span, GateInstantiation> {
117 let (s, a) = pass_switchtype(s)?;
118 let (s, b) = list(symbol(","), pass_switch_instance)(s)?;
119 let (s, c) = symbol(";")(s)?;
120 Ok((
121 s,
122 GateInstantiation::Pass(Box::new(GateInstantiationPass { nodes: (a, b, c) })),
123 ))
124}
125
126#[tracable_parser]
127#[packrat_parser]
128pub(crate) fn gate_instantiation_pulldown(s: Span) -> IResult<Span, GateInstantiation> {
129 let (s, a) = keyword("pulldown")(s)?;
130 let (s, b) = opt(pulldown_strength)(s)?;
131 let (s, c) = list(symbol(","), pull_gate_instance)(s)?;
132 let (s, d) = symbol(";")(s)?;
133 Ok((
134 s,
135 GateInstantiation::Pulldown(Box::new(GateInstantiationPulldown {
136 nodes: (a, b, c, d),
137 })),
138 ))
139}
140
141#[tracable_parser]
142#[packrat_parser]
143pub(crate) fn gate_instantiation_pullup(s: Span) -> IResult<Span, GateInstantiation> {
144 let (s, a) = keyword("pullup")(s)?;
145 let (s, b) = opt(pullup_strength)(s)?;
146 let (s, c) = list(symbol(","), pull_gate_instance)(s)?;
147 let (s, d) = symbol(";")(s)?;
148 Ok((
149 s,
150 GateInstantiation::Pullup(Box::new(GateInstantiationPullup {
151 nodes: (a, b, c, d),
152 })),
153 ))
154}
155
156#[tracable_parser]
157#[packrat_parser]
158pub(crate) fn cmos_switch_instance(s: Span) -> IResult<Span, CmosSwitchInstance> {
159 let (s, a) = opt(name_of_instance)(s)?;
160 let (s, b) = paren(tuple((
161 output_terminal,
162 symbol(","),
163 input_terminal,
164 symbol(","),
165 ncontrol_terminal,
166 symbol(","),
167 pcontrol_terminal,
168 )))(s)?;
169 Ok((s, CmosSwitchInstance { nodes: (a, b) }))
170}
171
172#[tracable_parser]
173#[packrat_parser]
174pub(crate) fn enable_gate_instance(s: Span) -> IResult<Span, EnableGateInstance> {
175 let (s, a) = opt(name_of_instance)(s)?;
176 let (s, b) = paren(tuple((
177 output_terminal,
178 symbol(","),
179 input_terminal,
180 symbol(","),
181 enable_terminal,
182 )))(s)?;
183 Ok((s, EnableGateInstance { nodes: (a, b) }))
184}
185
186#[tracable_parser]
187#[packrat_parser]
188pub(crate) fn mos_switch_instance(s: Span) -> IResult<Span, MosSwitchInstance> {
189 let (s, a) = opt(name_of_instance)(s)?;
190 let (s, b) = paren(tuple((
191 output_terminal,
192 symbol(","),
193 input_terminal,
194 symbol(","),
195 enable_terminal,
196 )))(s)?;
197 Ok((s, MosSwitchInstance { nodes: (a, b) }))
198}
199
200#[tracable_parser]
201#[packrat_parser]
202pub(crate) fn n_input_gate_instance(s: Span) -> IResult<Span, NInputGateInstance> {
203 let (s, a) = opt(name_of_instance)(s)?;
204 let (s, b) = paren(tuple((
205 output_terminal,
206 symbol(","),
207 list(symbol(","), input_terminal),
208 )))(s)?;
209 Ok((s, NInputGateInstance { nodes: (a, b) }))
210}
211
212#[tracable_parser]
213#[packrat_parser]
214pub(crate) fn n_output_gate_instance(s: Span) -> IResult<Span, NOutputGateInstance> {
215 let (s, a) = opt(name_of_instance)(s)?;
216 let (s, b) = paren(tuple((
217 list(
218 terminated(symbol(","), peek(pair(output_terminal, symbol(",")))),
219 output_terminal,
220 ),
221 symbol(","),
222 input_terminal,
223 )))(s)?;
224 Ok((s, NOutputGateInstance { nodes: (a, b) }))
225}
226
227#[tracable_parser]
228#[packrat_parser]
229pub(crate) fn pass_switch_instance(s: Span) -> IResult<Span, PassSwitchInstance> {
230 let (s, a) = opt(name_of_instance)(s)?;
231 let (s, b) = paren(tuple((inout_terminal, symbol(","), inout_terminal)))(s)?;
232 Ok((s, PassSwitchInstance { nodes: (a, b) }))
233}
234
235#[tracable_parser]
236#[packrat_parser]
237pub(crate) fn pass_enable_switch_instance(s: Span) -> IResult<Span, PassEnableSwitchInstance> {
238 let (s, a) = opt(name_of_instance)(s)?;
239 let (s, b) = paren(tuple((
240 inout_terminal,
241 symbol(","),
242 inout_terminal,
243 symbol(","),
244 enable_terminal,
245 )))(s)?;
246 Ok((s, PassEnableSwitchInstance { nodes: (a, b) }))
247}
248
249#[tracable_parser]
250#[packrat_parser]
251pub(crate) fn pull_gate_instance(s: Span) -> IResult<Span, PullGateInstance> {
252 let (s, a) = opt(name_of_instance)(s)?;
253 let (s, b) = paren(output_terminal)(s)?;
254 Ok((s, PullGateInstance { nodes: (a, b) }))
255}