parser refactoring
[sv2nmigen.git] / parse_sv.py
1 # %{
2 # /*
3 # * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com)
4 # * Copyright CERN 2012-2013 / Stephen Williams (steve@icarus.com)
5 # *
6 # * This source code is free software; you can redistribute it
7 # * and/or modify it in source code form under the terms of the GNU
8 # * General Public License as published by the Free Software
9 # * Foundation; either version 2 of the License, or (at your option)
10 # * any later version.
11 # *
12 # * This program is distributed in the hope that it will be useful,
13 # * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # * GNU General Public License for more details.
16 # *
17 # * You should have received a copy of the GNU General Public License
18 # * along with this program; if not, write to the Free Software
19 # * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # */
21
22 from lib2to3.pytree import Node, Leaf
23 from lib2to3.pgen2 import token
24 from lib2to3.pygram import python_symbols as syms
25
26 yacc1_debug = 0
27 yacc2_debug = 0
28 parse_debug = 1
29
30 from ply import yacc, lex
31
32 #from parse_tokens import tokens
33 import lexor
34 tokens = lexor.tokens # list(set(lexor.tokens).union(set(tokens)))
35 literals = lexor.literals
36
37 precedence = [\
38 ('right', 'K_PLUS_EQ', 'K_MINUS_EQ', 'K_MUL_EQ', 'K_DIV_EQ',
39 'K_MOD_EQ', 'K_AND_EQ', 'K_OR_EQ'),
40 ('right', 'K_XOR_EQ', 'K_LS_EQ', 'K_RS_EQ', 'K_RSS_EQ'),
41 ('right', '?', ':', 'K_inside'),
42 ('left', 'K_LOR'),
43 ('left', 'K_LAND'),
44 ('left', '|'),
45 ('left', '^', 'K_NXOR', 'K_NOR'),
46 ('left', '&', 'K_NAND'),
47 ('left', 'K_EQ', 'K_NE', 'K_CEQ', 'K_CNE', 'K_WEQ', 'K_WNE'),
48 ('left', 'K_GE', 'K_LE', '<', '>'),
49 ('left', 'K_LS', 'K_RS', 'K_RSS'),
50 ('left', '+', '-'),
51 ('left', '*', '/', '%'),
52 ('left', 'K_POW'),
53 ('left', 'UNARY_PREC'),
54 ('nonassoc', 'less_than_K_else'),
55 ('nonassoc', 'K_else'),
56 ('nonassoc', '('),
57 ('nonassoc', 'K_exclude'),
58 ('nonassoc', 'no_timeunits_declaration'),
59 ('nonassoc', 'one_timeunits_declaration'),
60 ('nonassoc', 'K_timeunit', 'K_timeprecision')
61 ]
62
63
64 IVL_VT_NO_TYPE = 'VT_NO_TYPE'
65 IVL_VT_BOOL = 'VT_BOOL'
66 IVL_VT_LOGIC = 'VT_LOGIC'
67 """
68 IVL_VT_VOID = 0, /* Not used */
69 IVL_VT_NO_TYPE = 1, /* Place holder for missing/unknown type. */
70 IVL_VT_REAL = 2,
71 IVL_VT_BOOL = 3,
72 IVL_VT_LOGIC = 4,
73 IVL_VT_STRING = 5,
74 IVL_VT_DARRAY = 6, /* Array (esp. dynamic array) */
75 IVL_VT_CLASS = 7, /* SystemVerilog class instances */
76 IVL_VT_QUEUE = 8, /* SystemVerilog queue instances */
77 IVL_VT_VECTOR = IVL_VT_LOGIC /* For compatibility */
78 """
79
80 NN_NONE = 'NONE'
81 NN_IMPLICIT = 'IMPLICIT'
82 NN_IMPLICIT_REG = 'IMPLICIT_REG'
83 NN_INTEGER = 'INTEGER'
84 NN_WIRE = 'WIRE'
85 NN_TRI = 'TRI'
86 NN_TRI1 = 'TRI1'
87 NN_SUPPLY0 = 'SUPPLY0'
88 NN_SUPPLY1 = 'SUPPLY1'
89 NN_WAND = 'WAND'
90 NN_TRIAND = 'TRIAND'
91 NN_TRI0 = 'TRI0'
92 NN_WOR = 'WOR'
93 NN_TRIOR = 'TRIOR'
94 NN_REG = 'REG'
95 NN_UNRESOLVED_WIRE = 'UNRESOLVED_WIRE'
96
97 NP_NOT_A_PORT = 'NOT_A_PORT'
98 NP_PIMPLICIT = 'PIMPLICIT'
99 NP_PINPUT = 'PINPUT'
100 NP_POUTPUT = 'POUTPUT'
101 NP_PINOUT = 'PINOUT'
102 NP_PREF = 'PREF'
103
104 def indent(s, i=4):
105 st = ''
106 for x in s:
107 st += str(x)
108 res = []
109 for p in st.split('\n'):
110 res.append(' ' * i + "#"+p)
111 return '\n'.join(res)
112
113
114 class DataType:
115 def __init__(self, typ, signed):
116 self.typ = typ
117 self.signed = signed
118
119 def port_decl(comment, dt, name):
120 if dt is None or dt.dims is None:
121 width = '' # width: 1
122 else:
123 width = dt.dims
124 # XXX TODO, better checking, should be using data structure... *sigh*
125 width = width[1:-1] # strip brackets
126 width = width.split(':')
127 assert width[0] == '0'
128 width = width[1]
129 return 'self.%s = Signal(%s) # %s' % (name, width, comment)
130
131 # -------------- RULES ----------------
132 ()
133 def p_source_text_1(p):
134 '''source_text : timeunits_declaration_opt _embed0_source_text description_list '''
135 if(parse_debug>2): print('source_text', list(p))
136 ()
137 def p_source_text_2(p):
138 '''source_text : '''
139 if(parse_debug): print('source_text', list(p))
140 ()
141 def p__embed0_source_text(p):
142 '''_embed0_source_text : '''
143 # { pform_set_scope_timescale(yyloc); }
144 ()
145 def p_assertion_item_1(p):
146 '''assertion_item : concurrent_assertion_item '''
147 if(parse_debug): print('assertion_item_1', list(p))
148 ()
149 def p_assignment_pattern_1(p):
150 '''assignment_pattern : K_LP expression_list_proper '}' '''
151 if(parse_debug): print('assignment_pattern_1', list(p))
152 # { PEAssignPattern*tmp = new PEAssignPattern(*p[2]);
153 # FILE_NAME(tmp, @1);
154 # delete p[2];
155 # p[0] = tmp;
156 # }
157 ()
158 def p_assignment_pattern_2(p):
159 '''assignment_pattern : K_LP '}' '''
160 if(parse_debug): print('assignment_pattern_2', list(p))
161 # { PEAssignPattern*tmp = new PEAssignPattern;
162 # FILE_NAME(tmp, @1);
163 # p[0] = tmp;
164 # }
165 ()
166 def p_block_identifier_opt_1(p):
167 '''block_identifier_opt : IDENTIFIER ':' '''
168 if(parse_debug): print('block_identifier_opt_1', list(p))
169 ()
170 def p_block_identifier_opt_2(p):
171 '''block_identifier_opt : '''
172 if(parse_debug): print('block_identifier_opt_2', list(p))
173 ()
174 def p_class_declaration_1(p):
175 '''class_declaration : K_virtual_opt K_class lifetime_opt class_identifier class_declaration_extends_opt ';' _embed0_class_declaration class_items_opt K_endclass _embed1_class_declaration class_declaration_endlabel_opt '''
176 if(parse_debug): print('class_declaration_1', list(p))
177 # { // Wrap up the class.
178 # if (p[11] && p[4] && p[4]->name != p[11]) {
179 # yyerror(@11, "error: Class end label doesn't match class name.");
180 # delete[]p[11];
181 # }
182 # }
183 ()
184 def p__embed0_class_declaration(p):
185 '''_embed0_class_declaration : '''
186 # { pform_start_class_declaration(@2, p[4], p[5].type, p[5].exprs, p[3]); }
187 ()
188 def p__embed1_class_declaration(p):
189 '''_embed1_class_declaration : '''
190 # { // Process a class.
191 # pform_end_class_declaration(@9);
192 # }
193 ()
194 def p_class_constraint_1(p):
195 '''class_constraint : constraint_prototype '''
196 if(parse_debug): print('class_constraint_1', list(p))
197 ()
198 def p_class_constraint_2(p):
199 '''class_constraint : constraint_declaration '''
200 if(parse_debug): print('class_constraint_2', list(p))
201 ()
202 def p_class_identifier_1(p):
203 '''class_identifier : IDENTIFIER '''
204 if(parse_debug): print('class_identifier_1', list(p))
205 # { // Create a synthetic typedef for the class name so that the
206 # // lexor detects the name as a type.
207 # perm_string name = lex_strings.make(p[1]);
208 # class_type_t*tmp = new class_type_t(name);
209 # FILE_NAME(tmp, @1);
210 # pform_set_typedef(name, tmp, NULL);
211 # delete[]p[1];
212 # p[0] = tmp;
213 # }
214 ()
215 def p_class_identifier_2(p):
216 '''class_identifier : TYPE_IDENTIFIER '''
217 if(parse_debug): print('class_identifier_2', list(p))
218 # { class_type_t*tmp = dynamic_cast<class_type_t*>(p[1].type);
219 # if (tmp == 0) {
220 # yyerror(@1, "Type name \"%s\"is not a predeclared class name.", p[1].text);
221 # }
222 # delete[]p[1].text;
223 # p[0] = tmp;
224 # }
225 ()
226 def p_class_declaration_endlabel_opt_1(p):
227 '''class_declaration_endlabel_opt : ':' TYPE_IDENTIFIER '''
228 if(parse_debug): print('class_declaration_endlabel_opt_1', list(p))
229 # { class_type_t*tmp = dynamic_cast<class_type_t*> (p[2].type);
230 # if (tmp == 0) {
231 # yyerror(@2, "error: class declaration endlabel \"%s\" is not a class name\n", p[2].text);
232 # p[0] = None
233 # } else {
234 # p[0] = strdupnew(tmp->name.str());
235 # }
236 # delete[]p[2].text;
237 # }
238 ()
239 def p_class_declaration_endlabel_opt_2(p):
240 '''class_declaration_endlabel_opt : ':' IDENTIFIER '''
241 if(parse_debug): print('class_declaration_endlabel_opt_2', list(p))
242 p[0] = p[2]
243 ()
244 def p_class_declaration_endlabel_opt_3(p):
245 '''class_declaration_endlabel_opt : '''
246 if(parse_debug): print('class_declaration_endlabel_opt_3', list(p))
247 # { p[0] = None }
248 ()
249 def p_class_declaration_extends_opt_1(p):
250 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '''
251 if(parse_debug): print('class_declaration_extends_opt_1', list(p))
252 # { p[0].type = p[2].type;
253 # p[0].exprs= 0;
254 # delete[]p[2].text;
255 # }
256 ()
257 def p_class_declaration_extends_opt_2(p):
258 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '(' expression_list_with_nuls ')' '''
259 if(parse_debug): print('class_declaration_extends_opt_2', list(p))
260 # { p[0].type = p[2].type;
261 # p[0].exprs = p[4];
262 # delete[]p[2].text;
263 # }
264 ()
265 def p_class_declaration_extends_opt_3(p):
266 '''class_declaration_extends_opt : '''
267 if(parse_debug): print('class_declaration_extends_opt_3', list(p))
268 # { p[0].type = 0; p[0].exprs = 0; }
269 ()
270 def p_class_items_opt_1(p):
271 '''class_items_opt : class_items '''
272 if(parse_debug): print('class_items_opt_1', list(p))
273 ()
274 def p_class_items_opt_2(p):
275 '''class_items_opt : '''
276 if(parse_debug): print('class_items_opt_2', list(p))
277 ()
278 def p_class_items_1(p):
279 '''class_items : class_items class_item '''
280 if(parse_debug): print('class_items_1', list(p))
281 ()
282 def p_class_items_2(p):
283 '''class_items : class_item '''
284 if(parse_debug): print('class_items_2', list(p))
285 ()
286 def p_class_item_1(p):
287 '''class_item : method_qualifier_opt K_function K_new _embed0_class_item '(' tf_port_list_opt ')' ';' function_item_list_opt statement_or_null_list_opt K_endfunction endnew_opt '''
288 if(parse_debug): print('class_item_1', list(p))
289 # { current_function->set_ports(p[6]);
290 # pform_set_constructor_return(current_function);
291 # pform_set_this_class(@3, current_function);
292 # current_function_set_statement(@3, p[10]);
293 # pform_pop_scope();
294 # current_function = 0;
295 # }
296 ()
297 def p_class_item_2(p):
298 '''class_item : property_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
299 if(parse_debug): print('class_item_2', list(p))
300 # { pform_class_property(@2, p[1], p[2], p[3]); }
301 ()
302 def p_class_item_3(p):
303 '''class_item : K_const class_item_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
304 if(parse_debug): print('class_item_3', list(p))
305 # { pform_class_property(@1, p[2] | property_qualifier_t::make_const(), p[3], p[4]); }
306 ()
307 def p_class_item_4(p):
308 '''class_item : method_qualifier_opt task_declaration '''
309 if(parse_debug): print('class_item_4', list(p))
310 # { /* The task_declaration rule puts this into the class */ }
311 ()
312 def p_class_item_5(p):
313 '''class_item : method_qualifier_opt function_declaration '''
314 if(parse_debug): print('class_item_5', list(p))
315 # { /* The function_declaration rule puts this into the class */ }
316 ()
317 def p_class_item_6(p):
318 '''class_item : K_extern method_qualifier_opt K_function K_new ';' '''
319 if(parse_debug): print('class_item_6', list(p))
320 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
321 ()
322 def p_class_item_7(p):
323 '''class_item : K_extern method_qualifier_opt K_function K_new '(' tf_port_list_opt ')' ';' '''
324 if(parse_debug): print('class_item_7', list(p))
325 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
326 ()
327 def p_class_item_8(p):
328 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER ';' '''
329 if(parse_debug): print('class_item_8', list(p))
330 # { yyerror(@1, "sorry: External methods are not yet supported.");
331 # delete[] p[5];
332 # }
333 ()
334 def p_class_item_9(p):
335 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' ';' '''
336 if(parse_debug): print('class_item_9', list(p))
337 # { yyerror(@1, "sorry: External methods are not yet supported.");
338 # delete[] p[5];
339 # }
340 ()
341 def p_class_item_10(p):
342 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER ';' '''
343 if(parse_debug): print('class_item_10', list(p))
344 # { yyerror(@1, "sorry: External methods are not yet supported.");
345 # delete[] p[4];
346 # }
347 ()
348 def p_class_item_11(p):
349 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER '(' tf_port_list_opt ')' ';' '''
350 if(parse_debug): print('class_item_11', list(p))
351 # { yyerror(@1, "sorry: External methods are not yet supported.");
352 # delete[] p[4];
353 # }
354 ()
355 def p_class_item_12(p):
356 '''class_item : class_constraint '''
357 if(parse_debug): print('class_item_12', list(p))
358 ()
359 def p_class_item_13(p):
360 '''class_item : property_qualifier_opt data_type error ';' '''
361 if(parse_debug): print('class_item_13', list(p))
362 # { yyerror(@3, "error: Errors in variable names after data type.");
363 # yyerrok;
364 # }
365 ()
366 def p_class_item_14(p):
367 '''class_item : property_qualifier_opt IDENTIFIER error ';' '''
368 if(parse_debug): print('class_item_14', list(p))
369 # { yyerror(@3, "error: %s doesn't name a type.", p[2]);
370 # yyerrok;
371 # }
372 ()
373 def p_class_item_15(p):
374 '''class_item : method_qualifier_opt K_function K_new error K_endfunction endnew_opt '''
375 if(parse_debug): print('class_item_15', list(p))
376 # { yyerror(@1, "error: I give up on this class constructor declaration.");
377 # yyerrok;
378 # }
379 ()
380 def p_class_item_16(p):
381 '''class_item : error ';' '''
382 if(parse_debug): print('class_item_16', list(p))
383 # { yyerror(@2, "error: invalid class item.");
384 # yyerrok;
385 # }
386 ()
387 def p__embed0_class_item(p):
388 '''_embed0_class_item : '''
389 # { assert(current_function==0);
390 # current_function = pform_push_constructor_scope(@3);
391 # }
392 ()
393 def p_class_item_qualifier_1(p):
394 '''class_item_qualifier : K_static '''
395 if(parse_debug): print('class_item_qualifier_1', list(p))
396 # { p[0] = property_qualifier_t::make_static(); }
397 ()
398 def p_class_item_qualifier_2(p):
399 '''class_item_qualifier : K_protected '''
400 if(parse_debug): print('class_item_qualifier_2', list(p))
401 # { p[0] = property_qualifier_t::make_protected(); }
402 ()
403 def p_class_item_qualifier_3(p):
404 '''class_item_qualifier : K_local '''
405 if(parse_debug): print('class_item_qualifier_3', list(p))
406 # { p[0] = property_qualifier_t::make_local(); }
407 ()
408 def p_class_item_qualifier_list_1(p):
409 '''class_item_qualifier_list : class_item_qualifier_list class_item_qualifier '''
410 if(parse_debug): print('class_item_qualifier_list_1', list(p))
411 # { p[0] = p[1] | p[2]; }
412 ()
413 def p_class_item_qualifier_list_2(p):
414 '''class_item_qualifier_list : class_item_qualifier '''
415 if(parse_debug): print('class_item_qualifier_list_2', list(p))
416 p[0] = p[1]
417 ()
418 def p_class_item_qualifier_opt_1(p):
419 '''class_item_qualifier_opt : class_item_qualifier_list '''
420 if(parse_debug): print('class_item_qualifier_opt_1', list(p))
421 p[0] = p[1]
422 ()
423 def p_class_item_qualifier_opt_2(p):
424 '''class_item_qualifier_opt : '''
425 if(parse_debug): print('class_item_qualifier_opt_2', list(p))
426 # { p[0] = property_qualifier_t::make_none(); }
427 ()
428 def p_class_new_1(p):
429 '''class_new : K_new '(' expression_list_with_nuls ')' '''
430 if(parse_debug): print('class_new_1', list(p))
431 # { list<PExpr*>*expr_list = p[3];
432 # strip_tail_items(expr_list);
433 # PENewClass*tmp = new PENewClass(*expr_list);
434 # FILE_NAME(tmp, @1);
435 # delete p[3];
436 # p[0] = tmp;
437 # }
438 ()
439 def p_class_new_2(p):
440 '''class_new : K_new hierarchy_identifier '''
441 if(parse_debug): print('class_new_2', list(p))
442 # { PEIdent*tmpi = new PEIdent(*p[2]);
443 # FILE_NAME(tmpi, @2);
444 # PENewCopy*tmp = new PENewCopy(tmpi);
445 # FILE_NAME(tmp, @1);
446 # delete p[2];
447 # p[0] = tmp;
448 # }
449 ()
450 def p_class_new_3(p):
451 '''class_new : K_new '''
452 if(parse_debug): print('class_new_3', list(p))
453 # { PENewClass*tmp = new PENewClass;
454 # FILE_NAME(tmp, @1);
455 # p[0] = tmp;
456 # }
457 ()
458 def p_concurrent_assertion_item_1(p):
459 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' property_spec ')' statement_or_null '''
460 if(parse_debug): print('concurrent_assertion_item_1', list(p))
461 # { /* */
462 # if (gn_assertions_flag) {
463 # yyerror(@2, "sorry: concurrent_assertion_item not supported."
464 # " Try -gno-assertion to turn this message off.");
465 # }
466 # }
467 ()
468 def p_concurrent_assertion_item_2(p):
469 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' error ')' statement_or_null '''
470 if(parse_debug): print('concurrent_assertion_item_2', list(p))
471 # { yyerrok;
472 # yyerror(@2, "error: Error in property_spec of concurrent assertion item.");
473 # }
474 ()
475 def p_constraint_block_item_1(p):
476 '''constraint_block_item : constraint_expression '''
477 if(parse_debug): print('constraint_block_item_1', list(p))
478 ()
479 def p_constraint_block_item_list_1(p):
480 '''constraint_block_item_list : constraint_block_item_list constraint_block_item '''
481 if(parse_debug): print('constraint_block_item_list_1', list(p))
482 ()
483 def p_constraint_block_item_list_2(p):
484 '''constraint_block_item_list : constraint_block_item '''
485 if(parse_debug): print('constraint_block_item_list_2', list(p))
486 ()
487 def p_constraint_block_item_list_opt_1(p):
488 '''constraint_block_item_list_opt : '''
489 if(parse_debug): print('constraint_block_item_list_opt_1', list(p))
490 ()
491 def p_constraint_block_item_list_opt_2(p):
492 '''constraint_block_item_list_opt : constraint_block_item_list '''
493 if(parse_debug): print('constraint_block_item_list_opt_2', list(p))
494 ()
495 def p_constraint_declaration_1(p):
496 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' constraint_block_item_list_opt '}' '''
497 if(parse_debug): print('constraint_declaration_1', list(p))
498 # { yyerror(@2, "sorry: Constraint declarations not supported."); }
499 ()
500 def p_constraint_declaration_2(p):
501 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' error '}' '''
502 if(parse_debug): print('constraint_declaration_2', list(p))
503 # { yyerror(@4, "error: Errors in the constraint block item list."); }
504 ()
505 def p_constraint_expression_1(p):
506 '''constraint_expression : expression ';' '''
507 if(parse_debug): print('constraint_expression_1', list(p))
508 ()
509 def p_constraint_expression_2(p):
510 '''constraint_expression : expression K_dist '{' '}' ';' '''
511 if(parse_debug): print('constraint_expression_2', list(p))
512 ()
513 def p_constraint_expression_3(p):
514 '''constraint_expression : expression K_TRIGGER constraint_set '''
515 if(parse_debug): print('constraint_expression_3', list(p))
516 ()
517 def p_constraint_expression_4(p):
518 '''constraint_expression : K_if '(' expression ')' constraint_set %prec less_than_K_else '''
519 if(parse_debug): print('constraint_expression_4', list(p))
520 ()
521 def p_constraint_expression_5(p):
522 '''constraint_expression : K_if '(' expression ')' constraint_set K_else constraint_set '''
523 if(parse_debug): print('constraint_expression_5', list(p))
524 ()
525 def p_constraint_expression_6(p):
526 '''constraint_expression : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' constraint_set '''
527 if(parse_debug): print('constraint_expression_6', list(p))
528 ()
529 def p_constraint_expression_list_1(p):
530 '''constraint_expression_list : constraint_expression_list constraint_expression '''
531 if(parse_debug): print('constraint_expression_list_1', list(p))
532 ()
533 def p_constraint_expression_list_2(p):
534 '''constraint_expression_list : constraint_expression '''
535 if(parse_debug): print('constraint_expression_list_2', list(p))
536 ()
537 def p_constraint_prototype_1(p):
538 '''constraint_prototype : K_static_opt K_constraint IDENTIFIER ';' '''
539 if(parse_debug): print('constraint_prototype_1', list(p))
540 # { yyerror(@2, "sorry: Constraint prototypes not supported."); }
541 ()
542 def p_constraint_set_1(p):
543 '''constraint_set : constraint_expression '''
544 if(parse_debug): print('constraint_set_1', list(p))
545 ()
546 def p_constraint_set_2(p):
547 '''constraint_set : '{' constraint_expression_list '}' '''
548 if(parse_debug): print('constraint_set_2', list(p))
549 ()
550 def p_data_declaration_1(p):
551 '''data_declaration : attribute_list_opt data_type_or_implicit list_of_variable_decl_assignments ';' '''
552 if(parse_debug): print('data_declaration_1', list(p))
553 # { data_type_t*data_type = p[2];
554 # if (data_type == 0) {
555 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
556 # FILE_NAME(data_type, @2);
557 # }
558 # pform_makewire(@2, 0, str_strength, p[3], NetNet::IMPLICIT_REG, data_type);
559 # }
560 ()
561 def p_data_type_1(p):
562 '''data_type : integer_vector_type unsigned_signed_opt dimensions_opt '''
563 if(parse_debug): print('data_type_1', list(p))
564 use_vtype = p[1]
565 reg_flag = False
566 if (use_vtype == IVL_VT_NO_TYPE):
567 use_vtype = IVL_VT_LOGIC
568 reg_flag = True
569 dt = DataType(use_vtype, signed=p[2])
570 dt.dims = p[3]
571 dt.reg_flag = reg_flag
572 p[0] = dt
573 # { ivl_variable_type_t use_vtype = p[1];
574 # bool reg_flag = false;
575 # if (use_vtype == IVL_VT_NO_TYPE) {
576 # use_vtype = IVL_VT_LOGIC;
577 # reg_flag = true;
578 # }
579 # vector_type_t*tmp = new vector_type_t(use_vtype, p[2], p[3]);
580 # tmp->reg_flag = reg_flag;
581 # FILE_NAME(tmp, @1);
582 # p[0] = tmp;
583 # }
584 ()
585 def p_data_type_2(p):
586 '''data_type : non_integer_type '''
587 if(parse_debug): print('data_type_2', list(p))
588 p[0] = p[1]
589 # { real_type_t*tmp = new real_type_t(p[1]);
590 # FILE_NAME(tmp, @1);
591 # p[0] = tmp;
592 # }
593 ()
594 def p_data_type_3(p):
595 '''data_type : struct_data_type '''
596 if(parse_debug): print('data_type_3', list(p))
597 p[0] = p[1]
598 # { if (!p[1]->packed_flag) {
599 # yyerror(@1, "sorry: Unpacked structs not supported.");
600 # }
601 # p[0] = p[1];
602 # }
603 ()
604 def p_data_type_4(p):
605 '''data_type : enum_data_type '''
606 if(parse_debug): print('data_type_4', list(p))
607 p[0] = p[1]
608 ()
609 def p_data_type_5(p):
610 '''data_type : atom2_type signed_unsigned_opt '''
611 if(parse_debug): print('data_type_5', list(p))
612 # { atom2_type_t*tmp = new atom2_type_t(p[1], p[2]);
613 # FILE_NAME(tmp, @1);
614 # p[0] = tmp;
615 # }
616 ()
617 def p_data_type_6(p):
618 '''data_type : K_integer signed_unsigned_opt '''
619 if(parse_debug): print('data_type_6', list(p))
620 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
621 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[2], pd);
622 # tmp->reg_flag = true;
623 # tmp->integer_flag = true;
624 # p[0] = tmp;
625 # }
626 ()
627 def p_data_type_7(p):
628 '''data_type : K_time '''
629 if(parse_debug): print('data_type_7', list(p))
630 # { list<pform_range_t>*pd = make_range_from_width(64);
631 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
632 # tmp->reg_flag = !gn_system_verilog();
633 # p[0] = tmp;
634 # }
635 ()
636 def p_data_type_8(p):
637 '''data_type : TYPE_IDENTIFIER dimensions_opt '''
638 if(parse_debug): print('data_type_8', list(p))
639 # { if (p[2]) {
640 # parray_type_t*tmp = new parray_type_t(p[1].type, p[2]);
641 # FILE_NAME(tmp, @1);
642 # p[0] = tmp;
643 # } else p[0] = p[1].type;
644 # delete[]p[1].text;
645 # }
646 ()
647 def p_data_type_9(p):
648 '''data_type : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_data_type TYPE_IDENTIFIER '''
649 if(parse_debug): print('data_type_9', list(p))
650 # { lex_in_package_scope(0);
651 # p[0] = p[4].type;
652 # delete[]p[4].text;
653 # }
654 ()
655 def p_data_type_10(p):
656 '''data_type : K_string '''
657 if(parse_debug): print('data_type_10', list(p))
658 # { string_type_t*tmp = new string_type_t;
659 # FILE_NAME(tmp, @1);
660 # p[0] = tmp;
661 # }
662 ()
663 def p__embed0_data_type(p):
664 '''_embed0_data_type : '''
665 # { lex_in_package_scope(p[1]); }
666 ()
667 def p_data_type_or_implicit_1(p):
668 '''data_type_or_implicit : data_type '''
669 if(parse_debug): print('data_type_or_implicit_1', list(p))
670 p[0] = p[1]
671 ()
672 def p_data_type_or_implicit_2(p):
673 '''data_type_or_implicit : signing dimensions_opt '''
674 if(parse_debug): print('data_type_or_implicit_2', list(p))
675 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[1], p[2]);
676 # tmp->implicit_flag = true;
677 # FILE_NAME(tmp, @1);
678 # p[0] = tmp;
679 # }
680 ()
681 def p_data_type_or_implicit_3(p):
682 '''data_type_or_implicit : dimensions '''
683 if(parse_debug): print('data_type_or_implicit_3', list(p))
684 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, p[1]);
685 # tmp->implicit_flag = true;
686 # FILE_NAME(tmp, @1);
687 # p[0] = tmp;
688 # }
689 ()
690 def p_data_type_or_implicit_4(p):
691 '''data_type_or_implicit : '''
692 if(parse_debug>2): print('data_type_or_implicit_4', list(p))
693 # { p[0] = None }
694 ()
695 def p_data_type_or_implicit_or_void_1(p):
696 '''data_type_or_implicit_or_void : data_type_or_implicit '''
697 if(parse_debug): print('data_type_or_implicit_or_void_1', list(p))
698 p[0] = p[1]
699 ()
700 def p_data_type_or_implicit_or_void_2(p):
701 '''data_type_or_implicit_or_void : K_void '''
702 if(parse_debug): print('data_type_or_implicit_or_void_2', list(p))
703 # { void_type_t*tmp = new void_type_t;
704 # FILE_NAME(tmp, @1);
705 # p[0] = tmp;
706 # }
707 ()
708 def p_description_1(p):
709 '''description : module '''
710 if(parse_debug>2): print('description_1', list(p))
711 ()
712 def p_description_2(p):
713 '''description : udp_primitive '''
714 if(parse_debug): print('description_2', list(p))
715 ()
716 def p_description_3(p):
717 '''description : config_declaration '''
718 if(parse_debug): print('description_3', list(p))
719 ()
720 def p_description_4(p):
721 '''description : nature_declaration '''
722 if(parse_debug): print('description_4', list(p))
723 ()
724 def p_description_5(p):
725 '''description : package_declaration '''
726 if(parse_debug): print('description_5', list(p))
727 ()
728 def p_description_6(p):
729 '''description : discipline_declaration '''
730 if(parse_debug): print('description_6', list(p))
731 ()
732 def p_description_7(p):
733 '''description : package_item '''
734 if(parse_debug): print('description_7', list(p))
735 ()
736 def p_description_8(p):
737 '''description : KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' '''
738 if(parse_debug): print('description_8', list(p))
739 # { perm_string tmp3 = lex_strings.make(p[3]);
740 # pform_set_type_attrib(tmp3, p[5], p[7]);
741 # delete[] p[3];
742 # delete[] p[5];
743 # }
744 ()
745 def p_description_list_1(p):
746 '''description_list : description '''
747 if(parse_debug>2): print('description_list_1', list(p))
748 ()
749 def p_description_list_2(p):
750 '''description_list : description_list description '''
751 if(parse_debug): print('description_list_2', list(p))
752 ()
753 def p_endnew_opt_1(p):
754 '''endnew_opt : ':' K_new '''
755 if(parse_debug): print('endnew_opt_1', list(p))
756 ()
757 def p_endnew_opt_2(p):
758 '''endnew_opt : '''
759 if(parse_debug): print('endnew_opt_2', list(p))
760 ()
761 def p_dynamic_array_new_1(p):
762 '''dynamic_array_new : K_new '[' expression ']' '''
763 if(parse_debug): print('dynamic_array_new_1', list(p))
764 # { p[0] = new PENewArray(p[3], 0);
765 # FILE_NAME(p[0], @1);
766 # }
767 ()
768 def p_dynamic_array_new_2(p):
769 '''dynamic_array_new : K_new '[' expression ']' '(' expression ')' '''
770 if(parse_debug): print('dynamic_array_new_2', list(p))
771 # { p[0] = new PENewArray(p[3], p[6]);
772 # FILE_NAME(p[0], @1);
773 # }
774 ()
775 def p_for_step_1(p):
776 '''for_step : lpvalue '=' expression '''
777 if(parse_debug): print('for_step_1', list(p))
778 # { PAssign*tmp = new PAssign(p[1],p[3]);
779 # FILE_NAME(tmp, @1);
780 # p[0] = tmp;
781 # }
782 ()
783 def p_for_step_2(p):
784 '''for_step : inc_or_dec_expression '''
785 if(parse_debug): print('for_step_2', list(p))
786 # { p[0] = pform_compressed_assign_from_inc_dec(@1, p[1]); }
787 ()
788 def p_for_step_3(p):
789 '''for_step : compressed_statement '''
790 if(parse_debug): print('for_step_3', list(p))
791 p[0] = p[1]
792 ()
793 def p_function_declaration_1(p):
794 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER ';' _embed0_function_declaration function_item_list statement_or_null_list_opt K_endfunction _embed1_function_declaration endlabel_opt '''
795 if(parse_debug): print('function_declaration_1', list(p))
796 # { // Last step: check any closing name.
797 # if (p[11]) {
798 # if (strcmp(p[4],p[11]) != 0) {
799 # yyerror(@11, "error: End label doesn't match "
800 # "function name");
801 # }
802 # if (! gn_system_verilog()) {
803 # yyerror(@11, "error: Function end labels require "
804 # "SystemVerilog.");
805 # }
806 # delete[]p[11];
807 # }
808 # delete[]p[4];
809 # }
810 ()
811 def p_function_declaration_2(p):
812 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER _embed2_function_declaration '(' tf_port_list_opt ')' ';' block_item_decls_opt statement_or_null_list_opt K_endfunction _embed3_function_declaration endlabel_opt '''
813 if(parse_debug): print('function_declaration_2', list(p))
814 # { // Last step: check any closing name.
815 # if (p[14]) {
816 # if (strcmp(p[4],p[14]) != 0) {
817 # yyerror(@14, "error: End label doesn't match "
818 # "function name");
819 # }
820 # if (! gn_system_verilog()) {
821 # yyerror(@14, "error: Function end labels require "
822 # "SystemVerilog.");
823 # }
824 # delete[]p[14];
825 # }
826 # delete[]p[4];
827 # }
828 ()
829 def p_function_declaration_3(p):
830 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER error K_endfunction _embed4_function_declaration endlabel_opt '''
831 if(parse_debug): print('function_declaration_3', list(p))
832 # { // Last step: check any closing name.
833 # if (p[8]) {
834 # if (strcmp(p[4],p[8]) != 0) {
835 # yyerror(@8, "error: End label doesn't match function name");
836 # }
837 # if (! gn_system_verilog()) {
838 # yyerror(@8, "error: Function end labels require "
839 # "SystemVerilog.");
840 # }
841 # delete[]p[8];
842 # }
843 # delete[]p[4];
844 # }
845 ()
846 def p__embed0_function_declaration(p):
847 '''_embed0_function_declaration : '''
848 # { assert(current_function == 0);
849 # current_function = pform_push_function_scope(@1, p[4], p[2]);
850 # }
851 ()
852 def p__embed1_function_declaration(p):
853 '''_embed1_function_declaration : '''
854 # { current_function->set_ports(p[7]);
855 # current_function->set_return(p[3]);
856 # current_function_set_statement(p[8]? @8 : @4, p[8]);
857 # pform_set_this_class(@4, current_function);
858 # pform_pop_scope();
859 # current_function = 0;
860 # }
861 ()
862 def p__embed2_function_declaration(p):
863 '''_embed2_function_declaration : '''
864 # { assert(current_function == 0);
865 # current_function = pform_push_function_scope(@1, p[4], p[2]);
866 # }
867 ()
868 def p__embed3_function_declaration(p):
869 '''_embed3_function_declaration : '''
870 # { current_function->set_ports(p[7]);
871 # current_function->set_return(p[3]);
872 # current_function_set_statement(p[11]? @11 : @4, p[11]);
873 # pform_set_this_class(@4, current_function);
874 # pform_pop_scope();
875 # current_function = 0;
876 # if (p[7]==0 && !gn_system_verilog()) {
877 # yyerror(@4, "error: Empty parenthesis syntax requires SystemVerilog.");
878 # }
879 # }
880 ()
881 def p__embed4_function_declaration(p):
882 '''_embed4_function_declaration : '''
883 # { /* */
884 # if (current_function) {
885 # pform_pop_scope();
886 # current_function = 0;
887 # }
888 # assert(current_function == 0);
889 # yyerror(@1, "error: Syntax error defining function.");
890 # yyerrok;
891 # }
892 ()
893 def p_import_export_1(p):
894 '''import_export : K_import '''
895 if(parse_debug): print('import_export_1', list(p))
896 p[0] = True
897 ()
898 def p_import_export_2(p):
899 '''import_export : K_export '''
900 if(parse_debug): print('import_export_2', list(p))
901 p[0] = False
902 ()
903 def p_implicit_class_handle_1(p):
904 '''implicit_class_handle : K_this '''
905 if(parse_debug): print('implicit_class_handle_1', list(p))
906 # { p[0] = pform_create_this(); }
907 ()
908 def p_implicit_class_handle_2(p):
909 '''implicit_class_handle : K_super '''
910 if(parse_debug): print('implicit_class_handle_2', list(p))
911 # { p[0] = pform_create_super(); }
912 ()
913 def p_inc_or_dec_expression_1(p):
914 '''inc_or_dec_expression : K_INCR lpvalue %prec UNARY_PREC '''
915 if(parse_debug): print('inc_or_dec_expression_1', list(p))
916 # { PEUnary*tmp = new PEUnary('I', p[2]);
917 # FILE_NAME(tmp, @2);
918 # p[0] = tmp;
919 # }
920 ()
921 def p_inc_or_dec_expression_2(p):
922 '''inc_or_dec_expression : lpvalue K_INCR %prec UNARY_PREC '''
923 if(parse_debug): print('inc_or_dec_expression_2', list(p))
924 # { PEUnary*tmp = new PEUnary('i', p[1]);
925 # FILE_NAME(tmp, @1);
926 # p[0] = tmp;
927 # }
928 ()
929 def p_inc_or_dec_expression_3(p):
930 '''inc_or_dec_expression : K_DECR lpvalue %prec UNARY_PREC '''
931 if(parse_debug): print('inc_or_dec_expression_3', list(p))
932 # { PEUnary*tmp = new PEUnary('D', p[2]);
933 # FILE_NAME(tmp, @2);
934 # p[0] = tmp;
935 # }
936 ()
937 def p_inc_or_dec_expression_4(p):
938 '''inc_or_dec_expression : lpvalue K_DECR %prec UNARY_PREC '''
939 if(parse_debug): print('inc_or_dec_expression_4', list(p))
940 # { PEUnary*tmp = new PEUnary('d', p[1]);
941 # FILE_NAME(tmp, @1);
942 # p[0] = tmp;
943 # }
944 ()
945 def p_inside_expression_1(p):
946 '''inside_expression : expression K_inside '{' open_range_list '}' '''
947 if(parse_debug): print('inside_expression_1', list(p))
948 # { yyerror(@2, "sorry: \"inside\" expressions not supported yet.");
949 # p[0] = None
950 # }
951 ()
952 def p_integer_vector_type_1(p):
953 '''integer_vector_type : K_reg '''
954 if(parse_debug): print('integer_vector_type_1', list(p))
955 p[0] = IVL_VT_NO_TYPE
956 ()
957 def p_integer_vector_type_2(p):
958 '''integer_vector_type : K_bit '''
959 if(parse_debug): print('integer_vector_type_2', list(p))
960 p[0] = IVL_VT_BOOL
961 ()
962 def p_integer_vector_type_3(p):
963 '''integer_vector_type : K_logic '''
964 if(parse_debug): print('integer_vector_type_3', list(p))
965 p[0] = IVL_VT_LOGIC
966 ()
967 def p_integer_vector_type_4(p):
968 '''integer_vector_type : K_bool '''
969 if(parse_debug): print('integer_vector_type_4', list(p))
970 # { p[0] = IVL_VT_BOOL; }
971 ()
972 def p_join_keyword_1(p):
973 '''join_keyword : K_join '''
974 if(parse_debug): print('join_keyword_1', list(p))
975 # { p[0] = PBlock::BL_PAR; }
976 ()
977 def p_join_keyword_2(p):
978 '''join_keyword : K_join_none '''
979 if(parse_debug): print('join_keyword_2', list(p))
980 # { p[0] = PBlock::BL_JOIN_NONE; }
981 ()
982 def p_join_keyword_3(p):
983 '''join_keyword : K_join_any '''
984 if(parse_debug): print('join_keyword_3', list(p))
985 # { p[0] = PBlock::BL_JOIN_ANY; }
986 ()
987 def p_jump_statement_1(p):
988 '''jump_statement : K_break ';' '''
989 if(parse_debug): print('jump_statement_1', list(p))
990 # { yyerror(@1, "sorry: break statements not supported.");
991 # p[0] = None
992 # }
993 ()
994 def p_jump_statement_2(p):
995 '''jump_statement : K_return ';' '''
996 if(parse_debug): print('jump_statement_2', list(p))
997 # { PReturn*tmp = new PReturn(0);
998 # FILE_NAME(tmp, @1);
999 # p[0] = tmp;
1000 # }
1001 ()
1002 def p_jump_statement_3(p):
1003 '''jump_statement : K_return expression ';' '''
1004 if(parse_debug): print('jump_statement_3', list(p))
1005 # { PReturn*tmp = new PReturn(p[2]);
1006 # FILE_NAME(tmp, @1);
1007 # p[0] = tmp;
1008 # }
1009 ()
1010 def p_lifetime_1(p):
1011 '''lifetime : K_automatic '''
1012 if(parse_debug): print('lifetime_1', list(p))
1013 # { p[0] = LexicalScope::AUTOMATIC; }
1014 ()
1015 def p_lifetime_2(p):
1016 '''lifetime : K_static '''
1017 if(parse_debug): print('lifetime_2', list(p))
1018 # { p[0] = LexicalScope::STATIC; }
1019 ()
1020 def p_lifetime_opt_1(p):
1021 '''lifetime_opt : lifetime '''
1022 if(parse_debug): print('lifetime_opt_1', list(p))
1023 p[0] = p[1]
1024 ()
1025 def p_lifetime_opt_2(p):
1026 '''lifetime_opt : '''
1027 if(parse_debug>2): print('lifetime_opt_2', list(p))
1028 # { p[0] = LexicalScope::INHERITED; }
1029 ()
1030 def p_loop_statement_1(p):
1031 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' for_step ')' statement_or_null '''
1032 if(parse_debug): print('loop_statement_1', list(p))
1033 # { PForStatement*tmp = new PForStatement(p[3], p[5], p[7], p[9], p[11]);
1034 # FILE_NAME(tmp, @1);
1035 # p[0] = tmp;
1036 # }
1037 ()
1038 def p_loop_statement_2(p):
1039 '''loop_statement : K_for '(' data_type IDENTIFIER '=' expression ';' expression ';' for_step ')' _embed0_loop_statement statement_or_null '''
1040 if(parse_debug): print('loop_statement_2', list(p))
1041 # { pform_name_t tmp_hident;
1042 # tmp_hident.push_back(name_component_t(lex_strings.make(p[4])));
1043 #
1044 # PEIdent*tmp_ident = pform_new_ident(tmp_hident);
1045 # FILE_NAME(tmp_ident, @4);
1046 #
1047 # PForStatement*tmp_for = new PForStatement(tmp_ident, p[6], p[8], p[10], p[13]);
1048 # FILE_NAME(tmp_for, @1);
1049 #
1050 # pform_pop_scope();
1051 # vector<Statement*>tmp_for_list (1);
1052 # tmp_for_list[0] = tmp_for;
1053 # PBlock*tmp_blk = current_block_stack.top();
1054 # current_block_stack.pop();
1055 # tmp_blk->set_statement(tmp_for_list);
1056 # p[0] = tmp_blk;
1057 # delete[]p[4];
1058 # }
1059 ()
1060 def p_loop_statement_3(p):
1061 '''loop_statement : K_forever statement_or_null '''
1062 if(parse_debug): print('loop_statement_3', list(p))
1063 # { PForever*tmp = new PForever(p[2]);
1064 # FILE_NAME(tmp, @1);
1065 # p[0] = tmp;
1066 # }
1067 ()
1068 def p_loop_statement_4(p):
1069 '''loop_statement : K_repeat '(' expression ')' statement_or_null '''
1070 if(parse_debug): print('loop_statement_4', list(p))
1071 # { PRepeat*tmp = new PRepeat(p[3], p[5]);
1072 # FILE_NAME(tmp, @1);
1073 # p[0] = tmp;
1074 # }
1075 ()
1076 def p_loop_statement_5(p):
1077 '''loop_statement : K_while '(' expression ')' statement_or_null '''
1078 if(parse_debug): print('loop_statement_5', list(p))
1079 # { PWhile*tmp = new PWhile(p[3], p[5]);
1080 # FILE_NAME(tmp, @1);
1081 # p[0] = tmp;
1082 # }
1083 ()
1084 def p_loop_statement_6(p):
1085 '''loop_statement : K_do statement_or_null K_while '(' expression ')' ';' '''
1086 if(parse_debug): print('loop_statement_6', list(p))
1087 # { PDoWhile*tmp = new PDoWhile(p[5], p[2]);
1088 # FILE_NAME(tmp, @1);
1089 # p[0] = tmp;
1090 # }
1091 ()
1092 def p_loop_statement_7(p):
1093 '''loop_statement : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' _embed1_loop_statement statement_or_null '''
1094 if(parse_debug): print('loop_statement_7', list(p))
1095 # { PForeach*tmp_for = pform_make_foreach(@1, p[3], p[5], p[9]);
1096 #
1097 # pform_pop_scope();
1098 # vector<Statement*>tmp_for_list(1);
1099 # tmp_for_list[0] = tmp_for;
1100 # PBlock*tmp_blk = current_block_stack.top();
1101 # current_block_stack.pop();
1102 # tmp_blk->set_statement(tmp_for_list);
1103 # p[0] = tmp_blk;
1104 # }
1105 ()
1106 def p_loop_statement_8(p):
1107 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' error ')' statement_or_null '''
1108 if(parse_debug): print('loop_statement_8', list(p))
1109 # { p[0] = None
1110 # yyerror(@1, "error: Error in for loop step assignment.");
1111 # }
1112 ()
1113 def p_loop_statement_9(p):
1114 '''loop_statement : K_for '(' lpvalue '=' expression ';' error ';' for_step ')' statement_or_null '''
1115 if(parse_debug): print('loop_statement_9', list(p))
1116 # { p[0] = None
1117 # yyerror(@1, "error: Error in for loop condition expression.");
1118 # }
1119 ()
1120 def p_loop_statement_10(p):
1121 '''loop_statement : K_for '(' error ')' statement_or_null '''
1122 if(parse_debug): print('loop_statement_10', list(p))
1123 # { p[0] = None
1124 # yyerror(@1, "error: Incomprehensible for loop.");
1125 # }
1126 ()
1127 def p_loop_statement_11(p):
1128 '''loop_statement : K_while '(' error ')' statement_or_null '''
1129 if(parse_debug): print('loop_statement_11', list(p))
1130 # { p[0] = None
1131 # yyerror(@1, "error: Error in while loop condition.");
1132 # }
1133 ()
1134 def p_loop_statement_12(p):
1135 '''loop_statement : K_do statement_or_null K_while '(' error ')' ';' '''
1136 if(parse_debug): print('loop_statement_12', list(p))
1137 # { p[0] = None
1138 # yyerror(@1, "error: Error in do/while loop condition.");
1139 # }
1140 ()
1141 def p_loop_statement_13(p):
1142 '''loop_statement : K_foreach '(' IDENTIFIER '[' error ']' ')' statement_or_null '''
1143 if(parse_debug): print('loop_statement_13', list(p))
1144 # { p[0] = None
1145 # yyerror(@4, "error: Errors in foreach loop variables list.");
1146 # }
1147 ()
1148 def p__embed0_loop_statement(p):
1149 '''_embed0_loop_statement : '''
1150 # { static unsigned for_counter = 0;
1151 # char for_block_name [64];
1152 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_for_loop%u", for_counter);
1153 # for_counter += 1;
1154 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1155 # FILE_NAME(tmp, @1);
1156 # current_block_stack.push(tmp);
1157 #
1158 # list<decl_assignment_t*>assign_list;
1159 # decl_assignment_t*tmp_assign = new decl_assignment_t;
1160 # tmp_assign->name = lex_strings.make(p[4]);
1161 # assign_list.push_back(tmp_assign);
1162 # pform_makewire(@4, 0, str_strength, &assign_list, NetNet::REG, p[3]);
1163 # }
1164 ()
1165 def p__embed1_loop_statement(p):
1166 '''_embed1_loop_statement : '''
1167 # { static unsigned foreach_counter = 0;
1168 # char for_block_name[64];
1169 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_foreach%u", foreach_counter);
1170 # foreach_counter += 1;
1171 #
1172 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1173 # FILE_NAME(tmp, @1);
1174 # current_block_stack.push(tmp);
1175 #
1176 # pform_make_foreach_declarations(@1, p[5]);
1177 # }
1178 ()
1179 def p_list_of_variable_decl_assignments_1(p):
1180 '''list_of_variable_decl_assignments : variable_decl_assignment '''
1181 if(parse_debug): print('list_of_variable_decl_assignments_1', list(p))
1182 # { list<decl_assignment_t*>*tmp = new list<decl_assignment_t*>;
1183 # tmp->push_back(p[1]);
1184 # p[0] = tmp;
1185 # }
1186 ()
1187 def p_list_of_variable_decl_assignments_2(p):
1188 '''list_of_variable_decl_assignments : list_of_variable_decl_assignments ',' variable_decl_assignment '''
1189 if(parse_debug): print('list_of_variable_decl_assignments_2', list(p))
1190 # { list<decl_assignment_t*>*tmp = p[1];
1191 # tmp->push_back(p[3]);
1192 # p[0] = tmp;
1193 # }
1194 ()
1195 def p_variable_decl_assignment_1(p):
1196 '''variable_decl_assignment : IDENTIFIER dimensions_opt '''
1197 if(parse_debug): print('variable_decl_assignment_1', list(p))
1198 # { decl_assignment_t*tmp = new decl_assignment_t;
1199 # tmp->name = lex_strings.make(p[1]);
1200 # if (p[2]) {
1201 # tmp->index = *p[2];
1202 # delete p[2];
1203 # }
1204 # delete[]p[1];
1205 # p[0] = tmp;
1206 # }
1207 ()
1208 def p_variable_decl_assignment_2(p):
1209 '''variable_decl_assignment : IDENTIFIER '=' expression '''
1210 if(parse_debug): print('variable_decl_assignment_2', list(p))
1211 # { decl_assignment_t*tmp = new decl_assignment_t;
1212 # tmp->name = lex_strings.make(p[1]);
1213 # tmp->expr .reset(p[3]);
1214 # delete[]p[1];
1215 # p[0] = tmp;
1216 # }
1217 ()
1218 def p_variable_decl_assignment_3(p):
1219 '''variable_decl_assignment : IDENTIFIER '=' K_new '(' ')' '''
1220 if(parse_debug): print('variable_decl_assignment_3', list(p))
1221 # { decl_assignment_t*tmp = new decl_assignment_t;
1222 # tmp->name = lex_strings.make(p[1]);
1223 # PENewClass*expr = new PENewClass;
1224 # FILE_NAME(expr, @3);
1225 # tmp->expr .reset(expr);
1226 # delete[]p[1];
1227 # p[0] = tmp;
1228 # }
1229 ()
1230 def p_loop_variables_1(p):
1231 '''loop_variables : loop_variables ',' IDENTIFIER '''
1232 if(parse_debug): print('loop_variables_1', list(p))
1233 # { list<perm_string>*tmp = p[1];
1234 # tmp->push_back(lex_strings.make(p[3]));
1235 # delete[]p[3];
1236 # p[0] = tmp;
1237 # }
1238 ()
1239 def p_loop_variables_2(p):
1240 '''loop_variables : IDENTIFIER '''
1241 if(parse_debug): print('loop_variables_2', list(p))
1242 # { list<perm_string>*tmp = new list<perm_string>;
1243 # tmp->push_back(lex_strings.make(p[1]));
1244 # delete[]p[1];
1245 # p[0] = tmp;
1246 # }
1247 ()
1248 def p_method_qualifier_1(p):
1249 '''method_qualifier : K_virtual '''
1250 if(parse_debug): print('method_qualifier_1', list(p))
1251 ()
1252 def p_method_qualifier_2(p):
1253 '''method_qualifier : class_item_qualifier '''
1254 if(parse_debug): print('method_qualifier_2', list(p))
1255 ()
1256 def p_method_qualifier_opt_1(p):
1257 '''method_qualifier_opt : method_qualifier '''
1258 if(parse_debug): print('method_qualifier_opt_1', list(p))
1259 ()
1260 def p_method_qualifier_opt_2(p):
1261 '''method_qualifier_opt : '''
1262 if(parse_debug): print('method_qualifier_opt_2', list(p))
1263 ()
1264 def p_modport_declaration_1(p):
1265 '''modport_declaration : K_modport _embed0_modport_declaration modport_item_list ';' '''
1266 if(parse_debug): print('modport_declaration_1', list(p))
1267 ()
1268 def p__embed0_modport_declaration(p):
1269 '''_embed0_modport_declaration : '''
1270 # { if (!pform_in_interface())
1271 # yyerror(@1, "error: modport declarations are only allowed "
1272 # "in interfaces.");
1273 # }
1274 ()
1275 def p_modport_item_list_1(p):
1276 '''modport_item_list : modport_item '''
1277 if(parse_debug): print('modport_item_list_1', list(p))
1278 ()
1279 def p_modport_item_list_2(p):
1280 '''modport_item_list : modport_item_list ',' modport_item '''
1281 if(parse_debug): print('modport_item_list_2', list(p))
1282 ()
1283 def p_modport_item_1(p):
1284 '''modport_item : IDENTIFIER _embed0_modport_item '(' modport_ports_list ')' '''
1285 if(parse_debug): print('modport_item_1', list(p))
1286 # { pform_end_modport_item(@1); }
1287 ()
1288 def p__embed0_modport_item(p):
1289 '''_embed0_modport_item : '''
1290 # { pform_start_modport_item(@1, p[1]); }
1291 ()
1292 def p_modport_ports_list_1(p):
1293 '''modport_ports_list : modport_ports_declaration '''
1294 if(parse_debug): print('modport_ports_list_1', list(p))
1295 ()
1296 def p_modport_ports_list_2(p):
1297 '''modport_ports_list : modport_ports_list ',' modport_ports_declaration '''
1298 if(parse_debug): print('modport_ports_list_2', list(p))
1299 ()
1300 def p_modport_ports_list_3(p):
1301 '''modport_ports_list : modport_ports_list ',' modport_simple_port '''
1302 if(parse_debug): print('modport_ports_list_3', list(p))
1303 # { if (last_modport_port.type == MP_SIMPLE) {
1304 # pform_add_modport_port(@3, last_modport_port.direction,
1305 # p[3]->name, p[3]->parm);
1306 # } else {
1307 # yyerror(@3, "error: modport expression not allowed here.");
1308 # }
1309 # delete p[3];
1310 # }
1311 ()
1312 def p_modport_ports_list_4(p):
1313 '''modport_ports_list : modport_ports_list ',' modport_tf_port '''
1314 if(parse_debug): print('modport_ports_list_4', list(p))
1315 # { if (last_modport_port.type != MP_TF)
1316 # yyerror(@3, "error: task/function declaration not allowed here.");
1317 # }
1318 ()
1319 def p_modport_ports_list_5(p):
1320 '''modport_ports_list : modport_ports_list ',' IDENTIFIER '''
1321 if(parse_debug): print('modport_ports_list_5', list(p))
1322 # { if (last_modport_port.type == MP_SIMPLE) {
1323 # pform_add_modport_port(@3, last_modport_port.direction,
1324 # lex_strings.make(p[3]), 0);
1325 # } else if (last_modport_port.type != MP_TF) {
1326 # yyerror(@3, "error: list of identifiers not allowed here.");
1327 # }
1328 # delete[] p[3];
1329 # }
1330 ()
1331 def p_modport_ports_list_6(p):
1332 '''modport_ports_list : modport_ports_list ',' '''
1333 if(parse_debug): print('modport_ports_list_6', list(p))
1334 # { yyerror(@2, "error: NULL port declarations are not allowed"); }
1335 ()
1336 def p_modport_ports_declaration_1(p):
1337 '''modport_ports_declaration : attribute_list_opt port_direction IDENTIFIER '''
1338 if(parse_debug): print('modport_ports_declaration_1', list(p))
1339 # { last_modport_port.type = MP_SIMPLE;
1340 # last_modport_port.direction = p[2];
1341 # pform_add_modport_port(@3, p[2], lex_strings.make(p[3]), 0);
1342 # delete[] p[3];
1343 # delete p[1];
1344 # }
1345 ()
1346 def p_modport_ports_declaration_2(p):
1347 '''modport_ports_declaration : attribute_list_opt port_direction modport_simple_port '''
1348 if(parse_debug): print('modport_ports_declaration_2', list(p))
1349 # { last_modport_port.type = MP_SIMPLE;
1350 # last_modport_port.direction = p[2];
1351 # pform_add_modport_port(@3, p[2], p[3]->name, p[3]->parm);
1352 # delete p[3];
1353 # delete p[1];
1354 # }
1355 ()
1356 def p_modport_ports_declaration_3(p):
1357 '''modport_ports_declaration : attribute_list_opt import_export IDENTIFIER '''
1358 if(parse_debug): print('modport_ports_declaration_3', list(p))
1359 # { last_modport_port.type = MP_TF;
1360 # last_modport_port.is_import = p[2];
1361 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
1362 # delete[] p[3];
1363 # delete p[1];
1364 # }
1365 ()
1366 def p_modport_ports_declaration_4(p):
1367 '''modport_ports_declaration : attribute_list_opt import_export modport_tf_port '''
1368 if(parse_debug): print('modport_ports_declaration_4', list(p))
1369 # { last_modport_port.type = MP_TF;
1370 # last_modport_port.is_import = p[2];
1371 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
1372 # delete p[1];
1373 # }
1374 ()
1375 def p_modport_ports_declaration_5(p):
1376 '''modport_ports_declaration : attribute_list_opt K_clocking IDENTIFIER '''
1377 if(parse_debug): print('modport_ports_declaration_5', list(p))
1378 # { last_modport_port.type = MP_CLOCKING;
1379 # last_modport_port.direction = NetNet::NOT_A_PORT;
1380 # yyerror(@3, "sorry: modport clocking declaration is not yet supported.");
1381 # delete[] p[3];
1382 # delete p[1];
1383 # }
1384 ()
1385 def p_modport_simple_port_1(p):
1386 '''modport_simple_port : '.' IDENTIFIER '(' expression ')' '''
1387 if(parse_debug): print('modport_simple_port_1', list(p))
1388 # { named_pexpr_t*tmp = new named_pexpr_t;
1389 # tmp->name = lex_strings.make(p[2]);
1390 # tmp->parm = p[4];
1391 # delete[]p[2];
1392 # p[0] = tmp;
1393 # }
1394 ()
1395 def p_modport_tf_port_1(p):
1396 '''modport_tf_port : K_task IDENTIFIER '''
1397 if(parse_debug): print('modport_tf_port_1', list(p))
1398 ()
1399 def p_modport_tf_port_2(p):
1400 '''modport_tf_port : K_task IDENTIFIER '(' tf_port_list_opt ')' '''
1401 if(parse_debug): print('modport_tf_port_2', list(p))
1402 ()
1403 def p_modport_tf_port_3(p):
1404 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '''
1405 if(parse_debug): print('modport_tf_port_3', list(p))
1406 ()
1407 def p_modport_tf_port_4(p):
1408 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' '''
1409 if(parse_debug): print('modport_tf_port_4', list(p))
1410 ()
1411 def p_non_integer_type_1(p):
1412 '''non_integer_type : K_real '''
1413 if(parse_debug): print('non_integer_type_1', list(p))
1414 # { p[0] = real_type_t::REAL; }
1415 ()
1416 def p_non_integer_type_2(p):
1417 '''non_integer_type : K_realtime '''
1418 if(parse_debug): print('non_integer_type_2', list(p))
1419 # { p[0] = real_type_t::REAL; }
1420 ()
1421 def p_non_integer_type_3(p):
1422 '''non_integer_type : K_shortreal '''
1423 if(parse_debug): print('non_integer_type_3', list(p))
1424 # { p[0] = real_type_t::SHORTREAL; }
1425 ()
1426 def p_number_1(p):
1427 '''number : BASED_NUMBER '''
1428 if(parse_debug): print('number_1', list(p))
1429 # { p[0] = p[1]; based_size = 0;}
1430 ()
1431 def p_number_2(p):
1432 '''number : DEC_NUMBER '''
1433 if(parse_debug): print('number_2', list(p))
1434 num = Leaf(token.NUMBER, "%s" % (p[1]))
1435 p[0] = num
1436 # { p[0] = p[1]; based_size = 0;}
1437 ()
1438 def p_number_3(p):
1439 '''number : DEC_NUMBER BASED_NUMBER '''
1440 if(parse_debug): print('number_3', list(p))
1441 num = Leaf(token.NUMBER, "%s:%s" % (p[1], p[2]))
1442 p[0] = num
1443 # { p[0] = pform_verinum_with_size(p[1],p[2], @2.text, @2.first_line);
1444 # based_size = 0; }
1445 ()
1446 def p_number_4(p):
1447 '''number : UNBASED_NUMBER '''
1448 if(parse_debug): print('number_4', list(p))
1449 # { p[0] = p[1]; based_size = 0;}
1450 ()
1451 def p_number_5(p):
1452 '''number : DEC_NUMBER UNBASED_NUMBER '''
1453 if(parse_debug): print('number_5', list(p))
1454 # { yyerror(@1, "error: Unbased SystemVerilog literal cannot have "
1455 # "a size.");
1456 # p[0] = p[1]; based_size = 0;}
1457 ()
1458 def p_open_range_list_1(p):
1459 '''open_range_list : open_range_list ',' value_range '''
1460 if(parse_debug): print('open_range_list_1', list(p))
1461 ()
1462 def p_open_range_list_2(p):
1463 '''open_range_list : value_range '''
1464 if(parse_debug): print('open_range_list_2', list(p))
1465 ()
1466 def p_package_declaration_1(p):
1467 '''package_declaration : K_package lifetime_opt IDENTIFIER ';' _embed0_package_declaration timeunits_declaration_opt _embed1_package_declaration package_item_list_opt K_endpackage endlabel_opt '''
1468 if(parse_debug): print('package_declaration_1', list(p))
1469 # { pform_end_package_declaration(@1);
1470 # // If an end label is present make sure it match the package name.
1471 # if (p[10]) {
1472 # if (strcmp(p[3],p[10]) != 0) {
1473 # yyerror(@10, "error: End label doesn't match package name");
1474 # }
1475 # delete[]p[10];
1476 # }
1477 # delete[]p[3];
1478 # }
1479 ()
1480 def p__embed0_package_declaration(p):
1481 '''_embed0_package_declaration : '''
1482 # { pform_start_package_declaration(@1, p[3], p[2]); }
1483 ()
1484 def p__embed1_package_declaration(p):
1485 '''_embed1_package_declaration : '''
1486 # { pform_set_scope_timescale(@1); }
1487 ()
1488 def p_module_package_import_list_opt_1(p):
1489 '''module_package_import_list_opt : '''
1490 if(parse_debug>1): print('module_package_import_list_opt_1', list(p))
1491 ()
1492 def p_module_package_import_list_opt_2(p):
1493 '''module_package_import_list_opt : package_import_list '''
1494 if(parse_debug): print('module_package_import_list_opt_2', list(p))
1495 ()
1496 def p_package_import_list_1(p):
1497 '''package_import_list : package_import_declaration '''
1498 if(parse_debug): print('package_import_list_1', list(p))
1499 ()
1500 def p_package_import_list_2(p):
1501 '''package_import_list : package_import_list package_import_declaration '''
1502 if(parse_debug): print('package_import_list_2', list(p))
1503 ()
1504 def p_package_import_declaration_1(p):
1505 '''package_import_declaration : K_import package_import_item_list ';' '''
1506 if(parse_debug): print('package_import_declaration_1', list(p))
1507 # { }
1508 ()
1509 def p_package_import_item_1(p):
1510 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '''
1511 if(parse_debug): print('package_import_item_1', list(p))
1512 # { pform_package_import(@2, p[1], p[3]);
1513 # delete[]p[3];
1514 # }
1515 ()
1516 def p_package_import_item_2(p):
1517 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES '*' '''
1518 if(parse_debug): print('package_import_item_2', list(p))
1519 # { pform_package_import(@2, p[1], 0);
1520 # }
1521 ()
1522 def p_package_import_item_list_1(p):
1523 '''package_import_item_list : package_import_item_list ',' package_import_item '''
1524 if(parse_debug): print('package_import_item_list_1', list(p))
1525 ()
1526 def p_package_import_item_list_2(p):
1527 '''package_import_item_list : package_import_item '''
1528 if(parse_debug): print('package_import_item_list_2', list(p))
1529 ()
1530 def p_package_item_1(p):
1531 '''package_item : timeunits_declaration '''
1532 if(parse_debug): print('package_item_1', list(p))
1533 ()
1534 def p_package_item_2(p):
1535 '''package_item : K_parameter param_type parameter_assign_list ';' '''
1536 if(parse_debug): print('package_item_2', list(p))
1537 ()
1538 def p_package_item_3(p):
1539 '''package_item : K_localparam param_type localparam_assign_list ';' '''
1540 if(parse_debug): print('package_item_3', list(p))
1541 ()
1542 def p_package_item_4(p):
1543 '''package_item : type_declaration '''
1544 if(parse_debug): print('package_item_4', list(p))
1545 ()
1546 def p_package_item_5(p):
1547 '''package_item : function_declaration '''
1548 if(parse_debug): print('package_item_5', list(p))
1549 ()
1550 def p_package_item_6(p):
1551 '''package_item : task_declaration '''
1552 if(parse_debug): print('package_item_6', list(p))
1553 ()
1554 def p_package_item_7(p):
1555 '''package_item : data_declaration '''
1556 if(parse_debug): print('package_item_7', list(p))
1557 ()
1558 def p_package_item_8(p):
1559 '''package_item : class_declaration '''
1560 if(parse_debug): print('package_item_8', list(p))
1561 ()
1562 def p_package_item_list_1(p):
1563 '''package_item_list : package_item_list package_item '''
1564 if(parse_debug): print('package_item_list_1', list(p))
1565 ()
1566 def p_package_item_list_2(p):
1567 '''package_item_list : package_item '''
1568 if(parse_debug): print('package_item_list_2', list(p))
1569 ()
1570 def p_package_item_list_opt_1(p):
1571 '''package_item_list_opt : package_item_list '''
1572 if(parse_debug): print('package_item_list_opt_1', list(p))
1573 ()
1574 def p_package_item_list_opt_2(p):
1575 '''package_item_list_opt : '''
1576 if(parse_debug): print('package_item_list_opt_2', list(p))
1577 ()
1578 def p_port_direction_1(p):
1579 '''port_direction : K_input '''
1580 if(parse_debug): print('port_direction_1', list(p))
1581 # { p[0] = NetNet::PINPUT; }
1582 ()
1583 def p_port_direction_2(p):
1584 '''port_direction : K_output '''
1585 if(parse_debug): print('port_direction_2', list(p))
1586 # { p[0] = NetNet::POUTPUT; }
1587 ()
1588 def p_port_direction_3(p):
1589 '''port_direction : K_inout '''
1590 if(parse_debug): print('port_direction_3', list(p))
1591 # { p[0] = NetNet::PINOUT; }
1592 ()
1593 def p_port_direction_4(p):
1594 '''port_direction : K_ref '''
1595 if(parse_debug): print('port_direction_4', list(p))
1596 # { p[0] = NetNet::PREF;
1597 # if (!gn_system_verilog()) {
1598 # yyerror(@1, "error: Reference ports (ref) require SystemVerilog.");
1599 # p[0] = NetNet::PINPUT;
1600 # }
1601 # }
1602 ()
1603 def p_port_direction_opt_1(p):
1604 '''port_direction_opt : port_direction '''
1605 if(parse_debug): print('port_direction_opt_1', list(p))
1606 p[0] = p[1]
1607 ()
1608 def p_port_direction_opt_2(p):
1609 '''port_direction_opt : '''
1610 if(parse_debug): print('port_direction_opt_2', list(p))
1611 # { p[0] = NetNet::PIMPLICIT; }
1612 ()
1613 def p_property_expr_1(p):
1614 '''property_expr : expression '''
1615 if(parse_debug): print('property_expr_1', list(p))
1616 ()
1617 def p_procedural_assertion_statement_1(p):
1618 '''procedural_assertion_statement : K_assert '(' expression ')' statement %prec less_than_K_else '''
1619 if(parse_debug): print('procedural_assertion_statement_1', list(p))
1620 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
1621 # p[0] = None
1622 # }
1623 ()
1624 def p_procedural_assertion_statement_2(p):
1625 '''procedural_assertion_statement : K_assert '(' expression ')' K_else statement '''
1626 if(parse_debug): print('procedural_assertion_statement_2', list(p))
1627 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
1628 # p[0] = None
1629 # }
1630 ()
1631 def p_procedural_assertion_statement_3(p):
1632 '''procedural_assertion_statement : K_assert '(' expression ')' statement K_else statement '''
1633 if(parse_debug): print('procedural_assertion_statement_3', list(p))
1634 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
1635 # p[0] = None
1636 # }
1637 ()
1638 def p_property_qualifier_1(p):
1639 '''property_qualifier : class_item_qualifier '''
1640 if(parse_debug): print('property_qualifier_1', list(p))
1641 ()
1642 def p_property_qualifier_2(p):
1643 '''property_qualifier : random_qualifier '''
1644 if(parse_debug): print('property_qualifier_2', list(p))
1645 ()
1646 def p_property_qualifier_opt_1(p):
1647 '''property_qualifier_opt : property_qualifier_list '''
1648 if(parse_debug): print('property_qualifier_opt_1', list(p))
1649 p[0] = p[1]
1650 ()
1651 def p_property_qualifier_opt_2(p):
1652 '''property_qualifier_opt : '''
1653 if(parse_debug): print('property_qualifier_opt_2', list(p))
1654 # { p[0] = property_qualifier_t::make_none(); }
1655 ()
1656 def p_property_qualifier_list_1(p):
1657 '''property_qualifier_list : property_qualifier_list property_qualifier '''
1658 if(parse_debug): print('property_qualifier_list_1', list(p))
1659 # { p[0] = p[1] | p[2]; }
1660 ()
1661 def p_property_qualifier_list_2(p):
1662 '''property_qualifier_list : property_qualifier '''
1663 if(parse_debug): print('property_qualifier_list_2', list(p))
1664 p[0] = p[1]
1665 ()
1666 def p_property_spec_1(p):
1667 '''property_spec : clocking_event_opt property_spec_disable_iff_opt property_expr '''
1668 if(parse_debug): print('property_spec_1', list(p))
1669 ()
1670 def p_property_spec_disable_iff_opt_1(p):
1671 '''property_spec_disable_iff_opt : K_disable K_iff '(' expression ')' '''
1672 if(parse_debug): print('property_spec_disable_iff_opt_1', list(p))
1673 ()
1674 def p_property_spec_disable_iff_opt_2(p):
1675 '''property_spec_disable_iff_opt : '''
1676 if(parse_debug): print('property_spec_disable_iff_opt_2', list(p))
1677 ()
1678 def p_random_qualifier_1(p):
1679 '''random_qualifier : K_rand '''
1680 if(parse_debug): print('random_qualifier_1', list(p))
1681 # { p[0] = property_qualifier_t::make_rand(); }
1682 ()
1683 def p_random_qualifier_2(p):
1684 '''random_qualifier : K_randc '''
1685 if(parse_debug): print('random_qualifier_2', list(p))
1686 # { p[0] = property_qualifier_t::make_randc(); }
1687 ()
1688 def p_real_or_realtime_1(p):
1689 '''real_or_realtime : K_real '''
1690 if(parse_debug): print('real_or_realtime_1', list(p))
1691 ()
1692 def p_real_or_realtime_2(p):
1693 '''real_or_realtime : K_realtime '''
1694 if(parse_debug): print('real_or_realtime_2', list(p))
1695 ()
1696 def p_signing_1(p):
1697 '''signing : K_signed '''
1698 if(parse_debug): print('signing_1', list(p))
1699 p[0] = True
1700 ()
1701 def p_signing_2(p):
1702 '''signing : K_unsigned '''
1703 if(parse_debug): print('signing_2', list(p))
1704 p[0] = False
1705 ()
1706 def p_simple_type_or_string_1(p):
1707 '''simple_type_or_string : integer_vector_type '''
1708 if(parse_debug): print('simple_type_or_string_1', list(p))
1709 # { ivl_variable_type_t use_vtype = p[1];
1710 # bool reg_flag = false;
1711 # if (use_vtype == IVL_VT_NO_TYPE) {
1712 # use_vtype = IVL_VT_LOGIC;
1713 # reg_flag = true;
1714 # }
1715 # vector_type_t*tmp = new vector_type_t(use_vtype, false, 0);
1716 # tmp->reg_flag = reg_flag;
1717 # FILE_NAME(tmp, @1);
1718 # p[0] = tmp;
1719 # }
1720 ()
1721 def p_simple_type_or_string_2(p):
1722 '''simple_type_or_string : non_integer_type '''
1723 if(parse_debug): print('simple_type_or_string_2', list(p))
1724 # { real_type_t*tmp = new real_type_t(p[1]);
1725 # FILE_NAME(tmp, @1);
1726 # p[0] = tmp;
1727 # }
1728 ()
1729 def p_simple_type_or_string_3(p):
1730 '''simple_type_or_string : atom2_type '''
1731 if(parse_debug): print('simple_type_or_string_3', list(p))
1732 # { atom2_type_t*tmp = new atom2_type_t(p[1], true);
1733 # FILE_NAME(tmp, @1);
1734 # p[0] = tmp;
1735 # }
1736 ()
1737 def p_simple_type_or_string_4(p):
1738 '''simple_type_or_string : K_integer '''
1739 if(parse_debug): print('simple_type_or_string_4', list(p))
1740 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
1741 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, true, pd);
1742 # tmp->reg_flag = true;
1743 # tmp->integer_flag = true;
1744 # p[0] = tmp;
1745 # }
1746 ()
1747 def p_simple_type_or_string_5(p):
1748 '''simple_type_or_string : K_time '''
1749 if(parse_debug): print('simple_type_or_string_5', list(p))
1750 # { list<pform_range_t>*pd = make_range_from_width(64);
1751 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
1752 # tmp->reg_flag = !gn_system_verilog();
1753 # p[0] = tmp;
1754 # }
1755 ()
1756 def p_simple_type_or_string_6(p):
1757 '''simple_type_or_string : TYPE_IDENTIFIER '''
1758 if(parse_debug): print('simple_type_or_string_6', list(p))
1759 # { p[0] = p[1].type;
1760 # delete[]p[1].text;
1761 # }
1762 ()
1763 def p_simple_type_or_string_7(p):
1764 '''simple_type_or_string : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_simple_type_or_string TYPE_IDENTIFIER '''
1765 if(parse_debug): print('simple_type_or_string_7', list(p))
1766 # { lex_in_package_scope(0);
1767 # p[0] = p[4].type;
1768 # delete[]p[4].text;
1769 # }
1770 ()
1771 def p_simple_type_or_string_8(p):
1772 '''simple_type_or_string : K_string '''
1773 if(parse_debug): print('simple_type_or_string_8', list(p))
1774 # { string_type_t*tmp = new string_type_t;
1775 # FILE_NAME(tmp, @1);
1776 # p[0] = tmp;
1777 # }
1778 ()
1779 def p__embed0_simple_type_or_string(p):
1780 '''_embed0_simple_type_or_string : '''
1781 # { lex_in_package_scope(p[1]); }
1782 ()
1783 def p_statement_1(p):
1784 '''statement : attribute_list_opt statement_item '''
1785 if(parse_debug): print('statement_1', list(p))
1786 # { pform_bind_attributes(p[2]->attributes, p[1]);
1787 # p[0] = p[2];
1788 # }
1789 ()
1790 def p_statement_or_null_1(p):
1791 '''statement_or_null : statement '''
1792 if(parse_debug): print('statement_or_null_1', list(p))
1793 p[0] = p[1]
1794 ()
1795 def p_statement_or_null_2(p):
1796 '''statement_or_null : attribute_list_opt ';' '''
1797 if(parse_debug): print('statement_or_null_2', list(p))
1798 # { p[0] = None }
1799 ()
1800 def p_stream_expression_1(p):
1801 '''stream_expression : expression '''
1802 if(parse_debug): print('stream_expression_1', list(p))
1803 ()
1804 def p_stream_expression_list_1(p):
1805 '''stream_expression_list : stream_expression_list ',' stream_expression '''
1806 if(parse_debug): print('stream_expression_list_1', list(p))
1807 ()
1808 def p_stream_expression_list_2(p):
1809 '''stream_expression_list : stream_expression '''
1810 if(parse_debug): print('stream_expression_list_2', list(p))
1811 ()
1812 def p_stream_operator_1(p):
1813 '''stream_operator : K_LS '''
1814 if(parse_debug): print('stream_operator_1', list(p))
1815 ()
1816 def p_stream_operator_2(p):
1817 '''stream_operator : K_RS '''
1818 if(parse_debug): print('stream_operator_2', list(p))
1819 ()
1820 def p_streaming_concatenation_1(p):
1821 '''streaming_concatenation : '{' stream_operator '{' stream_expression_list '}' '}' '''
1822 if(parse_debug): print('streaming_concatenation_1', list(p))
1823 # { /* streaming concatenation is a SystemVerilog thing. */
1824 # if (gn_system_verilog()) {
1825 # yyerror(@2, "sorry: Streaming concatenation not supported.");
1826 # p[0] = None
1827 # } else {
1828 # yyerror(@2, "error: Streaming concatenation requires SystemVerilog");
1829 # p[0] = None
1830 # }
1831 # }
1832 ()
1833 def p_task_declaration_1(p):
1834 '''task_declaration : K_task lifetime_opt IDENTIFIER ';' _embed0_task_declaration task_item_list_opt statement_or_null_list_opt K_endtask _embed1_task_declaration endlabel_opt '''
1835 if(parse_debug): print('task_declaration_1', list(p))
1836 # { // Last step: check any closing name. This is done late so
1837 # // that the parser can look ahead to detect the present
1838 # // endlabel_opt but still have the pform_endmodule() called
1839 # // early enough that the lexor can know we are outside the
1840 # // module.
1841 # if (p[10]) {
1842 # if (strcmp(p[3],p[10]) != 0) {
1843 # yyerror(@10, "error: End label doesn't match task name");
1844 # }
1845 # if (! gn_system_verilog()) {
1846 # yyerror(@10, "error: Task end labels require "
1847 # "SystemVerilog.");
1848 # }
1849 # delete[]p[10];
1850 # }
1851 # delete[]p[3];
1852 # }
1853 ()
1854 def p_task_declaration_2(p):
1855 '''task_declaration : K_task lifetime_opt IDENTIFIER '(' _embed2_task_declaration tf_port_list ')' ';' block_item_decls_opt statement_or_null_list_opt K_endtask _embed3_task_declaration endlabel_opt '''
1856 if(parse_debug): print('task_declaration_2', list(p))
1857 # { // Last step: check any closing name. This is done late so
1858 # // that the parser can look ahead to detect the present
1859 # // endlabel_opt but still have the pform_endmodule() called
1860 # // early enough that the lexor can know we are outside the
1861 # // module.
1862 # if (p[13]) {
1863 # if (strcmp(p[3],p[13]) != 0) {
1864 # yyerror(@13, "error: End label doesn't match task name");
1865 # }
1866 # if (! gn_system_verilog()) {
1867 # yyerror(@13, "error: Task end labels require "
1868 # "SystemVerilog.");
1869 # }
1870 # delete[]p[13];
1871 # }
1872 # delete[]p[3];
1873 # }
1874 ()
1875 def p_task_declaration_3(p):
1876 '''task_declaration : K_task lifetime_opt IDENTIFIER '(' ')' ';' _embed4_task_declaration block_item_decls_opt statement_or_null_list K_endtask _embed5_task_declaration endlabel_opt '''
1877 if(parse_debug): print('task_declaration_3', list(p))
1878 # { // Last step: check any closing name. This is done late so
1879 # // that the parser can look ahead to detect the present
1880 # // endlabel_opt but still have the pform_endmodule() called
1881 # // early enough that the lexor can know we are outside the
1882 # // module.
1883 # if (p[12]) {
1884 # if (strcmp(p[3],p[12]) != 0) {
1885 # yyerror(@12, "error: End label doesn't match task name");
1886 # }
1887 # if (! gn_system_verilog()) {
1888 # yyerror(@12, "error: Task end labels require "
1889 # "SystemVerilog.");
1890 # }
1891 # delete[]p[12];
1892 # }
1893 # delete[]p[3];
1894 # }
1895 ()
1896 def p_task_declaration_4(p):
1897 '''task_declaration : K_task lifetime_opt IDENTIFIER error K_endtask _embed6_task_declaration endlabel_opt '''
1898 if(parse_debug): print('task_declaration_4', list(p))
1899 # { // Last step: check any closing name. This is done late so
1900 # // that the parser can look ahead to detect the present
1901 # // endlabel_opt but still have the pform_endmodule() called
1902 # // early enough that the lexor can know we are outside the
1903 # // module.
1904 # if (p[7]) {
1905 # if (strcmp(p[3],p[7]) != 0) {
1906 # yyerror(@7, "error: End label doesn't match task name");
1907 # }
1908 # if (! gn_system_verilog()) {
1909 # yyerror(@7, "error: Task end labels require "
1910 # "SystemVerilog.");
1911 # }
1912 # delete[]p[7];
1913 # }
1914 # delete[]p[3];
1915 # }
1916 ()
1917 def p__embed0_task_declaration(p):
1918 '''_embed0_task_declaration : '''
1919 # { assert(current_task == 0);
1920 # current_task = pform_push_task_scope(@1, p[3], p[2]);
1921 # }
1922 ()
1923 def p__embed1_task_declaration(p):
1924 '''_embed1_task_declaration : '''
1925 # { current_task->set_ports(p[6]);
1926 # current_task_set_statement(@3, p[7]);
1927 # pform_set_this_class(@3, current_task);
1928 # pform_pop_scope();
1929 # current_task = 0;
1930 # if (p[7] && p[7]->size() > 1 && !gn_system_verilog()) {
1931 # yyerror(@7, "error: Task body with multiple statements requires SystemVerilog.");
1932 # }
1933 # delete p[7];
1934 # }
1935 ()
1936 def p__embed2_task_declaration(p):
1937 '''_embed2_task_declaration : '''
1938 # { assert(current_task == 0);
1939 # current_task = pform_push_task_scope(@1, p[3], p[2]);
1940 # }
1941 ()
1942 def p__embed3_task_declaration(p):
1943 '''_embed3_task_declaration : '''
1944 # { current_task->set_ports(p[6]);
1945 # current_task_set_statement(@3, p[10]);
1946 # pform_set_this_class(@3, current_task);
1947 # pform_pop_scope();
1948 # current_task = 0;
1949 # if (p[10]) delete p[10];
1950 # }
1951 ()
1952 def p__embed4_task_declaration(p):
1953 '''_embed4_task_declaration : '''
1954 # { assert(current_task == 0);
1955 # current_task = pform_push_task_scope(@1, p[3], p[2]);
1956 # }
1957 ()
1958 def p__embed5_task_declaration(p):
1959 '''_embed5_task_declaration : '''
1960 # { current_task->set_ports(0);
1961 # current_task_set_statement(@3, p[9]);
1962 # pform_set_this_class(@3, current_task);
1963 # if (! current_task->method_of()) {
1964 # cerr << @3 << ": warning: task definition for \"" << p[3]
1965 # << "\" has an empty port declaration list!" << endl;
1966 # }
1967 # pform_pop_scope();
1968 # current_task = 0;
1969 # if (p[9]->size() > 1 && !gn_system_verilog()) {
1970 # yyerror(@9, "error: Task body with multiple statements requires SystemVerilog.");
1971 # }
1972 # delete p[9];
1973 # }
1974 ()
1975 def p__embed6_task_declaration(p):
1976 '''_embed6_task_declaration : '''
1977 # {
1978 # if (current_task) {
1979 # pform_pop_scope();
1980 # current_task = 0;
1981 # }
1982 # }
1983 ()
1984 def p_tf_port_declaration_1(p):
1985 '''tf_port_declaration : port_direction K_reg_opt unsigned_signed_opt dimensions_opt list_of_identifiers ';' '''
1986 if(parse_debug): print('tf_port_declaration_1', list(p))
1987 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1],
1988 # p[2] ? IVL_VT_LOGIC :
1989 # IVL_VT_NO_TYPE,
1990 # p[3], p[4], p[5]);
1991 # p[0] = tmp;
1992 # }
1993 ()
1994 def p_tf_port_declaration_2(p):
1995 '''tf_port_declaration : port_direction K_integer list_of_identifiers ';' '''
1996 if(parse_debug): print('tf_port_declaration_2', list(p))
1997 # { list<pform_range_t>*range_stub = make_range_from_width(integer_width);
1998 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, true,
1999 # range_stub, p[3], true);
2000 # p[0] = tmp;
2001 # }
2002 ()
2003 def p_tf_port_declaration_3(p):
2004 '''tf_port_declaration : port_direction K_time list_of_identifiers ';' '''
2005 if(parse_debug): print('tf_port_declaration_3', list(p))
2006 # { list<pform_range_t>*range_stub = make_range_from_width(64);
2007 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, false,
2008 # range_stub, p[3]);
2009 # p[0] = tmp;
2010 # }
2011 ()
2012 def p_tf_port_declaration_4(p):
2013 '''tf_port_declaration : port_direction real_or_realtime list_of_identifiers ';' '''
2014 if(parse_debug): print('tf_port_declaration_4', list(p))
2015 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_REAL, true,
2016 # 0, p[3]);
2017 # p[0] = tmp;
2018 # }
2019 ()
2020 def p_tf_port_declaration_5(p):
2021 '''tf_port_declaration : port_direction K_string list_of_identifiers ';' '''
2022 if(parse_debug): print('tf_port_declaration_5', list(p))
2023 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_STRING, true,
2024 # 0, p[3]);
2025 # p[0] = tmp;
2026 # }
2027 ()
2028 def p_tf_port_item_1(p):
2029 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER dimensions_opt tf_port_item_expr_opt '''
2030 if(parse_debug): print('tf_port_item_1', list(p))
2031 # { vector<pform_tf_port_t>*tmp;
2032 # NetNet::PortType use_port_type = p[1];
2033 # if ((use_port_type == NetNet::PIMPLICIT) && (gn_system_verilog() || (p[2] == 0)))
2034 # use_port_type = port_declaration_context.port_type;
2035 # perm_string name = lex_strings.make(p[3]);
2036 # list<perm_string>* ilist = list_from_identifier(p[3]);
2037 #
2038 # if (use_port_type == NetNet::PIMPLICIT) {
2039 # yyerror(@1, "error: missing task/function port direction.");
2040 # use_port_type = NetNet::PINPUT; // for error recovery
2041 # }
2042 # if ((p[2] == 0) && (p[1]==NetNet::PIMPLICIT)) {
2043 # // Detect special case this is an undecorated
2044 # // identifier and we need to get the declaration from
2045 # // left context.
2046 # if (p[4] != 0) {
2047 # yyerror(@4, "internal error: How can there be an unpacked range here?\n");
2048 # }
2049 # tmp = pform_make_task_ports(@3, use_port_type,
2050 # port_declaration_context.data_type,
2051 # ilist);
2052 #
2053 # } else {
2054 # // Otherwise, the decorations for this identifier
2055 # // indicate the type. Save the type for any right
2056 # // context that may come later.
2057 # port_declaration_context.port_type = use_port_type;
2058 # if (p[2] == 0) {
2059 # p[2] = new vector_type_t(IVL_VT_LOGIC, false, 0);
2060 # FILE_NAME(p[2], @3);
2061 # }
2062 # port_declaration_context.data_type = p[2];
2063 # tmp = pform_make_task_ports(@3, use_port_type, p[2], ilist);
2064 # }
2065 # if (p[4] != 0) {
2066 # pform_set_reg_idx(name, p[4]);
2067 # }
2068 #
2069 # p[0] = tmp;
2070 # if (p[5]) {
2071 # assert(tmp->size()==1);
2072 # tmp->front().defe = p[5];
2073 # }
2074 # }
2075 ()
2076 def p_tf_port_item_2(p):
2077 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER error '''
2078 if(parse_debug): print('tf_port_item_2', list(p))
2079 # { yyerror(@3, "error: Error in task/function port item after port name %s.", p[3]);
2080 # yyerrok;
2081 # p[0] = None
2082 # }
2083 ()
2084 def p_tf_port_item_expr_opt_1(p):
2085 '''tf_port_item_expr_opt : '=' expression '''
2086 if(parse_debug): print('tf_port_item_expr_opt_1', list(p))
2087 # { if (! gn_system_verilog()) {
2088 # yyerror(@1, "error: Task/function default arguments require "
2089 # "SystemVerilog.");
2090 # }
2091 # p[0] = p[2];
2092 # }
2093 ()
2094 def p_tf_port_item_expr_opt_2(p):
2095 '''tf_port_item_expr_opt : '''
2096 if(parse_debug): print('tf_port_item_expr_opt_2', list(p))
2097 # { p[0] = None }
2098 ()
2099 def p_tf_port_list_1(p):
2100 '''tf_port_list : _embed0_tf_port_list tf_port_item_list '''
2101 if(parse_debug): print('tf_port_list_1', list(p))
2102 p[0] = p[2]
2103 ()
2104 def p__embed0_tf_port_list(p):
2105 '''_embed0_tf_port_list : '''
2106 # { port_declaration_context.port_type = gn_system_verilog() ? NetNet::PINPUT : NetNet::PIMPLICIT;
2107 # port_declaration_context.data_type = 0;
2108 # }
2109 ()
2110 def p_tf_port_item_list_1(p):
2111 '''tf_port_item_list : tf_port_item_list ',' tf_port_item '''
2112 if(parse_debug): print('tf_port_item_list_1', list(p))
2113 # { vector<pform_tf_port_t>*tmp;
2114 # if (p[1] && p[3]) {
2115 # size_t s1 = p[1]->size();
2116 # tmp = p[1];
2117 # tmp->resize(tmp->size()+p[3]->size());
2118 # for (size_t idx = 0 ; idx < p[3]->size() ; idx += 1)
2119 # tmp->at(s1+idx) = p[3]->at(idx);
2120 # delete p[3];
2121 # } else if (p[1]) {
2122 # tmp = p[1];
2123 # } else {
2124 # tmp = p[3];
2125 # }
2126 # p[0] = tmp;
2127 # }
2128 ()
2129 def p_tf_port_item_list_2(p):
2130 '''tf_port_item_list : tf_port_item '''
2131 if(parse_debug): print('tf_port_item_list_2', list(p))
2132 p[0] = p[1]
2133 ()
2134 def p_tf_port_item_list_3(p):
2135 '''tf_port_item_list : error ',' tf_port_item '''
2136 if(parse_debug): print('tf_port_item_list_3', list(p))
2137 # { yyerror(@2, "error: Syntax error in task/function port declaration.");
2138 # p[0] = p[3];
2139 # }
2140 ()
2141 def p_tf_port_item_list_4(p):
2142 '''tf_port_item_list : tf_port_item_list ',' '''
2143 if(parse_debug): print('tf_port_item_list_4', list(p))
2144 # { yyerror(@2, "error: NULL port declarations are not allowed.");
2145 # p[0] = p[1];
2146 # }
2147 ()
2148 def p_tf_port_item_list_5(p):
2149 '''tf_port_item_list : tf_port_item_list ';' '''
2150 if(parse_debug): print('tf_port_item_list_5', list(p))
2151 # { yyerror(@2, "error: ';' is an invalid port declaration separator.");
2152 # p[0] = p[1];
2153 # }
2154 ()
2155 def p_timeunits_declaration_1(p):
2156 '''timeunits_declaration : K_timeunit TIME_LITERAL ';' '''
2157 if(parse_debug): print('timeunits_declaration_1', list(p))
2158 # { pform_set_timeunit(p[2], allow_timeunit_decl); }
2159 ()
2160 def p_timeunits_declaration_2(p):
2161 '''timeunits_declaration : K_timeunit TIME_LITERAL '/' TIME_LITERAL ';' '''
2162 if(parse_debug): print('timeunits_declaration_2', list(p))
2163 # { bool initial_decl = allow_timeunit_decl && allow_timeprec_decl;
2164 # pform_set_timeunit(p[2], initial_decl);
2165 # pform_set_timeprec(p[4], initial_decl);
2166 # }
2167 ()
2168 def p_timeunits_declaration_3(p):
2169 '''timeunits_declaration : K_timeprecision TIME_LITERAL ';' '''
2170 if(parse_debug): print('timeunits_declaration_3', list(p))
2171 # { pform_set_timeprec(p[2], allow_timeprec_decl); }
2172 ()
2173 def p_timeunits_declaration_opt_1(p):
2174 '''timeunits_declaration_opt : %prec no_timeunits_declaration '''
2175 if(parse_debug>2): print('timeunits_declaration_opt_1', list(p))
2176 ()
2177 def p_timeunits_declaration_opt_2(p):
2178 '''timeunits_declaration_opt : timeunits_declaration %prec one_timeunits_declaration '''
2179 if(parse_debug): print('timeunits_declaration_opt_2', list(p))
2180 ()
2181 def p_timeunits_declaration_opt_3(p):
2182 '''timeunits_declaration_opt : timeunits_declaration timeunits_declaration '''
2183 if(parse_debug): print('timeunits_declaration_opt_3', list(p))
2184 ()
2185 def p_value_range_1(p):
2186 '''value_range : expression '''
2187 if(parse_debug): print('value_range_1', list(p))
2188 # { }
2189 ()
2190 def p_value_range_2(p):
2191 '''value_range : '[' expression ':' expression ']' '''
2192 if(parse_debug): print('value_range_2', list(p))
2193 # { }
2194 ()
2195 def p_variable_dimension_1(p):
2196 '''variable_dimension : '[' expression ':' expression ']' '''
2197 if(parse_debug): print('variable_dimension_1', list(p))
2198 # { list<pform_range_t> *tmp = new list<pform_range_t>;
2199 # pform_range_t index (p[2],p[4]);
2200 # tmp->push_back(index);
2201 # p[0] = tmp;
2202 # }
2203 # XXX TODO: subscriptlist
2204 start = str(p[4])
2205 end = str(p[2])
2206 if end.endswith("-1"):
2207 end = end[:-2]
2208 elif end.isdigit():
2209 end = str(int(end)+1)
2210 else:
2211 end = "1+%s" % end
2212 p[0] = '[%s:%s]' % (start, end) # python slice is LO:HI+1
2213 ()
2214 def p_variable_dimension_2(p):
2215 '''variable_dimension : '[' expression ']' '''
2216 if(parse_debug): print('variable_dimension_2', list(p))
2217 # { // SystemVerilog canonical range
2218 # if (!gn_system_verilog()) {
2219 # warn_count += 1;
2220 # cerr << @2 << ": warning: Use of SystemVerilog [size] dimension. "
2221 # << "Use at least -g2005-sv to remove this warning." << endl;
2222 # }
2223 # list<pform_range_t> *tmp = new list<pform_range_t>;
2224 # pform_range_t index;
2225 # index.first = new PENumber(new verinum((uint64_t)0, integer_width));
2226 # index.second = new PEBinary('-', p[2], new PENumber(new verinum((uint64_t)1, integer_width)));
2227 # tmp->push_back(index);
2228 # p[0] = tmp;
2229 # }
2230 ()
2231 def p_variable_dimension_3(p):
2232 '''variable_dimension : '[' ']' '''
2233 if(parse_debug): print('variable_dimension_3', list(p))
2234 # { list<pform_range_t> *tmp = new list<pform_range_t>;
2235 # pform_range_t index (0,0);
2236 # tmp->push_back(index);
2237 # p[0] = tmp;
2238 # }
2239 ()
2240 def p_variable_dimension_4(p):
2241 '''variable_dimension : '[' '$' ']' '''
2242 if(parse_debug): print('variable_dimension_4', list(p))
2243 # { // SystemVerilog queue
2244 # list<pform_range_t> *tmp = new list<pform_range_t>;
2245 # pform_range_t index (new PENull,0);
2246 # if (!gn_system_verilog()) {
2247 # yyerror("error: Queue declarations require SystemVerilog.");
2248 # }
2249 # tmp->push_back(index);
2250 # p[0] = tmp;
2251 # }
2252 ()
2253 def p_variable_lifetime_1(p):
2254 '''variable_lifetime : lifetime '''
2255 if(parse_debug): print('variable_lifetime_1', list(p))
2256 # { if (!gn_system_verilog()) {
2257 # yyerror(@1, "error: overriding the default variable lifetime "
2258 # "requires SystemVerilog.");
2259 # } else if (p[1] != pform_peek_scope()->default_lifetime) {
2260 # yyerror(@1, "sorry: overriding the default variable lifetime "
2261 # "is not yet supported.");
2262 # }
2263 # var_lifetime = p[1];
2264 # }
2265 ()
2266 def p_attribute_list_opt_1(p):
2267 '''attribute_list_opt : attribute_instance_list '''
2268 if(parse_debug): print('attribute_list_opt_1', list(p))
2269 p[0] = p[1]
2270 ()
2271 def p_attribute_list_opt_2(p):
2272 '''attribute_list_opt : '''
2273 if(parse_debug > 2): print('attribute_list_opt_2', list(p))
2274 # { p[0] = None }
2275 ()
2276 def p_attribute_instance_list_1(p):
2277 '''attribute_instance_list : K_PSTAR K_STARP '''
2278 if(parse_debug): print('attribute_instance_list_1', list(p))
2279 # { p[0] = None }
2280 ()
2281 def p_attribute_instance_list_2(p):
2282 '''attribute_instance_list : K_PSTAR attribute_list K_STARP '''
2283 if(parse_debug): print('attribute_instance_list_2', list(p))
2284 p[0] = p[2]
2285 ()
2286 def p_attribute_instance_list_3(p):
2287 '''attribute_instance_list : attribute_instance_list K_PSTAR K_STARP '''
2288 if(parse_debug): print('attribute_instance_list_3', list(p))
2289 p[0] = p[1]
2290 ()
2291 def p_attribute_instance_list_4(p):
2292 '''attribute_instance_list : attribute_instance_list K_PSTAR attribute_list K_STARP '''
2293 if(parse_debug): print('attribute_instance_list_4', list(p))
2294 # { list<named_pexpr_t>*tmp = p[1];
2295 # if (tmp) {
2296 # tmp->splice(tmp->end(), *p[3]);
2297 # delete p[3];
2298 # p[0] = tmp;
2299 # } else p[0] = p[3];
2300 # }
2301 ()
2302 def p_attribute_list_1(p):
2303 '''attribute_list : attribute_list ',' attribute '''
2304 if(parse_debug): print('attribute_list_1', list(p))
2305 # { list<named_pexpr_t>*tmp = p[1];
2306 # tmp->push_back(*p[3]);
2307 # delete p[3];
2308 # p[0] = tmp;
2309 # }
2310 ()
2311 def p_attribute_list_2(p):
2312 '''attribute_list : attribute '''
2313 if(parse_debug): print('attribute_list_2', list(p))
2314 # { list<named_pexpr_t>*tmp = new list<named_pexpr_t>;
2315 # tmp->push_back(*p[1]);
2316 # delete p[1];
2317 # p[0] = tmp;
2318 # }
2319 ()
2320 def p_attribute_1(p):
2321 '''attribute : IDENTIFIER '''
2322 if(parse_debug): print('attribute_1', list(p))
2323 # { named_pexpr_t*tmp = new named_pexpr_t;
2324 # tmp->name = lex_strings.make(p[1]);
2325 # tmp->parm = 0;
2326 # delete[]p[1];
2327 # p[0] = tmp;
2328 # }
2329 ()
2330 def p_attribute_2(p):
2331 '''attribute : IDENTIFIER '=' expression '''
2332 if(parse_debug): print('attribute_2', list(p))
2333 # { PExpr*tmp = p[3];
2334 # named_pexpr_t*tmp2 = new named_pexpr_t;
2335 # tmp2->name = lex_strings.make(p[1]);
2336 # tmp2->parm = tmp;
2337 # delete[]p[1];
2338 # p[0] = tmp2;
2339 # }
2340 ()
2341 def p_block_item_decl_1(p):
2342 '''block_item_decl : data_type register_variable_list ';' '''
2343 if(parse_debug): print('block_item_decl_1', list(p))
2344 # { if (p[1]) pform_set_data_type(@1, p[1], p[2], NetNet::REG, attributes_in_context);
2345 # }
2346 ()
2347 def p_block_item_decl_2(p):
2348 '''block_item_decl : variable_lifetime data_type register_variable_list ';' '''
2349 if(parse_debug): print('block_item_decl_2', list(p))
2350 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
2351 # var_lifetime = LexicalScope::INHERITED;
2352 # }
2353 ()
2354 def p_block_item_decl_3(p):
2355 '''block_item_decl : K_reg data_type register_variable_list ';' '''
2356 if(parse_debug): print('block_item_decl_3', list(p))
2357 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
2358 # }
2359 ()
2360 def p_block_item_decl_4(p):
2361 '''block_item_decl : variable_lifetime K_reg data_type register_variable_list ';' '''
2362 if(parse_debug): print('block_item_decl_4', list(p))
2363 # { if (p[3]) pform_set_data_type(@3, p[3], p[4], NetNet::REG, attributes_in_context);
2364 # var_lifetime = LexicalScope::INHERITED;
2365 # }
2366 ()
2367 def p_block_item_decl_5(p):
2368 '''block_item_decl : K_event event_variable_list ';' '''
2369 if(parse_debug): print('block_item_decl_5', list(p))
2370 # { if (p[2]) pform_make_events(p[2], @1.text, @1.first_line);
2371 # }
2372 ()
2373 def p_block_item_decl_6(p):
2374 '''block_item_decl : K_parameter param_type parameter_assign_list ';' '''
2375 if(parse_debug): print('block_item_decl_6', list(p))
2376 ()
2377 def p_block_item_decl_7(p):
2378 '''block_item_decl : K_localparam param_type localparam_assign_list ';' '''
2379 if(parse_debug): print('block_item_decl_7', list(p))
2380 ()
2381 def p_block_item_decl_8(p):
2382 '''block_item_decl : type_declaration '''
2383 if(parse_debug): print('block_item_decl_8', list(p))
2384 ()
2385 def p_block_item_decl_9(p):
2386 '''block_item_decl : K_integer error ';' '''
2387 if(parse_debug): print('block_item_decl_9', list(p))
2388 # { yyerror(@1, "error: syntax error in integer variable list.");
2389 # yyerrok;
2390 # }
2391 ()
2392 def p_block_item_decl_10(p):
2393 '''block_item_decl : K_time error ';' '''
2394 if(parse_debug): print('block_item_decl_10', list(p))
2395 # { yyerror(@1, "error: syntax error in time variable list.");
2396 # yyerrok;
2397 # }
2398 ()
2399 def p_block_item_decl_11(p):
2400 '''block_item_decl : K_parameter error ';' '''
2401 if(parse_debug): print('block_item_decl_11', list(p))
2402 # { yyerror(@1, "error: syntax error in parameter list.");
2403 # yyerrok;
2404 # }
2405 ()
2406 def p_block_item_decl_12(p):
2407 '''block_item_decl : K_localparam error ';' '''
2408 if(parse_debug): print('block_item_decl_12', list(p))
2409 # { yyerror(@1, "error: syntax error localparam list.");
2410 # yyerrok;
2411 # }
2412 ()
2413 def p_block_item_decls_1(p):
2414 '''block_item_decls : block_item_decl '''
2415 if(parse_debug): print('block_item_decls_1', list(p))
2416 ()
2417 def p_block_item_decls_2(p):
2418 '''block_item_decls : block_item_decls block_item_decl '''
2419 if(parse_debug): print('block_item_decls_2', list(p))
2420 ()
2421 def p_block_item_decls_opt_1(p):
2422 '''block_item_decls_opt : block_item_decls '''
2423 if(parse_debug): print('block_item_decls_opt_1', list(p))
2424 p[0] = True
2425 ()
2426 def p_block_item_decls_opt_2(p):
2427 '''block_item_decls_opt : '''
2428 if(parse_debug): print('block_item_decls_opt_2', list(p))
2429 p[0] = False
2430 ()
2431 def p_type_declaration_1(p):
2432 '''type_declaration : K_typedef data_type IDENTIFIER dimensions_opt ';' '''
2433 if(parse_debug): print('type_declaration_1', list(p))
2434 # { perm_string name = lex_strings.make(p[3]);
2435 # pform_set_typedef(name, p[2], p[4]);
2436 # delete[]p[3];
2437 # }
2438 ()
2439 def p_type_declaration_2(p):
2440 '''type_declaration : K_typedef data_type TYPE_IDENTIFIER ';' '''
2441 if(parse_debug): print('type_declaration_2', list(p))
2442 # { perm_string name = lex_strings.make(p[3].text);
2443 # if (pform_test_type_identifier_local(name)) {
2444 # yyerror(@3, "error: Typedef identifier \"%s\" is already a type name.", p[3].text);
2445 #
2446 # } else {
2447 # pform_set_typedef(name, p[2], NULL);
2448 # }
2449 # delete[]p[3].text;
2450 # }
2451 ()
2452 def p_type_declaration_3(p):
2453 '''type_declaration : K_typedef K_class IDENTIFIER ';' '''
2454 if(parse_debug): print('type_declaration_3', list(p))
2455 # { // Create a synthetic typedef for the class name so that the
2456 # // lexor detects the name as a type.
2457 # perm_string name = lex_strings.make(p[3]);
2458 # class_type_t*tmp = new class_type_t(name);
2459 # FILE_NAME(tmp, @3);
2460 # pform_set_typedef(name, tmp, NULL);
2461 # delete[]p[3];
2462 # }
2463 ()
2464 def p_type_declaration_4(p):
2465 '''type_declaration : K_typedef K_enum IDENTIFIER ';' '''
2466 if(parse_debug): print('type_declaration_4', list(p))
2467 # { yyerror(@1, "sorry: Enum forward declarations not supported yet."); }
2468 ()
2469 def p_type_declaration_5(p):
2470 '''type_declaration : K_typedef K_struct IDENTIFIER ';' '''
2471 if(parse_debug): print('type_declaration_5', list(p))
2472 # { yyerror(@1, "sorry: Struct forward declarations not supported yet."); }
2473 ()
2474 def p_type_declaration_6(p):
2475 '''type_declaration : K_typedef K_union IDENTIFIER ';' '''
2476 if(parse_debug): print('type_declaration_6', list(p))
2477 # { yyerror(@1, "sorry: Union forward declarations not supported yet."); }
2478 ()
2479 def p_type_declaration_7(p):
2480 '''type_declaration : K_typedef IDENTIFIER ';' '''
2481 if(parse_debug): print('type_declaration_7', list(p))
2482 # { // Create a synthetic typedef for the class name so that the
2483 # // lexor detects the name as a type.
2484 # perm_string name = lex_strings.make(p[2]);
2485 # class_type_t*tmp = new class_type_t(name);
2486 # FILE_NAME(tmp, @2);
2487 # pform_set_typedef(name, tmp, NULL);
2488 # delete[]p[2];
2489 # }
2490 ()
2491 def p_type_declaration_8(p):
2492 '''type_declaration : K_typedef error ';' '''
2493 if(parse_debug): print('type_declaration_8', list(p))
2494 # { yyerror(@2, "error: Syntax error in typedef clause.");
2495 # yyerrok;
2496 # }
2497 ()
2498 def p_enum_data_type_1(p):
2499 '''enum_data_type : K_enum '{' enum_name_list '}' '''
2500 if(parse_debug): print('enum_data_type_1', list(p))
2501 # { enum_type_t*enum_type = new enum_type_t;
2502 # FILE_NAME(enum_type, @1);
2503 # enum_type->names .reset(p[3]);
2504 # enum_type->base_type = IVL_VT_BOOL;
2505 # enum_type->signed_flag = true;
2506 # enum_type->integer_flag = false;
2507 # enum_type->range.reset(make_range_from_width(32));
2508 # p[0] = enum_type;
2509 # }
2510 ()
2511 def p_enum_data_type_2(p):
2512 '''enum_data_type : K_enum atom2_type signed_unsigned_opt '{' enum_name_list '}' '''
2513 if(parse_debug): print('enum_data_type_2', list(p))
2514 # { enum_type_t*enum_type = new enum_type_t;
2515 # FILE_NAME(enum_type, @1);
2516 # enum_type->names .reset(p[5]);
2517 # enum_type->base_type = IVL_VT_BOOL;
2518 # enum_type->signed_flag = p[3];
2519 # enum_type->integer_flag = false;
2520 # enum_type->range.reset(make_range_from_width(p[2]));
2521 # p[0] = enum_type;
2522 # }
2523 ()
2524 def p_enum_data_type_3(p):
2525 '''enum_data_type : K_enum K_integer signed_unsigned_opt '{' enum_name_list '}' '''
2526 if(parse_debug): print('enum_data_type_3', list(p))
2527 # { enum_type_t*enum_type = new enum_type_t;
2528 # FILE_NAME(enum_type, @1);
2529 # enum_type->names .reset(p[5]);
2530 # enum_type->base_type = IVL_VT_LOGIC;
2531 # enum_type->signed_flag = p[3];
2532 # enum_type->integer_flag = true;
2533 # enum_type->range.reset(make_range_from_width(integer_width));
2534 # p[0] = enum_type;
2535 # }
2536 ()
2537 def p_enum_data_type_4(p):
2538 '''enum_data_type : K_enum K_logic unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
2539 if(parse_debug): print('enum_data_type_4', list(p))
2540 # { enum_type_t*enum_type = new enum_type_t;
2541 # FILE_NAME(enum_type, @1);
2542 # enum_type->names .reset(p[6]);
2543 # enum_type->base_type = IVL_VT_LOGIC;
2544 # enum_type->signed_flag = p[3];
2545 # enum_type->integer_flag = false;
2546 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
2547 # p[0] = enum_type;
2548 # }
2549 ()
2550 def p_enum_data_type_5(p):
2551 '''enum_data_type : K_enum K_reg unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
2552 if(parse_debug): print('enum_data_type_5', list(p))
2553 # { enum_type_t*enum_type = new enum_type_t;
2554 # FILE_NAME(enum_type, @1);
2555 # enum_type->names .reset(p[6]);
2556 # enum_type->base_type = IVL_VT_LOGIC;
2557 # enum_type->signed_flag = p[3];
2558 # enum_type->integer_flag = false;
2559 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
2560 # p[0] = enum_type;
2561 # }
2562 ()
2563 def p_enum_data_type_6(p):
2564 '''enum_data_type : K_enum K_bit unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
2565 if(parse_debug): print('enum_data_type_6', list(p))
2566 # { enum_type_t*enum_type = new enum_type_t;
2567 # FILE_NAME(enum_type, @1);
2568 # enum_type->names .reset(p[6]);
2569 # enum_type->base_type = IVL_VT_BOOL;
2570 # enum_type->signed_flag = p[3];
2571 # enum_type->integer_flag = false;
2572 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
2573 # p[0] = enum_type;
2574 # }
2575 ()
2576 def p_enum_name_list_1(p):
2577 '''enum_name_list : enum_name '''
2578 if(parse_debug): print('enum_name_list_1', list(p))
2579 # { p[0] = p[1];
2580 # }
2581 ()
2582 def p_enum_name_list_2(p):
2583 '''enum_name_list : enum_name_list ',' enum_name '''
2584 if(parse_debug): print('enum_name_list_2', list(p))
2585 # { list<named_pexpr_t>*lst = p[1];
2586 # lst->splice(lst->end(), *p[3]);
2587 # delete p[3];
2588 # p[0] = lst;
2589 # }
2590 ()
2591 def p_pos_neg_number_1(p):
2592 '''pos_neg_number : number '''
2593 if(parse_debug): print('pos_neg_number_1', list(p))
2594 # { p[0] = p[1];
2595 # }
2596 ()
2597 def p_pos_neg_number_2(p):
2598 '''pos_neg_number : '-' number '''
2599 if(parse_debug): print('pos_neg_number_2', list(p))
2600 # { verinum tmp = -(*(p[2]));
2601 # *(p[2]) = tmp;
2602 # p[0] = p[2];
2603 # }
2604 ()
2605 def p_enum_name_1(p):
2606 '''enum_name : IDENTIFIER '''
2607 if(parse_debug): print('enum_name_1', list(p))
2608 # { perm_string name = lex_strings.make(p[1]);
2609 # delete[]p[1];
2610 # p[0] = make_named_number(name);
2611 # }
2612 ()
2613 def p_enum_name_2(p):
2614 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '''
2615 if(parse_debug): print('enum_name_2', list(p))
2616 # { perm_string name = lex_strings.make(p[1]);
2617 # long count = check_enum_seq_value(@1, p[3], false);
2618 # delete[]p[1];
2619 # p[0] = make_named_numbers(name, 0, count-1);
2620 # delete p[3];
2621 # }
2622 ()
2623 def p_enum_name_3(p):
2624 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '''
2625 if(parse_debug): print('enum_name_3', list(p))
2626 # { perm_string name = lex_strings.make(p[1]);
2627 # p[0] = make_named_numbers(name, check_enum_seq_value(@1, p[3], true),
2628 # check_enum_seq_value(@1, p[5], true));
2629 # delete[]p[1];
2630 # delete p[3];
2631 # delete p[5];
2632 # }
2633 ()
2634 def p_enum_name_4(p):
2635 '''enum_name : IDENTIFIER '=' expression '''
2636 if(parse_debug): print('enum_name_4', list(p))
2637 # { perm_string name = lex_strings.make(p[1]);
2638 # delete[]p[1];
2639 # p[0] = make_named_number(name, p[3]);
2640 # }
2641 ()
2642 def p_enum_name_5(p):
2643 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '=' expression '''
2644 if(parse_debug): print('enum_name_5', list(p))
2645 # { perm_string name = lex_strings.make(p[1]);
2646 # long count = check_enum_seq_value(@1, p[3], false);
2647 # p[0] = make_named_numbers(name, 0, count-1, p[6]);
2648 # delete[]p[1];
2649 # delete p[3];
2650 # }
2651 ()
2652 def p_enum_name_6(p):
2653 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '=' expression '''
2654 if(parse_debug): print('enum_name_6', list(p))
2655 # { perm_string name = lex_strings.make(p[1]);
2656 # p[0] = make_named_numbers(name, check_enum_seq_value(@1, p[3], true),
2657 # check_enum_seq_value(@1, p[5], true), p[8]);
2658 # delete[]p[1];
2659 # delete p[3];
2660 # delete p[5];
2661 # }
2662 ()
2663 def p_struct_data_type_1(p):
2664 '''struct_data_type : K_struct K_packed_opt '{' struct_union_member_list '}' '''
2665 if(parse_debug): print('struct_data_type_1', list(p))
2666 # { struct_type_t*tmp = new struct_type_t;
2667 # FILE_NAME(tmp, @1);
2668 # tmp->packed_flag = p[2];
2669 # tmp->union_flag = false;
2670 # tmp->members .reset(p[4]);
2671 # p[0] = tmp;
2672 # }
2673 ()
2674 def p_struct_data_type_2(p):
2675 '''struct_data_type : K_union K_packed_opt '{' struct_union_member_list '}' '''
2676 if(parse_debug): print('struct_data_type_2', list(p))
2677 # { struct_type_t*tmp = new struct_type_t;
2678 # FILE_NAME(tmp, @1);
2679 # tmp->packed_flag = p[2];
2680 # tmp->union_flag = true;
2681 # tmp->members .reset(p[4]);
2682 # p[0] = tmp;
2683 # }
2684 ()
2685 def p_struct_data_type_3(p):
2686 '''struct_data_type : K_struct K_packed_opt '{' error '}' '''
2687 if(parse_debug): print('struct_data_type_3', list(p))
2688 # { yyerror(@3, "error: Errors in struct member list.");
2689 # yyerrok;
2690 # struct_type_t*tmp = new struct_type_t;
2691 # FILE_NAME(tmp, @1);
2692 # tmp->packed_flag = p[2];
2693 # tmp->union_flag = false;
2694 # p[0] = tmp;
2695 # }
2696 ()
2697 def p_struct_data_type_4(p):
2698 '''struct_data_type : K_union K_packed_opt '{' error '}' '''
2699 if(parse_debug): print('struct_data_type_4', list(p))
2700 # { yyerror(@3, "error: Errors in union member list.");
2701 # yyerrok;
2702 # struct_type_t*tmp = new struct_type_t;
2703 # FILE_NAME(tmp, @1);
2704 # tmp->packed_flag = p[2];
2705 # tmp->union_flag = true;
2706 # p[0] = tmp;
2707 # }
2708 ()
2709 def p_struct_union_member_list_1(p):
2710 '''struct_union_member_list : struct_union_member_list struct_union_member '''
2711 if(parse_debug): print('struct_union_member_list_1', list(p))
2712 # { list<struct_member_t*>*tmp = p[1];
2713 # tmp->push_back(p[2]);
2714 # p[0] = tmp;
2715 # }
2716 ()
2717 def p_struct_union_member_list_2(p):
2718 '''struct_union_member_list : struct_union_member '''
2719 if(parse_debug): print('struct_union_member_list_2', list(p))
2720 # { list<struct_member_t*>*tmp = new list<struct_member_t*>;
2721 # tmp->push_back(p[1]);
2722 # p[0] = tmp;
2723 # }
2724 ()
2725 def p_struct_union_member_1(p):
2726 '''struct_union_member : attribute_list_opt data_type list_of_variable_decl_assignments ';' '''
2727 if(parse_debug): print('struct_union_member_1', list(p))
2728 # { struct_member_t*tmp = new struct_member_t;
2729 # FILE_NAME(tmp, @2);
2730 # tmp->type .reset(p[2]);
2731 # tmp->names .reset(p[3]);
2732 # p[0] = tmp;
2733 # }
2734 ()
2735 def p_struct_union_member_2(p):
2736 '''struct_union_member : error ';' '''
2737 if(parse_debug): print('struct_union_member_2', list(p))
2738 # { yyerror(@2, "Error in struct/union member.");
2739 # yyerrok;
2740 # p[0] = None
2741 # }
2742 ()
2743 def p_case_item_1(p):
2744 '''case_item : expression_list_proper ':' statement_or_null '''
2745 if(parse_debug): print('case_item_1', list(p))
2746 # { PCase::Item*tmp = new PCase::Item;
2747 # tmp->expr = *p[1];
2748 # tmp->stat = p[3];
2749 # delete p[1];
2750 # p[0] = tmp;
2751 # }
2752 ()
2753 def p_case_item_2(p):
2754 '''case_item : K_default ':' statement_or_null '''
2755 if(parse_debug): print('case_item_2', list(p))
2756 # { PCase::Item*tmp = new PCase::Item;
2757 # tmp->stat = p[3];
2758 # p[0] = tmp;
2759 # }
2760 ()
2761 def p_case_item_3(p):
2762 '''case_item : K_default statement_or_null '''
2763 if(parse_debug): print('case_item_3', list(p))
2764 # { PCase::Item*tmp = new PCase::Item;
2765 # tmp->stat = p[2];
2766 # p[0] = tmp;
2767 # }
2768 ()
2769 def p_case_item_4(p):
2770 '''case_item : error ':' statement_or_null '''
2771 if(parse_debug): print('case_item_4', list(p))
2772 # { yyerror(@2, "error: Incomprehensible case expression.");
2773 # yyerrok;
2774 # }
2775 ()
2776 def p_case_items_1(p):
2777 '''case_items : case_items case_item '''
2778 if(parse_debug): print('case_items_1', list(p))
2779 # { svector<PCase::Item*>*tmp;
2780 # tmp = new svector<PCase::Item*>(*p[1], p[2]);
2781 # delete p[1];
2782 # p[0] = tmp;
2783 # }
2784 ()
2785 def p_case_items_2(p):
2786 '''case_items : case_item '''
2787 if(parse_debug): print('case_items_2', list(p))
2788 # { svector<PCase::Item*>*tmp = new svector<PCase::Item*>(1);
2789 # (*tmp)[0] = p[1];
2790 # p[0] = tmp;
2791 # }
2792 ()
2793 def p_charge_strength_1(p):
2794 '''charge_strength : '(' K_small ')' '''
2795 if(parse_debug): print('charge_strength_1', list(p))
2796 ()
2797 def p_charge_strength_2(p):
2798 '''charge_strength : '(' K_medium ')' '''
2799 if(parse_debug): print('charge_strength_2', list(p))
2800 ()
2801 def p_charge_strength_3(p):
2802 '''charge_strength : '(' K_large ')' '''
2803 if(parse_debug): print('charge_strength_3', list(p))
2804 ()
2805 def p_charge_strength_opt_1(p):
2806 '''charge_strength_opt : charge_strength '''
2807 if(parse_debug): print('charge_strength_opt_1', list(p))
2808 ()
2809 def p_charge_strength_opt_2(p):
2810 '''charge_strength_opt : '''
2811 if(parse_debug): print('charge_strength_opt_2', list(p))
2812 ()
2813 def p_defparam_assign_1(p):
2814 '''defparam_assign : hierarchy_identifier '=' expression '''
2815 if(parse_debug): print('defparam_assign_1', list(p))
2816 # { pform_set_defparam(*p[1], p[3]);
2817 # delete p[1];
2818 # }
2819 ()
2820 def p_defparam_assign_list_1(p):
2821 '''defparam_assign_list : defparam_assign '''
2822 if(parse_debug): print('defparam_assign_list_1', list(p))
2823 ()
2824 def p_defparam_assign_list_2(p):
2825 '''defparam_assign_list : dimensions defparam_assign '''
2826 if(parse_debug): print('defparam_assign_list_2', list(p))
2827 # { yyerror(@1, "error: defparam may not include a range.");
2828 # delete p[1];
2829 # }
2830 ()
2831 def p_defparam_assign_list_3(p):
2832 '''defparam_assign_list : defparam_assign_list ',' defparam_assign '''
2833 if(parse_debug): print('defparam_assign_list_3', list(p))
2834 ()
2835 def p_delay1_1(p):
2836 '''delay1 : '#' delay_value_simple '''
2837 if(parse_debug): print('delay1_1', list(p))
2838 # { list<PExpr*>*tmp = new list<PExpr*>;
2839 # tmp->push_back(p[2]);
2840 # p[0] = tmp;
2841 # }
2842 ()
2843 def p_delay1_2(p):
2844 '''delay1 : '#' '(' delay_value ')' '''
2845 if(parse_debug): print('delay1_2', list(p))
2846 # { list<PExpr*>*tmp = new list<PExpr*>;
2847 # tmp->push_back(p[3]);
2848 # p[0] = tmp;
2849 # }
2850 ()
2851 def p_delay3_1(p):
2852 '''delay3 : '#' delay_value_simple '''
2853 if(parse_debug): print('delay3_1', list(p))
2854 # { list<PExpr*>*tmp = new list<PExpr*>;
2855 # tmp->push_back(p[2]);
2856 # p[0] = tmp;
2857 # }
2858 ()
2859 def p_delay3_2(p):
2860 '''delay3 : '#' '(' delay_value ')' '''
2861 if(parse_debug): print('delay3_2', list(p))
2862 # { list<PExpr*>*tmp = new list<PExpr*>;
2863 # tmp->push_back(p[3]);
2864 # p[0] = tmp;
2865 # }
2866 ()
2867 def p_delay3_3(p):
2868 '''delay3 : '#' '(' delay_value ',' delay_value ')' '''
2869 if(parse_debug): print('delay3_3', list(p))
2870 # { list<PExpr*>*tmp = new list<PExpr*>;
2871 # tmp->push_back(p[3]);
2872 # tmp->push_back(p[5]);
2873 # p[0] = tmp;
2874 # }
2875 ()
2876 def p_delay3_4(p):
2877 '''delay3 : '#' '(' delay_value ',' delay_value ',' delay_value ')' '''
2878 if(parse_debug): print('delay3_4', list(p))
2879 # { list<PExpr*>*tmp = new list<PExpr*>;
2880 # tmp->push_back(p[3]);
2881 # tmp->push_back(p[5]);
2882 # tmp->push_back(p[7]);
2883 # p[0] = tmp;
2884 # }
2885 ()
2886 def p_delay3_opt_1(p):
2887 '''delay3_opt : delay3 '''
2888 if(parse_debug): print('delay3_opt_1', list(p))
2889 p[0] = p[1]
2890 ()
2891 def p_delay3_opt_2(p):
2892 '''delay3_opt : '''
2893 if(parse_debug>2): print('delay3_opt_2', list(p))
2894 # { p[0] = None }
2895 ()
2896 def p_delay_value_list_1(p):
2897 '''delay_value_list : delay_value '''
2898 if(parse_debug): print('delay_value_list_1', list(p))
2899 # { list<PExpr*>*tmp = new list<PExpr*>;
2900 # tmp->push_back(p[1]);
2901 # p[0] = tmp;
2902 # }
2903 ()
2904 def p_delay_value_list_2(p):
2905 '''delay_value_list : delay_value_list ',' delay_value '''
2906 if(parse_debug): print('delay_value_list_2', list(p))
2907 # { list<PExpr*>*tmp = p[1];
2908 # tmp->push_back(p[3]);
2909 # p[0] = tmp;
2910 # }
2911 ()
2912 def p_delay_value_1(p):
2913 '''delay_value : expression '''
2914 if(parse_debug): print('delay_value_1', list(p))
2915 # { PExpr*tmp = p[1];
2916 # p[0] = tmp;
2917 # }
2918 ()
2919 def p_delay_value_2(p):
2920 '''delay_value : expression ':' expression ':' expression '''
2921 if(parse_debug): print('delay_value_2', list(p))
2922 # { p[0] = pform_select_mtm_expr(p[1], p[3], p[5]); }
2923 ()
2924 def p_delay_value_simple_1(p):
2925 '''delay_value_simple : DEC_NUMBER '''
2926 if(parse_debug): print('delay_value_simple_1', list(p))
2927 # { verinum*tmp = p[1];
2928 # if (tmp == 0) {
2929 # yyerror(@1, "internal error: delay.");
2930 # p[0] = None
2931 # } else {
2932 # p[0] = new PENumber(tmp);
2933 # FILE_NAME(p[0], @1);
2934 # }
2935 # based_size = 0;
2936 # }
2937 ()
2938 def p_delay_value_simple_2(p):
2939 '''delay_value_simple : REALTIME '''
2940 if(parse_debug): print('delay_value_simple_2', list(p))
2941 # { verireal*tmp = p[1];
2942 # if (tmp == 0) {
2943 # yyerror(@1, "internal error: delay.");
2944 # p[0] = None
2945 # } else {
2946 # p[0] = new PEFNumber(tmp);
2947 # FILE_NAME(p[0], @1);
2948 # }
2949 # }
2950 ()
2951 def p_delay_value_simple_3(p):
2952 '''delay_value_simple : IDENTIFIER '''
2953 if(parse_debug): print('delay_value_simple_3', list(p))
2954 # { PEIdent*tmp = new PEIdent(lex_strings.make(p[1]));
2955 # FILE_NAME(tmp, @1);
2956 # p[0] = tmp;
2957 # delete[]p[1];
2958 # }
2959 ()
2960 def p_delay_value_simple_4(p):
2961 '''delay_value_simple : TIME_LITERAL '''
2962 if(parse_debug): print('delay_value_simple_4', list(p))
2963 # { int unit;
2964 #
2965 # based_size = 0;
2966 # p[0] = 0;
2967 # if (p[1] == 0 || !get_time_unit(p[1], unit))
2968 # yyerror(@1, "internal error: delay.");
2969 # else {
2970 # double p = pow(10.0,
2971 # (double)(unit - pform_get_timeunit()));
2972 # double time = atof(p[1]) * p;
2973 #
2974 # verireal *v = new verireal(time);
2975 # p[0] = new PEFNumber(v);
2976 # FILE_NAME(p[0], @1);
2977 # }
2978 # }
2979 ()
2980 def p_optional_semicolon_1(p):
2981 '''optional_semicolon : ';' '''
2982 if(parse_debug): print('optional_semicolon_1', list(p))
2983 ()
2984 def p_optional_semicolon_2(p):
2985 '''optional_semicolon : '''
2986 if(parse_debug): print('optional_semicolon_2', list(p))
2987 ()
2988 def p_discipline_declaration_1(p):
2989 '''discipline_declaration : K_discipline IDENTIFIER optional_semicolon _embed0_discipline_declaration discipline_items K_enddiscipline '''
2990 if(parse_debug): print('discipline_declaration_1', list(p))
2991 # { pform_end_discipline(@1); delete[] p[2]; }
2992 ()
2993 def p__embed0_discipline_declaration(p):
2994 '''_embed0_discipline_declaration : '''
2995 # { pform_start_discipline(p[2]); }
2996 ()
2997 def p_discipline_items_1(p):
2998 '''discipline_items : discipline_items discipline_item '''
2999 if(parse_debug): print('discipline_items_1', list(p))
3000 ()
3001 def p_discipline_items_2(p):
3002 '''discipline_items : discipline_item '''
3003 if(parse_debug): print('discipline_items_2', list(p))
3004 ()
3005 def p_discipline_item_1(p):
3006 '''discipline_item : K_domain K_discrete ';' '''
3007 if(parse_debug): print('discipline_item_1', list(p))
3008 # { pform_discipline_domain(@1, IVL_DIS_DISCRETE); }
3009 ()
3010 def p_discipline_item_2(p):
3011 '''discipline_item : K_domain K_continuous ';' '''
3012 if(parse_debug): print('discipline_item_2', list(p))
3013 # { pform_discipline_domain(@1, IVL_DIS_CONTINUOUS); }
3014 ()
3015 def p_discipline_item_3(p):
3016 '''discipline_item : K_potential IDENTIFIER ';' '''
3017 if(parse_debug): print('discipline_item_3', list(p))
3018 # { pform_discipline_potential(@1, p[2]); delete[] p[2]; }
3019 ()
3020 def p_discipline_item_4(p):
3021 '''discipline_item : K_flow IDENTIFIER ';' '''
3022 if(parse_debug): print('discipline_item_4', list(p))
3023 # { pform_discipline_flow(@1, p[2]); delete[] p[2]; }
3024 ()
3025 def p_nature_declaration_1(p):
3026 '''nature_declaration : K_nature IDENTIFIER optional_semicolon _embed0_nature_declaration nature_items K_endnature '''
3027 if(parse_debug): print('nature_declaration_1', list(p))
3028 # { pform_end_nature(@1); delete[] p[2]; }
3029 ()
3030 def p__embed0_nature_declaration(p):
3031 '''_embed0_nature_declaration : '''
3032 # { pform_start_nature(p[2]); }
3033 ()
3034 def p_nature_items_1(p):
3035 '''nature_items : nature_items nature_item '''
3036 if(parse_debug): print('nature_items_1', list(p))
3037 ()
3038 def p_nature_items_2(p):
3039 '''nature_items : nature_item '''
3040 if(parse_debug): print('nature_items_2', list(p))
3041 ()
3042 def p_nature_item_1(p):
3043 '''nature_item : K_units '=' STRING ';' '''
3044 if(parse_debug): print('nature_item_1', list(p))
3045 # { delete[] p[3]; }
3046 ()
3047 def p_nature_item_2(p):
3048 '''nature_item : K_abstol '=' expression ';' '''
3049 if(parse_debug): print('nature_item_2', list(p))
3050 ()
3051 def p_nature_item_3(p):
3052 '''nature_item : K_access '=' IDENTIFIER ';' '''
3053 if(parse_debug): print('nature_item_3', list(p))
3054 # { pform_nature_access(@1, p[3]); delete[] p[3]; }
3055 ()
3056 def p_nature_item_4(p):
3057 '''nature_item : K_idt_nature '=' IDENTIFIER ';' '''
3058 if(parse_debug): print('nature_item_4', list(p))
3059 # { delete[] p[3]; }
3060 ()
3061 def p_nature_item_5(p):
3062 '''nature_item : K_ddt_nature '=' IDENTIFIER ';' '''
3063 if(parse_debug): print('nature_item_5', list(p))
3064 # { delete[] p[3]; }
3065 ()
3066 def p_config_declaration_1(p):
3067 '''config_declaration : K_config IDENTIFIER ';' K_design lib_cell_identifiers ';' list_of_config_rule_statements K_endconfig '''
3068 if(parse_debug): print('config_declaration_1', list(p))
3069 # { cerr << @1 << ": sorry: config declarations are not supported and "
3070 # "will be skipped." << endl;
3071 # delete[] p[2];
3072 # }
3073 ()
3074 def p_lib_cell_identifiers_1(p):
3075 '''lib_cell_identifiers : '''
3076 if(parse_debug): print('lib_cell_identifiers_1', list(p))
3077 ()
3078 def p_lib_cell_identifiers_2(p):
3079 '''lib_cell_identifiers : lib_cell_identifiers lib_cell_id '''
3080 if(parse_debug): print('lib_cell_identifiers_2', list(p))
3081 ()
3082 def p_list_of_config_rule_statements_1(p):
3083 '''list_of_config_rule_statements : '''
3084 if(parse_debug): print('list_of_config_rule_statements_1', list(p))
3085 ()
3086 def p_list_of_config_rule_statements_2(p):
3087 '''list_of_config_rule_statements : list_of_config_rule_statements config_rule_statement '''
3088 if(parse_debug): print('list_of_config_rule_statements_2', list(p))
3089 ()
3090 def p_config_rule_statement_1(p):
3091 '''config_rule_statement : K_default K_liblist list_of_libraries ';' '''
3092 if(parse_debug): print('config_rule_statement_1', list(p))
3093 ()
3094 def p_config_rule_statement_2(p):
3095 '''config_rule_statement : K_instance hierarchy_identifier K_liblist list_of_libraries ';' '''
3096 if(parse_debug): print('config_rule_statement_2', list(p))
3097 # { delete p[2]; }
3098 ()
3099 def p_config_rule_statement_3(p):
3100 '''config_rule_statement : K_instance hierarchy_identifier K_use lib_cell_id opt_config ';' '''
3101 if(parse_debug): print('config_rule_statement_3', list(p))
3102 # { delete p[2]; }
3103 ()
3104 def p_config_rule_statement_4(p):
3105 '''config_rule_statement : K_cell lib_cell_id K_liblist list_of_libraries ';' '''
3106 if(parse_debug): print('config_rule_statement_4', list(p))
3107 ()
3108 def p_config_rule_statement_5(p):
3109 '''config_rule_statement : K_cell lib_cell_id K_use lib_cell_id opt_config ';' '''
3110 if(parse_debug): print('config_rule_statement_5', list(p))
3111 ()
3112 def p_opt_config_1(p):
3113 '''opt_config : '''
3114 if(parse_debug): print('opt_config_1', list(p))
3115 ()
3116 def p_opt_config_2(p):
3117 '''opt_config : ':' K_config '''
3118 if(parse_debug): print('opt_config_2', list(p))
3119 ()
3120 def p_lib_cell_id_1(p):
3121 '''lib_cell_id : IDENTIFIER '''
3122 if(parse_debug): print('lib_cell_id_1', list(p))
3123 # { delete[] p[1]; }
3124 ()
3125 def p_lib_cell_id_2(p):
3126 '''lib_cell_id : IDENTIFIER '.' IDENTIFIER '''
3127 if(parse_debug): print('lib_cell_id_2', list(p))
3128 # { delete[] p[1]; delete[] p[3]; }
3129 ()
3130 def p_list_of_libraries_1(p):
3131 '''list_of_libraries : '''
3132 if(parse_debug): print('list_of_libraries_1', list(p))
3133 ()
3134 def p_list_of_libraries_2(p):
3135 '''list_of_libraries : list_of_libraries IDENTIFIER '''
3136 if(parse_debug): print('list_of_libraries_2', list(p))
3137 # { delete[] p[2]; }
3138 ()
3139 def p_drive_strength_1(p):
3140 '''drive_strength : '(' dr_strength0 ',' dr_strength1 ')' '''
3141 if(parse_debug): print('drive_strength_1', list(p))
3142 # { p[0].str0 = p[2].str0;
3143 # p[0].str1 = p[4].str1;
3144 # }
3145 ()
3146 def p_drive_strength_2(p):
3147 '''drive_strength : '(' dr_strength1 ',' dr_strength0 ')' '''
3148 if(parse_debug): print('drive_strength_2', list(p))
3149 # { p[0].str0 = p[4].str0;
3150 # p[0].str1 = p[2].str1;
3151 # }
3152 ()
3153 def p_drive_strength_3(p):
3154 '''drive_strength : '(' dr_strength0 ',' K_highz1 ')' '''
3155 if(parse_debug): print('drive_strength_3', list(p))
3156 # { p[0].str0 = p[2].str0;
3157 # p[0].str1 = IVL_DR_HiZ;
3158 # }
3159 ()
3160 def p_drive_strength_4(p):
3161 '''drive_strength : '(' dr_strength1 ',' K_highz0 ')' '''
3162 if(parse_debug): print('drive_strength_4', list(p))
3163 # { p[0].str0 = IVL_DR_HiZ;
3164 # p[0].str1 = p[2].str1;
3165 # }
3166 ()
3167 def p_drive_strength_5(p):
3168 '''drive_strength : '(' K_highz1 ',' dr_strength0 ')' '''
3169 if(parse_debug): print('drive_strength_5', list(p))
3170 # { p[0].str0 = p[4].str0;
3171 # p[0].str1 = IVL_DR_HiZ;
3172 # }
3173 ()
3174 def p_drive_strength_6(p):
3175 '''drive_strength : '(' K_highz0 ',' dr_strength1 ')' '''
3176 if(parse_debug): print('drive_strength_6', list(p))
3177 # { p[0].str0 = IVL_DR_HiZ;
3178 # p[0].str1 = p[4].str1;
3179 # }
3180 ()
3181 def p_drive_strength_opt_1(p):
3182 '''drive_strength_opt : drive_strength '''
3183 if(parse_debug): print('drive_strength_opt_1', list(p))
3184 p[0] = p[1]
3185 ()
3186 def p_drive_strength_opt_2(p):
3187 '''drive_strength_opt : '''
3188 if(parse_debug>2): print('drive_strength_opt_2', list(p))
3189 # { p[0].str0 = IVL_DR_STRONG; p[0].str1 = IVL_DR_STRONG; }
3190 ()
3191 def p_dr_strength0_1(p):
3192 '''dr_strength0 : K_supply0 '''
3193 if(parse_debug): print('dr_strength0_1', list(p))
3194 # { p[0].str0 = IVL_DR_SUPPLY; }
3195 ()
3196 def p_dr_strength0_2(p):
3197 '''dr_strength0 : K_strong0 '''
3198 if(parse_debug): print('dr_strength0_2', list(p))
3199 # { p[0].str0 = IVL_DR_STRONG; }
3200 ()
3201 def p_dr_strength0_3(p):
3202 '''dr_strength0 : K_pull0 '''
3203 if(parse_debug): print('dr_strength0_3', list(p))
3204 # { p[0].str0 = IVL_DR_PULL; }
3205 ()
3206 def p_dr_strength0_4(p):
3207 '''dr_strength0 : K_weak0 '''
3208 if(parse_debug): print('dr_strength0_4', list(p))
3209 # { p[0].str0 = IVL_DR_WEAK; }
3210 ()
3211 def p_dr_strength1_1(p):
3212 '''dr_strength1 : K_supply1 '''
3213 if(parse_debug): print('dr_strength1_1', list(p))
3214 # { p[0].str1 = IVL_DR_SUPPLY; }
3215 ()
3216 def p_dr_strength1_2(p):
3217 '''dr_strength1 : K_strong1 '''
3218 if(parse_debug): print('dr_strength1_2', list(p))
3219 # { p[0].str1 = IVL_DR_STRONG; }
3220 ()
3221 def p_dr_strength1_3(p):
3222 '''dr_strength1 : K_pull1 '''
3223 if(parse_debug): print('dr_strength1_3', list(p))
3224 # { p[0].str1 = IVL_DR_PULL; }
3225 ()
3226 def p_dr_strength1_4(p):
3227 '''dr_strength1 : K_weak1 '''
3228 if(parse_debug): print('dr_strength1_4', list(p))
3229 # { p[0].str1 = IVL_DR_WEAK; }
3230 ()
3231 def p_clocking_event_opt_1(p):
3232 '''clocking_event_opt : event_control '''
3233 if(parse_debug): print('clocking_event_opt_1', list(p))
3234 ()
3235 def p_clocking_event_opt_2(p):
3236 '''clocking_event_opt : '''
3237 if(parse_debug): print('clocking_event_opt_2', list(p))
3238 ()
3239 def p_event_control_1(p):
3240 '''event_control : '@' hierarchy_identifier '''
3241 if(parse_debug): print('event_control_1', list(p))
3242 # { PEIdent*tmpi = new PEIdent(*p[2]);
3243 # PEEvent*tmpe = new PEEvent(PEEvent::ANYEDGE, tmpi);
3244 # PEventStatement*tmps = new PEventStatement(tmpe);
3245 # FILE_NAME(tmps, @1);
3246 # p[0] = tmps;
3247 # delete p[2];
3248 # }
3249 ()
3250 def p_event_control_2(p):
3251 '''event_control : '@' '(' event_expression_list ')' '''
3252 if(parse_debug): print('event_control_2', list(p))
3253 # { PEventStatement*tmp = new PEventStatement(*p[3]);
3254 # FILE_NAME(tmp, @1);
3255 # delete p[3];
3256 # p[0] = tmp;
3257 # }
3258 ()
3259 def p_event_control_3(p):
3260 '''event_control : '@' '(' error ')' '''
3261 if(parse_debug): print('event_control_3', list(p))
3262 # { yyerror(@1, "error: Malformed event control expression.");
3263 # p[0] = None
3264 # }
3265 ()
3266 def p_event_expression_list_1(p):
3267 '''event_expression_list : event_expression '''
3268 if(parse_debug): print('event_expression_list_1', list(p))
3269 p[0] = p[1]
3270 ()
3271 def p_event_expression_list_2(p):
3272 '''event_expression_list : event_expression_list K_or event_expression '''
3273 if(parse_debug): print('event_expression_list_2', list(p))
3274 # { svector<PEEvent*>*tmp = new svector<PEEvent*>(*p[1], *p[3]);
3275 # delete p[1];
3276 # delete p[3];
3277 # p[0] = tmp;
3278 # }
3279 ()
3280 def p_event_expression_list_3(p):
3281 '''event_expression_list : event_expression_list ',' event_expression '''
3282 if(parse_debug): print('event_expression_list_3', list(p))
3283 # { svector<PEEvent*>*tmp = new svector<PEEvent*>(*p[1], *p[3]);
3284 # delete p[1];
3285 # delete p[3];
3286 # p[0] = tmp;
3287 # }
3288 ()
3289 def p_event_expression_1(p):
3290 '''event_expression : K_posedge expression '''
3291 if(parse_debug): print('event_expression_1', list(p))
3292 # { PEEvent*tmp = new PEEvent(PEEvent::POSEDGE, p[2]);
3293 # FILE_NAME(tmp, @1);
3294 # svector<PEEvent*>*tl = new svector<PEEvent*>(1);
3295 # (*tl)[0] = tmp;
3296 # p[0] = tl;
3297 # }
3298 ()
3299 def p_event_expression_2(p):
3300 '''event_expression : K_negedge expression '''
3301 if(parse_debug): print('event_expression_2', list(p))
3302 # { PEEvent*tmp = new PEEvent(PEEvent::NEGEDGE, p[2]);
3303 # FILE_NAME(tmp, @1);
3304 # svector<PEEvent*>*tl = new svector<PEEvent*>(1);
3305 # (*tl)[0] = tmp;
3306 # p[0] = tl;
3307 # }
3308 ()
3309 def p_event_expression_3(p):
3310 '''event_expression : expression '''
3311 if(parse_debug): print('event_expression_3', list(p))
3312 # { PEEvent*tmp = new PEEvent(PEEvent::ANYEDGE, p[1]);
3313 # FILE_NAME(tmp, @1);
3314 # svector<PEEvent*>*tl = new svector<PEEvent*>(1);
3315 # (*tl)[0] = tmp;
3316 # p[0] = tl;
3317 # }
3318 ()
3319 def p_branch_probe_expression_1(p):
3320 '''branch_probe_expression : IDENTIFIER '(' IDENTIFIER ',' IDENTIFIER ')' '''
3321 if(parse_debug): print('branch_probe_expression_1', list(p))
3322 # { p[0] = pform_make_branch_probe_expression(@1, p[1], p[3], p[5]); }
3323 ()
3324 def p_branch_probe_expression_2(p):
3325 '''branch_probe_expression : IDENTIFIER '(' IDENTIFIER ')' '''
3326 if(parse_debug): print('branch_probe_expression_2', list(p))
3327 # { p[0] = pform_make_branch_probe_expression(@1, p[1], p[3]); }
3328 ()
3329 def p_expression_1(p):
3330 '''expression : expr_primary_or_typename '''
3331 if(parse_debug>2): print('expression_1', list(p))
3332 p[0] = p[1]
3333 ()
3334 def p_expression_2(p):
3335 '''expression : inc_or_dec_expression '''
3336 if(parse_debug): print('expression_2', list(p))
3337 p[0] = p[1]
3338 ()
3339 def p_expression_3(p):
3340 '''expression : inside_expression '''
3341 if(parse_debug): print('expression_3', list(p))
3342 p[0] = p[1]
3343 ()
3344 def p_expression_4(p):
3345 '''expression : '+' attribute_list_opt expr_primary %prec UNARY_PREC '''
3346 if(parse_debug): print('expression_4', list(p))
3347 p[0] = p[3]
3348 ()
3349 def p_expression_5(p):
3350 '''expression : '-' attribute_list_opt expr_primary %prec UNARY_PREC '''
3351 if(parse_debug): print('expression_5', list(p))
3352 # { PEUnary*tmp = new PEUnary('-', p[3]);
3353 # FILE_NAME(tmp, @3);
3354 # p[0] = tmp;
3355 # }
3356 ()
3357 def p_expression_6(p):
3358 '''expression : '~' attribute_list_opt expr_primary %prec UNARY_PREC '''
3359 if(parse_debug): print('expression_6', list(p))
3360 # { PEUnary*tmp = new PEUnary('~', p[3]);
3361 # FILE_NAME(tmp, @3);
3362 # p[0] = tmp;
3363 # }
3364 ()
3365 def p_expression_7(p):
3366 '''expression : '&' attribute_list_opt expr_primary %prec UNARY_PREC '''
3367 if(parse_debug): print('expression_7', list(p))
3368 # { PEUnary*tmp = new PEUnary('&', p[3]);
3369 # FILE_NAME(tmp, @3);
3370 # p[0] = tmp;
3371 # }
3372 ()
3373 def p_expression_8(p):
3374 '''expression : '!' attribute_list_opt expr_primary %prec UNARY_PREC '''
3375 if(parse_debug): print('expression_8', list(p))
3376 # { PEUnary*tmp = new PEUnary('!', p[3]);
3377 # FILE_NAME(tmp, @3);
3378 # p[0] = tmp;
3379 # }
3380 ()
3381 def p_expression_9(p):
3382 '''expression : '|' attribute_list_opt expr_primary %prec UNARY_PREC '''
3383 if(parse_debug): print('expression_9', list(p))
3384 # { PEUnary*tmp = new PEUnary('|', p[3]);
3385 # FILE_NAME(tmp, @3);
3386 # p[0] = tmp;
3387 # }
3388 ()
3389 def p_expression_10(p):
3390 '''expression : '^' attribute_list_opt expr_primary %prec UNARY_PREC '''
3391 if(parse_debug): print('expression_10', list(p))
3392 # { PEUnary*tmp = new PEUnary('^', p[3]);
3393 # FILE_NAME(tmp, @3);
3394 # p[0] = tmp;
3395 # }
3396 ()
3397 def p_expression_11(p):
3398 '''expression : '~' '&' attribute_list_opt expr_primary %prec UNARY_PREC '''
3399 if(parse_debug): print('expression_11', list(p))
3400 # { yyerror(@1, "error: '~' '&' is not a valid expression. "
3401 # "Please use operator '~&' instead.");
3402 # p[0] = None
3403 # }
3404 ()
3405 def p_expression_12(p):
3406 '''expression : '~' '|' attribute_list_opt expr_primary %prec UNARY_PREC '''
3407 if(parse_debug): print('expression_12', list(p))
3408 # { yyerror(@1, "error: '~' '|' is not a valid expression. "
3409 # "Please use operator '~|' instead.");
3410 # p[0] = None
3411 # }
3412 ()
3413 def p_expression_13(p):
3414 '''expression : '~' '^' attribute_list_opt expr_primary %prec UNARY_PREC '''
3415 if(parse_debug): print('expression_13', list(p))
3416 # { yyerror(@1, "error: '~' '^' is not a valid expression. "
3417 # "Please use operator '~^' instead.");
3418 # p[0] = None
3419 # }
3420 ()
3421 def p_expression_14(p):
3422 '''expression : K_NAND attribute_list_opt expr_primary %prec UNARY_PREC '''
3423 if(parse_debug): print('expression_14', list(p))
3424 # { PEUnary*tmp = new PEUnary('A', p[3]);
3425 # FILE_NAME(tmp, @3);
3426 # p[0] = tmp;
3427 # }
3428 ()
3429 def p_expression_15(p):
3430 '''expression : K_NOR attribute_list_opt expr_primary %prec UNARY_PREC '''
3431 if(parse_debug): print('expression_15', list(p))
3432 # { PEUnary*tmp = new PEUnary('N', p[3]);
3433 # FILE_NAME(tmp, @3);
3434 # p[0] = tmp;
3435 # }
3436 ()
3437 def p_expression_16(p):
3438 '''expression : K_NXOR attribute_list_opt expr_primary %prec UNARY_PREC '''
3439 if(parse_debug): print('expression_16', list(p))
3440 # { PEUnary*tmp = new PEUnary('X', p[3]);
3441 # FILE_NAME(tmp, @3);
3442 # p[0] = tmp;
3443 # }
3444 ()
3445 def p_expression_17(p):
3446 '''expression : '!' error %prec UNARY_PREC '''
3447 if(parse_debug): print('expression_17', list(p))
3448 # { yyerror(@1, "error: Operand of unary ! "
3449 # "is not a primary expression.");
3450 # p[0] = None
3451 # }
3452 ()
3453 def p_expression_18(p):
3454 '''expression : '^' error %prec UNARY_PREC '''
3455 if(parse_debug): print('expression_18', list(p))
3456 # { yyerror(@1, "error: Operand of reduction ^ "
3457 # "is not a primary expression.");
3458 # p[0] = None
3459 # }
3460 ()
3461 def p_expression_19(p):
3462 '''expression : expression '^' attribute_list_opt expression '''
3463 if(parse_debug): print('expression_19', list(p))
3464 # { PEBinary*tmp = new PEBinary('^', p[1], p[4]);
3465 # FILE_NAME(tmp, @2);
3466 # p[0] = tmp;
3467 # }
3468 ()
3469 def p_expression_20(p):
3470 '''expression : expression K_POW attribute_list_opt expression '''
3471 if(parse_debug): print('expression_20', list(p))
3472 # { PEBinary*tmp = new PEBPower('p', p[1], p[4]);
3473 # FILE_NAME(tmp, @2);
3474 # p[0] = tmp;
3475 # }
3476 ()
3477 def p_expression_21(p):
3478 '''expression : expression '*' attribute_list_opt expression '''
3479 if(parse_debug): print('expression_21', list(p))
3480 # { PEBinary*tmp = new PEBinary('*', p[1], p[4]);
3481 # FILE_NAME(tmp, @2);
3482 # p[0] = tmp;
3483 # }
3484 ()
3485 def p_expression_22(p):
3486 '''expression : expression '/' attribute_list_opt expression '''
3487 if(parse_debug): print('expression_22', list(p))
3488 # { PEBinary*tmp = new PEBinary('/', p[1], p[4]);
3489 # FILE_NAME(tmp, @2);
3490 # p[0] = tmp;
3491 # }
3492 ()
3493 def p_expression_23(p):
3494 '''expression : expression '%' attribute_list_opt expression '''
3495 if(parse_debug): print('expression_23', list(p))
3496 # { PEBinary*tmp = new PEBinary('%', p[1], p[4]);
3497 # FILE_NAME(tmp, @2);
3498 # p[0] = tmp;
3499 # }
3500 ()
3501 def p_expression_24(p):
3502 '''expression : expression '+' attribute_list_opt expression '''
3503 if(parse_debug): print('expression_24', list(p))
3504 # { PEBinary*tmp = new PEBinary('+', p[1], p[4]);
3505 # FILE_NAME(tmp, @2);
3506 # p[0] = tmp;
3507 # }
3508 ()
3509 def p_expression_25(p):
3510 '''expression : expression '-' attribute_list_opt expression '''
3511 if(parse_debug): print('expression_25', list(p))
3512 # { PEBinary*tmp = new PEBinary('-', p[1], p[4]);
3513 # FILE_NAME(tmp, @2);
3514 # p[0] = tmp;
3515 # }
3516 p[0] = Node(syms.atom, [p[1], Leaf(token.MINUS, '-'), p[4]])
3517 ()
3518 def p_expression_26(p):
3519 '''expression : expression '&' attribute_list_opt expression '''
3520 if(parse_debug): print('expression_26', list(p))
3521 # { PEBinary*tmp = new PEBinary('&', p[1], p[4]);
3522 # FILE_NAME(tmp, @2);
3523 # p[0] = tmp;
3524 # }
3525 ()
3526 def p_expression_27(p):
3527 '''expression : expression '|' attribute_list_opt expression '''
3528 if(parse_debug): print('expression_27', list(p))
3529 # { PEBinary*tmp = new PEBinary('|', p[1], p[4]);
3530 # FILE_NAME(tmp, @2);
3531 # p[0] = tmp;
3532 # }
3533 ()
3534 def p_expression_28(p):
3535 '''expression : expression K_NAND attribute_list_opt expression '''
3536 if(parse_debug): print('expression_28', list(p))
3537 # { PEBinary*tmp = new PEBinary('A', p[1], p[4]);
3538 # FILE_NAME(tmp, @2);
3539 # p[0] = tmp;
3540 # }
3541 ()
3542 def p_expression_29(p):
3543 '''expression : expression K_NOR attribute_list_opt expression '''
3544 if(parse_debug): print('expression_29', list(p))
3545 # { PEBinary*tmp = new PEBinary('O', p[1], p[4]);
3546 # FILE_NAME(tmp, @2);
3547 # p[0] = tmp;
3548 # }
3549 ()
3550 def p_expression_30(p):
3551 '''expression : expression K_NXOR attribute_list_opt expression '''
3552 if(parse_debug): print('expression_30', list(p))
3553 # { PEBinary*tmp = new PEBinary('X', p[1], p[4]);
3554 # FILE_NAME(tmp, @2);
3555 # p[0] = tmp;
3556 # }
3557 ()
3558 def p_expression_31(p):
3559 '''expression : expression '<' attribute_list_opt expression '''
3560 if(parse_debug): print('expression_31', list(p))
3561 # { PEBinary*tmp = new PEBComp('<', p[1], p[4]);
3562 # FILE_NAME(tmp, @2);
3563 # p[0] = tmp;
3564 # }
3565 ()
3566 def p_expression_32(p):
3567 '''expression : expression '>' attribute_list_opt expression '''
3568 if(parse_debug): print('expression_32', list(p))
3569 # { PEBinary*tmp = new PEBComp('>', p[1], p[4]);
3570 # FILE_NAME(tmp, @2);
3571 # p[0] = tmp;
3572 # }
3573 ()
3574 def p_expression_33(p):
3575 '''expression : expression K_LS attribute_list_opt expression '''
3576 if(parse_debug): print('expression_33', list(p))
3577 # { PEBinary*tmp = new PEBShift('l', p[1], p[4]);
3578 # FILE_NAME(tmp, @2);
3579 # p[0] = tmp;
3580 # }
3581 ()
3582 def p_expression_34(p):
3583 '''expression : expression K_RS attribute_list_opt expression '''
3584 if(parse_debug): print('expression_34', list(p))
3585 # { PEBinary*tmp = new PEBShift('r', p[1], p[4]);
3586 # FILE_NAME(tmp, @2);
3587 # p[0] = tmp;
3588 # }
3589 ()
3590 def p_expression_35(p):
3591 '''expression : expression K_RSS attribute_list_opt expression '''
3592 if(parse_debug): print('expression_35', list(p))
3593 # { PEBinary*tmp = new PEBShift('R', p[1], p[4]);
3594 # FILE_NAME(tmp, @2);
3595 # p[0] = tmp;
3596 # }
3597 ()
3598 def p_expression_36(p):
3599 '''expression : expression K_EQ attribute_list_opt expression '''
3600 if(parse_debug): print('expression_36', list(p))
3601 # { PEBinary*tmp = new PEBComp('e', p[1], p[4]);
3602 # FILE_NAME(tmp, @2);
3603 # p[0] = tmp;
3604 # }
3605 ()
3606 def p_expression_37(p):
3607 '''expression : expression K_CEQ attribute_list_opt expression '''
3608 if(parse_debug): print('expression_37', list(p))
3609 # { PEBinary*tmp = new PEBComp('E', p[1], p[4]);
3610 # FILE_NAME(tmp, @2);
3611 # p[0] = tmp;
3612 # }
3613 ()
3614 def p_expression_38(p):
3615 '''expression : expression K_WEQ attribute_list_opt expression '''
3616 if(parse_debug): print('expression_38', list(p))
3617 # { PEBinary*tmp = new PEBComp('w', p[1], p[4]);
3618 # FILE_NAME(tmp, @2);
3619 # p[0] = tmp;
3620 # }
3621 ()
3622 def p_expression_39(p):
3623 '''expression : expression K_LE attribute_list_opt expression '''
3624 if(parse_debug): print('expression_39', list(p))
3625 # { PEBinary*tmp = new PEBComp('L', p[1], p[4]);
3626 # FILE_NAME(tmp, @2);
3627 # p[0] = tmp;
3628 # }
3629 ()
3630 def p_expression_40(p):
3631 '''expression : expression K_GE attribute_list_opt expression '''
3632 if(parse_debug): print('expression_40', list(p))
3633 # { PEBinary*tmp = new PEBComp('G', p[1], p[4]);
3634 # FILE_NAME(tmp, @2);
3635 # p[0] = tmp;
3636 # }
3637 ()
3638 def p_expression_41(p):
3639 '''expression : expression K_NE attribute_list_opt expression '''
3640 if(parse_debug): print('expression_41', list(p))
3641 # { PEBinary*tmp = new PEBComp('n', p[1], p[4]);
3642 # FILE_NAME(tmp, @2);
3643 # p[0] = tmp;
3644 # }
3645 ()
3646 def p_expression_42(p):
3647 '''expression : expression K_CNE attribute_list_opt expression '''
3648 if(parse_debug): print('expression_42', list(p))
3649 # { PEBinary*tmp = new PEBComp('N', p[1], p[4]);
3650 # FILE_NAME(tmp, @2);
3651 # p[0] = tmp;
3652 # }
3653 ()
3654 def p_expression_43(p):
3655 '''expression : expression K_WNE attribute_list_opt expression '''
3656 if(parse_debug): print('expression_43', list(p))
3657 # { PEBinary*tmp = new PEBComp('W', p[1], p[4]);
3658 # FILE_NAME(tmp, @2);
3659 # p[0] = tmp;
3660 # }
3661 ()
3662 def p_expression_44(p):
3663 '''expression : expression K_LOR attribute_list_opt expression '''
3664 if(parse_debug): print('expression_44', list(p))
3665 # { PEBinary*tmp = new PEBLogic('o', p[1], p[4]);
3666 # FILE_NAME(tmp, @2);
3667 # p[0] = tmp;
3668 # }
3669 ()
3670 def p_expression_45(p):
3671 '''expression : expression K_LAND attribute_list_opt expression '''
3672 if(parse_debug): print('expression_45', list(p))
3673 # { PEBinary*tmp = new PEBLogic('a', p[1], p[4]);
3674 # FILE_NAME(tmp, @2);
3675 # p[0] = tmp;
3676 # }
3677 ()
3678 def p_expression_46(p):
3679 '''expression : expression '?' attribute_list_opt expression ':' expression '''
3680 if(parse_debug): print('expression_46', list(p))
3681 # { PETernary*tmp = new PETernary(p[1], p[4], p[6]);
3682 # FILE_NAME(tmp, @2);
3683 # p[0] = tmp;
3684 # }
3685 ()
3686 def p_expr_mintypmax_1(p):
3687 '''expr_mintypmax : expression '''
3688 if(parse_debug): print('expr_mintypmax_1', list(p))
3689 p[0] = p[1]
3690 ()
3691 def p_expr_mintypmax_2(p):
3692 '''expr_mintypmax : expression ':' expression ':' expression '''
3693 if(parse_debug): print('expr_mintypmax_2', list(p))
3694 # { switch (min_typ_max_flag) {
3695 # case MIN:
3696 # p[0] = p[1];
3697 # delete p[3];
3698 # delete p[5];
3699 # break;
3700 # case TYP:
3701 # delete p[1];
3702 # p[0] = p[3];
3703 # delete p[5];
3704 # break;
3705 # case MAX:
3706 # delete p[1];
3707 # delete p[3];
3708 # p[0] = p[5];
3709 # break;
3710 # }
3711 # if (min_typ_max_warn > 0) {
3712 # cerr << p[0]->get_fileline() << ": warning: choosing ";
3713 # switch (min_typ_max_flag) {
3714 # case MIN:
3715 # cerr << "min";
3716 # break;
3717 # case TYP:
3718 # cerr << "typ";
3719 # break;
3720 # case MAX:
3721 # cerr << "max";
3722 # break;
3723 # }
3724 # cerr << " expression." << endl;
3725 # min_typ_max_warn -= 1;
3726 # }
3727 # }
3728 ()
3729 def p_expression_list_with_nuls_1(p):
3730 '''expression_list_with_nuls : expression_list_with_nuls ',' expression '''
3731 if(parse_debug): print('expression_list_with_nuls_1', list(p))
3732 # { list<PExpr*>*tmp = p[1];
3733 # tmp->push_back(p[3]);
3734 # p[0] = tmp;
3735 # }
3736 ()
3737 def p_expression_list_with_nuls_2(p):
3738 '''expression_list_with_nuls : expression '''
3739 if(parse_debug): print('expression_list_with_nuls_2', list(p))
3740 # { list<PExpr*>*tmp = new list<PExpr*>;
3741 # tmp->push_back(p[1]);
3742 # p[0] = tmp;
3743 # }
3744 ()
3745 def p_expression_list_with_nuls_3(p):
3746 '''expression_list_with_nuls : '''
3747 if(parse_debug): print('expression_list_with_nuls_3', list(p))
3748 # { list<PExpr*>*tmp = new list<PExpr*>;
3749 # tmp->push_back(0);
3750 # p[0] = tmp;
3751 # }
3752 ()
3753 def p_expression_list_with_nuls_4(p):
3754 '''expression_list_with_nuls : expression_list_with_nuls ',' '''
3755 if(parse_debug): print('expression_list_with_nuls_4', list(p))
3756 # { list<PExpr*>*tmp = p[1];
3757 # tmp->push_back(0);
3758 # p[0] = tmp;
3759 # }
3760 ()
3761 def p_expression_list_proper_1(p):
3762 '''expression_list_proper : expression_list_proper ',' expression '''
3763 if(parse_debug): print('expression_list_proper_1', list(p))
3764 # { list<PExpr*>*tmp = p[1];
3765 # tmp->push_back(p[3]);
3766 # p[0] = tmp;
3767 # }
3768 ()
3769 def p_expression_list_proper_2(p):
3770 '''expression_list_proper : expression '''
3771 if(parse_debug): print('expression_list_proper_2', list(p))
3772 # { list<PExpr*>*tmp = new list<PExpr*>;
3773 # tmp->push_back(p[1]);
3774 # p[0] = tmp;
3775 # }
3776 ()
3777 def p_expr_primary_or_typename_1(p):
3778 '''expr_primary_or_typename : expr_primary '''
3779 if(parse_debug>2): print('expr_primary_or_typename_1', list(p))
3780 p[0] = p[1]
3781 ()
3782 def p_expr_primary_or_typename_2(p):
3783 '''expr_primary_or_typename : TYPE_IDENTIFIER '''
3784 if(parse_debug): print('expr_primary_or_typename_2', list(p))
3785 p[0] = p[1]
3786 # { PETypename*tmp = new PETypename(p[1].type);
3787 # FILE_NAME(tmp,@1);
3788 # p[0] = tmp;
3789 # delete[]p[1].text;
3790 # }
3791 ()
3792 def p_expr_primary_1(p):
3793 '''expr_primary : number '''
3794 if(parse_debug): print('expr_primary_1', list(p))
3795 p[0] = p[1]
3796 # { assert(p[1]);
3797 # PENumber*tmp = new PENumber(p[1]);
3798 # FILE_NAME(tmp, @1);
3799 # p[0] = tmp;
3800 # }
3801 ()
3802 def p_expr_primary_2(p):
3803 '''expr_primary : REALTIME '''
3804 if(parse_debug): print('expr_primary_2', list(p))
3805 # { PEFNumber*tmp = new PEFNumber(p[1]);
3806 # FILE_NAME(tmp, @1);
3807 # p[0] = tmp;
3808 # }
3809 ()
3810 def p_expr_primary_3(p):
3811 '''expr_primary : STRING '''
3812 if(parse_debug): print('expr_primary_3', list(p))
3813 # { PEString*tmp = new PEString(p[1]);
3814 # FILE_NAME(tmp, @1);
3815 # p[0] = tmp;
3816 # }
3817 ()
3818 def p_expr_primary_4(p):
3819 '''expr_primary : TIME_LITERAL '''
3820 if(parse_debug): print('expr_primary_4', list(p))
3821 # { int unit;
3822 #
3823 # based_size = 0;
3824 # p[0] = 0;
3825 # if (p[1] == 0 || !get_time_unit(p[1], unit))
3826 # yyerror(@1, "internal error: delay.");
3827 # else {
3828 # double p = pow(10.0, (double)(unit - pform_get_timeunit()));
3829 # double time = atof(p[1]) * p;
3830 #
3831 # verireal *v = new verireal(time);
3832 # p[0] = new PEFNumber(v);
3833 # FILE_NAME(p[0], @1);
3834 # }
3835 # }
3836 ()
3837 def p_expr_primary_5(p):
3838 '''expr_primary : SYSTEM_IDENTIFIER '''
3839 if(parse_debug): print('expr_primary_5', list(p))
3840 # { perm_string tn = lex_strings.make(p[1]);
3841 # PECallFunction*tmp = new PECallFunction(tn);
3842 # FILE_NAME(tmp, @1);
3843 # p[0] = tmp;
3844 # delete[]p[1];
3845 # }
3846 ()
3847 def p_expr_primary_6(p):
3848 '''expr_primary : hierarchy_identifier '''
3849 if(parse_debug>2): print('expr_primary_6', list(p))
3850 p[0] = p[1]
3851 # { PEIdent*tmp = pform_new_ident(*p[1]);
3852 # FILE_NAME(tmp, @1);
3853 # p[0] = tmp;
3854 # delete p[1];
3855 # }
3856 ()
3857 def p_expr_primary_7(p):
3858 '''expr_primary : PACKAGE_IDENTIFIER K_SCOPE_RES hierarchy_identifier '''
3859 if(parse_debug): print('expr_primary_7', list(p))
3860 # { p[0] = pform_package_ident(@2, p[1], p[3]);
3861 # delete p[3];
3862 # }
3863 ()
3864 def p_expr_primary_8(p):
3865 '''expr_primary : hierarchy_identifier '(' expression_list_with_nuls ')' '''
3866 if(parse_debug): print('expr_primary_8', list(p))
3867 # { list<PExpr*>*expr_list = p[3];
3868 # strip_tail_items(expr_list);
3869 # PECallFunction*tmp = pform_make_call_function(@1, *p[1], *expr_list);
3870 # delete p[1];
3871 # p[0] = tmp;
3872 # }
3873 ()
3874 def p_expr_primary_9(p):
3875 '''expr_primary : implicit_class_handle '.' hierarchy_identifier '(' expression_list_with_nuls ')' '''
3876 if(parse_debug): print('expr_primary_9', list(p))
3877 # { pform_name_t*t_name = p[1];
3878 # while (! p[3]->empty()) {
3879 # t_name->push_back(p[3]->front());
3880 # p[3]->pop_front();
3881 # }
3882 # list<PExpr*>*expr_list = p[5];
3883 # strip_tail_items(expr_list);
3884 # PECallFunction*tmp = pform_make_call_function(@1, *t_name, *expr_list);
3885 # delete p[1];
3886 # delete p[3];
3887 # p[0] = tmp;
3888 # }
3889 ()
3890 def p_expr_primary_10(p):
3891 '''expr_primary : SYSTEM_IDENTIFIER '(' expression_list_proper ')' '''
3892 if(parse_debug): print('expr_primary_10', list(p))
3893 # { perm_string tn = lex_strings.make(p[1]);
3894 # PECallFunction*tmp = new PECallFunction(tn, *p[3]);
3895 # FILE_NAME(tmp, @1);
3896 # delete[]p[1];
3897 # p[0] = tmp;
3898 # }
3899 ()
3900 def p_expr_primary_11(p):
3901 '''expr_primary : PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '(' expression_list_proper ')' '''
3902 if(parse_debug): print('expr_primary_11', list(p))
3903 # { perm_string use_name = lex_strings.make(p[3]);
3904 # PECallFunction*tmp = new PECallFunction(p[1], use_name, *p[5]);
3905 # FILE_NAME(tmp, @3);
3906 # delete[]p[3];
3907 # p[0] = tmp;
3908 # }
3909 ()
3910 def p_expr_primary_12(p):
3911 '''expr_primary : SYSTEM_IDENTIFIER '(' ')' '''
3912 if(parse_debug): print('expr_primary_12', list(p))
3913 # { perm_string tn = lex_strings.make(p[1]);
3914 # const vector<PExpr*>empty;
3915 # PECallFunction*tmp = new PECallFunction(tn, empty);
3916 # FILE_NAME(tmp, @1);
3917 # delete[]p[1];
3918 # p[0] = tmp;
3919 # if (!gn_system_verilog()) {
3920 # yyerror(@1, "error: Empty function argument list requires SystemVerilog.");
3921 # }
3922 # }
3923 ()
3924 def p_expr_primary_13(p):
3925 '''expr_primary : implicit_class_handle '''
3926 if(parse_debug): print('expr_primary_13', list(p))
3927 # { PEIdent*tmp = new PEIdent(*p[1]);
3928 # FILE_NAME(tmp,@1);
3929 # delete p[1];
3930 # p[0] = tmp;
3931 # }
3932 ()
3933 def p_expr_primary_14(p):
3934 '''expr_primary : implicit_class_handle '.' hierarchy_identifier '''
3935 if(parse_debug): print('expr_primary_14', list(p))
3936 # { pform_name_t*t_name = p[1];
3937 # while (! p[3]->empty()) {
3938 # t_name->push_back(p[3]->front());
3939 # p[3]->pop_front();
3940 # }
3941 # PEIdent*tmp = new PEIdent(*t_name);
3942 # FILE_NAME(tmp,@1);
3943 # delete p[1];
3944 # delete p[3];
3945 # p[0] = tmp;
3946 # }
3947 ()
3948 def p_expr_primary_15(p):
3949 '''expr_primary : K_acos '(' expression ')' '''
3950 if(parse_debug): print('expr_primary_15', list(p))
3951 # { perm_string tn = perm_string::literal("$acos");
3952 # PECallFunction*tmp = make_call_function(tn, p[3]);
3953 # FILE_NAME(tmp,@1);
3954 # p[0] = tmp;
3955 # }
3956 ()
3957 def p_expr_primary_16(p):
3958 '''expr_primary : K_acosh '(' expression ')' '''
3959 if(parse_debug): print('expr_primary_16', list(p))
3960 # { perm_string tn = perm_string::literal("$acosh");
3961 # PECallFunction*tmp = make_call_function(tn, p[3]);
3962 # FILE_NAME(tmp,@1);
3963 # p[0] = tmp;
3964 # }
3965 ()
3966 def p_expr_primary_17(p):
3967 '''expr_primary : K_asin '(' expression ')' '''
3968 if(parse_debug): print('expr_primary_17', list(p))
3969 # { perm_string tn = perm_string::literal("$asin");
3970 # PECallFunction*tmp = make_call_function(tn, p[3]);
3971 # FILE_NAME(tmp,@1);
3972 # p[0] = tmp;
3973 # }
3974 ()
3975 def p_expr_primary_18(p):
3976 '''expr_primary : K_asinh '(' expression ')' '''
3977 if(parse_debug): print('expr_primary_18', list(p))
3978 # { perm_string tn = perm_string::literal("$asinh");
3979 # PECallFunction*tmp = make_call_function(tn, p[3]);
3980 # FILE_NAME(tmp,@1);
3981 # p[0] = tmp;
3982 # }
3983 ()
3984 def p_expr_primary_19(p):
3985 '''expr_primary : K_atan '(' expression ')' '''
3986 if(parse_debug): print('expr_primary_19', list(p))
3987 # { perm_string tn = perm_string::literal("$atan");
3988 # PECallFunction*tmp = make_call_function(tn, p[3]);
3989 # FILE_NAME(tmp,@1);
3990 # p[0] = tmp;
3991 # }
3992 ()
3993 def p_expr_primary_20(p):
3994 '''expr_primary : K_atanh '(' expression ')' '''
3995 if(parse_debug): print('expr_primary_20', list(p))
3996 # { perm_string tn = perm_string::literal("$atanh");
3997 # PECallFunction*tmp = make_call_function(tn, p[3]);
3998 # FILE_NAME(tmp,@1);
3999 # p[0] = tmp;
4000 # }
4001 ()
4002 def p_expr_primary_21(p):
4003 '''expr_primary : K_atan2 '(' expression ',' expression ')' '''
4004 if(parse_debug): print('expr_primary_21', list(p))
4005 # { perm_string tn = perm_string::literal("$atan2");
4006 # PECallFunction*tmp = make_call_function(tn, p[3], p[5]);
4007 # FILE_NAME(tmp,@1);
4008 # p[0] = tmp;
4009 # }
4010 ()
4011 def p_expr_primary_22(p):
4012 '''expr_primary : K_ceil '(' expression ')' '''
4013 if(parse_debug): print('expr_primary_22', list(p))
4014 # { perm_string tn = perm_string::literal("$ceil");
4015 # PECallFunction*tmp = make_call_function(tn, p[3]);
4016 # FILE_NAME(tmp,@1);
4017 # p[0] = tmp;
4018 # }
4019 ()
4020 def p_expr_primary_23(p):
4021 '''expr_primary : K_cos '(' expression ')' '''
4022 if(parse_debug): print('expr_primary_23', list(p))
4023 # { perm_string tn = perm_string::literal("$cos");
4024 # PECallFunction*tmp = make_call_function(tn, p[3]);
4025 # FILE_NAME(tmp,@1);
4026 # p[0] = tmp;
4027 # }
4028 ()
4029 def p_expr_primary_24(p):
4030 '''expr_primary : K_cosh '(' expression ')' '''
4031 if(parse_debug): print('expr_primary_24', list(p))
4032 # { perm_string tn = perm_string::literal("$cosh");
4033 # PECallFunction*tmp = make_call_function(tn, p[3]);
4034 # FILE_NAME(tmp,@1);
4035 # p[0] = tmp;
4036 # }
4037 ()
4038 def p_expr_primary_25(p):
4039 '''expr_primary : K_exp '(' expression ')' '''
4040 if(parse_debug): print('expr_primary_25', list(p))
4041 # { perm_string tn = perm_string::literal("$exp");
4042 # PECallFunction*tmp = make_call_function(tn, p[3]);
4043 # FILE_NAME(tmp,@1);
4044 # p[0] = tmp;
4045 # }
4046 ()
4047 def p_expr_primary_26(p):
4048 '''expr_primary : K_floor '(' expression ')' '''
4049 if(parse_debug): print('expr_primary_26', list(p))
4050 # { perm_string tn = perm_string::literal("$floor");
4051 # PECallFunction*tmp = make_call_function(tn, p[3]);
4052 # FILE_NAME(tmp,@1);
4053 # p[0] = tmp;
4054 # }
4055 ()
4056 def p_expr_primary_27(p):
4057 '''expr_primary : K_hypot '(' expression ',' expression ')' '''
4058 if(parse_debug): print('expr_primary_27', list(p))
4059 # { perm_string tn = perm_string::literal("$hypot");
4060 # PECallFunction*tmp = make_call_function(tn, p[3], p[5]);
4061 # FILE_NAME(tmp,@1);
4062 # p[0] = tmp;
4063 # }
4064 ()
4065 def p_expr_primary_28(p):
4066 '''expr_primary : K_ln '(' expression ')' '''
4067 if(parse_debug): print('expr_primary_28', list(p))
4068 # { perm_string tn = perm_string::literal("$ln");
4069 # PECallFunction*tmp = make_call_function(tn, p[3]);
4070 # FILE_NAME(tmp,@1);
4071 # p[0] = tmp;
4072 # }
4073 ()
4074 def p_expr_primary_29(p):
4075 '''expr_primary : K_log '(' expression ')' '''
4076 if(parse_debug): print('expr_primary_29', list(p))
4077 # { perm_string tn = perm_string::literal("$log10");
4078 # PECallFunction*tmp = make_call_function(tn, p[3]);
4079 # FILE_NAME(tmp,@1);
4080 # p[0] = tmp;
4081 # }
4082 ()
4083 def p_expr_primary_30(p):
4084 '''expr_primary : K_pow '(' expression ',' expression ')' '''
4085 if(parse_debug): print('expr_primary_30', list(p))
4086 # { perm_string tn = perm_string::literal("$pow");
4087 # PECallFunction*tmp = make_call_function(tn, p[3], p[5]);
4088 # FILE_NAME(tmp,@1);
4089 # p[0] = tmp;
4090 # }
4091 ()
4092 def p_expr_primary_31(p):
4093 '''expr_primary : K_sin '(' expression ')' '''
4094 if(parse_debug): print('expr_primary_31', list(p))
4095 # { perm_string tn = perm_string::literal("$sin");
4096 # PECallFunction*tmp = make_call_function(tn, p[3]);
4097 # FILE_NAME(tmp,@1);
4098 # p[0] = tmp;
4099 # }
4100 ()
4101 def p_expr_primary_32(p):
4102 '''expr_primary : K_sinh '(' expression ')' '''
4103 if(parse_debug): print('expr_primary_32', list(p))
4104 # { perm_string tn = perm_string::literal("$sinh");
4105 # PECallFunction*tmp = make_call_function(tn, p[3]);
4106 # FILE_NAME(tmp,@1);
4107 # p[0] = tmp;
4108 # }
4109 ()
4110 def p_expr_primary_33(p):
4111 '''expr_primary : K_sqrt '(' expression ')' '''
4112 if(parse_debug): print('expr_primary_33', list(p))
4113 # { perm_string tn = perm_string::literal("$sqrt");
4114 # PECallFunction*tmp = make_call_function(tn, p[3]);
4115 # FILE_NAME(tmp,@1);
4116 # p[0] = tmp;
4117 # }
4118 ()
4119 def p_expr_primary_34(p):
4120 '''expr_primary : K_tan '(' expression ')' '''
4121 if(parse_debug): print('expr_primary_34', list(p))
4122 # { perm_string tn = perm_string::literal("$tan");
4123 # PECallFunction*tmp = make_call_function(tn, p[3]);
4124 # FILE_NAME(tmp,@1);
4125 # p[0] = tmp;
4126 # }
4127 ()
4128 def p_expr_primary_35(p):
4129 '''expr_primary : K_tanh '(' expression ')' '''
4130 if(parse_debug): print('expr_primary_35', list(p))
4131 # { perm_string tn = perm_string::literal("$tanh");
4132 # PECallFunction*tmp = make_call_function(tn, p[3]);
4133 # FILE_NAME(tmp,@1);
4134 # p[0] = tmp;
4135 # }
4136 ()
4137 def p_expr_primary_36(p):
4138 '''expr_primary : K_abs '(' expression ')' '''
4139 if(parse_debug): print('expr_primary_36', list(p))
4140 # { PEUnary*tmp = new PEUnary('m', p[3]);
4141 # FILE_NAME(tmp,@1);
4142 # p[0] = tmp;
4143 # }
4144 ()
4145 def p_expr_primary_37(p):
4146 '''expr_primary : K_max '(' expression ',' expression ')' '''
4147 if(parse_debug): print('expr_primary_37', list(p))
4148 # { PEBinary*tmp = new PEBinary('M', p[3], p[5]);
4149 # FILE_NAME(tmp,@1);
4150 # p[0] = tmp;
4151 # }
4152 ()
4153 def p_expr_primary_38(p):
4154 '''expr_primary : K_min '(' expression ',' expression ')' '''
4155 if(parse_debug): print('expr_primary_38', list(p))
4156 # { PEBinary*tmp = new PEBinary('m', p[3], p[5]);
4157 # FILE_NAME(tmp,@1);
4158 # p[0] = tmp;
4159 # }
4160 ()
4161 def p_expr_primary_39(p):
4162 '''expr_primary : '(' expr_mintypmax ')' '''
4163 if(parse_debug): print('expr_primary_39', list(p))
4164 p[0] = p[2]
4165 ()
4166 def p_expr_primary_40(p):
4167 '''expr_primary : '{' expression_list_proper '}' '''
4168 if(parse_debug): print('expr_primary_40', list(p))
4169 # { PEConcat*tmp = new PEConcat(*p[2]);
4170 # FILE_NAME(tmp, @1);
4171 # delete p[2];
4172 # p[0] = tmp;
4173 # }
4174 ()
4175 def p_expr_primary_41(p):
4176 '''expr_primary : '{' expression '{' expression_list_proper '}' '}' '''
4177 if(parse_debug): print('expr_primary_41', list(p))
4178 # { PExpr*rep = p[2];
4179 # PEConcat*tmp = new PEConcat(*p[4], rep);
4180 # FILE_NAME(tmp, @1);
4181 # delete p[4];
4182 # p[0] = tmp;
4183 # }
4184 ()
4185 def p_expr_primary_42(p):
4186 '''expr_primary : '{' expression '{' expression_list_proper '}' error '}' '''
4187 if(parse_debug): print('expr_primary_42', list(p))
4188 # { PExpr*rep = p[2];
4189 # PEConcat*tmp = new PEConcat(*p[4], rep);
4190 # FILE_NAME(tmp, @1);
4191 # delete p[4];
4192 # p[0] = tmp;
4193 # yyerror(@5, "error: Syntax error between internal '}' "
4194 # "and closing '}' of repeat concatenation.");
4195 # yyerrok;
4196 # }
4197 ()
4198 def p_expr_primary_43(p):
4199 '''expr_primary : '{' '}' '''
4200 if(parse_debug): print('expr_primary_43', list(p))
4201 # { // This is the empty queue syntax.
4202 # if (gn_system_verilog()) {
4203 # list<PExpr*> empty_list;
4204 # PEConcat*tmp = new PEConcat(empty_list);
4205 # FILE_NAME(tmp, @1);
4206 # p[0] = tmp;
4207 # } else {
4208 # yyerror(@1, "error: Concatenations are not allowed to be empty.");
4209 # p[0] = None
4210 # }
4211 # }
4212 ()
4213 def p_expr_primary_44(p):
4214 '''expr_primary : expr_primary "'" '(' expression ')' '''
4215 if(parse_debug): print('expr_primary_44', list(p))
4216 # { PExpr*base = p[4];
4217 # if (gn_system_verilog()) {
4218 # PECastSize*tmp = new PECastSize(p[1], base);
4219 # FILE_NAME(tmp, @1);
4220 # p[0] = tmp;
4221 # } else {
4222 # yyerror(@1, "error: Size cast requires SystemVerilog.");
4223 # p[0] = base;
4224 # }
4225 # }
4226 ()
4227 def p_expr_primary_45(p):
4228 '''expr_primary : simple_type_or_string "'" '(' expression ')' '''
4229 if(parse_debug): print('expr_primary_45', list(p))
4230 # { PExpr*base = p[4];
4231 # if (gn_system_verilog()) {
4232 # PECastType*tmp = new PECastType(p[1], base);
4233 # FILE_NAME(tmp, @1);
4234 # p[0] = tmp;
4235 # } else {
4236 # yyerror(@1, "error: Type cast requires SystemVerilog.");
4237 # p[0] = base;
4238 # }
4239 # }
4240 ()
4241 def p_expr_primary_46(p):
4242 '''expr_primary : assignment_pattern '''
4243 if(parse_debug): print('expr_primary_46', list(p))
4244 p[0] = p[1]
4245 ()
4246 def p_expr_primary_47(p):
4247 '''expr_primary : streaming_concatenation '''
4248 if(parse_debug): print('expr_primary_47', list(p))
4249 p[0] = p[1]
4250 ()
4251 def p_expr_primary_48(p):
4252 '''expr_primary : K_null '''
4253 if(parse_debug): print('expr_primary_48', list(p))
4254 # { PENull*tmp = new PENull;
4255 # FILE_NAME(tmp, @1);
4256 # p[0] = tmp;
4257 # }
4258 ()
4259 def p_function_item_list_opt_1(p):
4260 '''function_item_list_opt : function_item_list '''
4261 if(parse_debug): print('function_item_list_opt_1', list(p))
4262 p[0] = p[1]
4263 ()
4264 def p_function_item_list_opt_2(p):
4265 '''function_item_list_opt : '''
4266 if(parse_debug): print('function_item_list_opt_2', list(p))
4267 # { p[0] = None }
4268 ()
4269 def p_function_item_list_1(p):
4270 '''function_item_list : function_item '''
4271 if(parse_debug): print('function_item_list_1', list(p))
4272 p[0] = p[1]
4273 ()
4274 def p_function_item_list_2(p):
4275 '''function_item_list : function_item_list function_item '''
4276 if(parse_debug): print('function_item_list_2', list(p))
4277 # { /* */
4278 # if (p[1] && p[2]) {
4279 # vector<pform_tf_port_t>*tmp = p[1];
4280 # size_t s1 = tmp->size();
4281 # tmp->resize(s1 + p[2]->size());
4282 # for (size_t idx = 0 ; idx < p[2]->size() ; idx += 1)
4283 # tmp->at(s1+idx) = p[2]->at(idx);
4284 # delete p[2];
4285 # p[0] = tmp;
4286 # } else if (p[1]) {
4287 # p[0] = p[1];
4288 # } else {
4289 # p[0] = p[2];
4290 # }
4291 # }
4292 ()
4293 def p_function_item_1(p):
4294 '''function_item : tf_port_declaration '''
4295 if(parse_debug): print('function_item_1', list(p))
4296 p[0] = p[1]
4297 ()
4298 def p_function_item_2(p):
4299 '''function_item : block_item_decl '''
4300 if(parse_debug): print('function_item_2', list(p))
4301 # { p[0] = None }
4302 ()
4303 def p_gate_instance_1(p):
4304 '''gate_instance : IDENTIFIER '(' expression_list_with_nuls ')' '''
4305 if(parse_debug): print('gate_instance_1', list(p))
4306 # { lgate*tmp = new lgate;
4307 # tmp->name = p[1];
4308 # tmp->parms = p[3];
4309 # tmp->file = @1.text;
4310 # tmp->lineno = @1.first_line;
4311 # delete[]p[1];
4312 # p[0] = tmp;
4313 # }
4314 ()
4315 def p_gate_instance_2(p):
4316 '''gate_instance : IDENTIFIER dimensions '(' expression_list_with_nuls ')' '''
4317 if(parse_debug): print('gate_instance_2', list(p))
4318 # { lgate*tmp = new lgate;
4319 # list<pform_range_t>*rng = p[2];
4320 # tmp->name = p[1];
4321 # tmp->parms = p[4];
4322 # tmp->range = rng->front();
4323 # rng->pop_front();
4324 # assert(rng->empty());
4325 # tmp->file = @1.text;
4326 # tmp->lineno = @1.first_line;
4327 # delete[]p[1];
4328 # delete rng;
4329 # p[0] = tmp;
4330 # }
4331 ()
4332 def p_gate_instance_3(p):
4333 '''gate_instance : '(' expression_list_with_nuls ')' '''
4334 if(parse_debug): print('gate_instance_3', list(p))
4335 # { lgate*tmp = new lgate;
4336 # tmp->name = "";
4337 # tmp->parms = p[2];
4338 # tmp->file = @1.text;
4339 # tmp->lineno = @1.first_line;
4340 # p[0] = tmp;
4341 # }
4342 ()
4343 def p_gate_instance_4(p):
4344 '''gate_instance : IDENTIFIER dimensions '''
4345 if(parse_debug): print('gate_instance_4', list(p))
4346 # { lgate*tmp = new lgate;
4347 # list<pform_range_t>*rng = p[2];
4348 # tmp->name = p[1];
4349 # tmp->parms = 0;
4350 # tmp->parms_by_name = 0;
4351 # tmp->range = rng->front();
4352 # rng->pop_front();
4353 # assert(rng->empty());
4354 # tmp->file = @1.text;
4355 # tmp->lineno = @1.first_line;
4356 # delete[]p[1];
4357 # delete rng;
4358 # p[0] = tmp;
4359 # }
4360 ()
4361 def p_gate_instance_5(p):
4362 '''gate_instance : IDENTIFIER '(' port_name_list ')' '''
4363 if(parse_debug): print('gate_instance_5', list(p))
4364 # { lgate*tmp = new lgate;
4365 # tmp->name = p[1];
4366 # tmp->parms = 0;
4367 # tmp->parms_by_name = p[3];
4368 # tmp->file = @1.text;
4369 # tmp->lineno = @1.first_line;
4370 # delete[]p[1];
4371 # p[0] = tmp;
4372 # }
4373 ()
4374 def p_gate_instance_6(p):
4375 '''gate_instance : IDENTIFIER dimensions '(' port_name_list ')' '''
4376 if(parse_debug): print('gate_instance_6', list(p))
4377 # { lgate*tmp = new lgate;
4378 # list<pform_range_t>*rng = p[2];
4379 # tmp->name = p[1];
4380 # tmp->parms = 0;
4381 # tmp->parms_by_name = p[4];
4382 # tmp->range = rng->front();
4383 # rng->pop_front();
4384 # assert(rng->empty());
4385 # tmp->file = @1.text;
4386 # tmp->lineno = @1.first_line;
4387 # delete[]p[1];
4388 # delete rng;
4389 # p[0] = tmp;
4390 # }
4391 ()
4392 def p_gate_instance_7(p):
4393 '''gate_instance : IDENTIFIER '(' error ')' '''
4394 if(parse_debug): print('gate_instance_7', list(p))
4395 # { lgate*tmp = new lgate;
4396 # tmp->name = p[1];
4397 # tmp->parms = 0;
4398 # tmp->parms_by_name = 0;
4399 # tmp->file = @1.text;
4400 # tmp->lineno = @1.first_line;
4401 # yyerror(@2, "error: Syntax error in instance port "
4402 # "expression(s).");
4403 # delete[]p[1];
4404 # p[0] = tmp;
4405 # }
4406 ()
4407 def p_gate_instance_8(p):
4408 '''gate_instance : IDENTIFIER dimensions '(' error ')' '''
4409 if(parse_debug): print('gate_instance_8', list(p))
4410 # { lgate*tmp = new lgate;
4411 # tmp->name = p[1];
4412 # tmp->parms = 0;
4413 # tmp->parms_by_name = 0;
4414 # tmp->file = @1.text;
4415 # tmp->lineno = @1.first_line;
4416 # yyerror(@3, "error: Syntax error in instance port "
4417 # "expression(s).");
4418 # delete[]p[1];
4419 # p[0] = tmp;
4420 # }
4421 ()
4422 def p_gate_instance_list_1(p):
4423 '''gate_instance_list : gate_instance_list ',' gate_instance '''
4424 if(parse_debug): print('gate_instance_list_1', list(p))
4425 # { svector<lgate>*tmp1 = p[1];
4426 # lgate*tmp2 = p[3];
4427 # svector<lgate>*out = new svector<lgate> (*tmp1, *tmp2);
4428 # delete tmp1;
4429 # delete tmp2;
4430 # p[0] = out;
4431 # }
4432 ()
4433 def p_gate_instance_list_2(p):
4434 '''gate_instance_list : gate_instance '''
4435 if(parse_debug): print('gate_instance_list_2', list(p))
4436 # { svector<lgate>*tmp = new svector<lgate>(1);
4437 # (*tmp)[0] = *p[1];
4438 # delete p[1];
4439 # p[0] = tmp;
4440 # }
4441 ()
4442 def p_gatetype_1(p):
4443 '''gatetype : K_and '''
4444 if(parse_debug): print('gatetype_1', list(p))
4445 # { p[0] = PGBuiltin::AND; }
4446 ()
4447 def p_gatetype_2(p):
4448 '''gatetype : K_nand '''
4449 if(parse_debug): print('gatetype_2', list(p))
4450 # { p[0] = PGBuiltin::NAND; }
4451 ()
4452 def p_gatetype_3(p):
4453 '''gatetype : K_or '''
4454 if(parse_debug): print('gatetype_3', list(p))
4455 # { p[0] = PGBuiltin::OR; }
4456 ()
4457 def p_gatetype_4(p):
4458 '''gatetype : K_nor '''
4459 if(parse_debug): print('gatetype_4', list(p))
4460 # { p[0] = PGBuiltin::NOR; }
4461 ()
4462 def p_gatetype_5(p):
4463 '''gatetype : K_xor '''
4464 if(parse_debug): print('gatetype_5', list(p))
4465 # { p[0] = PGBuiltin::XOR; }
4466 ()
4467 def p_gatetype_6(p):
4468 '''gatetype : K_xnor '''
4469 if(parse_debug): print('gatetype_6', list(p))
4470 # { p[0] = PGBuiltin::XNOR; }
4471 ()
4472 def p_gatetype_7(p):
4473 '''gatetype : K_buf '''
4474 if(parse_debug): print('gatetype_7', list(p))
4475 # { p[0] = PGBuiltin::BUF; }
4476 ()
4477 def p_gatetype_8(p):
4478 '''gatetype : K_bufif0 '''
4479 if(parse_debug): print('gatetype_8', list(p))
4480 # { p[0] = PGBuiltin::BUFIF0; }
4481 ()
4482 def p_gatetype_9(p):
4483 '''gatetype : K_bufif1 '''
4484 if(parse_debug): print('gatetype_9', list(p))
4485 # { p[0] = PGBuiltin::BUFIF1; }
4486 ()
4487 def p_gatetype_10(p):
4488 '''gatetype : K_not '''
4489 if(parse_debug): print('gatetype_10', list(p))
4490 # { p[0] = PGBuiltin::NOT; }
4491 ()
4492 def p_gatetype_11(p):
4493 '''gatetype : K_notif0 '''
4494 if(parse_debug): print('gatetype_11', list(p))
4495 # { p[0] = PGBuiltin::NOTIF0; }
4496 ()
4497 def p_gatetype_12(p):
4498 '''gatetype : K_notif1 '''
4499 if(parse_debug): print('gatetype_12', list(p))
4500 # { p[0] = PGBuiltin::NOTIF1; }
4501 ()
4502 def p_switchtype_1(p):
4503 '''switchtype : K_nmos '''
4504 if(parse_debug): print('switchtype_1', list(p))
4505 # { p[0] = PGBuiltin::NMOS; }
4506 ()
4507 def p_switchtype_2(p):
4508 '''switchtype : K_rnmos '''
4509 if(parse_debug): print('switchtype_2', list(p))
4510 # { p[0] = PGBuiltin::RNMOS; }
4511 ()
4512 def p_switchtype_3(p):
4513 '''switchtype : K_pmos '''
4514 if(parse_debug): print('switchtype_3', list(p))
4515 # { p[0] = PGBuiltin::PMOS; }
4516 ()
4517 def p_switchtype_4(p):
4518 '''switchtype : K_rpmos '''
4519 if(parse_debug): print('switchtype_4', list(p))
4520 # { p[0] = PGBuiltin::RPMOS; }
4521 ()
4522 def p_switchtype_5(p):
4523 '''switchtype : K_cmos '''
4524 if(parse_debug): print('switchtype_5', list(p))
4525 # { p[0] = PGBuiltin::CMOS; }
4526 ()
4527 def p_switchtype_6(p):
4528 '''switchtype : K_rcmos '''
4529 if(parse_debug): print('switchtype_6', list(p))
4530 # { p[0] = PGBuiltin::RCMOS; }
4531 ()
4532 def p_switchtype_7(p):
4533 '''switchtype : K_tran '''
4534 if(parse_debug): print('switchtype_7', list(p))
4535 # { p[0] = PGBuiltin::TRAN; }
4536 ()
4537 def p_switchtype_8(p):
4538 '''switchtype : K_rtran '''
4539 if(parse_debug): print('switchtype_8', list(p))
4540 # { p[0] = PGBuiltin::RTRAN; }
4541 ()
4542 def p_switchtype_9(p):
4543 '''switchtype : K_tranif0 '''
4544 if(parse_debug): print('switchtype_9', list(p))
4545 # { p[0] = PGBuiltin::TRANIF0; }
4546 ()
4547 def p_switchtype_10(p):
4548 '''switchtype : K_tranif1 '''
4549 if(parse_debug): print('switchtype_10', list(p))
4550 # { p[0] = PGBuiltin::TRANIF1; }
4551 ()
4552 def p_switchtype_11(p):
4553 '''switchtype : K_rtranif0 '''
4554 if(parse_debug): print('switchtype_11', list(p))
4555 # { p[0] = PGBuiltin::RTRANIF0; }
4556 ()
4557 def p_switchtype_12(p):
4558 '''switchtype : K_rtranif1 '''
4559 if(parse_debug): print('switchtype_12', list(p))
4560 # { p[0] = PGBuiltin::RTRANIF1; }
4561 ()
4562 def p_hierarchy_identifier_1(p):
4563 '''hierarchy_identifier : IDENTIFIER '''
4564 if(parse_debug): print('hierarchy_identifier_1 FIXME', list(p))
4565 lpvalue = Leaf(token.NAME, p[1])
4566 p[0] = lpvalue
4567 # { p[0] = new pform_name_t;
4568 # p[0]->push_back(name_component_t(lex_strings.make(p[1])));
4569 # delete[]p[1];
4570 # }
4571 ()
4572 def p_hierarchy_identifier_2(p):
4573 '''hierarchy_identifier : hierarchy_identifier '.' IDENTIFIER '''
4574 if(parse_debug): print('hierarchy_identifier_2', list(p))
4575 # { pform_name_t * tmp = p[1];
4576 # tmp->push_back(name_component_t(lex_strings.make(p[3])));
4577 # delete[]p[3];
4578 # p[0] = tmp;
4579 # }
4580 ()
4581 def p_hierarchy_identifier_3(p):
4582 '''hierarchy_identifier : hierarchy_identifier '[' expression ']' '''
4583 if(parse_debug): print('hierarchy_identifier_3', list(p))
4584 # { pform_name_t * tmp = p[1];
4585 # name_component_t&tail = tmp->back();
4586 # index_component_t itmp;
4587 # itmp.sel = index_component_t::SEL_BIT;
4588 # itmp.msb = p[3];
4589 # tail.index.push_back(itmp);
4590 # p[0] = tmp;
4591 # }
4592 ()
4593 def p_hierarchy_identifier_4(p):
4594 '''hierarchy_identifier : hierarchy_identifier '[' '$' ']' '''
4595 if(parse_debug): print('hierarchy_identifier_4', list(p))
4596 # { pform_name_t * tmp = p[1];
4597 # name_component_t&tail = tmp->back();
4598 # if (! gn_system_verilog()) {
4599 # yyerror(@3, "error: Last element expression ($) "
4600 # "requires SystemVerilog. Try enabling SystemVerilog.");
4601 # }
4602 # index_component_t itmp;
4603 # itmp.sel = index_component_t::SEL_BIT_LAST;
4604 # itmp.msb = 0;
4605 # itmp.lsb = 0;
4606 # tail.index.push_back(itmp);
4607 # p[0] = tmp;
4608 # }
4609 ()
4610 def p_hierarchy_identifier_5(p):
4611 '''hierarchy_identifier : hierarchy_identifier '[' expression ':' expression ']' '''
4612 if(parse_debug): print('hierarchy_identifier_5', list(p))
4613 # { pform_name_t * tmp = p[1];
4614 # name_component_t&tail = tmp->back();
4615 # index_component_t itmp;
4616 # itmp.sel = index_component_t::SEL_PART;
4617 # itmp.msb = p[3];
4618 # itmp.lsb = p[5];
4619 # tail.index.push_back(itmp);
4620 # p[0] = tmp;
4621 # }
4622 ()
4623 def p_hierarchy_identifier_6(p):
4624 '''hierarchy_identifier : hierarchy_identifier '[' expression K_PO_POS expression ']' '''
4625 if(parse_debug): print('hierarchy_identifier_6', list(p))
4626 # { pform_name_t * tmp = p[1];
4627 # name_component_t&tail = tmp->back();
4628 # index_component_t itmp;
4629 # itmp.sel = index_component_t::SEL_IDX_UP;
4630 # itmp.msb = p[3];
4631 # itmp.lsb = p[5];
4632 # tail.index.push_back(itmp);
4633 # p[0] = tmp;
4634 # }
4635 ()
4636 def p_hierarchy_identifier_7(p):
4637 '''hierarchy_identifier : hierarchy_identifier '[' expression K_PO_NEG expression ']' '''
4638 if(parse_debug): print('hierarchy_identifier_7', list(p))
4639 # { pform_name_t * tmp = p[1];
4640 # name_component_t&tail = tmp->back();
4641 # index_component_t itmp;
4642 # itmp.sel = index_component_t::SEL_IDX_DO;
4643 # itmp.msb = p[3];
4644 # itmp.lsb = p[5];
4645 # tail.index.push_back(itmp);
4646 # p[0] = tmp;
4647 # }
4648 ()
4649 def p_list_of_identifiers_1(p):
4650 '''list_of_identifiers : IDENTIFIER '''
4651 if(parse_debug): print('list_of_identifiers_1', list(p))
4652 # { p[0] = list_from_identifier(p[1]); }
4653 ()
4654 def p_list_of_identifiers_2(p):
4655 '''list_of_identifiers : list_of_identifiers ',' IDENTIFIER '''
4656 if(parse_debug): print('list_of_identifiers_2', list(p))
4657 # { p[0] = list_from_identifier(p[1], p[3]); }
4658 ()
4659 def p_list_of_port_identifiers_1(p):
4660 '''list_of_port_identifiers : IDENTIFIER dimensions_opt '''
4661 if(parse_debug): print('list_of_port_identifiers_1', list(p))
4662 # { p[0] = make_port_list(p[1], p[2], 0); }
4663 ()
4664 def p_list_of_port_identifiers_2(p):
4665 '''list_of_port_identifiers : list_of_port_identifiers ',' IDENTIFIER dimensions_opt '''
4666 if(parse_debug): print('list_of_port_identifiers_2', list(p))
4667 # { p[0] = make_port_list(p[1], p[3], p[4], 0); }
4668 ()
4669 def p_list_of_variable_port_identifiers_1(p):
4670 '''list_of_variable_port_identifiers : IDENTIFIER dimensions_opt '''
4671 if(parse_debug): print('list_of_variable_port_identifiers_1', list(p))
4672 # { p[0] = make_port_list(p[1], p[2], 0); }
4673 ()
4674 def p_list_of_variable_port_identifiers_2(p):
4675 '''list_of_variable_port_identifiers : IDENTIFIER dimensions_opt '=' expression '''
4676 if(parse_debug): print('list_of_variable_port_identifiers_2', list(p))
4677 # { p[0] = make_port_list(p[1], p[2], p[4]); }
4678 ()
4679 def p_list_of_variable_port_identifiers_3(p):
4680 '''list_of_variable_port_identifiers : list_of_variable_port_identifiers ',' IDENTIFIER dimensions_opt '''
4681 if(parse_debug): print('list_of_variable_port_identifiers_3', list(p))
4682 # { p[0] = make_port_list(p[1], p[3], p[4], 0); }
4683 ()
4684 def p_list_of_variable_port_identifiers_4(p):
4685 '''list_of_variable_port_identifiers : list_of_variable_port_identifiers ',' IDENTIFIER dimensions_opt '=' expression '''
4686 if(parse_debug): print('list_of_variable_port_identifiers_4', list(p))
4687 # { p[0] = make_port_list(p[1], p[3], p[4], p[6]); }
4688 ()
4689 def p_list_of_ports_1(p):
4690 '''list_of_ports : port_opt '''
4691 if(parse_debug): print('list_of_ports_1', list(p))
4692 # { vector<Module::port_t*>*tmp
4693 # = new vector<Module::port_t*>(1);
4694 # (*tmp)[0] = p[1];
4695 # p[0] = tmp;
4696 # }
4697 ()
4698 def p_list_of_ports_2(p):
4699 '''list_of_ports : list_of_ports ',' port_opt '''
4700 if(parse_debug): print('list_of_ports_2', list(p))
4701 # { vector<Module::port_t*>*tmp = p[1];
4702 # tmp->push_back(p[3]);
4703 # p[0] = tmp;
4704 # }
4705 ()
4706 def p_list_of_port_declarations_1(p):
4707 '''list_of_port_declarations : port_declaration '''
4708 if(parse_debug>1): print('list_of_port_declarations_1', list(p))
4709 p[0] = [p[1]]
4710 # { vector<Module::port_t*>*tmp
4711 # = new vector<Module::port_t*>(1);
4712 # (*tmp)[0] = p[1];
4713 # p[0] = tmp;
4714 # }
4715 ()
4716 def p_list_of_port_declarations_2(p):
4717 '''list_of_port_declarations : list_of_port_declarations ',' port_declaration '''
4718 if(parse_debug): print('list_of_port_declarations_2 FIXME', list(p))
4719 p[1].append(Leaf(token.NEWLINE, '\n')) # should be a comma
4720 # XXX p[3].prefix=' ' # add a space after the NL, must go in parameter
4721 p[1].append(p[3])
4722 p[0] = p[1]
4723 # { vector<Module::port_t*>*tmp = p[1];
4724 # tmp->push_back(p[3]);
4725 # p[0] = tmp;
4726 # }
4727 ()
4728 def p_list_of_port_declarations_3(p):
4729 '''list_of_port_declarations : list_of_port_declarations ',' IDENTIFIER '''
4730 if(parse_debug): print('list_of_port_declarations_3', list(p))
4731 # { Module::port_t*ptmp;
4732 # perm_string name = lex_strings.make(p[3]);
4733 # ptmp = pform_module_port_reference(name, @3.text,
4734 # @3.first_line);
4735 # vector<Module::port_t*>*tmp = p[1];
4736 # tmp->push_back(ptmp);
4737 #
4738 # /* Get the port declaration details, the port type
4739 # and what not, from context data stored by the
4740 # last port_declaration rule. */
4741 # pform_module_define_port(@3, name,
4742 # port_declaration_context.port_type,
4743 # port_declaration_context.port_net_type,
4744 # port_declaration_context.data_type, 0);
4745 # delete[]p[3];
4746 # p[0] = tmp;
4747 # }
4748 ()
4749 def p_list_of_port_declarations_4(p):
4750 '''list_of_port_declarations : list_of_port_declarations ',' '''
4751 if(parse_debug): print('list_of_port_declarations_4', list(p))
4752 # {
4753 # yyerror(@2, "error: NULL port declarations are not "
4754 # "allowed.");
4755 # }
4756 ()
4757 def p_list_of_port_declarations_5(p):
4758 '''list_of_port_declarations : list_of_port_declarations ';' '''
4759 if(parse_debug): print('list_of_port_declarations_5', list(p))
4760 # {
4761 # yyerror(@2, "error: ';' is an invalid port declaration "
4762 # "separator.");
4763 # }
4764 ()
4765 def p_port_declaration_1(p):
4766 '''port_declaration : attribute_list_opt K_input net_type_opt data_type_or_implicit IDENTIFIER dimensions_opt '''
4767 if(parse_debug): print('port_declaration_1 FIXME', list(p))
4768 # XXX TODO: python AST
4769 comment, dt, name = p[2], p[4], p[5]
4770 p[0] = port_decl(comment, dt, name)
4771 # { Module::port_t*ptmp;
4772 # perm_string name = lex_strings.make(p[5]);
4773 # data_type_t*use_type = p[4];
4774 # if (p[6]) use_type = new uarray_type_t(use_type, p[6]);
4775 # ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
4776 # pform_module_define_port(@2, name, NetNet::PINPUT, p[3], use_type, p[1]);
4777 # port_declaration_context.port_type = NetNet::PINPUT;
4778 # port_declaration_context.port_net_type = p[3];
4779 # port_declaration_context.data_type = p[4];
4780 # delete[]p[5];
4781 # p[0] = ptmp;
4782 # }
4783 ()
4784 def p_port_declaration_2(p):
4785 '''port_declaration : attribute_list_opt K_input K_wreal IDENTIFIER '''
4786 if(parse_debug): print('port_declaration_2', list(p))
4787 # { Module::port_t*ptmp;
4788 # perm_string name = lex_strings.make(p[4]);
4789 # ptmp = pform_module_port_reference(name, @2.text,
4790 # @2.first_line);
4791 # real_type_t*real_type = new real_type_t(real_type_t::REAL);
4792 # FILE_NAME(real_type, @3);
4793 # pform_module_define_port(@2, name, NetNet::PINPUT,
4794 # NetNet::WIRE, real_type, p[1]);
4795 # port_declaration_context.port_type = NetNet::PINPUT;
4796 # port_declaration_context.port_net_type = NetNet::WIRE;
4797 # port_declaration_context.data_type = real_type;
4798 # delete[]p[4];
4799 # p[0] = ptmp;
4800 # }
4801 ()
4802 def p_port_declaration_3(p):
4803 '''port_declaration : attribute_list_opt K_inout net_type_opt data_type_or_implicit IDENTIFIER dimensions_opt '''
4804 if(parse_debug): print('port_declaration_3', list(p))
4805 # { Module::port_t*ptmp;
4806 # perm_string name = lex_strings.make(p[5]);
4807 # ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
4808 # pform_module_define_port(@2, name, NetNet::PINOUT, p[3], p[4], p[1]);
4809 # port_declaration_context.port_type = NetNet::PINOUT;
4810 # port_declaration_context.port_net_type = p[3];
4811 # port_declaration_context.data_type = p[4];
4812 # delete[]p[5];
4813 # if (p[6]) {
4814 # yyerror(@6, "sorry: Inout ports with unpacked dimensions not supported.");
4815 # delete p[6];
4816 # }
4817 # p[0] = ptmp;
4818 # }
4819 ()
4820 def p_port_declaration_4(p):
4821 '''port_declaration : attribute_list_opt K_inout K_wreal IDENTIFIER '''
4822 if(parse_debug): print('port_declaration_4', list(p))
4823 # { Module::port_t*ptmp;
4824 # perm_string name = lex_strings.make(p[4]);
4825 # ptmp = pform_module_port_reference(name, @2.text,
4826 # @2.first_line);
4827 # real_type_t*real_type = new real_type_t(real_type_t::REAL);
4828 # FILE_NAME(real_type, @3);
4829 # pform_module_define_port(@2, name, NetNet::PINOUT,
4830 # NetNet::WIRE, real_type, p[1]);
4831 # port_declaration_context.port_type = NetNet::PINOUT;
4832 # port_declaration_context.port_net_type = NetNet::WIRE;
4833 # port_declaration_context.data_type = real_type;
4834 # delete[]p[4];
4835 # p[0] = ptmp;
4836 # }
4837 ()
4838 def p_port_declaration_5(p):
4839 '''port_declaration : attribute_list_opt K_output net_type_opt data_type_or_implicit IDENTIFIER dimensions_opt '''
4840 if(parse_debug): print('port_declaration_5 FIXME', list(p))
4841 # XXX TODO: python AST
4842 comment, dt, name = p[2], p[4], p[5]
4843 p[0] = port_decl(comment, dt, name)
4844 # { Module::port_t*ptmp;
4845 # perm_string name = lex_strings.make(p[5]);
4846 # data_type_t*use_dtype = p[4];
4847 # if (p[6]) use_dtype = new uarray_type_t(use_dtype, p[6]);
4848 # NetNet::Type use_type = p[3];
4849 # if (use_type == NetNet::IMPLICIT) {
4850 # if (vector_type_t*dtype = dynamic_cast<vector_type_t*> (p[4])) {
4851 # if (dtype->reg_flag)
4852 # use_type = NetNet::REG;
4853 # else if (dtype->implicit_flag)
4854 # use_type = NetNet::IMPLICIT;
4855 # else
4856 # use_type = NetNet::IMPLICIT_REG;
4857 #
4858 # // The SystemVerilog types that can show up as
4859 # // output ports are implicitly (on the inside)
4860 # // variables because "reg" is not valid syntax
4861 # // here.
4862 # } else if (dynamic_cast<atom2_type_t*> (p[4])) {
4863 # use_type = NetNet::IMPLICIT_REG;
4864 # } else if (dynamic_cast<struct_type_t*> (p[4])) {
4865 # use_type = NetNet::IMPLICIT_REG;
4866 # } else if (enum_type_t*etype = dynamic_cast<enum_type_t*> (p[4])) {
4867 # if(etype->base_type == IVL_VT_LOGIC)
4868 # use_type = NetNet::IMPLICIT_REG;
4869 # }
4870 # }
4871 # ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
4872 # pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, use_dtype, p[1]);
4873 # port_declaration_context.port_type = NetNet::POUTPUT;
4874 # port_declaration_context.port_net_type = use_type;
4875 # port_declaration_context.data_type = p[4];
4876 # delete[]p[5];
4877 # p[0] = ptmp;
4878 # }
4879 ()
4880 def p_port_declaration_6(p):
4881 '''port_declaration : attribute_list_opt K_output K_wreal IDENTIFIER '''
4882 if(parse_debug): print('port_declaration_6', list(p))
4883 # { Module::port_t*ptmp;
4884 # perm_string name = lex_strings.make(p[4]);
4885 # ptmp = pform_module_port_reference(name, @2.text,
4886 # @2.first_line);
4887 # real_type_t*real_type = new real_type_t(real_type_t::REAL);
4888 # FILE_NAME(real_type, @3);
4889 # pform_module_define_port(@2, name, NetNet::POUTPUT,
4890 # NetNet::WIRE, real_type, p[1]);
4891 # port_declaration_context.port_type = NetNet::POUTPUT;
4892 # port_declaration_context.port_net_type = NetNet::WIRE;
4893 # port_declaration_context.data_type = real_type;
4894 # delete[]p[4];
4895 # p[0] = ptmp;
4896 # }
4897 ()
4898 def p_port_declaration_7(p):
4899 '''port_declaration : attribute_list_opt K_output net_type_opt data_type_or_implicit IDENTIFIER '=' expression '''
4900 if(parse_debug): print('port_declaration_7', list(p))
4901 # { Module::port_t*ptmp;
4902 # perm_string name = lex_strings.make(p[5]);
4903 # NetNet::Type use_type = p[3];
4904 # if (use_type == NetNet::IMPLICIT) {
4905 # if (vector_type_t*dtype = dynamic_cast<vector_type_t*> (p[4])) {
4906 # if (dtype->reg_flag)
4907 # use_type = NetNet::REG;
4908 # else
4909 # use_type = NetNet::IMPLICIT_REG;
4910 # } else {
4911 # use_type = NetNet::IMPLICIT_REG;
4912 # }
4913 # }
4914 # ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
4915 # pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, p[4], p[1]);
4916 # port_declaration_context.port_type = NetNet::PINOUT;
4917 # port_declaration_context.port_net_type = use_type;
4918 # port_declaration_context.data_type = p[4];
4919 #
4920 # pform_make_var_init(@5, name, p[7]);
4921 #
4922 # delete[]p[5];
4923 # p[0] = ptmp;
4924 # }
4925 ()
4926 def p_net_type_opt_1(p):
4927 '''net_type_opt : net_type '''
4928 if(parse_debug): print('net_type_opt_1', list(p))
4929 p[0] = p[1]
4930 ()
4931 def p_net_type_opt_2(p):
4932 '''net_type_opt : '''
4933 if(parse_debug>2): print('net_type_opt_2', list(p))
4934 p[0] = NN_IMPLICIT
4935 ()
4936 def p_unsigned_signed_opt_1(p):
4937 '''unsigned_signed_opt : K_signed '''
4938 if(parse_debug): print('unsigned_signed_opt_1', list(p))
4939 p[0] = True
4940 ()
4941 def p_unsigned_signed_opt_2(p):
4942 '''unsigned_signed_opt : K_unsigned '''
4943 if(parse_debug): print('unsigned_signed_opt_2', list(p))
4944 p[0] = False
4945 ()
4946 def p_unsigned_signed_opt_3(p):
4947 '''unsigned_signed_opt : '''
4948 if(parse_debug): print('unsigned_signed_opt_3', list(p))
4949 p[0] = False
4950 ()
4951 def p_signed_unsigned_opt_1(p):
4952 '''signed_unsigned_opt : K_signed '''
4953 if(parse_debug): print('signed_unsigned_opt_1', list(p))
4954 p[0] = True
4955 ()
4956 def p_signed_unsigned_opt_2(p):
4957 '''signed_unsigned_opt : K_unsigned '''
4958 if(parse_debug): print('signed_unsigned_opt_2', list(p))
4959 p[0] = False
4960 ()
4961 def p_signed_unsigned_opt_3(p):
4962 '''signed_unsigned_opt : '''
4963 if(parse_debug): print('signed_unsigned_opt_3', list(p))
4964 p[0] = True
4965 ()
4966 def p_atom2_type_1(p):
4967 '''atom2_type : K_byte '''
4968 if(parse_debug): print('atom2_type_1', list(p))
4969 # { p[0] = 8; }
4970 ()
4971 def p_atom2_type_2(p):
4972 '''atom2_type : K_shortint '''
4973 if(parse_debug): print('atom2_type_2', list(p))
4974 # { p[0] = 16; }
4975 ()
4976 def p_atom2_type_3(p):
4977 '''atom2_type : K_int '''
4978 if(parse_debug): print('atom2_type_3', list(p))
4979 # { p[0] = 32; }
4980 ()
4981 def p_atom2_type_4(p):
4982 '''atom2_type : K_longint '''
4983 if(parse_debug): print('atom2_type_4', list(p))
4984 # { p[0] = 64; }
4985 ()
4986 def p_lpvalue_1(p):
4987 '''lpvalue : hierarchy_identifier '''
4988 if(parse_debug>2): print('lpvalue_1', list(p))
4989 p[0] = p[1]
4990 # { PEIdent*tmp = pform_new_ident(*p[1]);
4991 # FILE_NAME(tmp, @1);
4992 # p[0] = tmp;
4993 # delete p[1];
4994 # }
4995 ()
4996 def p_lpvalue_2(p):
4997 '''lpvalue : implicit_class_handle '.' hierarchy_identifier '''
4998 if(parse_debug): print('lpvalue_2', list(p))
4999 # { pform_name_t*t_name = p[1];
5000 # while (!p[3]->empty()) {
5001 # t_name->push_back(p[3]->front());
5002 # p[3]->pop_front();
5003 # }
5004 # PEIdent*tmp = new PEIdent(*t_name);
5005 # FILE_NAME(tmp, @1);
5006 # p[0] = tmp;
5007 # delete p[1];
5008 # delete p[3];
5009 # }
5010 ()
5011 def p_lpvalue_3(p):
5012 '''lpvalue : '{' expression_list_proper '}' '''
5013 if(parse_debug): print('lpvalue_3', list(p))
5014 # { PEConcat*tmp = new PEConcat(*p[2]);
5015 # FILE_NAME(tmp, @1);
5016 # delete p[2];
5017 # p[0] = tmp;
5018 # }
5019 ()
5020 def p_lpvalue_4(p):
5021 '''lpvalue : streaming_concatenation '''
5022 if(parse_debug): print('lpvalue_4', list(p))
5023 # { yyerror(@1, "sorry: streaming concatenation not supported in l-values.");
5024 # p[0] = None
5025 # }
5026 ()
5027 def p_cont_assign_1(p):
5028 '''cont_assign : lpvalue '=' expression '''
5029 if(parse_debug): print('cont_assign_1 TODO', list(p))
5030 # { list<PExpr*>*tmp = new list<PExpr*>;
5031 # tmp->push_back(p[1]);
5032 # tmp->push_back(p[3]);
5033 # p[0] = tmp;
5034 # }
5035 ()
5036 def p_cont_assign_list_1(p):
5037 '''cont_assign_list : cont_assign_list ',' cont_assign '''
5038 if(parse_debug): print('cont_assign_list_1', list(p))
5039 # { list<PExpr*>*tmp = p[1];
5040 # tmp->splice(tmp->end(), *p[3]);
5041 # delete p[3];
5042 # p[0] = tmp;
5043 # }
5044 ()
5045 def p_cont_assign_list_2(p):
5046 '''cont_assign_list : cont_assign '''
5047 if(parse_debug>2): print('cont_assign_list_2', list(p))
5048 p[0] = p[1]
5049 ()
5050 def p_module_1(p):
5051 '''module : attribute_list_opt module_start lifetime_opt IDENTIFIER _embed0_module module_package_import_list_opt module_parameter_port_list_opt module_port_list_opt module_attribute_foreign ';' _embed1_module timeunits_declaration_opt _embed2_module module_item_list_opt module_end _embed3_module endlabel_opt '''
5052 if(parse_debug>2): print('module_1', list(p))
5053 absyn.printpy("# module_1")
5054 params = p[7]
5055 clsname = [Leaf(token.NAME, 'class'),
5056 Leaf(token.NAME, p[4], prefix=' '),
5057 Leaf(token.COLON, ':')]
5058 pass_stmt = Node(syms.pass_stmt, [Leaf(token.NAME, "pass"),])
5059 if params:
5060 params = [Leaf(token.LPAR, '(')] + params + [Leaf(token.RPAR, ')')]
5061 fn = [Leaf(token.NAME, 'def'),
5062 Leaf(token.NAME, '__init__', prefix=' '),
5063 Node(syms.parameters, params),
5064 Leaf(token.COLON, ':')]
5065 fndef = Node(syms.funcdef, fn)
5066 stmts = Node(syms.stmt, [fndef])
5067 else:
5068 stmts = Node(syms.small_stmt, [pass_stmt, Leaf(token.NEWLINE, '\n')])
5069 stmts = Node(syms.stmt, [stmts])
5070
5071 # XXX TODO ports as py nodes
5072 ports = p[8]
5073 stmts.children.append(Leaf(token.STRING, '\n' + indent(ports, 8)))
5074 suite = Node(syms.suite, [Leaf(token.NEWLINE, '\n'),
5075 Leaf(token.INDENT, ' '),
5076 stmts,
5077 Leaf(token.DEDENT, '')
5078 ])
5079 clsdecl = Node(syms.classdef, clsname + [suite])
5080 clsdecl = Node(syms.compound_stmt, [clsdecl])
5081 absyn.printpy("#clsdecl"+ repr(clsdecl))
5082 absyn.printpy("#clsstr:")
5083 absyn.printpy(str(clsdecl))
5084 p[0] = clsdecl
5085 # { // Last step: check any closing name. This is done late so
5086 # // that the parser can look ahead to detect the present
5087 # // endlabel_opt but still have the pform_endmodule() called
5088 # // early enough that the lexor can know we are outside the
5089 # // module.
5090 # if (p[1]7) {
5091 # if (strcmp(p[4],p[1]7) != 0) {
5092 # switch (p[2]) {
5093 # case K_module:
5094 # yyerror(@17, "error: End label doesn't match "
5095 # "module name.");
5096 # break;
5097 # case K_program:
5098 # yyerror(@17, "error: End label doesn't match "
5099 # "program name.");
5100 # break;
5101 # case K_interface:
5102 # yyerror(@17, "error: End label doesn't match "
5103 # "interface name.");
5104 # break;
5105 # default:
5106 # break;
5107 # }
5108 # }
5109 # if ((p[2] == K_module) && (! gn_system_verilog())) {
5110 # yyerror(@8, "error: Module end labels require "
5111 # "SystemVerilog.");
5112 # }
5113 # delete[]p[1]7;
5114 # }
5115 # delete[]p[4];
5116 # }
5117 ()
5118 def p__embed0_module(p):
5119 '''_embed0_module : '''
5120 # { pform_startmodule(@2, p[4], p[2]==K_program, p[2]==K_interface, p[3], p[1]); }
5121 ()
5122 def p__embed1_module(p):
5123 '''_embed1_module : '''
5124 # { pform_module_set_ports(p[8]); }
5125 ()
5126 def p__embed2_module(p):
5127 '''_embed2_module : '''
5128 # { pform_set_scope_timescale(@2); }
5129 ()
5130 def p__embed3_module(p):
5131 '''_embed3_module : '''
5132 # { Module::UCDriveType ucd;
5133 # // The lexor detected `unconnected_drive directives and
5134 # // marked what it found in the uc_drive variable. Use that
5135 # // to generate a UCD flag for the module.
5136 # switch (uc_drive) {
5137 # case UCD_NONE:
5138 # default:
5139 # ucd = Module::UCD_NONE;
5140 # break;
5141 # case UCD_PULL0:
5142 # ucd = Module::UCD_PULL0;
5143 # break;
5144 # case UCD_PULL1:
5145 # ucd = Module::UCD_PULL1;
5146 # break;
5147 # }
5148 # // Check that program/endprogram and module/endmodule
5149 # // keywords match.
5150 # if (p[2] != p[15]) {
5151 # switch (p[2]) {
5152 # case K_module:
5153 # yyerror(@15, "error: module not closed by endmodule.");
5154 # break;
5155 # case K_program:
5156 # yyerror(@15, "error: program not closed by endprogram.");
5157 # break;
5158 # case K_interface:
5159 # yyerror(@15, "error: interface not closed by endinterface.");
5160 # break;
5161 # default:
5162 # break;
5163 # }
5164 # }
5165 # pform_endmodule(p[4], in_celldefine, ucd);
5166 # }
5167 ()
5168 def p_module_start_1(p):
5169 '''module_start : K_module '''
5170 if(parse_debug>1): print('module_start_1', list(p))
5171 # { p[0] = K_module; }
5172 ()
5173 def p_module_start_2(p):
5174 '''module_start : K_macromodule '''
5175 if(parse_debug): print('module_start_2', list(p))
5176 # { p[0] = K_module; }
5177 ()
5178 def p_module_start_3(p):
5179 '''module_start : K_program '''
5180 if(parse_debug): print('module_start_3', list(p))
5181 # { p[0] = K_program; }
5182 ()
5183 def p_module_start_4(p):
5184 '''module_start : K_interface '''
5185 if(parse_debug): print('module_start_4', list(p))
5186 # { p[0] = K_interface; }
5187 ()
5188 def p_module_end_1(p):
5189 '''module_end : K_endmodule '''
5190 if(parse_debug>2): print('module_end_1', list(p))
5191 # { p[0] = K_module; }
5192 ()
5193 def p_module_end_2(p):
5194 '''module_end : K_endprogram '''
5195 if(parse_debug): print('module_end_2', list(p))
5196 # { p[0] = K_program; }
5197 ()
5198 def p_module_end_3(p):
5199 '''module_end : K_endinterface '''
5200 if(parse_debug): print('module_end_3', list(p))
5201 # { p[0] = K_interface; }
5202 ()
5203 def p_endlabel_opt_1(p):
5204 '''endlabel_opt : ':' IDENTIFIER '''
5205 if(parse_debug): print('endlabel_opt_1', list(p))
5206 p[0] = p[2]
5207 ()
5208 def p_endlabel_opt_2(p):
5209 '''endlabel_opt : '''
5210 if(parse_debug>2): print('endlabel_opt_2', list(p))
5211 # { p[0] = None }
5212 ()
5213 def p_module_attribute_foreign_1(p):
5214 '''module_attribute_foreign : K_PSTAR IDENTIFIER K_integer IDENTIFIER '=' STRING ';' K_STARP '''
5215 if(parse_debug): print('module_attribute_foreign_1', list(p))
5216 # { p[0] = None }
5217 ()
5218 def p_module_attribute_foreign_2(p):
5219 '''module_attribute_foreign : '''
5220 if(parse_debug>2): print('module_attribute_foreign_2', list(p))
5221 # { p[0] = None }
5222 ()
5223 def p_module_port_list_opt_1(p):
5224 '''module_port_list_opt : '(' list_of_ports ')' '''
5225 if(parse_debug): print('module_port_list_opt_1', list(p))
5226 p[0] = p[2]
5227 ()
5228 def p_module_port_list_opt_2(p):
5229 '''module_port_list_opt : '(' list_of_port_declarations ')' '''
5230 if(parse_debug>2): print('module_port_list_opt_2', list(p))
5231 p[0] = p[2]
5232 ()
5233 def p_module_port_list_opt_3(p):
5234 '''module_port_list_opt : '''
5235 if(parse_debug): print('module_port_list_opt_3', list(p))
5236 # { p[0] = None }
5237 ()
5238 def p_module_port_list_opt_4(p):
5239 '''module_port_list_opt : '(' error ')' '''
5240 if(parse_debug): print('module_port_list_opt_4', list(p))
5241 # { yyerror(@2, "Errors in port declarations.");
5242 # yyerrok;
5243 # p[0] = None
5244 # }
5245 ()
5246 def p_module_parameter_port_list_opt_1(p):
5247 '''module_parameter_port_list_opt : '''
5248 if(parse_debug>2): print('module_parameter_port_list_opt_1', list(p))
5249 ()
5250 def p_module_parameter_port_list_opt_2(p):
5251 '''module_parameter_port_list_opt : '#' '(' module_parameter_port_list ')' '''
5252 if(parse_debug): print('module_parameter_port_list_opt_2', list(p))
5253 p[0] = p[3]
5254 ()
5255 def p_module_parameter_port_list_1(p):
5256 '''module_parameter_port_list : K_parameter param_type parameter_assign '''
5257 if(parse_debug): print('module_parameter_port_list_1', list(p))
5258 p[0] = [p[3]]
5259 ()
5260 def p_module_parameter_port_list_2(p):
5261 '''module_parameter_port_list : module_parameter_port_list ',' parameter_assign '''
5262 if(parse_debug): print('module_parameter_port_list_2', list(p))
5263 p[0] = p[1].append(p[3])
5264 ()
5265 def p_module_parameter_port_list_3(p):
5266 '''module_parameter_port_list : module_parameter_port_list ',' K_parameter param_type parameter_assign '''
5267 if(parse_debug): print('module_parameter_port_list_3', list(p))
5268 p[1].append(Leaf(token.COMMA, ','))
5269 p[1].append(Leaf(token.NEWLINE, '\n'))
5270 p[5].prefix=' ' # add space after newline
5271 p[1].append(p[5])
5272 p[0] = p[1]
5273 ()
5274 def p_module_item_1(p):
5275 '''module_item : module '''
5276 if(parse_debug): print('module_item_1', list(p))
5277 ()
5278 def p_module_item_2(p):
5279 '''module_item : attribute_list_opt net_type data_type_or_implicit delay3_opt net_variable_list ';' '''
5280 if(parse_debug): print('module_item_2', list(p))
5281 # { data_type_t*data_type = p[3];
5282 # if (data_type == 0) {
5283 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
5284 # FILE_NAME(data_type, @2);
5285 # }
5286 # pform_set_data_type(@2, data_type, p[5], p[2], p[1]);
5287 # if (p[4] != 0) {
5288 # yyerror(@2, "sorry: net delays not supported.");
5289 # delete p[4];
5290 # }
5291 # delete p[1];
5292 # }
5293 ()
5294 def p_module_item_3(p):
5295 '''module_item : attribute_list_opt K_wreal delay3 net_variable_list ';' '''
5296 if(parse_debug): print('module_item_3', list(p))
5297 # { real_type_t*tmpt = new real_type_t(real_type_t::REAL);
5298 # pform_set_data_type(@2, tmpt, p[4], NetNet::WIRE, p[1]);
5299 # if (p[3] != 0) {
5300 # yyerror(@3, "sorry: net delays not supported.");
5301 # delete p[3];
5302 # }
5303 # delete p[1];
5304 # }
5305 ()
5306 def p_module_item_4(p):
5307 '''module_item : attribute_list_opt K_wreal net_variable_list ';' '''
5308 if(parse_debug): print('module_item_4', list(p))
5309 # { real_type_t*tmpt = new real_type_t(real_type_t::REAL);
5310 # pform_set_data_type(@2, tmpt, p[3], NetNet::WIRE, p[1]);
5311 # delete p[1];
5312 # }
5313 ()
5314 def p_module_item_5(p):
5315 '''module_item : attribute_list_opt net_type data_type_or_implicit delay3_opt net_decl_assigns ';' '''
5316 if(parse_debug): print('module_item_5', list(p))
5317 # { data_type_t*data_type = p[3];
5318 # if (data_type == 0) {
5319 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
5320 # FILE_NAME(data_type, @2);
5321 # }
5322 # pform_makewire(@2, p[4], str_strength, p[5], p[2], data_type);
5323 # if (p[1]) {
5324 # yywarn(@2, "Attributes are not supported on net declaration "
5325 # "assignments and will be discarded.");
5326 # delete p[1];
5327 # }
5328 # }
5329 ()
5330 def p_module_item_6(p):
5331 '''module_item : attribute_list_opt net_type data_type_or_implicit drive_strength net_decl_assigns ';' '''
5332 if(parse_debug): print('module_item_6', list(p))
5333 # { data_type_t*data_type = p[3];
5334 # if (data_type == 0) {
5335 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
5336 # FILE_NAME(data_type, @2);
5337 # }
5338 # pform_makewire(@2, 0, p[4], p[5], p[2], data_type);
5339 # if (p[1]) {
5340 # yywarn(@2, "Attributes are not supported on net declaration "
5341 # "assignments and will be discarded.");
5342 # delete p[1];
5343 # }
5344 # }
5345 ()
5346 def p_module_item_7(p):
5347 '''module_item : attribute_list_opt K_wreal net_decl_assigns ';' '''
5348 if(parse_debug): print('module_item_7', list(p))
5349 # { real_type_t*data_type = new real_type_t(real_type_t::REAL);
5350 # pform_makewire(@2, 0, str_strength, p[3], NetNet::WIRE, data_type);
5351 # if (p[1]) {
5352 # yywarn(@2, "Attributes are not supported on net declaration "
5353 # "assignments and will be discarded.");
5354 # delete p[1];
5355 # }
5356 # }
5357 ()
5358 def p_module_item_8(p):
5359 '''module_item : K_trireg charge_strength_opt dimensions_opt delay3_opt list_of_identifiers ';' '''
5360 if(parse_debug): print('module_item_8', list(p))
5361 # { yyerror(@1, "sorry: trireg nets not supported.");
5362 # delete p[3];
5363 # delete p[4];
5364 # }
5365 ()
5366 def p_module_item_9(p):
5367 '''module_item : attribute_list_opt port_direction net_type data_type_or_implicit list_of_port_identifiers ';' '''
5368 if(parse_debug): print('module_item_9', list(p))
5369 # { pform_module_define_port(@2, p[5], p[2], p[3], p[4], p[1]); }
5370 ()
5371 def p_module_item_10(p):
5372 '''module_item : attribute_list_opt port_direction K_wreal list_of_port_identifiers ';' '''
5373 if(parse_debug): print('module_item_10', list(p))
5374 # { real_type_t*real_type = new real_type_t(real_type_t::REAL);
5375 # pform_module_define_port(@2, p[4], p[2], NetNet::WIRE, real_type, p[1]);
5376 # }
5377 ()
5378 def p_module_item_11(p):
5379 '''module_item : attribute_list_opt K_inout data_type_or_implicit list_of_port_identifiers ';' '''
5380 if(parse_debug): print('module_item_11', list(p))
5381 # { NetNet::Type use_type = p[3] ? NetNet::IMPLICIT : NetNet::NONE;
5382 # if (vector_type_t*dtype = dynamic_cast<vector_type_t*> (p[3])) {
5383 # if (dtype->implicit_flag)
5384 # use_type = NetNet::NONE;
5385 # }
5386 # if (use_type == NetNet::NONE)
5387 # pform_set_port_type(@2, p[4], NetNet::PINOUT, p[3], p[1]);
5388 # else
5389 # pform_module_define_port(@2, p[4], NetNet::PINOUT, use_type, p[3], p[1]);
5390 # }
5391 ()
5392 def p_module_item_12(p):
5393 '''module_item : attribute_list_opt K_input data_type_or_implicit list_of_port_identifiers ';' '''
5394 if(parse_debug): print('module_item_12', list(p))
5395 # { NetNet::Type use_type = p[3] ? NetNet::IMPLICIT : NetNet::NONE;
5396 # if (vector_type_t*dtype = dynamic_cast<vector_type_t*> (p[3])) {
5397 # if (dtype->implicit_flag)
5398 # use_type = NetNet::NONE;
5399 # }
5400 # if (use_type == NetNet::NONE)
5401 # pform_set_port_type(@2, p[4], NetNet::PINPUT, p[3], p[1]);
5402 # else
5403 # pform_module_define_port(@2, p[4], NetNet::PINPUT, use_type, p[3], p[1]);
5404 # }
5405 ()
5406 def p_module_item_13(p):
5407 '''module_item : attribute_list_opt K_output data_type_or_implicit list_of_variable_port_identifiers ';' '''
5408 if(parse_debug): print('module_item_13', list(p))
5409 # { NetNet::Type use_type = p[3] ? NetNet::IMPLICIT : NetNet::NONE;
5410 # if (vector_type_t*dtype = dynamic_cast<vector_type_t*> (p[3])) {
5411 # if (dtype->implicit_flag)
5412 # use_type = NetNet::NONE;
5413 # else if (dtype->reg_flag)
5414 # use_type = NetNet::REG;
5415 # else
5416 # use_type = NetNet::IMPLICIT_REG;
5417 #
5418 # // The SystemVerilog types that can show up as
5419 # // output ports are implicitly (on the inside)
5420 # // variables because "reg" is not valid syntax
5421 # // here.
5422 # } else if (dynamic_cast<atom2_type_t*> (p[3])) {
5423 # use_type = NetNet::IMPLICIT_REG;
5424 # } else if (dynamic_cast<struct_type_t*> (p[3])) {
5425 # use_type = NetNet::IMPLICIT_REG;
5426 # } else if (enum_type_t*etype = dynamic_cast<enum_type_t*> (p[3])) {
5427 # if(etype->base_type == IVL_VT_LOGIC)
5428 # use_type = NetNet::IMPLICIT_REG;
5429 # }
5430 # if (use_type == NetNet::NONE)
5431 # pform_set_port_type(@2, p[4], NetNet::POUTPUT, p[3], p[1]);
5432 # else
5433 # pform_module_define_port(@2, p[4], NetNet::POUTPUT, use_type, p[3], p[1]);
5434 # }
5435 ()
5436 def p_module_item_14(p):
5437 '''module_item : attribute_list_opt port_direction net_type data_type_or_implicit error ';' '''
5438 if(parse_debug): print('module_item_14', list(p))
5439 # { yyerror(@2, "error: Invalid variable list in port declaration.");
5440 # if (p[1]) delete p[1];
5441 # if (p[4]) delete p[4];
5442 # yyerrok;
5443 # }
5444 ()
5445 def p_module_item_15(p):
5446 '''module_item : attribute_list_opt K_inout data_type_or_implicit error ';' '''
5447 if(parse_debug): print('module_item_15', list(p))
5448 # { yyerror(@2, "error: Invalid variable list in port declaration.");
5449 # if (p[1]) delete p[1];
5450 # if (p[3]) delete p[3];
5451 # yyerrok;
5452 # }
5453 ()
5454 def p_module_item_16(p):
5455 '''module_item : attribute_list_opt K_input data_type_or_implicit error ';' '''
5456 if(parse_debug): print('module_item_16', list(p))
5457 # { yyerror(@2, "error: Invalid variable list in port declaration.");
5458 # if (p[1]) delete p[1];
5459 # if (p[3]) delete p[3];
5460 # yyerrok;
5461 # }
5462 ()
5463 def p_module_item_17(p):
5464 '''module_item : attribute_list_opt K_output data_type_or_implicit error ';' '''
5465 if(parse_debug): print('module_item_17', list(p))
5466 # { yyerror(@2, "error: Invalid variable list in port declaration.");
5467 # if (p[1]) delete p[1];
5468 # if (p[3]) delete p[3];
5469 # yyerrok;
5470 # }
5471 ()
5472 def p_module_item_18(p):
5473 '''module_item : DISCIPLINE_IDENTIFIER list_of_identifiers ';' '''
5474 if(parse_debug): print('module_item_18', list(p))
5475 # { pform_attach_discipline(@1, p[1], p[2]); }
5476 ()
5477 def p_module_item_19(p):
5478 '''module_item : attribute_list_opt _embed0_module_item block_item_decl '''
5479 if(parse_debug): print('module_item_19', list(p))
5480 # { delete attributes_in_context;
5481 # attributes_in_context = 0;
5482 # }
5483 ()
5484 def p_module_item_20(p):
5485 '''module_item : K_defparam _embed1_module_item defparam_assign_list ';' '''
5486 if(parse_debug): print('module_item_20', list(p))
5487 ()
5488 def p_module_item_21(p):
5489 '''module_item : attribute_list_opt gatetype gate_instance_list ';' '''
5490 if(parse_debug): print('module_item_21', list(p))
5491 # { pform_makegates(@2, p[2], str_strength, 0, p[3], p[1]); }
5492 ()
5493 def p_module_item_22(p):
5494 '''module_item : attribute_list_opt gatetype delay3 gate_instance_list ';' '''
5495 if(parse_debug): print('module_item_22', list(p))
5496 # { pform_makegates(@2, p[2], str_strength, p[3], p[4], p[1]); }
5497 ()
5498 def p_module_item_23(p):
5499 '''module_item : attribute_list_opt gatetype drive_strength gate_instance_list ';' '''
5500 if(parse_debug): print('module_item_23', list(p))
5501 # { pform_makegates(@2, p[2], p[3], 0, p[4], p[1]); }
5502 ()
5503 def p_module_item_24(p):
5504 '''module_item : attribute_list_opt gatetype drive_strength delay3 gate_instance_list ';' '''
5505 if(parse_debug): print('module_item_24', list(p))
5506 # { pform_makegates(@2, p[2], p[3], p[4], p[5], p[1]); }
5507 ()
5508 def p_module_item_25(p):
5509 '''module_item : attribute_list_opt switchtype gate_instance_list ';' '''
5510 if(parse_debug): print('module_item_25', list(p))
5511 # { pform_makegates(@2, p[2], str_strength, 0, p[3], p[1]); }
5512 ()
5513 def p_module_item_26(p):
5514 '''module_item : attribute_list_opt switchtype delay3 gate_instance_list ';' '''
5515 if(parse_debug): print('module_item_26', list(p))
5516 # { pform_makegates(@2, p[2], str_strength, p[3], p[4], p[1]); }
5517 ()
5518 def p_module_item_27(p):
5519 '''module_item : K_pullup gate_instance_list ';' '''
5520 if(parse_debug): print('module_item_27', list(p))
5521 # { pform_makegates(@1, PGBuiltin::PULLUP, pull_strength, 0, p[2], 0); }
5522 ()
5523 def p_module_item_28(p):
5524 '''module_item : K_pulldown gate_instance_list ';' '''
5525 if(parse_debug): print('module_item_28', list(p))
5526 # { pform_makegates(@1, PGBuiltin::PULLDOWN, pull_strength, 0, p[2], 0); }
5527 ()
5528 def p_module_item_29(p):
5529 '''module_item : K_pullup '(' dr_strength1 ')' gate_instance_list ';' '''
5530 if(parse_debug): print('module_item_29', list(p))
5531 # { pform_makegates(@1, PGBuiltin::PULLUP, p[3], 0, p[5], 0); }
5532 ()
5533 def p_module_item_30(p):
5534 '''module_item : K_pullup '(' dr_strength1 ',' dr_strength0 ')' gate_instance_list ';' '''
5535 if(parse_debug): print('module_item_30', list(p))
5536 # { pform_makegates(@1, PGBuiltin::PULLUP, p[3], 0, p[7], 0); }
5537 ()
5538 def p_module_item_31(p):
5539 '''module_item : K_pullup '(' dr_strength0 ',' dr_strength1 ')' gate_instance_list ';' '''
5540 if(parse_debug): print('module_item_31', list(p))
5541 # { pform_makegates(@1, PGBuiltin::PULLUP, p[5], 0, p[7], 0); }
5542 ()
5543 def p_module_item_32(p):
5544 '''module_item : K_pulldown '(' dr_strength0 ')' gate_instance_list ';' '''
5545 if(parse_debug): print('module_item_32', list(p))
5546 # { pform_makegates(@1, PGBuiltin::PULLDOWN, p[3], 0, p[5], 0); }
5547 ()
5548 def p_module_item_33(p):
5549 '''module_item : K_pulldown '(' dr_strength1 ',' dr_strength0 ')' gate_instance_list ';' '''
5550 if(parse_debug): print('module_item_33', list(p))
5551 # { pform_makegates(@1, PGBuiltin::PULLDOWN, p[5], 0, p[7], 0); }
5552 ()
5553 def p_module_item_34(p):
5554 '''module_item : K_pulldown '(' dr_strength0 ',' dr_strength1 ')' gate_instance_list ';' '''
5555 if(parse_debug): print('module_item_34', list(p))
5556 # { pform_makegates(@1, PGBuiltin::PULLDOWN, p[3], 0, p[7], 0); }
5557 ()
5558 def p_module_item_35(p):
5559 '''module_item : attribute_list_opt IDENTIFIER parameter_value_opt gate_instance_list ';' '''
5560 if(parse_debug): print('module_item_35', list(p))
5561 # { perm_string tmp1 = lex_strings.make(p[2]);
5562 # pform_make_modgates(@2, tmp1, p[3], p[4], p[1]);
5563 # delete[]p[2];
5564 # }
5565 ()
5566 def p_module_item_36(p):
5567 '''module_item : attribute_list_opt IDENTIFIER parameter_value_opt error ';' '''
5568 if(parse_debug): print('module_item_36', list(p))
5569 # { yyerror(@2, "error: Invalid module instantiation");
5570 # delete[]p[2];
5571 # if (p[1]) delete p[1];
5572 # }
5573 ()
5574 def p_module_item_37(p):
5575 '''module_item : K_assign drive_strength_opt delay3_opt cont_assign_list ';' '''
5576 if(parse_debug>2): print('module_item_37', list(p))
5577 # { pform_make_pgassign_list(p[4], p[3], p[2], @1.text, @1.first_line); }
5578 ()
5579 def p_module_item_38(p):
5580 '''module_item : attribute_list_opt K_always statement_item '''
5581 if(parse_debug): print('module_item_38', list(p))
5582 # { PProcess*tmp = pform_make_behavior(IVL_PR_ALWAYS, p[3], p[1]);
5583 # FILE_NAME(tmp, @2);
5584 # }
5585 ()
5586 def p_module_item_39(p):
5587 '''module_item : attribute_list_opt K_always_comb statement_item '''
5588 if(parse_debug): print('module_item_39', list(p))
5589 # { PProcess*tmp = pform_make_behavior(IVL_PR_ALWAYS_COMB, p[3], p[1]);
5590 # FILE_NAME(tmp, @2);
5591 # }
5592 ()
5593 def p_module_item_40(p):
5594 '''module_item : attribute_list_opt K_always_ff statement_item '''
5595 if(parse_debug): print('module_item_40', list(p))
5596 # { PProcess*tmp = pform_make_behavior(IVL_PR_ALWAYS_FF, p[3], p[1]);
5597 # FILE_NAME(tmp, @2);
5598 # }
5599 ()
5600 def p_module_item_41(p):
5601 '''module_item : attribute_list_opt K_always_latch statement_item '''
5602 if(parse_debug): print('module_item_41', list(p))
5603 # { PProcess*tmp = pform_make_behavior(IVL_PR_ALWAYS_LATCH, p[3], p[1]);
5604 # FILE_NAME(tmp, @2);
5605 # }
5606 ()
5607 def p_module_item_42(p):
5608 '''module_item : attribute_list_opt K_initial statement_item '''
5609 if(parse_debug): print('module_item_42', list(p))
5610 # { PProcess*tmp = pform_make_behavior(IVL_PR_INITIAL, p[3], p[1]);
5611 # FILE_NAME(tmp, @2);
5612 # }
5613 ()
5614 def p_module_item_43(p):
5615 '''module_item : attribute_list_opt K_final statement_item '''
5616 if(parse_debug): print('module_item_43', list(p))
5617 # { PProcess*tmp = pform_make_behavior(IVL_PR_FINAL, p[3], p[1]);
5618 # FILE_NAME(tmp, @2);
5619 # }
5620 ()
5621 def p_module_item_44(p):
5622 '''module_item : attribute_list_opt K_analog analog_statement '''
5623 if(parse_debug): print('module_item_44', list(p))
5624 # { pform_make_analog_behavior(@2, IVL_PR_ALWAYS, p[3]); }
5625 ()
5626 def p_module_item_45(p):
5627 '''module_item : attribute_list_opt assertion_item '''
5628 if(parse_debug): print('module_item_45', list(p))
5629 ()
5630 def p_module_item_46(p):
5631 '''module_item : timeunits_declaration '''
5632 if(parse_debug): print('module_item_46', list(p))
5633 ()
5634 def p_module_item_47(p):
5635 '''module_item : class_declaration '''
5636 if(parse_debug): print('module_item_47', list(p))
5637 ()
5638 def p_module_item_48(p):
5639 '''module_item : task_declaration '''
5640 if(parse_debug): print('module_item_48', list(p))
5641 ()
5642 def p_module_item_49(p):
5643 '''module_item : function_declaration '''
5644 if(parse_debug): print('module_item_49', list(p))
5645 ()
5646 def p_module_item_50(p):
5647 '''module_item : K_generate generate_item_list_opt K_endgenerate '''
5648 if(parse_debug): print('module_item_50', list(p))
5649 # { // Test for bad nesting. I understand it, but it is illegal.
5650 # if (pform_parent_generate()) {
5651 # cerr << @1 << ": error: Generate/endgenerate regions cannot nest." << endl;
5652 # cerr << @1 << ": : Try removing optional generate/endgenerate keywords," << endl;
5653 # cerr << @1 << ": : or move them to surround the parent generate scheme." << endl;
5654 # error_count += 1;
5655 # }
5656 # }
5657 ()
5658 def p_module_item_51(p):
5659 '''module_item : K_genvar list_of_identifiers ';' '''
5660 if(parse_debug): print('module_item_51', list(p))
5661 # { pform_genvars(@1, p[2]); }
5662 ()
5663 def p_module_item_52(p):
5664 '''module_item : K_for '(' IDENTIFIER '=' expression ';' expression ';' IDENTIFIER '=' expression ')' _embed2_module_item generate_block '''
5665 if(parse_debug): print('module_item_52', list(p))
5666 # { pform_endgenerate(); }
5667 ()
5668 def p_module_item_53(p):
5669 '''module_item : generate_if generate_block_opt K_else _embed3_module_item generate_block '''
5670 if(parse_debug): print('module_item_53', list(p))
5671 # { pform_endgenerate(); }
5672 ()
5673 def p_module_item_54(p):
5674 '''module_item : generate_if generate_block_opt %prec less_than_K_else '''
5675 if(parse_debug): print('module_item_54', list(p))
5676 # { pform_endgenerate(); }
5677 ()
5678 def p_module_item_55(p):
5679 '''module_item : K_case '(' expression ')' _embed4_module_item generate_case_items K_endcase '''
5680 if(parse_debug): print('module_item_55', list(p))
5681 # { pform_endgenerate(); }
5682 ()
5683 def p_module_item_56(p):
5684 '''module_item : modport_declaration '''
5685 if(parse_debug): print('module_item_56', list(p))
5686 ()
5687 def p_module_item_57(p):
5688 '''module_item : package_import_declaration '''
5689 if(parse_debug): print('module_item_57', list(p))
5690 ()
5691 def p_module_item_58(p):
5692 '''module_item : attribute_list_opt K_specparam _embed5_module_item specparam_decl ';' '''
5693 if(parse_debug): print('module_item_58', list(p))
5694 ()
5695 def p_module_item_59(p):
5696 '''module_item : K_specify _embed6_module_item specify_item_list_opt K_endspecify '''
5697 if(parse_debug): print('module_item_59', list(p))
5698 ()
5699 def p_module_item_60(p):
5700 '''module_item : K_specify error K_endspecify '''
5701 if(parse_debug): print('module_item_60', list(p))
5702 # { yyerror(@1, "error: syntax error in specify block");
5703 # yyerrok;
5704 # }
5705 ()
5706 def p_module_item_61(p):
5707 '''module_item : error ';' '''
5708 if(parse_debug): print('module_item_61', list(p))
5709 # { yyerror(@2, "error: invalid module item.");
5710 # yyerrok;
5711 # }
5712 ()
5713 def p_module_item_62(p):
5714 '''module_item : K_assign error '=' expression ';' '''
5715 if(parse_debug): print('module_item_62', list(p))
5716 # { yyerror(@1, "error: syntax error in left side "
5717 # "of continuous assignment.");
5718 # yyerrok;
5719 # }
5720 ()
5721 def p_module_item_63(p):
5722 '''module_item : K_assign error ';' '''
5723 if(parse_debug): print('module_item_63', list(p))
5724 # { yyerror(@1, "error: syntax error in "
5725 # "continuous assignment");
5726 # yyerrok;
5727 # }
5728 ()
5729 def p_module_item_64(p):
5730 '''module_item : K_function error K_endfunction endlabel_opt '''
5731 if(parse_debug): print('module_item_64', list(p))
5732 # { yyerror(@1, "error: I give up on this "
5733 # "function definition.");
5734 # if (p[4]) {
5735 # if (!gn_system_verilog()) {
5736 # yyerror(@4, "error: Function end names require "
5737 # "SystemVerilog.");
5738 # }
5739 # delete[]p[4];
5740 # }
5741 # yyerrok;
5742 # }
5743 ()
5744 def p_module_item_65(p):
5745 '''module_item : KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' ';' '''
5746 if(parse_debug): print('module_item_65', list(p))
5747 # { perm_string tmp3 = lex_strings.make(p[3]);
5748 # perm_string tmp5 = lex_strings.make(p[5]);
5749 # pform_set_attrib(tmp3, tmp5, p[7]);
5750 # delete[] p[3];
5751 # delete[] p[5];
5752 # }
5753 ()
5754 def p_module_item_66(p):
5755 '''module_item : KK_attribute '(' error ')' ';' '''
5756 if(parse_debug): print('module_item_66', list(p))
5757 # { yyerror(@1, "error: Malformed $attribute parameter list."); }
5758 ()
5759 def p__embed0_module_item(p):
5760 '''_embed0_module_item : '''
5761 # { attributes_in_context = p[1]; }
5762 ()
5763 def p__embed1_module_item(p):
5764 '''_embed1_module_item : '''
5765 # { if (pform_in_interface())
5766 # yyerror(@1, "error: Parameter overrides are not allowed "
5767 # "in interfaces.");
5768 # }
5769 ()
5770 def p__embed2_module_item(p):
5771 '''_embed2_module_item : '''
5772 # { pform_start_generate_for(@1, p[3], p[5], p[7], p[9], p[11]); }
5773 ()
5774 def p__embed3_module_item(p):
5775 '''_embed3_module_item : '''
5776 # { pform_start_generate_else(@1); }
5777 ()
5778 def p__embed4_module_item(p):
5779 '''_embed4_module_item : '''
5780 # { pform_start_generate_case(@1, p[3]); }
5781 ()
5782 def p__embed5_module_item(p):
5783 '''_embed5_module_item : '''
5784 # { if (pform_in_interface())
5785 # yyerror(@1, "error: specparam declarations are not allowed "
5786 # "in interfaces.");
5787 # }
5788 ()
5789 def p__embed6_module_item(p):
5790 '''_embed6_module_item : '''
5791 # { if (pform_in_interface())
5792 # yyerror(@1, "error: specify blocks are not allowed "
5793 # "in interfaces.");
5794 # }
5795 ()
5796 def p_module_item_list_1(p):
5797 '''module_item_list : module_item_list module_item '''
5798 if(parse_debug): print('module_item_list_1', list(p))
5799 ()
5800 def p_module_item_list_2(p):
5801 '''module_item_list : module_item '''
5802 if(parse_debug>2): print('module_item_list_2', list(p))
5803 ()
5804 def p_module_item_list_opt_1(p):
5805 '''module_item_list_opt : module_item_list '''
5806 if(parse_debug>2): print('module_item_list_opt_1', list(p))
5807 ()
5808 def p_module_item_list_opt_2(p):
5809 '''module_item_list_opt : '''
5810 if(parse_debug): print('module_item_list_opt_2', list(p))
5811 ()
5812 def p_generate_if_1(p):
5813 '''generate_if : K_if '(' expression ')' '''
5814 if(parse_debug): print('generate_if_1', list(p))
5815 # { pform_start_generate_if(@1, p[3]); }
5816 ()
5817 def p_generate_case_items_1(p):
5818 '''generate_case_items : generate_case_items generate_case_item '''
5819 if(parse_debug): print('generate_case_items_1', list(p))
5820 ()
5821 def p_generate_case_items_2(p):
5822 '''generate_case_items : generate_case_item '''
5823 if(parse_debug): print('generate_case_items_2', list(p))
5824 ()
5825 def p_generate_case_item_1(p):
5826 '''generate_case_item : expression_list_proper ':' _embed0_generate_case_item generate_block_opt '''
5827 if(parse_debug): print('generate_case_item_1', list(p))
5828 # { pform_endgenerate(); }
5829 ()
5830 def p_generate_case_item_2(p):
5831 '''generate_case_item : K_default ':' _embed1_generate_case_item generate_block_opt '''
5832 if(parse_debug): print('generate_case_item_2', list(p))
5833 # { pform_endgenerate(); }
5834 ()
5835 def p__embed0_generate_case_item(p):
5836 '''_embed0_generate_case_item : '''
5837 # { pform_generate_case_item(@1, p[1]); }
5838 ()
5839 def p__embed1_generate_case_item(p):
5840 '''_embed1_generate_case_item : '''
5841 # { pform_generate_case_item(@1, 0); }
5842 ()
5843 def p_generate_item_1(p):
5844 '''generate_item : module_item '''
5845 if(parse_debug): print('generate_item_1', list(p))
5846 ()
5847 def p_generate_item_2(p):
5848 '''generate_item : K_begin generate_item_list_opt K_end '''
5849 if(parse_debug): print('generate_item_2', list(p))
5850 # { /* Detect and warn about anachronistic begin/end use */
5851 # if (generation_flag > GN_VER2001 && warn_anachronisms) {
5852 # warn_count += 1;
5853 # cerr << @1 << ": warning: Anachronistic use of begin/end to surround generate schemes." << endl;
5854 # }
5855 # }
5856 ()
5857 def p_generate_item_3(p):
5858 '''generate_item : K_begin ':' IDENTIFIER _embed0_generate_item generate_item_list_opt K_end '''
5859 if(parse_debug): print('generate_item_3', list(p))
5860 # { /* Detect and warn about anachronistic named begin/end use */
5861 # if (generation_flag > GN_VER2001 && warn_anachronisms) {
5862 # warn_count += 1;
5863 # cerr << @1 << ": warning: Anachronistic use of named begin/end to surround generate schemes." << endl;
5864 # }
5865 # pform_endgenerate();
5866 # }
5867 ()
5868 def p__embed0_generate_item(p):
5869 '''_embed0_generate_item : '''
5870 # {
5871 # pform_start_generate_nblock(@1, p[3]);
5872 # }
5873 ()
5874 def p_generate_item_list_1(p):
5875 '''generate_item_list : generate_item_list generate_item '''
5876 if(parse_debug): print('generate_item_list_1', list(p))
5877 ()
5878 def p_generate_item_list_2(p):
5879 '''generate_item_list : generate_item '''
5880 if(parse_debug): print('generate_item_list_2', list(p))
5881 ()
5882 def p_generate_item_list_opt_1(p):
5883 '''generate_item_list_opt : generate_item_list '''
5884 if(parse_debug): print('generate_item_list_opt_1', list(p))
5885 ()
5886 def p_generate_item_list_opt_2(p):
5887 '''generate_item_list_opt : '''
5888 if(parse_debug): print('generate_item_list_opt_2', list(p))
5889 ()
5890 def p_generate_block_1(p):
5891 '''generate_block : module_item '''
5892 if(parse_debug): print('generate_block_1', list(p))
5893 ()
5894 def p_generate_block_2(p):
5895 '''generate_block : K_begin generate_item_list_opt K_end '''
5896 if(parse_debug): print('generate_block_2', list(p))
5897 ()
5898 def p_generate_block_3(p):
5899 '''generate_block : K_begin ':' IDENTIFIER generate_item_list_opt K_end endlabel_opt '''
5900 if(parse_debug): print('generate_block_3', list(p))
5901 # { pform_generate_block_name(p[3]);
5902 # if (p[6]) {
5903 # if (strcmp(p[3],p[6]) != 0) {
5904 # yyerror(@6, "error: End label doesn't match "
5905 # "begin name");
5906 # }
5907 # if (! gn_system_verilog()) {
5908 # yyerror(@6, "error: Begin end labels require "
5909 # "SystemVerilog.");
5910 # }
5911 # delete[]p[6];
5912 # }
5913 # delete[]p[3];
5914 # }
5915 ()
5916 def p_generate_block_opt_1(p):
5917 '''generate_block_opt : generate_block '''
5918 if(parse_debug): print('generate_block_opt_1', list(p))
5919 ()
5920 def p_generate_block_opt_2(p):
5921 '''generate_block_opt : ';' '''
5922 if(parse_debug): print('generate_block_opt_2', list(p))
5923 ()
5924 def p_net_decl_assign_1(p):
5925 '''net_decl_assign : IDENTIFIER '=' expression '''
5926 if(parse_debug): print('net_decl_assign_1', list(p))
5927 # { net_decl_assign_t*tmp = new net_decl_assign_t;
5928 # tmp->next = tmp;
5929 # tmp->name = lex_strings.make(p[1]);
5930 # tmp->expr = p[3];
5931 # delete[]p[1];
5932 # p[0] = tmp;
5933 # }
5934 ()
5935 def p_net_decl_assigns_1(p):
5936 '''net_decl_assigns : net_decl_assigns ',' net_decl_assign '''
5937 if(parse_debug): print('net_decl_assigns_1', list(p))
5938 # { net_decl_assign_t*tmp = p[1];
5939 # p[3]->next = tmp->next;
5940 # tmp->next = p[3];
5941 # p[0] = tmp;
5942 # }
5943 ()
5944 def p_net_decl_assigns_2(p):
5945 '''net_decl_assigns : net_decl_assign '''
5946 if(parse_debug): print('net_decl_assigns_2', list(p))
5947 # { p[0] = p[1];
5948 # }
5949 ()
5950 def p_bit_logic_1(p):
5951 '''bit_logic : K_logic '''
5952 if(parse_debug): print('bit_logic_1', list(p))
5953 # { p[0] = IVL_VT_LOGIC; }
5954 ()
5955 def p_bit_logic_2(p):
5956 '''bit_logic : K_bool '''
5957 if(parse_debug): print('bit_logic_2', list(p))
5958 # { p[0] = IVL_VT_BOOL; /* Icarus misc */}
5959 ()
5960 def p_bit_logic_3(p):
5961 '''bit_logic : K_bit '''
5962 if(parse_debug): print('bit_logic_3', list(p))
5963 # { p[0] = IVL_VT_BOOL; /* IEEE1800 / IEEE1364-2009 */}
5964 ()
5965 def p_bit_logic_opt_1(p):
5966 '''bit_logic_opt : bit_logic '''
5967 if(parse_debug): print('bit_logic_opt_1', list(p))
5968 ()
5969 def p_bit_logic_opt_2(p):
5970 '''bit_logic_opt : '''
5971 if(parse_debug): print('bit_logic_opt_2', list(p))
5972 # { p[0] = IVL_VT_NO_TYPE; }
5973 ()
5974 def p_net_type_1(p):
5975 '''net_type : K_wire '''
5976 if(parse_debug): print('net_type_1', list(p))
5977 # { p[0] = NetNet::WIRE; }
5978 ()
5979 def p_net_type_2(p):
5980 '''net_type : K_tri '''
5981 if(parse_debug): print('net_type_2', list(p))
5982 # { p[0] = NetNet::TRI; }
5983 ()
5984 def p_net_type_3(p):
5985 '''net_type : K_tri1 '''
5986 if(parse_debug): print('net_type_3', list(p))
5987 # { p[0] = NetNet::TRI1; }
5988 ()
5989 def p_net_type_4(p):
5990 '''net_type : K_supply0 '''
5991 if(parse_debug): print('net_type_4', list(p))
5992 # { p[0] = NetNet::SUPPLY0; }
5993 ()
5994 def p_net_type_5(p):
5995 '''net_type : K_wand '''
5996 if(parse_debug): print('net_type_5', list(p))
5997 # { p[0] = NetNet::WAND; }
5998 ()
5999 def p_net_type_6(p):
6000 '''net_type : K_triand '''
6001 if(parse_debug): print('net_type_6', list(p))
6002 # { p[0] = NetNet::TRIAND; }
6003 ()
6004 def p_net_type_7(p):
6005 '''net_type : K_tri0 '''
6006 if(parse_debug): print('net_type_7', list(p))
6007 # { p[0] = NetNet::TRI0; }
6008 ()
6009 def p_net_type_8(p):
6010 '''net_type : K_supply1 '''
6011 if(parse_debug): print('net_type_8', list(p))
6012 # { p[0] = NetNet::SUPPLY1; }
6013 ()
6014 def p_net_type_9(p):
6015 '''net_type : K_wor '''
6016 if(parse_debug): print('net_type_9', list(p))
6017 # { p[0] = NetNet::WOR; }
6018 ()
6019 def p_net_type_10(p):
6020 '''net_type : K_trior '''
6021 if(parse_debug): print('net_type_10', list(p))
6022 # { p[0] = NetNet::TRIOR; }
6023 ()
6024 def p_net_type_11(p):
6025 '''net_type : K_wone '''
6026 if(parse_debug): print('net_type_11', list(p))
6027 # { p[0] = NetNet::UNRESOLVED_WIRE;
6028 # cerr << @1.text << ":" << @1.first_line << ": warning: "
6029 # "'wone' is deprecated, please use 'uwire' "
6030 # "instead." << endl;
6031 # }
6032 ()
6033 def p_net_type_12(p):
6034 '''net_type : K_uwire '''
6035 if(parse_debug): print('net_type_12', list(p))
6036 # { p[0] = NetNet::UNRESOLVED_WIRE; }
6037 ()
6038 def p_param_type_1(p):
6039 '''param_type : bit_logic_opt unsigned_signed_opt dimensions_opt '''
6040 if(parse_debug): print('param_type_1', list(p))
6041 # { param_active_range = p[3];
6042 # param_active_signed = p[2];
6043 # if ((p[1] == IVL_VT_NO_TYPE) && (p[3] != 0))
6044 # param_active_type = IVL_VT_LOGIC;
6045 # else
6046 # param_active_type = p[1];
6047 # }
6048 ()
6049 def p_param_type_2(p):
6050 '''param_type : K_integer '''
6051 if(parse_debug): print('param_type_2', list(p))
6052 # { param_active_range = make_range_from_width(integer_width);
6053 # param_active_signed = true;
6054 # param_active_type = IVL_VT_LOGIC;
6055 # }
6056 ()
6057 def p_param_type_3(p):
6058 '''param_type : K_time '''
6059 if(parse_debug): print('param_type_3', list(p))
6060 # { param_active_range = make_range_from_width(64);
6061 # param_active_signed = false;
6062 # param_active_type = IVL_VT_LOGIC;
6063 # }
6064 ()
6065 def p_param_type_4(p):
6066 '''param_type : real_or_realtime '''
6067 if(parse_debug): print('param_type_4', list(p))
6068 # { param_active_range = 0;
6069 # param_active_signed = true;
6070 # param_active_type = IVL_VT_REAL;
6071 # }
6072 ()
6073 def p_param_type_5(p):
6074 '''param_type : atom2_type '''
6075 if(parse_debug): print('param_type_5', list(p))
6076 # { param_active_range = make_range_from_width(p[1]);
6077 # param_active_signed = true;
6078 # param_active_type = IVL_VT_BOOL;
6079 # }
6080 ()
6081 def p_param_type_6(p):
6082 '''param_type : TYPE_IDENTIFIER '''
6083 if(parse_debug): print('param_type_6', list(p))
6084 # { pform_set_param_from_type(@1, p[1].type, p[1].text, param_active_range,
6085 # param_active_signed, param_active_type);
6086 # delete[]p[1].text;
6087 # }
6088 ()
6089 def p_parameter_assign_list_1(p):
6090 '''parameter_assign_list : parameter_assign '''
6091 if(parse_debug): print('parameter_assign_list_1', list(p))
6092 ()
6093 def p_parameter_assign_list_2(p):
6094 '''parameter_assign_list : parameter_assign_list ',' parameter_assign '''
6095 if(parse_debug): print('parameter_assign_list_2', list(p))
6096 ()
6097 def p_localparam_assign_list_1(p):
6098 '''localparam_assign_list : localparam_assign '''
6099 if(parse_debug): print('localparam_assign_list_1', list(p))
6100 ()
6101 def p_localparam_assign_list_2(p):
6102 '''localparam_assign_list : localparam_assign_list ',' localparam_assign '''
6103 if(parse_debug): print('localparam_assign_list_2', list(p))
6104 ()
6105 def p_parameter_assign_1(p):
6106 '''parameter_assign : IDENTIFIER '=' expression parameter_value_ranges_opt '''
6107 if(parse_debug): print('parameter_assign_1', list(p))
6108 tpname = Node(syms.tname, [Leaf(token.NAME, p[1])])
6109 expr = Node(syms.tfpdef, [tpname, Leaf(token.EQUAL, p[2]), p[3] ])
6110 p[0] = expr
6111 # { PExpr*tmp = p[3];
6112 # pform_set_parameter(@1, lex_strings.make(p[1]), param_active_type,
6113 # param_active_signed, param_active_range, tmp, p[4]);
6114 # delete[]p[1];
6115 # }
6116 ()
6117 def p_localparam_assign_1(p):
6118 '''localparam_assign : IDENTIFIER '=' expression '''
6119 if(parse_debug): print('localparam_assign_1', list(p))
6120 # { PExpr*tmp = p[3];
6121 # pform_set_localparam(@1, lex_strings.make(p[1]), param_active_type,
6122 # param_active_signed, param_active_range, tmp);
6123 # delete[]p[1];
6124 # }
6125 ()
6126 def p_parameter_value_ranges_opt_1(p):
6127 '''parameter_value_ranges_opt : parameter_value_ranges '''
6128 if(parse_debug): print('parameter_value_ranges_opt_1', list(p))
6129 p[0] = p[1]
6130 ()
6131 def p_parameter_value_ranges_opt_2(p):
6132 '''parameter_value_ranges_opt : '''
6133 if(parse_debug): print('parameter_value_ranges_opt_2', list(p))
6134 # { p[0] = None }
6135 ()
6136 def p_parameter_value_ranges_1(p):
6137 '''parameter_value_ranges : parameter_value_ranges parameter_value_range '''
6138 if(parse_debug): print('parameter_value_ranges_1', list(p))
6139 # { p[0] = p[2]; p[0]->next = p[1]; }
6140 ()
6141 def p_parameter_value_ranges_2(p):
6142 '''parameter_value_ranges : parameter_value_range '''
6143 if(parse_debug): print('parameter_value_ranges_2', list(p))
6144 # { p[0] = p[1]; p[0]->next = 0; }
6145 ()
6146 def p_parameter_value_range_1(p):
6147 '''parameter_value_range : from_exclude '[' value_range_expression ':' value_range_expression ']' '''
6148 if(parse_debug): print('parameter_value_range_1', list(p))
6149 # { p[0] = pform_parameter_value_range(p[1], false, p[3], false, p[5]); }
6150 ()
6151 def p_parameter_value_range_2(p):
6152 '''parameter_value_range : from_exclude '[' value_range_expression ':' value_range_expression ')' '''
6153 if(parse_debug): print('parameter_value_range_2', list(p))
6154 # { p[0] = pform_parameter_value_range(p[1], false, p[3], true, p[5]); }
6155 ()
6156 def p_parameter_value_range_3(p):
6157 '''parameter_value_range : from_exclude '(' value_range_expression ':' value_range_expression ']' '''
6158 if(parse_debug): print('parameter_value_range_3', list(p))
6159 # { p[0] = pform_parameter_value_range(p[1], true, p[3], false, p[5]); }
6160 ()
6161 def p_parameter_value_range_4(p):
6162 '''parameter_value_range : from_exclude '(' value_range_expression ':' value_range_expression ')' '''
6163 if(parse_debug): print('parameter_value_range_4', list(p))
6164 # { p[0] = pform_parameter_value_range(p[1], true, p[3], true, p[5]); }
6165 ()
6166 def p_parameter_value_range_5(p):
6167 '''parameter_value_range : K_exclude expression '''
6168 if(parse_debug): print('parameter_value_range_5', list(p))
6169 # { p[0] = pform_parameter_value_range(true, false, p[2], false, p[2]); }
6170 ()
6171 def p_value_range_expression_1(p):
6172 '''value_range_expression : expression '''
6173 if(parse_debug): print('value_range_expression_1', list(p))
6174 p[0] = p[1]
6175 ()
6176 def p_value_range_expression_2(p):
6177 '''value_range_expression : K_inf '''
6178 if(parse_debug): print('value_range_expression_2', list(p))
6179 # { p[0] = None }
6180 ()
6181 def p_value_range_expression_3(p):
6182 '''value_range_expression : '+' K_inf '''
6183 if(parse_debug): print('value_range_expression_3', list(p))
6184 # { p[0] = None }
6185 ()
6186 def p_value_range_expression_4(p):
6187 '''value_range_expression : '-' K_inf '''
6188 if(parse_debug): print('value_range_expression_4', list(p))
6189 # { p[0] = None }
6190 ()
6191 def p_from_exclude_1(p):
6192 '''from_exclude : K_from '''
6193 if(parse_debug): print('from_exclude_1', list(p))
6194 p[0] = False
6195 ()
6196 def p_from_exclude_2(p):
6197 '''from_exclude : K_exclude '''
6198 if(parse_debug): print('from_exclude_2', list(p))
6199 p[0] = True
6200 ()
6201 def p_parameter_value_opt_1(p):
6202 '''parameter_value_opt : '#' '(' expression_list_with_nuls ')' '''
6203 if(parse_debug): print('parameter_value_opt_1', list(p))
6204 # { struct parmvalue_t*tmp = new struct parmvalue_t;
6205 # tmp->by_order = p[3];
6206 # tmp->by_name = 0;
6207 # p[0] = tmp;
6208 # }
6209 ()
6210 def p_parameter_value_opt_2(p):
6211 '''parameter_value_opt : '#' '(' parameter_value_byname_list ')' '''
6212 if(parse_debug): print('parameter_value_opt_2', list(p))
6213 # { struct parmvalue_t*tmp = new struct parmvalue_t;
6214 # tmp->by_order = 0;
6215 # tmp->by_name = p[3];
6216 # p[0] = tmp;
6217 # }
6218 ()
6219 def p_parameter_value_opt_3(p):
6220 '''parameter_value_opt : '#' DEC_NUMBER '''
6221 if(parse_debug): print('parameter_value_opt_3', list(p))
6222 # { assert(p[2]);
6223 # PENumber*tmp = new PENumber(p[2]);
6224 # FILE_NAME(tmp, @1);
6225 #
6226 # struct parmvalue_t*lst = new struct parmvalue_t;
6227 # lst->by_order = new list<PExpr*>;
6228 # lst->by_order->push_back(tmp);
6229 # lst->by_name = 0;
6230 # p[0] = lst;
6231 # based_size = 0;
6232 # }
6233 ()
6234 def p_parameter_value_opt_4(p):
6235 '''parameter_value_opt : '#' REALTIME '''
6236 if(parse_debug): print('parameter_value_opt_4', list(p))
6237 # { assert(p[2]);
6238 # PEFNumber*tmp = new PEFNumber(p[2]);
6239 # FILE_NAME(tmp, @1);
6240 #
6241 # struct parmvalue_t*lst = new struct parmvalue_t;
6242 # lst->by_order = new list<PExpr*>;
6243 # lst->by_order->push_back(tmp);
6244 # lst->by_name = 0;
6245 # p[0] = lst;
6246 # }
6247 ()
6248 def p_parameter_value_opt_5(p):
6249 '''parameter_value_opt : '#' error '''
6250 if(parse_debug): print('parameter_value_opt_5', list(p))
6251 # { yyerror(@1, "error: syntax error in parameter value "
6252 # "assignment list.");
6253 # p[0] = None
6254 # }
6255 ()
6256 def p_parameter_value_opt_6(p):
6257 '''parameter_value_opt : '''
6258 if(parse_debug): print('parameter_value_opt_6', list(p))
6259 # { p[0] = None }
6260 ()
6261 def p_parameter_value_byname_1(p):
6262 '''parameter_value_byname : '.' IDENTIFIER '(' expression ')' '''
6263 if(parse_debug): print('parameter_value_byname_1', list(p))
6264 # { named_pexpr_t*tmp = new named_pexpr_t;
6265 # tmp->name = lex_strings.make(p[2]);
6266 # tmp->parm = p[4];
6267 # delete[]p[2];
6268 # p[0] = tmp;
6269 # }
6270 ()
6271 def p_parameter_value_byname_2(p):
6272 '''parameter_value_byname : '.' IDENTIFIER '(' ')' '''
6273 if(parse_debug): print('parameter_value_byname_2', list(p))
6274 # { named_pexpr_t*tmp = new named_pexpr_t;
6275 # tmp->name = lex_strings.make(p[2]);
6276 # tmp->parm = 0;
6277 # delete[]p[2];
6278 # p[0] = tmp;
6279 # }
6280 ()
6281 def p_parameter_value_byname_list_1(p):
6282 '''parameter_value_byname_list : parameter_value_byname '''
6283 if(parse_debug): print('parameter_value_byname_list_1', list(p))
6284 # { list<named_pexpr_t>*tmp = new list<named_pexpr_t>;
6285 # tmp->push_back(*p[1]);
6286 # delete p[1];
6287 # p[0] = tmp;
6288 # }
6289 ()
6290 def p_parameter_value_byname_list_2(p):
6291 '''parameter_value_byname_list : parameter_value_byname_list ',' parameter_value_byname '''
6292 if(parse_debug): print('parameter_value_byname_list_2', list(p))
6293 # { list<named_pexpr_t>*tmp = p[1];
6294 # tmp->push_back(*p[3]);
6295 # delete p[3];
6296 # p[0] = tmp;
6297 # }
6298 ()
6299 def p_port_1(p):
6300 '''port : port_reference '''
6301 if(parse_debug): print('port_1', list(p))
6302 p[0] = p[1]
6303 ()
6304 def p_port_2(p):
6305 '''port : '.' IDENTIFIER '(' port_reference ')' '''
6306 if(parse_debug): print('port_2', list(p))
6307 # { Module::port_t*tmp = p[4];
6308 # tmp->name = lex_strings.make(p[2]);
6309 # delete[]p[2];
6310 # p[0] = tmp;
6311 # }
6312 ()
6313 def p_port_3(p):
6314 '''port : '{' port_reference_list '}' '''
6315 if(parse_debug): print('port_3', list(p))
6316 # { Module::port_t*tmp = p[2];
6317 # tmp->name = perm_string();
6318 # p[0] = tmp;
6319 # }
6320 ()
6321 def p_port_4(p):
6322 '''port : '.' IDENTIFIER '(' '{' port_reference_list '}' ')' '''
6323 if(parse_debug): print('port_4', list(p))
6324 # { Module::port_t*tmp = p[5];
6325 # tmp->name = lex_strings.make(p[2]);
6326 # delete[]p[2];
6327 # p[0] = tmp;
6328 # }
6329 ()
6330 def p_port_opt_1(p):
6331 '''port_opt : port '''
6332 if(parse_debug): print('port_opt_1', list(p))
6333 p[0] = p[1]
6334 ()
6335 def p_port_opt_2(p):
6336 '''port_opt : '''
6337 if(parse_debug): print('port_opt_2', list(p))
6338 # { p[0] = None }
6339 ()
6340 def p_port_name_1(p):
6341 '''port_name : '.' IDENTIFIER '(' expression ')' '''
6342 if(parse_debug): print('port_name_1', list(p))
6343 # { named_pexpr_t*tmp = new named_pexpr_t;
6344 # tmp->name = lex_strings.make(p[2]);
6345 # tmp->parm = p[4];
6346 # delete[]p[2];
6347 # p[0] = tmp;
6348 # }
6349 ()
6350 def p_port_name_2(p):
6351 '''port_name : '.' IDENTIFIER '(' error ')' '''
6352 if(parse_debug): print('port_name_2', list(p))
6353 # { yyerror(@3, "error: invalid port connection expression.");
6354 # named_pexpr_t*tmp = new named_pexpr_t;
6355 # tmp->name = lex_strings.make(p[2]);
6356 # tmp->parm = 0;
6357 # delete[]p[2];
6358 # p[0] = tmp;
6359 # }
6360 ()
6361 def p_port_name_3(p):
6362 '''port_name : '.' IDENTIFIER '(' ')' '''
6363 if(parse_debug): print('port_name_3', list(p))
6364 # { named_pexpr_t*tmp = new named_pexpr_t;
6365 # tmp->name = lex_strings.make(p[2]);
6366 # tmp->parm = 0;
6367 # delete[]p[2];
6368 # p[0] = tmp;
6369 # }
6370 ()
6371 def p_port_name_4(p):
6372 '''port_name : '.' IDENTIFIER '''
6373 if(parse_debug): print('port_name_4', list(p))
6374 # { named_pexpr_t*tmp = new named_pexpr_t;
6375 # tmp->name = lex_strings.make(p[2]);
6376 # tmp->parm = new PEIdent(lex_strings.make(p[2]), true);
6377 # FILE_NAME(tmp->parm, @1);
6378 # delete[]p[2];
6379 # p[0] = tmp;
6380 # }
6381 ()
6382 def p_port_name_5(p):
6383 '''port_name : K_DOTSTAR '''
6384 if(parse_debug): print('port_name_5', list(p))
6385 # { named_pexpr_t*tmp = new named_pexpr_t;
6386 # tmp->name = lex_strings.make("*");
6387 # tmp->parm = 0;
6388 # p[0] = tmp;
6389 # }
6390 ()
6391 def p_port_name_list_1(p):
6392 '''port_name_list : port_name_list ',' port_name '''
6393 if(parse_debug): print('port_name_list_1', list(p))
6394 # { list<named_pexpr_t>*tmp = p[1];
6395 # tmp->push_back(*p[3]);
6396 # delete p[3];
6397 # p[0] = tmp;
6398 # }
6399 ()
6400 def p_port_name_list_2(p):
6401 '''port_name_list : port_name '''
6402 if(parse_debug): print('port_name_list_2', list(p))
6403 # { list<named_pexpr_t>*tmp = new list<named_pexpr_t>;
6404 # tmp->push_back(*p[1]);
6405 # delete p[1];
6406 # p[0] = tmp;
6407 # }
6408 ()
6409 def p_port_reference_1(p):
6410 '''port_reference : IDENTIFIER '''
6411 if(parse_debug): print('port_reference_1', list(p))
6412 # { Module::port_t*ptmp;
6413 # perm_string name = lex_strings.make(p[1]);
6414 # ptmp = pform_module_port_reference(name, @1.text, @1.first_line);
6415 # delete[]p[1];
6416 # p[0] = ptmp;
6417 # }
6418 ()
6419 def p_port_reference_2(p):
6420 '''port_reference : IDENTIFIER '[' expression ':' expression ']' '''
6421 if(parse_debug): print('port_reference_2', list(p))
6422 # { index_component_t itmp;
6423 # itmp.sel = index_component_t::SEL_PART;
6424 # itmp.msb = p[3];
6425 # itmp.lsb = p[5];
6426 #
6427 # name_component_t ntmp (lex_strings.make(p[1]));
6428 # ntmp.index.push_back(itmp);
6429 #
6430 # pform_name_t pname;
6431 # pname.push_back(ntmp);
6432 #
6433 # PEIdent*wtmp = new PEIdent(pname);
6434 # FILE_NAME(wtmp, @1);
6435 #
6436 # Module::port_t*ptmp = new Module::port_t;
6437 # ptmp->name = perm_string();
6438 # ptmp->expr.push_back(wtmp);
6439 #
6440 # delete[]p[1];
6441 # p[0] = ptmp;
6442 # }
6443 ()
6444 def p_port_reference_3(p):
6445 '''port_reference : IDENTIFIER '[' expression ']' '''
6446 if(parse_debug): print('port_reference_3', list(p))
6447 # { index_component_t itmp;
6448 # itmp.sel = index_component_t::SEL_BIT;
6449 # itmp.msb = p[3];
6450 # itmp.lsb = 0;
6451 #
6452 # name_component_t ntmp (lex_strings.make(p[1]));
6453 # ntmp.index.push_back(itmp);
6454 #
6455 # pform_name_t pname;
6456 # pname.push_back(ntmp);
6457 #
6458 # PEIdent*tmp = new PEIdent(pname);
6459 # FILE_NAME(tmp, @1);
6460 #
6461 # Module::port_t*ptmp = new Module::port_t;
6462 # ptmp->name = perm_string();
6463 # ptmp->expr.push_back(tmp);
6464 # delete[]p[1];
6465 # p[0] = ptmp;
6466 # }
6467 ()
6468 def p_port_reference_4(p):
6469 '''port_reference : IDENTIFIER '[' error ']' '''
6470 if(parse_debug): print('port_reference_4', list(p))
6471 # { yyerror(@1, "error: invalid port bit select");
6472 # Module::port_t*ptmp = new Module::port_t;
6473 # PEIdent*wtmp = new PEIdent(lex_strings.make(p[1]));
6474 # FILE_NAME(wtmp, @1);
6475 # ptmp->name = lex_strings.make(p[1]);
6476 # ptmp->expr.push_back(wtmp);
6477 # delete[]p[1];
6478 # p[0] = ptmp;
6479 # }
6480 ()
6481 def p_port_reference_list_1(p):
6482 '''port_reference_list : port_reference '''
6483 if(parse_debug): print('port_reference_list_1', list(p))
6484 p[0] = p[1]
6485 ()
6486 def p_port_reference_list_2(p):
6487 '''port_reference_list : port_reference_list ',' port_reference '''
6488 if(parse_debug): print('port_reference_list_2', list(p))
6489 # { Module::port_t*tmp = p[1];
6490 # append(tmp->expr, p[3]->expr);
6491 # delete p[3];
6492 # p[0] = tmp;
6493 # }
6494 ()
6495 def p_dimensions_opt_1(p):
6496 '''dimensions_opt : '''
6497 if(parse_debug>2): print('dimensions_opt_1', list(p))
6498 # { p[0] = None }
6499 ()
6500 def p_dimensions_opt_2(p):
6501 '''dimensions_opt : dimensions '''
6502 if(parse_debug): print('dimensions_opt_2', list(p))
6503 p[0] = p[1]
6504 ()
6505 def p_dimensions_1(p):
6506 '''dimensions : variable_dimension '''
6507 if(parse_debug): print('dimensions_1', list(p))
6508 p[0] = p[1]
6509 ()
6510 def p_dimensions_2(p):
6511 '''dimensions : dimensions variable_dimension '''
6512 if(parse_debug): print('dimensions_2', list(p))
6513 # { list<pform_range_t> *tmp = p[1];
6514 # if (p[2]) {
6515 # tmp->splice(tmp->end(), *p[2]);
6516 # delete p[2];
6517 # }
6518 # p[0] = tmp;
6519 # }
6520 ()
6521 def p_register_variable_1(p):
6522 '''register_variable : IDENTIFIER dimensions_opt '''
6523 if(parse_debug): print('register_variable_1', list(p))
6524 # { perm_string name = lex_strings.make(p[1]);
6525 # pform_makewire(@1, name, NetNet::REG,
6526 # NetNet::NOT_A_PORT, IVL_VT_NO_TYPE, 0);
6527 # pform_set_reg_idx(name, p[2]);
6528 # p[0] = p[1];
6529 # }
6530 ()
6531 def p_register_variable_2(p):
6532 '''register_variable : IDENTIFIER dimensions_opt '=' expression '''
6533 if(parse_debug): print('register_variable_2', list(p))
6534 # { if (pform_peek_scope()->var_init_needs_explicit_lifetime()
6535 # && (var_lifetime == LexicalScope::INHERITED)) {
6536 # cerr << @3 << ": warning: Static variable initialization requires "
6537 # "explicit lifetime in this context." << endl;
6538 # warn_count += 1;
6539 # }
6540 # perm_string name = lex_strings.make(p[1]);
6541 # pform_makewire(@1, name, NetNet::REG,
6542 # NetNet::NOT_A_PORT, IVL_VT_NO_TYPE, 0);
6543 # pform_set_reg_idx(name, p[2]);
6544 # pform_make_var_init(@1, name, p[4]);
6545 # p[0] = p[1];
6546 # }
6547 ()
6548 def p_register_variable_list_1(p):
6549 '''register_variable_list : register_variable '''
6550 if(parse_debug): print('register_variable_list_1', list(p))
6551 # { list<perm_string>*tmp = new list<perm_string>;
6552 # tmp->push_back(lex_strings.make(p[1]));
6553 # p[0] = tmp;
6554 # delete[]p[1];
6555 # }
6556 ()
6557 def p_register_variable_list_2(p):
6558 '''register_variable_list : register_variable_list ',' register_variable '''
6559 if(parse_debug): print('register_variable_list_2', list(p))
6560 # { list<perm_string>*tmp = p[1];
6561 # tmp->push_back(lex_strings.make(p[3]));
6562 # p[0] = tmp;
6563 # delete[]p[3];
6564 # }
6565 ()
6566 def p_net_variable_1(p):
6567 '''net_variable : IDENTIFIER dimensions_opt '''
6568 if(parse_debug): print('net_variable_1', list(p))
6569 # { perm_string name = lex_strings.make(p[1]);
6570 # pform_makewire(@1, name, NetNet::IMPLICIT,
6571 # NetNet::NOT_A_PORT, IVL_VT_NO_TYPE, 0);
6572 # pform_set_reg_idx(name, p[2]);
6573 # p[0] = p[1];
6574 # }
6575 ()
6576 def p_net_variable_list_1(p):
6577 '''net_variable_list : net_variable '''
6578 if(parse_debug): print('net_variable_list_1', list(p))
6579 # { list<perm_string>*tmp = new list<perm_string>;
6580 # tmp->push_back(lex_strings.make(p[1]));
6581 # p[0] = tmp;
6582 # delete[]p[1];
6583 # }
6584 ()
6585 def p_net_variable_list_2(p):
6586 '''net_variable_list : net_variable_list ',' net_variable '''
6587 if(parse_debug): print('net_variable_list_2', list(p))
6588 # { list<perm_string>*tmp = p[1];
6589 # tmp->push_back(lex_strings.make(p[3]));
6590 # p[0] = tmp;
6591 # delete[]p[3];
6592 # }
6593 ()
6594 def p_event_variable_1(p):
6595 '''event_variable : IDENTIFIER dimensions_opt '''
6596 if(parse_debug): print('event_variable_1', list(p))
6597 # { if (p[2]) {
6598 # yyerror(@2, "sorry: event arrays are not supported.");
6599 # delete p[2];
6600 # }
6601 # p[0] = p[1];
6602 # }
6603 ()
6604 def p_event_variable_list_1(p):
6605 '''event_variable_list : event_variable '''
6606 if(parse_debug): print('event_variable_list_1', list(p))
6607 # { p[0] = list_from_identifier(p[1]); }
6608 ()
6609 def p_event_variable_list_2(p):
6610 '''event_variable_list : event_variable_list ',' event_variable '''
6611 if(parse_debug): print('event_variable_list_2', list(p))
6612 # { p[0] = list_from_identifier(p[1], p[3]); }
6613 ()
6614 def p_specify_item_1(p):
6615 '''specify_item : K_specparam specparam_decl ';' '''
6616 if(parse_debug): print('specify_item_1', list(p))
6617 ()
6618 def p_specify_item_2(p):
6619 '''specify_item : specify_simple_path_decl ';' '''
6620 if(parse_debug): print('specify_item_2', list(p))
6621 # { pform_module_specify_path(p[1]);
6622 # }
6623 ()
6624 def p_specify_item_3(p):
6625 '''specify_item : specify_edge_path_decl ';' '''
6626 if(parse_debug): print('specify_item_3', list(p))
6627 # { pform_module_specify_path(p[1]);
6628 # }
6629 ()
6630 def p_specify_item_4(p):
6631 '''specify_item : K_if '(' expression ')' specify_simple_path_decl ';' '''
6632 if(parse_debug): print('specify_item_4', list(p))
6633 # { PSpecPath*tmp = p[5];
6634 # if (tmp) {
6635 # tmp->conditional = true;
6636 # tmp->condition = p[3];
6637 # }
6638 # pform_module_specify_path(tmp);
6639 # }
6640 ()
6641 def p_specify_item_5(p):
6642 '''specify_item : K_if '(' expression ')' specify_edge_path_decl ';' '''
6643 if(parse_debug): print('specify_item_5', list(p))
6644 # { PSpecPath*tmp = p[5];
6645 # if (tmp) {
6646 # tmp->conditional = true;
6647 # tmp->condition = p[3];
6648 # }
6649 # pform_module_specify_path(tmp);
6650 # }
6651 ()
6652 def p_specify_item_6(p):
6653 '''specify_item : K_ifnone specify_simple_path_decl ';' '''
6654 if(parse_debug): print('specify_item_6', list(p))
6655 # { PSpecPath*tmp = p[2];
6656 # if (tmp) {
6657 # tmp->conditional = true;
6658 # tmp->condition = 0;
6659 # }
6660 # pform_module_specify_path(tmp);
6661 # }
6662 ()
6663 def p_specify_item_7(p):
6664 '''specify_item : K_ifnone specify_edge_path_decl ';' '''
6665 if(parse_debug): print('specify_item_7', list(p))
6666 # { yyerror(@1, "Sorry: ifnone with an edge-sensitive path is "
6667 # "not supported.");
6668 # yyerrok;
6669 # }
6670 ()
6671 def p_specify_item_8(p):
6672 '''specify_item : K_Sfullskew '(' spec_reference_event ',' spec_reference_event ',' delay_value ',' delay_value spec_notifier_opt ')' ';' '''
6673 if(parse_debug): print('specify_item_8', list(p))
6674 # { delete p[7];
6675 # delete p[9];
6676 # }
6677 ()
6678 def p_specify_item_9(p):
6679 '''specify_item : K_Shold '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
6680 if(parse_debug): print('specify_item_9', list(p))
6681 # { delete p[7];
6682 # }
6683 ()
6684 def p_specify_item_10(p):
6685 '''specify_item : K_Snochange '(' spec_reference_event ',' spec_reference_event ',' delay_value ',' delay_value spec_notifier_opt ')' ';' '''
6686 if(parse_debug): print('specify_item_10', list(p))
6687 # { delete p[7];
6688 # delete p[9];
6689 # }
6690 ()
6691 def p_specify_item_11(p):
6692 '''specify_item : K_Speriod '(' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
6693 if(parse_debug): print('specify_item_11', list(p))
6694 # { delete p[5];
6695 # }
6696 ()
6697 def p_specify_item_12(p):
6698 '''specify_item : K_Srecovery '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
6699 if(parse_debug): print('specify_item_12', list(p))
6700 # { delete p[7];
6701 # }
6702 ()
6703 def p_specify_item_13(p):
6704 '''specify_item : K_Srecrem '(' spec_reference_event ',' spec_reference_event ',' delay_value ',' delay_value spec_notifier_opt ')' ';' '''
6705 if(parse_debug): print('specify_item_13', list(p))
6706 # { delete p[7];
6707 # delete p[9];
6708 # }
6709 ()
6710 def p_specify_item_14(p):
6711 '''specify_item : K_Sremoval '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
6712 if(parse_debug): print('specify_item_14', list(p))
6713 # { delete p[7];
6714 # }
6715 ()
6716 def p_specify_item_15(p):
6717 '''specify_item : K_Ssetup '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
6718 if(parse_debug): print('specify_item_15', list(p))
6719 # { delete p[7];
6720 # }
6721 ()
6722 def p_specify_item_16(p):
6723 '''specify_item : K_Ssetuphold '(' spec_reference_event ',' spec_reference_event ',' delay_value ',' delay_value spec_notifier_opt ')' ';' '''
6724 if(parse_debug): print('specify_item_16', list(p))
6725 # { delete p[7];
6726 # delete p[9];
6727 # }
6728 ()
6729 def p_specify_item_17(p):
6730 '''specify_item : K_Sskew '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
6731 if(parse_debug): print('specify_item_17', list(p))
6732 # { delete p[7];
6733 # }
6734 ()
6735 def p_specify_item_18(p):
6736 '''specify_item : K_Stimeskew '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
6737 if(parse_debug): print('specify_item_18', list(p))
6738 # { delete p[7];
6739 # }
6740 ()
6741 def p_specify_item_19(p):
6742 '''specify_item : K_Swidth '(' spec_reference_event ',' delay_value ',' expression spec_notifier_opt ')' ';' '''
6743 if(parse_debug): print('specify_item_19', list(p))
6744 # { delete p[5];
6745 # delete p[7];
6746 # }
6747 ()
6748 def p_specify_item_20(p):
6749 '''specify_item : K_Swidth '(' spec_reference_event ',' delay_value ')' ';' '''
6750 if(parse_debug): print('specify_item_20', list(p))
6751 # { delete p[5];
6752 # }
6753 ()
6754 def p_specify_item_21(p):
6755 '''specify_item : K_pulsestyle_onevent specify_path_identifiers ';' '''
6756 if(parse_debug): print('specify_item_21', list(p))
6757 # { delete p[2];
6758 # }
6759 ()
6760 def p_specify_item_22(p):
6761 '''specify_item : K_pulsestyle_ondetect specify_path_identifiers ';' '''
6762 if(parse_debug): print('specify_item_22', list(p))
6763 # { delete p[2];
6764 # }
6765 ()
6766 def p_specify_item_23(p):
6767 '''specify_item : K_showcancelled specify_path_identifiers ';' '''
6768 if(parse_debug): print('specify_item_23', list(p))
6769 # { delete p[2];
6770 # }
6771 ()
6772 def p_specify_item_24(p):
6773 '''specify_item : K_noshowcancelled specify_path_identifiers ';' '''
6774 if(parse_debug): print('specify_item_24', list(p))
6775 # { delete p[2];
6776 # }
6777 ()
6778 def p_specify_item_list_1(p):
6779 '''specify_item_list : specify_item '''
6780 if(parse_debug): print('specify_item_list_1', list(p))
6781 ()
6782 def p_specify_item_list_2(p):
6783 '''specify_item_list : specify_item_list specify_item '''
6784 if(parse_debug): print('specify_item_list_2', list(p))
6785 ()
6786 def p_specify_item_list_opt_1(p):
6787 '''specify_item_list_opt : '''
6788 if(parse_debug): print('specify_item_list_opt_1', list(p))
6789 # { }
6790 ()
6791 def p_specify_item_list_opt_2(p):
6792 '''specify_item_list_opt : specify_item_list '''
6793 if(parse_debug): print('specify_item_list_opt_2', list(p))
6794 # { }
6795 ()
6796 def p_specify_edge_path_decl_1(p):
6797 '''specify_edge_path_decl : specify_edge_path '=' '(' delay_value_list ')' '''
6798 if(parse_debug): print('specify_edge_path_decl_1', list(p))
6799 # { p[0] = pform_assign_path_delay(p[1], p[4]); }
6800 ()
6801 def p_specify_edge_path_decl_2(p):
6802 '''specify_edge_path_decl : specify_edge_path '=' delay_value_simple '''
6803 if(parse_debug): print('specify_edge_path_decl_2', list(p))
6804 # { list<PExpr*>*tmp = new list<PExpr*>;
6805 # tmp->push_back(p[3]);
6806 # p[0] = pform_assign_path_delay(p[1], tmp);
6807 # }
6808 ()
6809 def p_edge_operator_1(p):
6810 '''edge_operator : K_posedge '''
6811 if(parse_debug): print('edge_operator_1', list(p))
6812 p[0] = True
6813 ()
6814 def p_edge_operator_2(p):
6815 '''edge_operator : K_negedge '''
6816 if(parse_debug): print('edge_operator_2', list(p))
6817 p[0] = False
6818 ()
6819 def p_specify_edge_path_1(p):
6820 '''specify_edge_path : '(' specify_path_identifiers spec_polarity K_EG '(' specify_path_identifiers polarity_operator expression ')' ')' '''
6821 if(parse_debug): print('specify_edge_path_1', list(p))
6822 # { int edge_flag = 0;
6823 # p[0] = pform_make_specify_edge_path(@1, edge_flag, p[2], p[3], false, p[6], p[8]); }
6824 ()
6825 def p_specify_edge_path_2(p):
6826 '''specify_edge_path : '(' edge_operator specify_path_identifiers spec_polarity K_EG '(' specify_path_identifiers polarity_operator expression ')' ')' '''
6827 if(parse_debug): print('specify_edge_path_2', list(p))
6828 # { int edge_flag = p[2]? 1 : -1;
6829 # p[0] = pform_make_specify_edge_path(@1, edge_flag, p[3], p[4], false, p[7], p[9]);}
6830 ()
6831 def p_specify_edge_path_3(p):
6832 '''specify_edge_path : '(' specify_path_identifiers spec_polarity K_SG '(' specify_path_identifiers polarity_operator expression ')' ')' '''
6833 if(parse_debug): print('specify_edge_path_3', list(p))
6834 # { int edge_flag = 0;
6835 # p[0] = pform_make_specify_edge_path(@1, edge_flag, p[2], p[3], true, p[6], p[8]); }
6836 ()
6837 def p_specify_edge_path_4(p):
6838 '''specify_edge_path : '(' edge_operator specify_path_identifiers spec_polarity K_SG '(' specify_path_identifiers polarity_operator expression ')' ')' '''
6839 if(parse_debug): print('specify_edge_path_4', list(p))
6840 # { int edge_flag = p[2]? 1 : -1;
6841 # p[0] = pform_make_specify_edge_path(@1, edge_flag, p[3], p[4], true, p[7], p[9]); }
6842 ()
6843 def p_polarity_operator_1(p):
6844 '''polarity_operator : K_PO_POS '''
6845 if(parse_debug): print('polarity_operator_1', list(p))
6846 ()
6847 def p_polarity_operator_2(p):
6848 '''polarity_operator : K_PO_NEG '''
6849 if(parse_debug): print('polarity_operator_2', list(p))
6850 ()
6851 def p_polarity_operator_3(p):
6852 '''polarity_operator : ':' '''
6853 if(parse_debug): print('polarity_operator_3', list(p))
6854 ()
6855 def p_specify_simple_path_decl_1(p):
6856 '''specify_simple_path_decl : specify_simple_path '=' '(' delay_value_list ')' '''
6857 if(parse_debug): print('specify_simple_path_decl_1', list(p))
6858 # { p[0] = pform_assign_path_delay(p[1], p[4]); }
6859 ()
6860 def p_specify_simple_path_decl_2(p):
6861 '''specify_simple_path_decl : specify_simple_path '=' delay_value_simple '''
6862 if(parse_debug): print('specify_simple_path_decl_2', list(p))
6863 # { list<PExpr*>*tmp = new list<PExpr*>;
6864 # tmp->push_back(p[3]);
6865 # p[0] = pform_assign_path_delay(p[1], tmp);
6866 # }
6867 ()
6868 def p_specify_simple_path_decl_3(p):
6869 '''specify_simple_path_decl : specify_simple_path '=' '(' error ')' '''
6870 if(parse_debug): print('specify_simple_path_decl_3', list(p))
6871 # { yyerror(@3, "Syntax error in delay value list.");
6872 # yyerrok;
6873 # p[0] = None
6874 # }
6875 ()
6876 def p_specify_simple_path_1(p):
6877 '''specify_simple_path : '(' specify_path_identifiers spec_polarity K_EG specify_path_identifiers ')' '''
6878 if(parse_debug): print('specify_simple_path_1', list(p))
6879 # { p[0] = pform_make_specify_path(@1, p[2], p[3], false, p[5]); }
6880 ()
6881 def p_specify_simple_path_2(p):
6882 '''specify_simple_path : '(' specify_path_identifiers spec_polarity K_SG specify_path_identifiers ')' '''
6883 if(parse_debug): print('specify_simple_path_2', list(p))
6884 # { p[0] = pform_make_specify_path(@1, p[2], p[3], true, p[5]); }
6885 ()
6886 def p_specify_simple_path_3(p):
6887 '''specify_simple_path : '(' error ')' '''
6888 if(parse_debug): print('specify_simple_path_3', list(p))
6889 # { yyerror(@1, "Invalid simple path");
6890 # yyerrok;
6891 # }
6892 ()
6893 def p_specify_path_identifiers_1(p):
6894 '''specify_path_identifiers : IDENTIFIER '''
6895 if(parse_debug): print('specify_path_identifiers_1', list(p))
6896 # { list<perm_string>*tmp = new list<perm_string>;
6897 # tmp->push_back(lex_strings.make(p[1]));
6898 # p[0] = tmp;
6899 # delete[]p[1];
6900 # }
6901 ()
6902 def p_specify_path_identifiers_2(p):
6903 '''specify_path_identifiers : IDENTIFIER '[' expr_primary ']' '''
6904 if(parse_debug): print('specify_path_identifiers_2', list(p))
6905 # { if (gn_specify_blocks_flag) {
6906 # yywarn(@4, "Bit selects are not currently supported "
6907 # "in path declarations. The declaration "
6908 # "will be applied to the whole vector.");
6909 # }
6910 # list<perm_string>*tmp = new list<perm_string>;
6911 # tmp->push_back(lex_strings.make(p[1]));
6912 # p[0] = tmp;
6913 # delete[]p[1];
6914 # }
6915 ()
6916 def p_specify_path_identifiers_3(p):
6917 '''specify_path_identifiers : IDENTIFIER '[' expr_primary polarity_operator expr_primary ']' '''
6918 if(parse_debug): print('specify_path_identifiers_3', list(p))
6919 # { if (gn_specify_blocks_flag) {
6920 # yywarn(@4, "Part selects are not currently supported "
6921 # "in path declarations. The declaration "
6922 # "will be applied to the whole vector.");
6923 # }
6924 # list<perm_string>*tmp = new list<perm_string>;
6925 # tmp->push_back(lex_strings.make(p[1]));
6926 # p[0] = tmp;
6927 # delete[]p[1];
6928 # }
6929 ()
6930 def p_specify_path_identifiers_4(p):
6931 '''specify_path_identifiers : specify_path_identifiers ',' IDENTIFIER '''
6932 if(parse_debug): print('specify_path_identifiers_4', list(p))
6933 # { list<perm_string>*tmp = p[1];
6934 # tmp->push_back(lex_strings.make(p[3]));
6935 # p[0] = tmp;
6936 # delete[]p[3];
6937 # }
6938 ()
6939 def p_specify_path_identifiers_5(p):
6940 '''specify_path_identifiers : specify_path_identifiers ',' IDENTIFIER '[' expr_primary ']' '''
6941 if(parse_debug): print('specify_path_identifiers_5', list(p))
6942 # { if (gn_specify_blocks_flag) {
6943 # yywarn(@4, "Bit selects are not currently supported "
6944 # "in path declarations. The declaration "
6945 # "will be applied to the whole vector.");
6946 # }
6947 # list<perm_string>*tmp = p[1];
6948 # tmp->push_back(lex_strings.make(p[3]));
6949 # p[0] = tmp;
6950 # delete[]p[3];
6951 # }
6952 ()
6953 def p_specify_path_identifiers_6(p):
6954 '''specify_path_identifiers : specify_path_identifiers ',' IDENTIFIER '[' expr_primary polarity_operator expr_primary ']' '''
6955 if(parse_debug): print('specify_path_identifiers_6', list(p))
6956 # { if (gn_specify_blocks_flag) {
6957 # yywarn(@4, "Part selects are not currently supported "
6958 # "in path declarations. The declaration "
6959 # "will be applied to the whole vector.");
6960 # }
6961 # list<perm_string>*tmp = p[1];
6962 # tmp->push_back(lex_strings.make(p[3]));
6963 # p[0] = tmp;
6964 # delete[]p[3];
6965 # }
6966 ()
6967 def p_specparam_1(p):
6968 '''specparam : IDENTIFIER '=' expression '''
6969 if(parse_debug): print('specparam_1', list(p))
6970 # { PExpr*tmp = p[3];
6971 # pform_set_specparam(@1, lex_strings.make(p[1]),
6972 # param_active_range, tmp);
6973 # delete[]p[1];
6974 # }
6975 ()
6976 def p_specparam_2(p):
6977 '''specparam : IDENTIFIER '=' expression ':' expression ':' expression '''
6978 if(parse_debug): print('specparam_2', list(p))
6979 # { PExpr*tmp = 0;
6980 # switch (min_typ_max_flag) {
6981 # case MIN:
6982 # tmp = p[3];
6983 # delete p[5];
6984 # delete p[7];
6985 # break;
6986 # case TYP:
6987 # delete p[3];
6988 # tmp = p[5];
6989 # delete p[7];
6990 # break;
6991 # case MAX:
6992 # delete p[3];
6993 # delete p[5];
6994 # tmp = p[7];
6995 # break;
6996 # }
6997 # if (min_typ_max_warn > 0) {
6998 # cerr << tmp->get_fileline() << ": warning: choosing ";
6999 # switch (min_typ_max_flag) {
7000 # case MIN:
7001 # cerr << "min";
7002 # break;
7003 # case TYP:
7004 # cerr << "typ";
7005 # break;
7006 # case MAX:
7007 # cerr << "max";
7008 # break;
7009 # }
7010 # cerr << " expression." << endl;
7011 # min_typ_max_warn -= 1;
7012 # }
7013 # pform_set_specparam(@1, lex_strings.make(p[1]),
7014 # param_active_range, tmp);
7015 # delete[]p[1];
7016 # }
7017 ()
7018 def p_specparam_3(p):
7019 '''specparam : PATHPULSE_IDENTIFIER '=' expression '''
7020 if(parse_debug): print('specparam_3', list(p))
7021 # { delete[]p[1];
7022 # delete p[3];
7023 # }
7024 ()
7025 def p_specparam_4(p):
7026 '''specparam : PATHPULSE_IDENTIFIER '=' '(' expression ',' expression ')' '''
7027 if(parse_debug): print('specparam_4', list(p))
7028 # { delete[]p[1];
7029 # delete p[4];
7030 # delete p[6];
7031 # }
7032 ()
7033 def p_specparam_list_1(p):
7034 '''specparam_list : specparam '''
7035 if(parse_debug): print('specparam_list_1', list(p))
7036 ()
7037 def p_specparam_list_2(p):
7038 '''specparam_list : specparam_list ',' specparam '''
7039 if(parse_debug): print('specparam_list_2', list(p))
7040 ()
7041 def p_specparam_decl_1(p):
7042 '''specparam_decl : specparam_list '''
7043 if(parse_debug): print('specparam_decl_1', list(p))
7044 ()
7045 def p_specparam_decl_2(p):
7046 '''specparam_decl : dimensions _embed0_specparam_decl specparam_list '''
7047 if(parse_debug): print('specparam_decl_2', list(p))
7048 # { param_active_range = 0; }
7049 ()
7050 def p__embed0_specparam_decl(p):
7051 '''_embed0_specparam_decl : '''
7052 # { param_active_range = p[1]; }
7053 ()
7054 def p_spec_polarity_1(p):
7055 '''spec_polarity : '+' '''
7056 if(parse_debug): print('spec_polarity_1', list(p))
7057 # { p[0] = '+'; }
7058 ()
7059 def p_spec_polarity_2(p):
7060 '''spec_polarity : '-' '''
7061 if(parse_debug): print('spec_polarity_2', list(p))
7062 # { p[0] = '-'; }
7063 ()
7064 def p_spec_polarity_3(p):
7065 '''spec_polarity : '''
7066 if(parse_debug): print('spec_polarity_3', list(p))
7067 # { p[0] = None }
7068 ()
7069 def p_spec_reference_event_1(p):
7070 '''spec_reference_event : K_posedge expression '''
7071 if(parse_debug): print('spec_reference_event_1', list(p))
7072 # { delete p[2]; }
7073 ()
7074 def p_spec_reference_event_2(p):
7075 '''spec_reference_event : K_negedge expression '''
7076 if(parse_debug): print('spec_reference_event_2', list(p))
7077 # { delete p[2]; }
7078 ()
7079 def p_spec_reference_event_3(p):
7080 '''spec_reference_event : K_posedge expr_primary K_TAND expression '''
7081 if(parse_debug): print('spec_reference_event_3', list(p))
7082 # { delete p[2];
7083 # delete p[4];
7084 # }
7085 ()
7086 def p_spec_reference_event_4(p):
7087 '''spec_reference_event : K_negedge expr_primary K_TAND expression '''
7088 if(parse_debug): print('spec_reference_event_4', list(p))
7089 # { delete p[2];
7090 # delete p[4];
7091 # }
7092 ()
7093 def p_spec_reference_event_5(p):
7094 '''spec_reference_event : K_edge '[' edge_descriptor_list ']' expr_primary '''
7095 if(parse_debug): print('spec_reference_event_5', list(p))
7096 # { delete p[5]; }
7097 ()
7098 def p_spec_reference_event_6(p):
7099 '''spec_reference_event : K_edge '[' edge_descriptor_list ']' expr_primary K_TAND expression '''
7100 if(parse_debug): print('spec_reference_event_6', list(p))
7101 # { delete p[5];
7102 # delete p[7];
7103 # }
7104 ()
7105 def p_spec_reference_event_7(p):
7106 '''spec_reference_event : expr_primary K_TAND expression '''
7107 if(parse_debug): print('spec_reference_event_7', list(p))
7108 # { delete p[1];
7109 # delete p[3];
7110 # }
7111 ()
7112 def p_spec_reference_event_8(p):
7113 '''spec_reference_event : expr_primary '''
7114 if(parse_debug): print('spec_reference_event_8', list(p))
7115 # { delete p[1]; }
7116 ()
7117 def p_edge_descriptor_list_1(p):
7118 '''edge_descriptor_list : edge_descriptor_list ',' K_edge_descriptor '''
7119 if(parse_debug): print('edge_descriptor_list_1', list(p))
7120 ()
7121 def p_edge_descriptor_list_2(p):
7122 '''edge_descriptor_list : K_edge_descriptor '''
7123 if(parse_debug): print('edge_descriptor_list_2', list(p))
7124 ()
7125 def p_spec_notifier_opt_1(p):
7126 '''spec_notifier_opt : '''
7127 if(parse_debug): print('spec_notifier_opt_1', list(p))
7128 # { }
7129 ()
7130 def p_spec_notifier_opt_2(p):
7131 '''spec_notifier_opt : spec_notifier '''
7132 if(parse_debug): print('spec_notifier_opt_2', list(p))
7133 # { }
7134 ()
7135 def p_spec_notifier_1(p):
7136 '''spec_notifier : ',' '''
7137 if(parse_debug): print('spec_notifier_1', list(p))
7138 # { args_after_notifier = 0; }
7139 ()
7140 def p_spec_notifier_2(p):
7141 '''spec_notifier : ',' hierarchy_identifier '''
7142 if(parse_debug): print('spec_notifier_2', list(p))
7143 # { args_after_notifier = 0; delete p[2]; }
7144 ()
7145 def p_spec_notifier_3(p):
7146 '''spec_notifier : spec_notifier ',' '''
7147 if(parse_debug): print('spec_notifier_3', list(p))
7148 # { args_after_notifier += 1; }
7149 ()
7150 def p_spec_notifier_4(p):
7151 '''spec_notifier : spec_notifier ',' hierarchy_identifier '''
7152 if(parse_debug): print('spec_notifier_4', list(p))
7153 # { args_after_notifier += 1;
7154 # if (args_after_notifier >= 3) {
7155 # cerr << @3 << ": warning: timing checks are not supported "
7156 # "and delayed signal \"" << *p[3]
7157 # << "\" will not be driven." << endl;
7158 # }
7159 # delete p[3]; }
7160 ()
7161 def p_spec_notifier_5(p):
7162 '''spec_notifier : IDENTIFIER '''
7163 if(parse_debug): print('spec_notifier_5', list(p))
7164 # { args_after_notifier = 0; delete[]p[1]; }
7165 ()
7166 def p_statement_item_1(p):
7167 '''statement_item : K_assign lpvalue '=' expression ';' '''
7168 if(parse_debug): print('statement_item_1', list(p))
7169 # { PCAssign*tmp = new PCAssign(p[2], p[4]);
7170 # FILE_NAME(tmp, @1);
7171 # p[0] = tmp;
7172 # }
7173 ()
7174 def p_statement_item_2(p):
7175 '''statement_item : K_deassign lpvalue ';' '''
7176 if(parse_debug): print('statement_item_2', list(p))
7177 # { PDeassign*tmp = new PDeassign(p[2]);
7178 # FILE_NAME(tmp, @1);
7179 # p[0] = tmp;
7180 # }
7181 ()
7182 def p_statement_item_3(p):
7183 '''statement_item : K_force lpvalue '=' expression ';' '''
7184 if(parse_debug): print('statement_item_3', list(p))
7185 # { PForce*tmp = new PForce(p[2], p[4]);
7186 # FILE_NAME(tmp, @1);
7187 # p[0] = tmp;
7188 # }
7189 ()
7190 def p_statement_item_4(p):
7191 '''statement_item : K_release lpvalue ';' '''
7192 if(parse_debug): print('statement_item_4', list(p))
7193 # { PRelease*tmp = new PRelease(p[2]);
7194 # FILE_NAME(tmp, @1);
7195 # p[0] = tmp;
7196 # }
7197 ()
7198 def p_statement_item_5(p):
7199 '''statement_item : K_begin K_end '''
7200 if(parse_debug): print('statement_item_5', list(p))
7201 # { PBlock*tmp = new PBlock(PBlock::BL_SEQ);
7202 # FILE_NAME(tmp, @1);
7203 # p[0] = tmp;
7204 # }
7205 ()
7206 def p_statement_item_6(p):
7207 '''statement_item : K_begin _embed0_statement_item block_item_decls_opt _embed1_statement_item statement_or_null_list K_end '''
7208 if(parse_debug): print('statement_item_6', list(p))
7209 # { PBlock*tmp;
7210 # if (p[3]) {
7211 # pform_pop_scope();
7212 # assert(! current_block_stack.empty());
7213 # tmp = current_block_stack.top();
7214 # current_block_stack.pop();
7215 # } else {
7216 # tmp = new PBlock(PBlock::BL_SEQ);
7217 # FILE_NAME(tmp, @1);
7218 # }
7219 # if (p[5]) tmp->set_statement(*p[5]);
7220 # delete p[5];
7221 # p[0] = tmp;
7222 # }
7223 ()
7224 def p_statement_item_7(p):
7225 '''statement_item : K_begin ':' IDENTIFIER _embed2_statement_item block_item_decls_opt statement_or_null_list_opt K_end endlabel_opt '''
7226 if(parse_debug): print('statement_item_7', list(p))
7227 # { pform_pop_scope();
7228 # assert(! current_block_stack.empty());
7229 # PBlock*tmp = current_block_stack.top();
7230 # current_block_stack.pop();
7231 # if (p[6]) tmp->set_statement(*p[6]);
7232 # delete p[6];
7233 # if (p[8]) {
7234 # if (strcmp(p[3],p[8]) != 0) {
7235 # yyerror(@8, "error: End label doesn't match begin name");
7236 # }
7237 # if (! gn_system_verilog()) {
7238 # yyerror(@8, "error: Begin end labels require "
7239 # "SystemVerilog.");
7240 # }
7241 # delete[]p[8];
7242 # }
7243 # delete[]p[3];
7244 # p[0] = tmp;
7245 # }
7246 ()
7247 def p_statement_item_8(p):
7248 '''statement_item : K_fork join_keyword '''
7249 if(parse_debug): print('statement_item_8', list(p))
7250 # { PBlock*tmp = new PBlock(p[2]);
7251 # FILE_NAME(tmp, @1);
7252 # p[0] = tmp;
7253 # }
7254 ()
7255 def p_statement_item_9(p):
7256 '''statement_item : K_fork _embed3_statement_item block_item_decls_opt _embed4_statement_item statement_or_null_list join_keyword '''
7257 if(parse_debug): print('statement_item_9', list(p))
7258 # { PBlock*tmp;
7259 # if (p[3]) {
7260 # pform_pop_scope();
7261 # assert(! current_block_stack.empty());
7262 # tmp = current_block_stack.top();
7263 # current_block_stack.pop();
7264 # tmp->set_join_type(p[6]);
7265 # } else {
7266 # tmp = new PBlock(p[6]);
7267 # FILE_NAME(tmp, @1);
7268 # }
7269 # if (p[5]) tmp->set_statement(*p[5]);
7270 # delete p[5];
7271 # p[0] = tmp;
7272 # }
7273 ()
7274 def p_statement_item_10(p):
7275 '''statement_item : K_fork ':' IDENTIFIER _embed5_statement_item block_item_decls_opt statement_or_null_list_opt join_keyword endlabel_opt '''
7276 if(parse_debug): print('statement_item_10', list(p))
7277 # { pform_pop_scope();
7278 # assert(! current_block_stack.empty());
7279 # PBlock*tmp = current_block_stack.top();
7280 # current_block_stack.pop();
7281 # tmp->set_join_type(p[7]);
7282 # if (p[6]) tmp->set_statement(*p[6]);
7283 # delete p[6];
7284 # if (p[8]) {
7285 # if (strcmp(p[3],p[8]) != 0) {
7286 # yyerror(@8, "error: End label doesn't match fork name");
7287 # }
7288 # if (! gn_system_verilog()) {
7289 # yyerror(@8, "error: Fork end labels require "
7290 # "SystemVerilog.");
7291 # }
7292 # delete[]p[8];
7293 # }
7294 # delete[]p[3];
7295 # p[0] = tmp;
7296 # }
7297 ()
7298 def p_statement_item_11(p):
7299 '''statement_item : K_disable hierarchy_identifier ';' '''
7300 if(parse_debug): print('statement_item_11', list(p))
7301 # { PDisable*tmp = new PDisable(*p[2]);
7302 # FILE_NAME(tmp, @1);
7303 # delete p[2];
7304 # p[0] = tmp;
7305 # }
7306 ()
7307 def p_statement_item_12(p):
7308 '''statement_item : K_disable K_fork ';' '''
7309 if(parse_debug): print('statement_item_12', list(p))
7310 # { pform_name_t tmp_name;
7311 # PDisable*tmp = new PDisable(tmp_name);
7312 # FILE_NAME(tmp, @1);
7313 # p[0] = tmp;
7314 # }
7315 ()
7316 def p_statement_item_13(p):
7317 '''statement_item : K_TRIGGER hierarchy_identifier ';' '''
7318 if(parse_debug): print('statement_item_13', list(p))
7319 # { PTrigger*tmp = new PTrigger(*p[2]);
7320 # FILE_NAME(tmp, @1);
7321 # delete p[2];
7322 # p[0] = tmp;
7323 # }
7324 ()
7325 def p_statement_item_14(p):
7326 '''statement_item : procedural_assertion_statement '''
7327 if(parse_debug): print('statement_item_14', list(p))
7328 p[0] = p[1]
7329 ()
7330 def p_statement_item_15(p):
7331 '''statement_item : loop_statement '''
7332 if(parse_debug): print('statement_item_15', list(p))
7333 p[0] = p[1]
7334 ()
7335 def p_statement_item_16(p):
7336 '''statement_item : jump_statement '''
7337 if(parse_debug): print('statement_item_16', list(p))
7338 p[0] = p[1]
7339 ()
7340 def p_statement_item_17(p):
7341 '''statement_item : K_case '(' expression ')' case_items K_endcase '''
7342 if(parse_debug): print('statement_item_17', list(p))
7343 # { PCase*tmp = new PCase(NetCase::EQ, p[3], p[5]);
7344 # FILE_NAME(tmp, @1);
7345 # p[0] = tmp;
7346 # }
7347 ()
7348 def p_statement_item_18(p):
7349 '''statement_item : K_casex '(' expression ')' case_items K_endcase '''
7350 if(parse_debug): print('statement_item_18', list(p))
7351 # { PCase*tmp = new PCase(NetCase::EQX, p[3], p[5]);
7352 # FILE_NAME(tmp, @1);
7353 # p[0] = tmp;
7354 # }
7355 ()
7356 def p_statement_item_19(p):
7357 '''statement_item : K_casez '(' expression ')' case_items K_endcase '''
7358 if(parse_debug): print('statement_item_19', list(p))
7359 # { PCase*tmp = new PCase(NetCase::EQZ, p[3], p[5]);
7360 # FILE_NAME(tmp, @1);
7361 # p[0] = tmp;
7362 # }
7363 ()
7364 def p_statement_item_20(p):
7365 '''statement_item : K_case '(' expression ')' error K_endcase '''
7366 if(parse_debug): print('statement_item_20', list(p))
7367 # { yyerrok; }
7368 ()
7369 def p_statement_item_21(p):
7370 '''statement_item : K_casex '(' expression ')' error K_endcase '''
7371 if(parse_debug): print('statement_item_21', list(p))
7372 # { yyerrok; }
7373 ()
7374 def p_statement_item_22(p):
7375 '''statement_item : K_casez '(' expression ')' error K_endcase '''
7376 if(parse_debug): print('statement_item_22', list(p))
7377 # { yyerrok; }
7378 ()
7379 def p_statement_item_23(p):
7380 '''statement_item : K_if '(' expression ')' statement_or_null %prec less_than_K_else '''
7381 if(parse_debug): print('statement_item_23', list(p))
7382 # { PCondit*tmp = new PCondit(p[3], p[5], 0);
7383 # FILE_NAME(tmp, @1);
7384 # p[0] = tmp;
7385 # }
7386 ()
7387 def p_statement_item_24(p):
7388 '''statement_item : K_if '(' expression ')' statement_or_null K_else statement_or_null '''
7389 if(parse_debug): print('statement_item_24', list(p))
7390 # { PCondit*tmp = new PCondit(p[3], p[5], p[7]);
7391 # FILE_NAME(tmp, @1);
7392 # p[0] = tmp;
7393 # }
7394 ()
7395 def p_statement_item_25(p):
7396 '''statement_item : K_if '(' error ')' statement_or_null %prec less_than_K_else '''
7397 if(parse_debug): print('statement_item_25', list(p))
7398 # { yyerror(@1, "error: Malformed conditional expression.");
7399 # p[0] = p[5];
7400 # }
7401 ()
7402 def p_statement_item_26(p):
7403 '''statement_item : K_if '(' error ')' statement_or_null K_else statement_or_null '''
7404 if(parse_debug): print('statement_item_26', list(p))
7405 # { yyerror(@1, "error: Malformed conditional expression.");
7406 # p[0] = p[5];
7407 # }
7408 ()
7409 def p_statement_item_27(p):
7410 '''statement_item : compressed_statement ';' '''
7411 if(parse_debug): print('statement_item_27', list(p))
7412 p[0] = p[1]
7413 ()
7414 def p_statement_item_28(p):
7415 '''statement_item : inc_or_dec_expression ';' '''
7416 if(parse_debug): print('statement_item_28', list(p))
7417 # { p[0] = pform_compressed_assign_from_inc_dec(@1, p[1]); }
7418 ()
7419 def p_statement_item_29(p):
7420 '''statement_item : delay1 statement_or_null '''
7421 if(parse_debug): print('statement_item_29', list(p))
7422 # { PExpr*del = p[1]->front();
7423 # assert(p[1]->size() == 1);
7424 # delete p[1];
7425 # PDelayStatement*tmp = new PDelayStatement(del, p[2]);
7426 # FILE_NAME(tmp, @1);
7427 # p[0] = tmp;
7428 # }
7429 ()
7430 def p_statement_item_30(p):
7431 '''statement_item : event_control statement_or_null '''
7432 if(parse_debug): print('statement_item_30', list(p))
7433 # { PEventStatement*tmp = p[1];
7434 # if (tmp == 0) {
7435 # yyerror(@1, "error: Invalid event control.");
7436 # p[0] = None
7437 # } else {
7438 # tmp->set_statement(p[2]);
7439 # p[0] = tmp;
7440 # }
7441 # }
7442 ()
7443 def p_statement_item_31(p):
7444 '''statement_item : '@' '*' statement_or_null '''
7445 if(parse_debug): print('statement_item_31', list(p))
7446 # { PEventStatement*tmp = new PEventStatement;
7447 # FILE_NAME(tmp, @1);
7448 # tmp->set_statement(p[3]);
7449 # p[0] = tmp;
7450 # }
7451 ()
7452 def p_statement_item_32(p):
7453 '''statement_item : '@' '(' '*' ')' statement_or_null '''
7454 if(parse_debug): print('statement_item_32', list(p))
7455 # { PEventStatement*tmp = new PEventStatement;
7456 # FILE_NAME(tmp, @1);
7457 # tmp->set_statement(p[5]);
7458 # p[0] = tmp;
7459 # }
7460 ()
7461 def p_statement_item_33(p):
7462 '''statement_item : lpvalue '=' expression ';' '''
7463 if(parse_debug): print('statement_item33', list(p))
7464 if p[3]:
7465 expr = Node(syms.expr_stmt, [p[1], Leaf(token.EQUAL, p[2]), p[3] ])
7466 if(parse_debug): print ("expr TODO", repr(expr))
7467 else:
7468 expr = Node(syms.expr_stmt, [p[1], Leaf(token.EQUAL, p[2]), ])
7469 if(parse_debug): print ("expr", repr(expr))
7470 if(parse_debug): print ("expr (python):'%s'" % expr)
7471 p[0] = expr
7472 # { PAssign*tmp = new PAssign(p[1],p[3]);
7473 # FILE_NAME(tmp, @1);
7474 # p[0] = tmp;
7475 # }
7476 ()
7477 def p_statement_item_34(p):
7478 '''statement_item : error '=' expression ';' '''
7479 if(parse_debug): print('statement_item_34', list(p))
7480 # { yyerror(@2, "Syntax in assignment statement l-value.");
7481 # yyerrok;
7482 # p[0] = new PNoop;
7483 # }
7484 ()
7485 def p_statement_item_35(p):
7486 '''statement_item : lpvalue K_LE expression ';' '''
7487 if(parse_debug): print('statement_item_35', list(p))
7488 # { PAssignNB*tmp = new PAssignNB(p[1],p[3]);
7489 # FILE_NAME(tmp, @1);
7490 # p[0] = tmp;
7491 # }
7492 ()
7493 def p_statement_item_36(p):
7494 '''statement_item : error K_LE expression ';' '''
7495 if(parse_debug): print('statement_item_36', list(p))
7496 # { yyerror(@2, "Syntax in assignment statement l-value.");
7497 # yyerrok;
7498 # p[0] = new PNoop;
7499 # }
7500 ()
7501 def p_statement_item_37(p):
7502 '''statement_item : lpvalue '=' delay1 expression ';' '''
7503 if(parse_debug): print('statement_item_37', list(p))
7504 # { PExpr*del = p[3]->front(); p[3]->pop_front();
7505 # assert(p[3]->empty());
7506 # PAssign*tmp = new PAssign(p[1],del,p[4]);
7507 # FILE_NAME(tmp, @1);
7508 # p[0] = tmp;
7509 # }
7510 ()
7511 def p_statement_item_38(p):
7512 '''statement_item : lpvalue K_LE delay1 expression ';' '''
7513 if(parse_debug): print('statement_item_38', list(p))
7514 # { PExpr*del = p[3]->front(); p[3]->pop_front();
7515 # assert(p[3]->empty());
7516 # PAssignNB*tmp = new PAssignNB(p[1],del,p[4]);
7517 # FILE_NAME(tmp, @1);
7518 # p[0] = tmp;
7519 # }
7520 ()
7521 def p_statement_item_39(p):
7522 '''statement_item : lpvalue '=' event_control expression ';' '''
7523 if(parse_debug): print('statement_item_39', list(p))
7524 # { PAssign*tmp = new PAssign(p[1],0,p[3],p[4]);
7525 # FILE_NAME(tmp, @1);
7526 # p[0] = tmp;
7527 # }
7528 ()
7529 def p_statement_item_40(p):
7530 '''statement_item : lpvalue '=' K_repeat '(' expression ')' event_control expression ';' '''
7531 if(parse_debug): print('statement_item_40', list(p))
7532 # { PAssign*tmp = new PAssign(p[1],p[5],p[7],p[8]);
7533 # FILE_NAME(tmp,@1);
7534 # tmp->set_lineno(@1.first_line);
7535 # p[0] = tmp;
7536 # }
7537 ()
7538 def p_statement_item_41(p):
7539 '''statement_item : lpvalue K_LE event_control expression ';' '''
7540 if(parse_debug): print('statement_item_41', list(p))
7541 # { PAssignNB*tmp = new PAssignNB(p[1],0,p[3],p[4]);
7542 # FILE_NAME(tmp, @1);
7543 # p[0] = tmp;
7544 # }
7545 ()
7546 def p_statement_item_42(p):
7547 '''statement_item : lpvalue K_LE K_repeat '(' expression ')' event_control expression ';' '''
7548 if(parse_debug): print('statement_item_42', list(p))
7549 # { PAssignNB*tmp = new PAssignNB(p[1],p[5],p[7],p[8]);
7550 # FILE_NAME(tmp, @1);
7551 # p[0] = tmp;
7552 # }
7553 ()
7554 def p_statement_item_43(p):
7555 '''statement_item : lpvalue '=' dynamic_array_new ';' '''
7556 if(parse_debug): print('statement_item_43', list(p))
7557 # { PAssign*tmp = new PAssign(p[1],p[3]);
7558 # FILE_NAME(tmp, @1);
7559 # p[0] = tmp;
7560 # }
7561 ()
7562 def p_statement_item_44(p):
7563 '''statement_item : lpvalue '=' class_new ';' '''
7564 if(parse_debug): print('statement_item_44', list(p))
7565 # { PAssign*tmp = new PAssign(p[1],p[3]);
7566 # FILE_NAME(tmp, @1);
7567 # p[0] = tmp;
7568 # }
7569 ()
7570 def p_statement_item_45(p):
7571 '''statement_item : K_wait '(' expression ')' statement_or_null '''
7572 if(parse_debug): print('statement_item_45', list(p))
7573 # { PEventStatement*tmp;
7574 # PEEvent*etmp = new PEEvent(PEEvent::POSITIVE, p[3]);
7575 # tmp = new PEventStatement(etmp);
7576 # FILE_NAME(tmp,@1);
7577 # tmp->set_statement(p[5]);
7578 # p[0] = tmp;
7579 # }
7580 ()
7581 def p_statement_item_46(p):
7582 '''statement_item : K_wait K_fork ';' '''
7583 if(parse_debug): print('statement_item_46', list(p))
7584 # { PEventStatement*tmp = new PEventStatement((PEEvent*)0);
7585 # FILE_NAME(tmp,@1);
7586 # p[0] = tmp;
7587 # }
7588 ()
7589 def p_statement_item_47(p):
7590 '''statement_item : SYSTEM_IDENTIFIER '(' expression_list_with_nuls ')' ';' '''
7591 if(parse_debug): print('statement_item_47', list(p))
7592 # { PCallTask*tmp = new PCallTask(lex_strings.make(p[1]), *p[3]);
7593 # FILE_NAME(tmp,@1);
7594 # delete[]p[1];
7595 # delete p[3];
7596 # p[0] = tmp;
7597 # }
7598 ()
7599 def p_statement_item_48(p):
7600 '''statement_item : SYSTEM_IDENTIFIER ';' '''
7601 if(parse_debug): print('statement_item_48', list(p))
7602 # { list<PExpr*>pt;
7603 # PCallTask*tmp = new PCallTask(lex_strings.make(p[1]), pt);
7604 # FILE_NAME(tmp,@1);
7605 # delete[]p[1];
7606 # p[0] = tmp;
7607 # }
7608 ()
7609 def p_statement_item_49(p):
7610 '''statement_item : hierarchy_identifier '(' expression_list_with_nuls ')' ';' '''
7611 if(parse_debug): print('statement_item_49', list(p))
7612 # { PCallTask*tmp = pform_make_call_task(@1, *p[1], *p[3]);
7613 # delete p[1];
7614 # delete p[3];
7615 # p[0] = tmp;
7616 # }
7617 ()
7618 def p_statement_item_50(p):
7619 '''statement_item : hierarchy_identifier K_with '{' constraint_block_item_list_opt '}' ';' '''
7620 if(parse_debug): print('statement_item_50', list(p))
7621 # { /* ....randomize with { <constraints> } */
7622 # if (p[1] && peek_tail_name(*p[1]) == "randomize") {
7623 # if (!gn_system_verilog())
7624 # yyerror(@2, "error: Randomize with constraint requires SystemVerilog.");
7625 # else
7626 # yyerror(@2, "sorry: Randomize with constraint not supported.");
7627 # } else {
7628 # yyerror(@2, "error: Constraint block can only be applied to randomize method.");
7629 # }
7630 # list<PExpr*>pt;
7631 # PCallTask*tmp = new PCallTask(*p[1], pt);
7632 # FILE_NAME(tmp, @1);
7633 # delete p[1];
7634 # p[0] = tmp;
7635 # }
7636 ()
7637 def p_statement_item_51(p):
7638 '''statement_item : implicit_class_handle '.' hierarchy_identifier '(' expression_list_with_nuls ')' ';' '''
7639 if(parse_debug): print('statement_item_51', list(p))
7640 # { pform_name_t*t_name = p[1];
7641 # while (! p[3]->empty()) {
7642 # t_name->push_back(p[3]->front());
7643 # p[3]->pop_front();
7644 # }
7645 # PCallTask*tmp = new PCallTask(*t_name, *p[5]);
7646 # FILE_NAME(tmp, @1);
7647 # delete p[1];
7648 # delete p[3];
7649 # delete p[5];
7650 # p[0] = tmp;
7651 # }
7652 ()
7653 def p_statement_item_52(p):
7654 '''statement_item : hierarchy_identifier ';' '''
7655 if(parse_debug): print('statement_item_52', list(p))
7656 # { list<PExpr*>pt;
7657 # PCallTask*tmp = pform_make_call_task(@1, *p[1], pt);
7658 # delete p[1];
7659 # p[0] = tmp;
7660 # }
7661 ()
7662 def p_statement_item_53(p):
7663 '''statement_item : implicit_class_handle '.' K_new '(' expression_list_with_nuls ')' ';' '''
7664 if(parse_debug): print('statement_item_53', list(p))
7665 # { PChainConstructor*tmp = new PChainConstructor(*p[5]);
7666 # FILE_NAME(tmp, @3);
7667 # delete p[1];
7668 # p[0] = tmp;
7669 # }
7670 ()
7671 def p_statement_item_54(p):
7672 '''statement_item : hierarchy_identifier '(' error ')' ';' '''
7673 if(parse_debug): print('statement_item_54', list(p))
7674 # { yyerror(@3, "error: Syntax error in task arguments.");
7675 # list<PExpr*>pt;
7676 # PCallTask*tmp = pform_make_call_task(@1, *p[1], pt);
7677 # delete p[1];
7678 # p[0] = tmp;
7679 # }
7680 ()
7681 def p_statement_item_55(p):
7682 '''statement_item : error ';' '''
7683 if(parse_debug): print('statement_item_55', list(p))
7684 # { yyerror(@2, "error: malformed statement");
7685 # yyerrok;
7686 # p[0] = new PNoop;
7687 # }
7688 ()
7689 def p__embed0_statement_item(p):
7690 '''_embed0_statement_item : '''
7691 # { PBlock*tmp = pform_push_block_scope(0, PBlock::BL_SEQ);
7692 # FILE_NAME(tmp, @1);
7693 # current_block_stack.push(tmp);
7694 # }
7695 ()
7696 def p__embed1_statement_item(p):
7697 '''_embed1_statement_item : '''
7698 # { if (p[3]) {
7699 # if (! gn_system_verilog()) {
7700 # yyerror("error: Variable declaration in unnamed block "
7701 # "requires SystemVerilog.");
7702 # }
7703 # } else {
7704 # /* If there are no declarations in the scope then just delete it. */
7705 # pform_pop_scope();
7706 # assert(! current_block_stack.empty());
7707 # PBlock*tmp = current_block_stack.top();
7708 # current_block_stack.pop();
7709 # delete tmp;
7710 # }
7711 # }
7712 ()
7713 def p__embed2_statement_item(p):
7714 '''_embed2_statement_item : '''
7715 # { PBlock*tmp = pform_push_block_scope(p[3], PBlock::BL_SEQ);
7716 # FILE_NAME(tmp, @1);
7717 # current_block_stack.push(tmp);
7718 # }
7719 ()
7720 def p__embed3_statement_item(p):
7721 '''_embed3_statement_item : '''
7722 # { PBlock*tmp = pform_push_block_scope(0, PBlock::BL_PAR);
7723 # FILE_NAME(tmp, @1);
7724 # current_block_stack.push(tmp);
7725 # }
7726 ()
7727 def p__embed4_statement_item(p):
7728 '''_embed4_statement_item : '''
7729 # { if (p[3]) {
7730 # if (! gn_system_verilog()) {
7731 # yyerror("error: Variable declaration in unnamed block "
7732 # "requires SystemVerilog.");
7733 # }
7734 # } else {
7735 # /* If there are no declarations in the scope then just delete it. */
7736 # pform_pop_scope();
7737 # assert(! current_block_stack.empty());
7738 # PBlock*tmp = current_block_stack.top();
7739 # current_block_stack.pop();
7740 # delete tmp;
7741 # }
7742 # }
7743 ()
7744 def p__embed5_statement_item(p):
7745 '''_embed5_statement_item : '''
7746 # { PBlock*tmp = pform_push_block_scope(p[3], PBlock::BL_PAR);
7747 # FILE_NAME(tmp, @1);
7748 # current_block_stack.push(tmp);
7749 # }
7750 ()
7751 def p_compressed_statement_1(p):
7752 '''compressed_statement : lpvalue K_PLUS_EQ expression '''
7753 if(parse_debug): print('compressed_statement_1', list(p))
7754 # { PAssign*tmp = new PAssign(p[1], '+', p[3]);
7755 # FILE_NAME(tmp, @1);
7756 # p[0] = tmp;
7757 # }
7758 ()
7759 def p_compressed_statement_2(p):
7760 '''compressed_statement : lpvalue K_MINUS_EQ expression '''
7761 if(parse_debug): print('compressed_statement_2', list(p))
7762 # { PAssign*tmp = new PAssign(p[1], '-', p[3]);
7763 # FILE_NAME(tmp, @1);
7764 # p[0] = tmp;
7765 # }
7766 ()
7767 def p_compressed_statement_3(p):
7768 '''compressed_statement : lpvalue K_MUL_EQ expression '''
7769 if(parse_debug): print('compressed_statement_3', list(p))
7770 # { PAssign*tmp = new PAssign(p[1], '*', p[3]);
7771 # FILE_NAME(tmp, @1);
7772 # p[0] = tmp;
7773 # }
7774 ()
7775 def p_compressed_statement_4(p):
7776 '''compressed_statement : lpvalue K_DIV_EQ expression '''
7777 if(parse_debug): print('compressed_statement_4', list(p))
7778 # { PAssign*tmp = new PAssign(p[1], '/', p[3]);
7779 # FILE_NAME(tmp, @1);
7780 # p[0] = tmp;
7781 # }
7782 ()
7783 def p_compressed_statement_5(p):
7784 '''compressed_statement : lpvalue K_MOD_EQ expression '''
7785 if(parse_debug): print('compressed_statement_5', list(p))
7786 # { PAssign*tmp = new PAssign(p[1], '%', p[3]);
7787 # FILE_NAME(tmp, @1);
7788 # p[0] = tmp;
7789 # }
7790 ()
7791 def p_compressed_statement_6(p):
7792 '''compressed_statement : lpvalue K_AND_EQ expression '''
7793 if(parse_debug): print('compressed_statement_6', list(p))
7794 # { PAssign*tmp = new PAssign(p[1], '&', p[3]);
7795 # FILE_NAME(tmp, @1);
7796 # p[0] = tmp;
7797 # }
7798 ()
7799 def p_compressed_statement_7(p):
7800 '''compressed_statement : lpvalue K_OR_EQ expression '''
7801 if(parse_debug): print('compressed_statement_7', list(p))
7802 # { PAssign*tmp = new PAssign(p[1], '|', p[3]);
7803 # FILE_NAME(tmp, @1);
7804 # p[0] = tmp;
7805 # }
7806 ()
7807 def p_compressed_statement_8(p):
7808 '''compressed_statement : lpvalue K_XOR_EQ expression '''
7809 if(parse_debug): print('compressed_statement_8', list(p))
7810 # { PAssign*tmp = new PAssign(p[1], '^', p[3]);
7811 # FILE_NAME(tmp, @1);
7812 # p[0] = tmp;
7813 # }
7814 ()
7815 def p_compressed_statement_9(p):
7816 '''compressed_statement : lpvalue K_LS_EQ expression '''
7817 if(parse_debug): print('compressed_statement_9', list(p))
7818 # { PAssign *tmp = new PAssign(p[1], 'l', p[3]);
7819 # FILE_NAME(tmp, @1);
7820 # p[0] = tmp;
7821 # }
7822 ()
7823 def p_compressed_statement_10(p):
7824 '''compressed_statement : lpvalue K_RS_EQ expression '''
7825 if(parse_debug): print('compressed_statement_10', list(p))
7826 # { PAssign*tmp = new PAssign(p[1], 'r', p[3]);
7827 # FILE_NAME(tmp, @1);
7828 # p[0] = tmp;
7829 # }
7830 ()
7831 def p_compressed_statement_11(p):
7832 '''compressed_statement : lpvalue K_RSS_EQ expression '''
7833 if(parse_debug): print('compressed_statement_11', list(p))
7834 # { PAssign *tmp = new PAssign(p[1], 'R', p[3]);
7835 # FILE_NAME(tmp, @1);
7836 # p[0] = tmp;
7837 # }
7838 ()
7839 def p_statement_or_null_list_opt_1(p):
7840 '''statement_or_null_list_opt : statement_or_null_list '''
7841 if(parse_debug): print('statement_or_null_list_opt_1', list(p))
7842 p[0] = p[1]
7843 ()
7844 def p_statement_or_null_list_opt_2(p):
7845 '''statement_or_null_list_opt : '''
7846 if(parse_debug): print('statement_or_null_list_opt_2', list(p))
7847 # { p[0] = None }
7848 ()
7849 def p_statement_or_null_list_1(p):
7850 '''statement_or_null_list : statement_or_null_list statement_or_null '''
7851 if(parse_debug): print('statement_or_null_list_1', list(p))
7852 # { vector<Statement*>*tmp = p[1];
7853 # if (p[2]) tmp->push_back(p[2]);
7854 # p[0] = tmp;
7855 # }
7856 ()
7857 def p_statement_or_null_list_2(p):
7858 '''statement_or_null_list : statement_or_null '''
7859 if(parse_debug): print('statement_or_null_list_2', list(p))
7860 # { vector<Statement*>*tmp = new vector<Statement*>(0);
7861 # if (p[1]) tmp->push_back(p[1]);
7862 # p[0] = tmp;
7863 # }
7864 ()
7865 def p_analog_statement_1(p):
7866 '''analog_statement : branch_probe_expression K_CONTRIBUTE expression ';' '''
7867 if(parse_debug): print('analog_statement_1', list(p))
7868 # { p[0] = pform_contribution_statement(@2, p[1], p[3]); }
7869 ()
7870 def p_task_item_1(p):
7871 '''task_item : block_item_decl '''
7872 if(parse_debug): print('task_item_1', list(p))
7873 # { p[0] = new vector<pform_tf_port_t>(0); }
7874 ()
7875 def p_task_item_2(p):
7876 '''task_item : tf_port_declaration '''
7877 if(parse_debug): print('task_item_2', list(p))
7878 p[0] = p[1]
7879 ()
7880 def p_task_item_list_1(p):
7881 '''task_item_list : task_item_list task_item '''
7882 if(parse_debug): print('task_item_list_1', list(p))
7883 # { vector<pform_tf_port_t>*tmp = p[1];
7884 # size_t s1 = tmp->size();
7885 # tmp->resize(s1 + p[2]->size());
7886 # for (size_t idx = 0 ; idx < p[2]->size() ; idx += 1)
7887 # tmp->at(s1 + idx) = p[2]->at(idx);
7888 # delete p[2];
7889 # p[0] = tmp;
7890 # }
7891 ()
7892 def p_task_item_list_2(p):
7893 '''task_item_list : task_item '''
7894 if(parse_debug): print('task_item_list_2', list(p))
7895 p[0] = p[1]
7896 ()
7897 def p_task_item_list_opt_1(p):
7898 '''task_item_list_opt : task_item_list '''
7899 if(parse_debug): print('task_item_list_opt_1', list(p))
7900 p[0] = p[1]
7901 ()
7902 def p_task_item_list_opt_2(p):
7903 '''task_item_list_opt : '''
7904 if(parse_debug): print('task_item_list_opt_2', list(p))
7905 # { p[0] = None }
7906 ()
7907 def p_tf_port_list_opt_1(p):
7908 '''tf_port_list_opt : tf_port_list '''
7909 if(parse_debug): print('tf_port_list_opt_1', list(p))
7910 p[0] = p[1]
7911 ()
7912 def p_tf_port_list_opt_2(p):
7913 '''tf_port_list_opt : '''
7914 if(parse_debug): print('tf_port_list_opt_2', list(p))
7915 # { p[0] = None }
7916 ()
7917 def p_udp_body_1(p):
7918 '''udp_body : K_table udp_entry_list K_endtable '''
7919 if(parse_debug): print('udp_body_1', list(p))
7920 # { lex_end_table();
7921 # p[0] = p[2];
7922 # }
7923 ()
7924 def p_udp_body_2(p):
7925 '''udp_body : K_table K_endtable '''
7926 if(parse_debug): print('udp_body_2', list(p))
7927 # { lex_end_table();
7928 # yyerror(@1, "error: Empty UDP table.");
7929 # p[0] = None
7930 # }
7931 ()
7932 def p_udp_body_3(p):
7933 '''udp_body : K_table error K_endtable '''
7934 if(parse_debug): print('udp_body_3', list(p))
7935 # { lex_end_table();
7936 # yyerror(@2, "Errors in UDP table");
7937 # yyerrok;
7938 # p[0] = None
7939 # }
7940 ()
7941 def p_udp_entry_list_1(p):
7942 '''udp_entry_list : udp_comb_entry_list '''
7943 if(parse_debug): print('udp_entry_list_1', list(p))
7944 ()
7945 def p_udp_entry_list_2(p):
7946 '''udp_entry_list : udp_sequ_entry_list '''
7947 if(parse_debug): print('udp_entry_list_2', list(p))
7948 ()
7949 def p_udp_comb_entry_1(p):
7950 '''udp_comb_entry : udp_input_list ':' udp_output_sym ';' '''
7951 if(parse_debug): print('udp_comb_entry_1', list(p))
7952 # { char*tmp = new char[strlen(p[1])+3];
7953 # strcpy(tmp, p[1]);
7954 # char*tp = tmp+strlen(tmp);
7955 # *tp++ = ':';
7956 # *tp++ = p[3];
7957 # *tp++ = 0;
7958 # delete[]p[1];
7959 # p[0] = tmp;
7960 # }
7961 ()
7962 def p_udp_comb_entry_list_1(p):
7963 '''udp_comb_entry_list : udp_comb_entry '''
7964 if(parse_debug): print('udp_comb_entry_list_1', list(p))
7965 # { list<string>*tmp = new list<string>;
7966 # tmp->push_back(p[1]);
7967 # delete[]p[1];
7968 # p[0] = tmp;
7969 # }
7970 ()
7971 def p_udp_comb_entry_list_2(p):
7972 '''udp_comb_entry_list : udp_comb_entry_list udp_comb_entry '''
7973 if(parse_debug): print('udp_comb_entry_list_2', list(p))
7974 # { list<string>*tmp = p[1];
7975 # tmp->push_back(p[2]);
7976 # delete[]p[2];
7977 # p[0] = tmp;
7978 # }
7979 ()
7980 def p_udp_sequ_entry_list_1(p):
7981 '''udp_sequ_entry_list : udp_sequ_entry '''
7982 if(parse_debug): print('udp_sequ_entry_list_1', list(p))
7983 # { list<string>*tmp = new list<string>;
7984 # tmp->push_back(p[1]);
7985 # delete[]p[1];
7986 # p[0] = tmp;
7987 # }
7988 ()
7989 def p_udp_sequ_entry_list_2(p):
7990 '''udp_sequ_entry_list : udp_sequ_entry_list udp_sequ_entry '''
7991 if(parse_debug): print('udp_sequ_entry_list_2', list(p))
7992 # { list<string>*tmp = p[1];
7993 # tmp->push_back(p[2]);
7994 # delete[]p[2];
7995 # p[0] = tmp;
7996 # }
7997 ()
7998 def p_udp_sequ_entry_1(p):
7999 '''udp_sequ_entry : udp_input_list ':' udp_input_sym ':' udp_output_sym ';' '''
8000 if(parse_debug): print('udp_sequ_entry_1', list(p))
8001 # { char*tmp = new char[strlen(p[1])+5];
8002 # strcpy(tmp, p[1]);
8003 # char*tp = tmp+strlen(tmp);
8004 # *tp++ = ':';
8005 # *tp++ = p[3];
8006 # *tp++ = ':';
8007 # *tp++ = p[5];
8008 # *tp++ = 0;
8009 # p[0] = tmp;
8010 # }
8011 ()
8012 def p_udp_initial_1(p):
8013 '''udp_initial : K_initial IDENTIFIER '=' number ';' '''
8014 if(parse_debug): print('udp_initial_1', list(p))
8015 # { PExpr*etmp = new PENumber(p[4]);
8016 # PEIdent*itmp = new PEIdent(lex_strings.make(p[2]));
8017 # PAssign*atmp = new PAssign(itmp, etmp);
8018 # FILE_NAME(atmp, @2);
8019 # delete[]p[2];
8020 # p[0] = atmp;
8021 # }
8022 ()
8023 def p_udp_init_opt_1(p):
8024 '''udp_init_opt : udp_initial '''
8025 if(parse_debug): print('udp_init_opt_1', list(p))
8026 p[0] = p[1]
8027 ()
8028 def p_udp_init_opt_2(p):
8029 '''udp_init_opt : '''
8030 if(parse_debug): print('udp_init_opt_2', list(p))
8031 # { p[0] = None }
8032 ()
8033 def p_udp_input_list_1(p):
8034 '''udp_input_list : udp_input_sym '''
8035 if(parse_debug): print('udp_input_list_1', list(p))
8036 # { char*tmp = new char[2];
8037 # tmp[0] = p[1];
8038 # tmp[1] = 0;
8039 # p[0] = tmp;
8040 # }
8041 ()
8042 def p_udp_input_list_2(p):
8043 '''udp_input_list : udp_input_list udp_input_sym '''
8044 if(parse_debug): print('udp_input_list_2', list(p))
8045 # { char*tmp = new char[strlen(p[1])+2];
8046 # strcpy(tmp, p[1]);
8047 # char*tp = tmp+strlen(tmp);
8048 # *tp++ = p[2];
8049 # *tp++ = 0;
8050 # delete[]p[1];
8051 # p[0] = tmp;
8052 # }
8053 ()
8054 def p_udp_input_sym_1(p):
8055 '''udp_input_sym : '0' '''
8056 if(parse_debug): print('udp_input_sym_1', list(p))
8057 # { p[0] = '0'; }
8058 ()
8059 def p_udp_input_sym_2(p):
8060 '''udp_input_sym : '1' '''
8061 if(parse_debug): print('udp_input_sym_2', list(p))
8062 # { p[0] = '1'; }
8063 ()
8064 def p_udp_input_sym_3(p):
8065 '''udp_input_sym : 'x' '''
8066 if(parse_debug): print('udp_input_sym_3', list(p))
8067 # { p[0] = 'x'; }
8068 ()
8069 def p_udp_input_sym_4(p):
8070 '''udp_input_sym : '?' '''
8071 if(parse_debug): print('udp_input_sym_4', list(p))
8072 # { p[0] = '?'; }
8073 ()
8074 def p_udp_input_sym_5(p):
8075 '''udp_input_sym : 'b' '''
8076 if(parse_debug): print('udp_input_sym_5', list(p))
8077 # { p[0] = 'b'; }
8078 ()
8079 def p_udp_input_sym_6(p):
8080 '''udp_input_sym : '*' '''
8081 if(parse_debug): print('udp_input_sym_6', list(p))
8082 # { p[0] = '*'; }
8083 ()
8084 def p_udp_input_sym_7(p):
8085 '''udp_input_sym : '%' '''
8086 if(parse_debug): print('udp_input_sym_7', list(p))
8087 # { p[0] = '%'; }
8088 ()
8089 def p_udp_input_sym_8(p):
8090 '''udp_input_sym : 'f' '''
8091 if(parse_debug): print('udp_input_sym_8', list(p))
8092 # { p[0] = 'f'; }
8093 ()
8094 def p_udp_input_sym_9(p):
8095 '''udp_input_sym : 'F' '''
8096 if(parse_debug): print('udp_input_sym_9', list(p))
8097 # { p[0] = 'F'; }
8098 ()
8099 def p_udp_input_sym_10(p):
8100 '''udp_input_sym : 'l' '''
8101 if(parse_debug): print('udp_input_sym_10', list(p))
8102 # { p[0] = 'l'; }
8103 ()
8104 def p_udp_input_sym_11(p):
8105 '''udp_input_sym : 'h' '''
8106 if(parse_debug): print('udp_input_sym_11', list(p))
8107 # { p[0] = 'h'; }
8108 ()
8109 def p_udp_input_sym_12(p):
8110 '''udp_input_sym : 'B' '''
8111 if(parse_debug): print('udp_input_sym_12', list(p))
8112 # { p[0] = 'B'; }
8113 ()
8114 def p_udp_input_sym_13(p):
8115 '''udp_input_sym : 'r' '''
8116 if(parse_debug): print('udp_input_sym_13', list(p))
8117 # { p[0] = 'r'; }
8118 ()
8119 def p_udp_input_sym_14(p):
8120 '''udp_input_sym : 'R' '''
8121 if(parse_debug): print('udp_input_sym_14', list(p))
8122 # { p[0] = 'R'; }
8123 ()
8124 def p_udp_input_sym_15(p):
8125 '''udp_input_sym : 'M' '''
8126 if(parse_debug): print('udp_input_sym_15', list(p))
8127 # { p[0] = 'M'; }
8128 ()
8129 def p_udp_input_sym_16(p):
8130 '''udp_input_sym : 'n' '''
8131 if(parse_debug): print('udp_input_sym_16', list(p))
8132 # { p[0] = 'n'; }
8133 ()
8134 def p_udp_input_sym_17(p):
8135 '''udp_input_sym : 'N' '''
8136 if(parse_debug): print('udp_input_sym_17', list(p))
8137 # { p[0] = 'N'; }
8138 ()
8139 def p_udp_input_sym_18(p):
8140 '''udp_input_sym : 'p' '''
8141 if(parse_debug): print('udp_input_sym_18', list(p))
8142 # { p[0] = 'p'; }
8143 ()
8144 def p_udp_input_sym_19(p):
8145 '''udp_input_sym : 'P' '''
8146 if(parse_debug): print('udp_input_sym_19', list(p))
8147 # { p[0] = 'P'; }
8148 ()
8149 def p_udp_input_sym_20(p):
8150 '''udp_input_sym : 'Q' '''
8151 if(parse_debug): print('udp_input_sym_20', list(p))
8152 # { p[0] = 'Q'; }
8153 ()
8154 def p_udp_input_sym_21(p):
8155 '''udp_input_sym : 'q' '''
8156 if(parse_debug): print('udp_input_sym_21', list(p))
8157 # { p[0] = 'q'; }
8158 ()
8159 def p_udp_input_sym_22(p):
8160 '''udp_input_sym : '_' '''
8161 if(parse_debug): print('udp_input_sym_22', list(p))
8162 # { p[0] = '_'; }
8163 ()
8164 def p_udp_input_sym_23(p):
8165 '''udp_input_sym : '+' '''
8166 if(parse_debug): print('udp_input_sym_23', list(p))
8167 # { p[0] = '+'; }
8168 ()
8169 def p_udp_input_sym_24(p):
8170 '''udp_input_sym : DEC_NUMBER '''
8171 if(parse_debug): print('udp_input_sym_24', list(p))
8172 # { yyerror(@1, "internal error: Input digits parse as decimal number!"); p[0] = '0'; }
8173 ()
8174 def p_udp_output_sym_1(p):
8175 '''udp_output_sym : '0' '''
8176 if(parse_debug): print('udp_output_sym_1', list(p))
8177 # { p[0] = '0'; }
8178 ()
8179 def p_udp_output_sym_2(p):
8180 '''udp_output_sym : '1' '''
8181 if(parse_debug): print('udp_output_sym_2', list(p))
8182 # { p[0] = '1'; }
8183 ()
8184 def p_udp_output_sym_3(p):
8185 '''udp_output_sym : 'x' '''
8186 if(parse_debug): print('udp_output_sym_3', list(p))
8187 # { p[0] = 'x'; }
8188 ()
8189 def p_udp_output_sym_4(p):
8190 '''udp_output_sym : '-' '''
8191 if(parse_debug): print('udp_output_sym_4', list(p))
8192 # { p[0] = '-'; }
8193 ()
8194 def p_udp_output_sym_5(p):
8195 '''udp_output_sym : DEC_NUMBER '''
8196 if(parse_debug): print('udp_output_sym_5', list(p))
8197 # { yyerror(@1, "internal error: Output digits parse as decimal number!"); p[0] = '0'; }
8198 ()
8199 def p_udp_port_decl_1(p):
8200 '''udp_port_decl : K_input list_of_identifiers ';' '''
8201 if(parse_debug): print('udp_port_decl_1', list(p))
8202 # { p[0] = pform_make_udp_input_ports(p[2]); }
8203 ()
8204 def p_udp_port_decl_2(p):
8205 '''udp_port_decl : K_output IDENTIFIER ';' '''
8206 if(parse_debug): print('udp_port_decl_2', list(p))
8207 # { perm_string pname = lex_strings.make(p[2]);
8208 # PWire*pp = new PWire(pname, NetNet::IMPLICIT, NetNet::POUTPUT, IVL_VT_LOGIC);
8209 # vector<PWire*>*tmp = new vector<PWire*>(1);
8210 # (*tmp)[0] = pp;
8211 # p[0] = tmp;
8212 # delete[]p[2];
8213 # }
8214 ()
8215 def p_udp_port_decl_3(p):
8216 '''udp_port_decl : K_reg IDENTIFIER ';' '''
8217 if(parse_debug): print('udp_port_decl_3', list(p))
8218 # { perm_string pname = lex_strings.make(p[2]);
8219 # PWire*pp = new PWire(pname, NetNet::REG, NetNet::PIMPLICIT, IVL_VT_LOGIC);
8220 # vector<PWire*>*tmp = new vector<PWire*>(1);
8221 # (*tmp)[0] = pp;
8222 # p[0] = tmp;
8223 # delete[]p[2];
8224 # }
8225 ()
8226 def p_udp_port_decl_4(p):
8227 '''udp_port_decl : K_reg K_output IDENTIFIER ';' '''
8228 if(parse_debug): print('udp_port_decl_4', list(p))
8229 # { perm_string pname = lex_strings.make(p[3]);
8230 # PWire*pp = new PWire(pname, NetNet::REG, NetNet::POUTPUT, IVL_VT_LOGIC);
8231 # vector<PWire*>*tmp = new vector<PWire*>(1);
8232 # (*tmp)[0] = pp;
8233 # p[0] = tmp;
8234 # delete[]p[3];
8235 # }
8236 ()
8237 def p_udp_port_decls_1(p):
8238 '''udp_port_decls : udp_port_decl '''
8239 if(parse_debug): print('udp_port_decls_1', list(p))
8240 p[0] = p[1]
8241 ()
8242 def p_udp_port_decls_2(p):
8243 '''udp_port_decls : udp_port_decls udp_port_decl '''
8244 if(parse_debug): print('udp_port_decls_2', list(p))
8245 # { vector<PWire*>*tmp = p[1];
8246 # size_t s1 = p[1]->size();
8247 # tmp->resize(s1+p[2]->size());
8248 # for (size_t idx = 0 ; idx < p[2]->size() ; idx += 1)
8249 # tmp->at(s1+idx) = p[2]->at(idx);
8250 # p[0] = tmp;
8251 # delete p[2];
8252 # }
8253 ()
8254 def p_udp_port_list_1(p):
8255 '''udp_port_list : IDENTIFIER '''
8256 if(parse_debug): print('udp_port_list_1', list(p))
8257 # { list<perm_string>*tmp = new list<perm_string>;
8258 # tmp->push_back(lex_strings.make(p[1]));
8259 # delete[]p[1];
8260 # p[0] = tmp;
8261 # }
8262 ()
8263 def p_udp_port_list_2(p):
8264 '''udp_port_list : udp_port_list ',' IDENTIFIER '''
8265 if(parse_debug): print('udp_port_list_2', list(p))
8266 # { list<perm_string>*tmp = p[1];
8267 # tmp->push_back(lex_strings.make(p[3]));
8268 # delete[]p[3];
8269 # p[0] = tmp;
8270 # }
8271 ()
8272 def p_udp_reg_opt_1(p):
8273 '''udp_reg_opt : K_reg '''
8274 if(parse_debug): print('udp_reg_opt_1', list(p))
8275 p[0] = True
8276 ()
8277 def p_udp_reg_opt_2(p):
8278 '''udp_reg_opt : '''
8279 if(parse_debug): print('udp_reg_opt_2', list(p))
8280 p[0] = False
8281 ()
8282 def p_udp_initial_expr_opt_1(p):
8283 '''udp_initial_expr_opt : '=' expression '''
8284 if(parse_debug): print('udp_initial_expr_opt_1', list(p))
8285 p[0] = p[2]
8286 ()
8287 def p_udp_initial_expr_opt_2(p):
8288 '''udp_initial_expr_opt : '''
8289 if(parse_debug): print('udp_initial_expr_opt_2', list(p))
8290 # { p[0] = None }
8291 ()
8292 def p_udp_input_declaration_list_1(p):
8293 '''udp_input_declaration_list : K_input IDENTIFIER '''
8294 if(parse_debug): print('udp_input_declaration_list_1', list(p))
8295 # { list<perm_string>*tmp = new list<perm_string>;
8296 # tmp->push_back(lex_strings.make(p[2]));
8297 # p[0] = tmp;
8298 # delete[]p[2];
8299 # }
8300 ()
8301 def p_udp_input_declaration_list_2(p):
8302 '''udp_input_declaration_list : udp_input_declaration_list ',' K_input IDENTIFIER '''
8303 if(parse_debug): print('udp_input_declaration_list_2', list(p))
8304 # { list<perm_string>*tmp = p[1];
8305 # tmp->push_back(lex_strings.make(p[4]));
8306 # p[0] = tmp;
8307 # delete[]p[4];
8308 # }
8309 ()
8310 def p_udp_primitive_1(p):
8311 '''udp_primitive : K_primitive IDENTIFIER '(' udp_port_list ')' ';' udp_port_decls udp_init_opt udp_body K_endprimitive endlabel_opt '''
8312 if(parse_debug): print('udp_primitive_1', list(p))
8313 # { perm_string tmp2 = lex_strings.make(p[2]);
8314 # pform_make_udp(tmp2, p[4], p[7], p[9], p[8],
8315 # @2.text, @2.first_line);
8316 # if (p[11]) {
8317 # if (strcmp(p[2],p[11]) != 0) {
8318 # yyerror(@11, "error: End label doesn't match "
8319 # "primitive name");
8320 # }
8321 # if (! gn_system_verilog()) {
8322 # yyerror(@11, "error: Primitive end labels "
8323 # "require SystemVerilog.");
8324 # }
8325 # delete[]p[11];
8326 # }
8327 # delete[]p[2];
8328 # }
8329 ()
8330 def p_udp_primitive_2(p):
8331 '''udp_primitive : K_primitive IDENTIFIER '(' K_output udp_reg_opt IDENTIFIER udp_initial_expr_opt ',' udp_input_declaration_list ')' ';' udp_body K_endprimitive endlabel_opt '''
8332 if(parse_debug): print('udp_primitive_2', list(p))
8333 # { perm_string tmp2 = lex_strings.make(p[2]);
8334 # perm_string tmp6 = lex_strings.make(p[6]);
8335 # pform_make_udp(tmp2, p[5], tmp6, p[7], p[9], p[12],
8336 # @2.text, @2.first_line);
8337 # if (p[14]) {
8338 # if (strcmp(p[2],p[14]) != 0) {
8339 # yyerror(@14, "error: End label doesn't match "
8340 # "primitive name");
8341 # }
8342 # if (! gn_system_verilog()) {
8343 # yyerror(@14, "error: Primitive end labels "
8344 # "require SystemVerilog.");
8345 # }
8346 # delete[]p[14];
8347 # }
8348 # delete[]p[2];
8349 # delete[]p[6];
8350 # }
8351 ()
8352 def p_K_packed_opt_1(p):
8353 '''K_packed_opt : K_packed '''
8354 if(parse_debug): print('K_packed_opt', list(p))
8355 p[0] = True
8356 ()
8357 def p_K_packed_opt_2(p):
8358 '''K_packed_opt : '''
8359 if(parse_debug): print('K_packed_opt', list(p))
8360 p[0] = False
8361 ()
8362 def p_K_reg_opt_1(p):
8363 '''K_reg_opt : K_reg '''
8364 if(parse_debug): print('K_reg_opt', list(p))
8365 p[0] = True
8366 ()
8367 def p_K_reg_opt_2(p):
8368 '''K_reg_opt : '''
8369 if(parse_debug): print('K_reg_opt', list(p))
8370 p[0] = False
8371 ()
8372 def p_K_static_opt_1(p):
8373 '''K_static_opt : K_static '''
8374 if(parse_debug): print('K_static_opt', list(p))
8375 p[0] = True
8376 ()
8377 def p_K_static_opt_2(p):
8378 '''K_static_opt : '''
8379 if(parse_debug): print('K_static_opt', list(p))
8380 p[0] = False
8381 ()
8382
8383 def p_K_virtual_opt_1(p):
8384 '''K_virtual_opt : K_virtual '''
8385 if(parse_debug): print(p)
8386 p[0] = True
8387 ()
8388 def p_K_virtual_opt_2(p):
8389 '''K_virtual_opt : '''
8390 if(parse_debug): print(p)
8391 p[0] = False
8392 ()
8393
8394 def p_error(p):
8395 if(parse_debug): print ("error", p)
8396 exit(0)
8397
8398 yacc.yacc(debug=0)
8399