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