parser refactoring
[sv2nmigen.git] / parse_sv.py
1 # %{
2 # /*
3 # * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com)
4 # * Copyright CERN 2012-2013 / Stephen Williams (steve@icarus.com)
5 # *
6 # * This source code is free software; you can redistribute it
7 # * and/or modify it in source code form under the terms of the GNU
8 # * General Public License as published by the Free Software
9 # * Foundation; either version 2 of the License, or (at your option)
10 # * any later version.
11 # *
12 # * This program is distributed in the hope that it will be useful,
13 # * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # * GNU General Public License for more details.
16 # *
17 # * You should have received a copy of the GNU General Public License
18 # * along with this program; if not, write to the Free Software
19 # * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # */
21
22 from lib2to3.pytree import Node, Leaf
23 from lib2to3.pgen2 import token
24 from lib2to3.pygram import python_symbols as syms
25
26 yacc1_debug = 0
27 yacc2_debug = 0
28 parse_debug = 1
29
30 from ply import yacc, lex
31
32 #from parse_tokens import tokens
33 import lexor
34 tokens = lexor.tokens # list(set(lexor.tokens).union(set(tokens)))
35 literals = lexor.literals
36
37 precedence = [\
38 ('right', 'K_PLUS_EQ', 'K_MINUS_EQ', 'K_MUL_EQ', 'K_DIV_EQ',
39 'K_MOD_EQ', 'K_AND_EQ', 'K_OR_EQ'),
40 ('right', 'K_XOR_EQ', 'K_LS_EQ', 'K_RS_EQ', 'K_RSS_EQ'),
41 ('right', '?', ':', 'K_inside'),
42 ('left', 'K_LOR'),
43 ('left', 'K_LAND'),
44 ('left', '|'),
45 ('left', '^', 'K_NXOR', 'K_NOR'),
46 ('left', '&', 'K_NAND'),
47 ('left', 'K_EQ', 'K_NE', 'K_CEQ', 'K_CNE', 'K_WEQ', 'K_WNE'),
48 ('left', 'K_GE', 'K_LE', '<', '>'),
49 ('left', 'K_LS', 'K_RS', 'K_RSS'),
50 ('left', '+', '-'),
51 ('left', '*', '/', '%'),
52 ('left', 'K_POW'),
53 ('left', 'UNARY_PREC'),
54 ('nonassoc', 'less_than_K_else'),
55 ('nonassoc', 'K_else'),
56 ('nonassoc', '('),
57 ('nonassoc', 'K_exclude'),
58 ('nonassoc', 'no_timeunits_declaration'),
59 ('nonassoc', 'one_timeunits_declaration'),
60 ('nonassoc', 'K_timeunit', 'K_timeprecision')
61 ]
62
63
64 IVL_VT_NO_TYPE = 'VT_NO_TYPE'
65 IVL_VT_BOOL = 'VT_BOOL'
66 IVL_VT_LOGIC = 'VT_LOGIC'
67 """
68 IVL_VT_VOID = 0, /* Not used */
69 IVL_VT_NO_TYPE = 1, /* Place holder for missing/unknown type. */
70 IVL_VT_REAL = 2,
71 IVL_VT_BOOL = 3,
72 IVL_VT_LOGIC = 4,
73 IVL_VT_STRING = 5,
74 IVL_VT_DARRAY = 6, /* Array (esp. dynamic array) */
75 IVL_VT_CLASS = 7, /* SystemVerilog class instances */
76 IVL_VT_QUEUE = 8, /* SystemVerilog queue instances */
77 IVL_VT_VECTOR = IVL_VT_LOGIC /* For compatibility */
78 """
79
80 NN_NONE = 'NONE'
81 NN_IMPLICIT = 'IMPLICIT'
82 NN_IMPLICIT_REG = 'IMPLICIT_REG'
83 NN_INTEGER = 'INTEGER'
84 NN_WIRE = 'WIRE'
85 NN_TRI = 'TRI'
86 NN_TRI1 = 'TRI1'
87 NN_SUPPLY0 = 'SUPPLY0'
88 NN_SUPPLY1 = 'SUPPLY1'
89 NN_WAND = 'WAND'
90 NN_TRIAND = 'TRIAND'
91 NN_TRI0 = 'TRI0'
92 NN_WOR = 'WOR'
93 NN_TRIOR = 'TRIOR'
94 NN_REG = 'REG'
95 NN_UNRESOLVED_WIRE = 'UNRESOLVED_WIRE'
96
97 NP_NOT_A_PORT = 'NOT_A_PORT'
98 NP_PIMPLICIT = 'PIMPLICIT'
99 NP_PINPUT = 'PINPUT'
100 NP_POUTPUT = 'POUTPUT'
101 NP_PINOUT = 'PINOUT'
102 NP_PREF = 'PREF'
103
104 def indent(s, i=4):
105 st = ''
106 for x in s:
107 st += str(x)
108 res = []
109 for p in st.split('\n'):
110 res.append(' ' * i + "#"+p)
111 return '\n'.join(res)
112
113
114 class DataType:
115 def __init__(self, typ, signed):
116 self.typ = typ
117 self.signed = signed
118
119 def port_decl(comment, dt, name):
120 if dt is None or dt.dims is None:
121 width = '' # width: 1
122 else:
123 width = dt.dims
124 # XXX TODO, better checking, should be using data structure... *sigh*
125 width = width[1:-1] # strip brackets
126 width = width.split(':')
127 assert width[0] == '0'
128 width = width[1]
129 return 'self.%s = Signal(%s) # %s' % (name, width, comment)
130
131 # -------------- RULES ----------------
132 ()
133 def p_source_text_1(p):
134 '''source_text : timeunits_declaration_opt _embed0_source_text description_list '''
135 if(parse_debug>2): print('source_text', list(p))
136 ()
137 def p_source_text_2(p):
138 '''source_text : '''
139 if(parse_debug): print('source_text', list(p))
140 ()
141 def p__embed0_source_text(p):
142 '''_embed0_source_text : '''
143 # { pform_set_scope_timescale(yyloc); }
144 ()
145 def p_assertion_item_1(p):
146 '''assertion_item : concurrent_assertion_item '''
147 if(parse_debug): print('assertion_item_1', list(p))
148 ()
149 def p_assignment_pattern_1(p):
150 '''assignment_pattern : K_LP expression_list_proper '}' '''
151 if(parse_debug): print('assignment_pattern_1', list(p))
152 # { PEAssignPattern*tmp = new PEAssignPattern(*p[2]);
153 # FILE_NAME(tmp, @1);
154 # delete p[2];
155 # p[0] = tmp;
156 # }
157 ()
158 def p_assignment_pattern_2(p):
159 '''assignment_pattern : K_LP '}' '''
160 if(parse_debug): print('assignment_pattern_2', list(p))
161 # { PEAssignPattern*tmp = new PEAssignPattern;
162 # FILE_NAME(tmp, @1);
163 # p[0] = tmp;
164 # }
165 ()
166 def p_block_identifier_opt_1(p):
167 '''block_identifier_opt : IDENTIFIER ':' '''
168 if(parse_debug): print('block_identifier_opt_1', list(p))
169 ()
170 def p_block_identifier_opt_2(p):
171 '''block_identifier_opt : '''
172 if(parse_debug): print('block_identifier_opt_2', list(p))
173 ()
174 def p_class_declaration_1(p):
175 '''class_declaration : K_virtual_opt K_class lifetime_opt class_identifier class_declaration_extends_opt ';' _embed0_class_declaration class_items_opt K_endclass _embed1_class_declaration class_declaration_endlabel_opt '''
176 if(parse_debug): print('class_declaration_1', list(p))
177 # { // Wrap up the class.
178 # if (p[11] && p[4] && p[4]->name != p[11]) {
179 # yyerror(@11, "error: Class end label doesn't match class name.");
180 # delete[]p[11];
181 # }
182 # }
183 ()
184 def p__embed0_class_declaration(p):
185 '''_embed0_class_declaration : '''
186 # { pform_start_class_declaration(@2, p[4], p[5].type, p[5].exprs, p[3]); }
187 ()
188 def p__embed1_class_declaration(p):
189 '''_embed1_class_declaration : '''
190 # { // Process a class.
191 # pform_end_class_declaration(@9);
192 # }
193 ()
194 def p_class_constraint_1(p):
195 '''class_constraint : constraint_prototype '''
196 if(parse_debug): print('class_constraint_1', list(p))
197 ()
198 def p_class_constraint_2(p):
199 '''class_constraint : constraint_declaration '''
200 if(parse_debug): print('class_constraint_2', list(p))
201 ()
202 def p_class_identifier_1(p):
203 '''class_identifier : IDENTIFIER '''
204 if(parse_debug): print('class_identifier_1', list(p))
205 # { // Create a synthetic typedef for the class name so that the
206 # // lexor detects the name as a type.
207 # perm_string name = lex_strings.make(p[1]);
208 # class_type_t*tmp = new class_type_t(name);
209 # FILE_NAME(tmp, @1);
210 # pform_set_typedef(name, tmp, NULL);
211 # delete[]p[1];
212 # p[0] = tmp;
213 # }
214 ()
215 def p_class_identifier_2(p):
216 '''class_identifier : TYPE_IDENTIFIER '''
217 if(parse_debug): print('class_identifier_2', list(p))
218 # { class_type_t*tmp = dynamic_cast<class_type_t*>(p[1].type);
219 # if (tmp == 0) {
220 # yyerror(@1, "Type name \"%s\"is not a predeclared class name.", p[1].text);
221 # }
222 # delete[]p[1].text;
223 # p[0] = tmp;
224 # }
225 ()
226 def p_class_declaration_endlabel_opt_1(p):
227 '''class_declaration_endlabel_opt : ':' TYPE_IDENTIFIER '''
228 if(parse_debug): print('class_declaration_endlabel_opt_1', list(p))
229 # { class_type_t*tmp = dynamic_cast<class_type_t*> (p[2].type);
230 # if (tmp == 0) {
231 # yyerror(@2, "error: class declaration endlabel \"%s\" is not a class name\n", p[2].text);
232 # p[0] = None
233 # } else {
234 # p[0] = strdupnew(tmp->name.str());
235 # }
236 # delete[]p[2].text;
237 # }
238 ()
239 def p_class_declaration_endlabel_opt_2(p):
240 '''class_declaration_endlabel_opt : ':' IDENTIFIER '''
241 if(parse_debug): print('class_declaration_endlabel_opt_2', list(p))
242 p[0] = p[2]
243 ()
244 def p_class_declaration_endlabel_opt_3(p):
245 '''class_declaration_endlabel_opt : '''
246 if(parse_debug): print('class_declaration_endlabel_opt_3', list(p))
247 # { p[0] = None }
248 ()
249 def p_class_declaration_extends_opt_1(p):
250 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '''
251 if(parse_debug): print('class_declaration_extends_opt_1', list(p))
252 # { p[0].type = p[2].type;
253 # p[0].exprs= 0;
254 # delete[]p[2].text;
255 # }
256 ()
257 def p_class_declaration_extends_opt_2(p):
258 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '(' expression_list_with_nuls ')' '''
259 if(parse_debug): print('class_declaration_extends_opt_2', list(p))
260 # { p[0].type = p[2].type;
261 # p[0].exprs = p[4];
262 # delete[]p[2].text;
263 # }
264 ()
265 def p_class_declaration_extends_opt_3(p):
266 '''class_declaration_extends_opt : '''
267 if(parse_debug): print('class_declaration_extends_opt_3', list(p))
268 # { p[0].type = 0; p[0].exprs = 0; }
269 ()
270 def p_class_items_opt_1(p):
271 '''class_items_opt : class_items '''
272 if(parse_debug): print('class_items_opt_1', list(p))
273 ()
274 def p_class_items_opt_2(p):
275 '''class_items_opt : '''
276 if(parse_debug): print('class_items_opt_2', list(p))
277 ()
278 def p_class_items_1(p):
279 '''class_items : class_items class_item '''
280 if(parse_debug): print('class_items_1', list(p))
281 ()
282 def p_class_items_2(p):
283 '''class_items : class_item '''
284 if(parse_debug): print('class_items_2', list(p))
285 ()
286 def p_class_item_1(p):
287 '''class_item : method_qualifier_opt K_function K_new _embed0_class_item '(' tf_port_list_opt ')' ';' function_item_list_opt statement_or_null_list_opt K_endfunction endnew_opt '''
288 if(parse_debug): print('class_item_1', list(p))
289 # { current_function->set_ports(p[6]);
290 # pform_set_constructor_return(current_function);
291 # pform_set_this_class(@3, current_function);
292 # current_function_set_statement(@3, p[10]);
293 # pform_pop_scope();
294 # current_function = 0;
295 # }
296 ()
297 def p_class_item_2(p):
298 '''class_item : property_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
299 if(parse_debug): print('class_item_2', list(p))
300 # { pform_class_property(@2, p[1], p[2], p[3]); }
301 ()
302 def p_class_item_3(p):
303 '''class_item : K_const class_item_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
304 if(parse_debug): print('class_item_3', list(p))
305 # { pform_class_property(@1, p[2] | property_qualifier_t::make_const(), p[3], p[4]); }
306 ()
307 def p_class_item_4(p):
308 '''class_item : method_qualifier_opt task_declaration '''
309 if(parse_debug): print('class_item_4', list(p))
310 # { /* The task_declaration rule puts this into the class */ }
311 ()
312 def p_class_item_5(p):
313 '''class_item : method_qualifier_opt function_declaration '''
314 if(parse_debug): print('class_item_5', list(p))
315 # { /* The function_declaration rule puts this into the class */ }
316 ()
317 def p_class_item_6(p):
318 '''class_item : K_extern method_qualifier_opt K_function K_new ';' '''
319 if(parse_debug): print('class_item_6', list(p))
320 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
321 ()
322 def p_class_item_7(p):
323 '''class_item : K_extern method_qualifier_opt K_function K_new '(' tf_port_list_opt ')' ';' '''
324 if(parse_debug): print('class_item_7', list(p))
325 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
326 ()
327 def p_class_item_8(p):
328 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER ';' '''
329 if(parse_debug): print('class_item_8', list(p))
330 # { yyerror(@1, "sorry: External methods are not yet supported.");
331 # delete[] p[5];
332 # }
333 ()
334 def p_class_item_9(p):
335 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' ';' '''
336 if(parse_debug): print('class_item_9', list(p))
337 # { yyerror(@1, "sorry: External methods are not yet supported.");
338 # delete[] p[5];
339 # }
340 ()
341 def p_class_item_10(p):
342 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER ';' '''
343 if(parse_debug): print('class_item_10', list(p))
344 # { yyerror(@1, "sorry: External methods are not yet supported.");
345 # delete[] p[4];
346 # }
347 ()
348 def p_class_item_11(p):
349 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER '(' tf_port_list_opt ')' ';' '''
350 if(parse_debug): print('class_item_11', list(p))
351 # { yyerror(@1, "sorry: External methods are not yet supported.");
352 # delete[] p[4];
353 # }
354 ()
355 def p_class_item_12(p):
356 '''class_item : class_constraint '''
357 if(parse_debug): print('class_item_12', list(p))
358 ()
359 def p_class_item_13(p):
360 '''class_item : property_qualifier_opt data_type error ';' '''
361 if(parse_debug): print('class_item_13', list(p))
362 # { yyerror(@3, "error: Errors in variable names after data type.");
363 # yyerrok;
364 # }
365 ()
366 def p_class_item_14(p):
367 '''class_item : property_qualifier_opt IDENTIFIER error ';' '''
368 if(parse_debug): print('class_item_14', list(p))
369 # { yyerror(@3, "error: %s doesn't name a type.", p[2]);
370 # yyerrok;
371 # }
372 ()
373 def p_class_item_15(p):
374 '''class_item : method_qualifier_opt K_function K_new error K_endfunction endnew_opt '''
375 if(parse_debug): print('class_item_15', list(p))
376 # { yyerror(@1, "error: I give up on this class constructor declaration.");
377 # yyerrok;
378 # }
379 ()
380 def p_class_item_16(p):
381 '''class_item : error ';' '''
382 if(parse_debug): print('class_item_16', list(p))
383 # { yyerror(@2, "error: invalid class item.");
384 # yyerrok;
385 # }
386 ()
387 def p__embed0_class_item(p):
388 '''_embed0_class_item : '''
389 # { assert(current_function==0);
390 # current_function = pform_push_constructor_scope(@3);
391 # }
392 ()
393 def p_class_item_qualifier_1(p):
394 '''class_item_qualifier : K_static '''
395 if(parse_debug): print('class_item_qualifier_1', list(p))
396 # { p[0] = property_qualifier_t::make_static(); }
397 ()
398 def p_class_item_qualifier_2(p):
399 '''class_item_qualifier : K_protected '''
400 if(parse_debug): print('class_item_qualifier_2', list(p))
401 # { p[0] = property_qualifier_t::make_protected(); }
402 ()
403 def p_class_item_qualifier_3(p):
404 '''class_item_qualifier : K_local '''
405 if(parse_debug): print('class_item_qualifier_3', list(p))
406 # { p[0] = property_qualifier_t::make_local(); }
407 ()
408 def p_class_item_qualifier_list_1(p):
409 '''class_item_qualifier_list : class_item_qualifier_list class_item_qualifier '''
410 if(parse_debug): print('class_item_qualifier_list_1', list(p))
411 # { p[0] = p[1] | p[2]; }
412 ()
413 def p_class_item_qualifier_list_2(p):
414 '''class_item_qualifier_list : class_item_qualifier '''
415 if(parse_debug): print('class_item_qualifier_list_2', list(p))
416 p[0] = p[1]
417 ()
418 def p_class_item_qualifier_opt_1(p):
419 '''class_item_qualifier_opt : class_item_qualifier_list '''
420 if(parse_debug): print('class_item_qualifier_opt_1', list(p))
421 p[0] = p[1]
422 ()
423 def p_class_item_qualifier_opt_2(p):
424 '''class_item_qualifier_opt : '''
425 if(parse_debug): print('class_item_qualifier_opt_2', list(p))
426 # { p[0] = property_qualifier_t::make_none(); }
427 ()
428 def p_class_new_1(p):
429 '''class_new : K_new '(' expression_list_with_nuls ')' '''
430 if(parse_debug): print('class_new_1', list(p))
431 # { list<PExpr*>*expr_list = p[3];
432 # strip_tail_items(expr_list);
433 # PENewClass*tmp = new PENewClass(*expr_list);
434 # FILE_NAME(tmp, @1);
435 # delete p[3];
436 # p[0] = tmp;
437 # }
438 ()
439 def p_class_new_2(p):
440 '''class_new : K_new hierarchy_identifier '''
441 if(parse_debug): print('class_new_2', list(p))
442 # { PEIdent*tmpi = new PEIdent(*p[2]);
443 # FILE_NAME(tmpi, @2);
444 # PENewCopy*tmp = new PENewCopy(tmpi);
445 # FILE_NAME(tmp, @1);
446 # delete p[2];
447 # p[0] = tmp;
448 # }
449 ()
450 def p_class_new_3(p):
451 '''class_new : K_new '''
452 if(parse_debug): print('class_new_3', list(p))
453 # { PENewClass*tmp = new PENewClass;
454 # FILE_NAME(tmp, @1);
455 # p[0] = tmp;
456 # }
457 ()
458 def p_concurrent_assertion_item_1(p):
459 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' property_spec ')' statement_or_null '''
460 if(parse_debug): print('concurrent_assertion_item_1', list(p))
461 # { /* */
462 # if (gn_assertions_flag) {
463 # yyerror(@2, "sorry: concurrent_assertion_item not supported."
464 # " Try -gno-assertion to turn this message off.");
465 # }
466 # }
467 ()
468 def p_concurrent_assertion_item_2(p):
469 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' error ')' statement_or_null '''
470 if(parse_debug): print('concurrent_assertion_item_2', list(p))
471 # { yyerrok;
472 # yyerror(@2, "error: Error in property_spec of concurrent assertion item.");
473 # }
474 ()
475 def p_constraint_block_item_1(p):
476 '''constraint_block_item : constraint_expression '''
477 if(parse_debug): print('constraint_block_item_1', list(p))
478 ()
479 def p_constraint_block_item_list_1(p):
480 '''constraint_block_item_list : constraint_block_item_list constraint_block_item '''
481 if(parse_debug): print('constraint_block_item_list_1', list(p))
482 ()
483 def p_constraint_block_item_list_2(p):
484 '''constraint_block_item_list : constraint_block_item '''
485 if(parse_debug): print('constraint_block_item_list_2', list(p))
486 ()
487 def p_constraint_block_item_list_opt_1(p):
488 '''constraint_block_item_list_opt : '''
489 if(parse_debug): print('constraint_block_item_list_opt_1', list(p))
490 ()
491 def p_constraint_block_item_list_opt_2(p):
492 '''constraint_block_item_list_opt : constraint_block_item_list '''
493 if(parse_debug): print('constraint_block_item_list_opt_2', list(p))
494 ()
495 def p_constraint_declaration_1(p):
496 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' constraint_block_item_list_opt '}' '''
497 if(parse_debug): print('constraint_declaration_1', list(p))
498 # { yyerror(@2, "sorry: Constraint declarations not supported."); }
499 ()
500 def p_constraint_declaration_2(p):
501 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' error '}' '''
502 if(parse_debug): print('constraint_declaration_2', list(p))
503 # { yyerror(@4, "error: Errors in the constraint block item list."); }
504 ()
505 def p_constraint_expression_1(p):
506 '''constraint_expression : expression ';' '''
507 if(parse_debug): print('constraint_expression_1', list(p))
508 ()
509 def p_constraint_expression_2(p):
510 '''constraint_expression : expression K_dist '{' '}' ';' '''
511 if(parse_debug): print('constraint_expression_2', list(p))
512 ()
513 def p_constraint_expression_3(p):
514 '''constraint_expression : expression K_TRIGGER constraint_set '''
515 if(parse_debug): print('constraint_expression_3', list(p))
516 ()
517 def p_constraint_expression_4(p):
518 '''constraint_expression : K_if '(' expression ')' constraint_set %prec less_than_K_else '''
519 if(parse_debug): print('constraint_expression_4', list(p))
520 ()
521 def p_constraint_expression_5(p):
522 '''constraint_expression : K_if '(' expression ')' constraint_set K_else constraint_set '''
523 if(parse_debug): print('constraint_expression_5', list(p))
524 ()
525 def p_constraint_expression_6(p):
526 '''constraint_expression : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' constraint_set '''
527 if(parse_debug): print('constraint_expression_6', list(p))
528 ()
529 def p_constraint_expression_list_1(p):
530 '''constraint_expression_list : constraint_expression_list constraint_expression '''
531 if(parse_debug): print('constraint_expression_list_1', list(p))
532 ()
533 def p_constraint_expression_list_2(p):
534 '''constraint_expression_list : constraint_expression '''
535 if(parse_debug): print('constraint_expression_list_2', list(p))
536 ()
537 def p_constraint_prototype_1(p):
538 '''constraint_prototype : K_static_opt K_constraint IDENTIFIER ';' '''
539 if(parse_debug): print('constraint_prototype_1', list(p))
540 # { yyerror(@2, "sorry: Constraint prototypes not supported."); }
541 ()
542 def p_constraint_set_1(p):
543 '''constraint_set : constraint_expression '''
544 if(parse_debug): print('constraint_set_1', list(p))
545 ()
546 def p_constraint_set_2(p):
547 '''constraint_set : '{' constraint_expression_list '}' '''
548 if(parse_debug): print('constraint_set_2', list(p))
549 ()
550 def p_data_declaration_1(p):
551 '''data_declaration : attribute_list_opt data_type_or_implicit list_of_variable_decl_assignments ';' '''
552 if(parse_debug): print('data_declaration_1', list(p))
553 # { data_type_t*data_type = p[2];
554 # if (data_type == 0) {
555 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
556 # FILE_NAME(data_type, @2);
557 # }
558 # pform_makewire(@2, 0, str_strength, p[3], NetNet::IMPLICIT_REG, data_type);
559 # }
560 ()
561 def p_data_type_1(p):
562 '''data_type : integer_vector_type unsigned_signed_opt dimensions_opt '''
563 if(parse_debug): print('data_type_1', list(p))
564 use_vtype = p[1]
565 reg_flag = False
566 if (use_vtype == IVL_VT_NO_TYPE):
567 use_vtype = IVL_VT_LOGIC
568 reg_flag = True
569 dt = DataType(use_vtype, signed=p[2])
570 dt.dims = p[3]
571 dt.reg_flag = reg_flag
572 p[0] = dt
573 # { ivl_variable_type_t use_vtype = p[1];
574 # bool reg_flag = false;
575 # if (use_vtype == IVL_VT_NO_TYPE) {
576 # use_vtype = IVL_VT_LOGIC;
577 # reg_flag = true;
578 # }
579 # vector_type_t*tmp = new vector_type_t(use_vtype, p[2], p[3]);
580 # tmp->reg_flag = reg_flag;
581 # FILE_NAME(tmp, @1);
582 # p[0] = tmp;
583 # }
584 ()
585 def p_data_type_2(p):
586 '''data_type : non_integer_type '''
587 if(parse_debug): print('data_type_2', list(p))
588 p[0] = p[1]
589 # { real_type_t*tmp = new real_type_t(p[1]);
590 # FILE_NAME(tmp, @1);
591 # p[0] = tmp;
592 # }
593 ()
594 def p_data_type_3(p):
595 '''data_type : struct_data_type '''
596 if(parse_debug): print('data_type_3', list(p))
597 p[0] = p[1]
598 # { if (!p[1]->packed_flag) {
599 # yyerror(@1, "sorry: Unpacked structs not supported.");
600 # }
601 # p[0] = p[1];
602 # }
603 ()
604 def p_data_type_4(p):
605 '''data_type : enum_data_type '''
606 if(parse_debug): print('data_type_4', list(p))
607 p[0] = p[1]
608 ()
609 def p_data_type_5(p):
610 '''data_type : atom2_type signed_unsigned_opt '''
611 if(parse_debug): print('data_type_5', list(p))
612 # { atom2_type_t*tmp = new atom2_type_t(p[1], p[2]);
613 # FILE_NAME(tmp, @1);
614 # p[0] = tmp;
615 # }
616 ()
617 def p_data_type_6(p):
618 '''data_type : K_integer signed_unsigned_opt '''
619 if(parse_debug): print('data_type_6', list(p))
620 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
621 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[2], pd);
622 # tmp->reg_flag = true;
623 # tmp->integer_flag = true;
624 # p[0] = tmp;
625 # }
626 ()
627 def p_data_type_7(p):
628 '''data_type : K_time '''
629 if(parse_debug): print('data_type_7', list(p))
630 # { list<pform_range_t>*pd = make_range_from_width(64);
631 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
632 # tmp->reg_flag = !gn_system_verilog();
633 # p[0] = tmp;
634 # }
635 ()
636 def p_data_type_8(p):
637 '''data_type : TYPE_IDENTIFIER dimensions_opt '''
638 if(parse_debug): print('data_type_8', list(p))
639 # { if (p[2]) {
640 # parray_type_t*tmp = new parray_type_t(p[1].type, p[2]);
641 # FILE_NAME(tmp, @1);
642 # p[0] = tmp;
643 # } else p[0] = p[1].type;
644 # delete[]p[1].text;
645 # }
646 ()
647 def p_data_type_9(p):
648 '''data_type : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_data_type TYPE_IDENTIFIER '''
649 if(parse_debug): print('data_type_9', list(p))
650 # { lex_in_package_scope(0);
651 # p[0] = p[4].type;
652 # delete[]p[4].text;
653 # }
654 ()
655 def p_data_type_10(p):
656 '''data_type : K_string '''
657 if(parse_debug): print('data_type_10', list(p))
658 # { string_type_t*tmp = new string_type_t;
659 # FILE_NAME(tmp, @1);
660 # p[0] = tmp;
661 # }
662 ()
663 def p__embed0_data_type(p):
664 '''_embed0_data_type : '''
665 # { lex_in_package_scope(p[1]); }
666 ()
667 def p_data_type_or_implicit_1(p):
668 '''data_type_or_implicit : data_type '''
669 if(parse_debug): print('data_type_or_implicit_1', list(p))
670 p[0] = p[1]
671 ()
672 def p_data_type_or_implicit_2(p):
673 '''data_type_or_implicit : signing dimensions_opt '''
674 if(parse_debug): print('data_type_or_implicit_2', list(p))
675 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[1], p[2]);
676 # tmp->implicit_flag = true;
677 # FILE_NAME(tmp, @1);
678 # p[0] = tmp;
679 # }
680 ()
681 def p_data_type_or_implicit_3(p):
682 '''data_type_or_implicit : dimensions '''
683 if(parse_debug): print('data_type_or_implicit_3', list(p))
684 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, p[1]);
685 # tmp->implicit_flag = true;
686 # FILE_NAME(tmp, @1);
687 # p[0] = tmp;
688 # }
689 ()
690 def p_data_type_or_implicit_4(p):
691 '''data_type_or_implicit : '''
692 if(parse_debug>2): print('data_type_or_implicit_4', list(p))
693 # { p[0] = None }
694 ()
695 def p_data_type_or_implicit_or_void_1(p):
696 '''data_type_or_implicit_or_void : data_type_or_implicit '''
697 if(parse_debug): print('data_type_or_implicit_or_void_1', list(p))
698 p[0] = p[1]
699 ()
700 def p_data_type_or_implicit_or_void_2(p):
701 '''data_type_or_implicit_or_void : K_void '''
702 if(parse_debug): print('data_type_or_implicit_or_void_2', list(p))
703 # { void_type_t*tmp = new void_type_t;
704 # FILE_NAME(tmp, @1);
705 # p[0] = tmp;
706 # }
707 ()
708 def p_description_1(p):
709 '''description : module '''
710 if(parse_debug>2): print('description_1', list(p))
711 ()
712 def p_description_2(p):
713 '''description : udp_primitive '''
714 if(parse_debug): print('description_2', list(p))
715 ()
716 def p_description_3(p):
717 '''description : config_declaration '''
718 if(parse_debug): print('description_3', list(p))
719 ()
720 def p_description_4(p):
721 '''description : nature_declaration '''
722 if(parse_debug): print('description_4', list(p))
723 ()
724 def p_description_5(p):
725 '''description : package_declaration '''
726 if(parse_debug): print('description_5', list(p))
727 ()
728 def p_description_6(p):
729 '''description : discipline_declaration '''
730 if(parse_debug): print('description_6', list(p))
731 ()
732 def p_description_7(p):
733 '''description : package_item '''
734 if(parse_debug): print('description_7', list(p))
735 ()
736 def p_description_8(p):
737 '''description : KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' '''
738 if(parse_debug): print('description_8', list(p))
739 # { perm_string tmp3 = lex_strings.make(p[3]);
740 # pform_set_type_attrib(tmp3, p[5], p[7]);
741 # delete[] p[3];
742 # delete[] p[5];
743 # }
744 ()
745 def p_description_list_1(p):
746 '''description_list : description '''
747 if(parse_debug>2): print('description_list_1', list(p))
748 ()
749 def p_description_list_2(p):
750 '''description_list : description_list description '''
751 if(parse_debug): print('description_list_2', list(p))
752 ()
753 def p_endnew_opt_1(p):
754 '''endnew_opt : ':' K_new '''
755 if(parse_debug): print('endnew_opt_1', list(p))
756 ()
757 def p_endnew_opt_2(p):
758 '''endnew_opt : '''
759 if(parse_debug): print('endnew_opt_2', list(p))
760 ()
761 def p_dynamic_array_new_1(p):
762 '''dynamic_array_new : K_new '[' expression ']' '''
763 if(parse_debug): print('dynamic_array_new_1', list(p))
764 # { p[0] = new PENewArray(p[3], 0);
765 # FILE_NAME(p[0], @1);
766 # }
767 ()
768 def p_dynamic_array_new_2(p):
769 '''dynamic_array_new : K_new '[' expression ']' '(' expression ')' '''
770 if(parse_debug): print('dynamic_array_new_2', list(p))
771 # { p[0] = new PENewArray(p[3], p[6]);
772 # FILE_NAME(p[0], @1);
773 # }
774 ()
775 def p_for_step_1(p):
776 '''for_step : lpvalue '=' expression '''
777 if(parse_debug): print('for_step_1', list(p))
778 # { PAssign*tmp = new PAssign(p[1],p[3]);
779 # FILE_NAME(tmp, @1);
780 # p[0] = tmp;
781 # }
782 ()
783 def p_for_step_2(p):
784 '''for_step : inc_or_dec_expression '''
785 if(parse_debug): print('for_step_2', list(p))
786 # { p[0] = pform_compressed_assign_from_inc_dec(@1, p[1]); }
787 ()
788 def p_for_step_3(p):
789 '''for_step : compressed_statement '''
790 if(parse_debug): print('for_step_3', list(p))
791 p[0] = p[1]
792 ()
793 def p_function_declaration_1(p):
794 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER ';' _embed0_function_declaration function_item_list statement_or_null_list_opt K_endfunction _embed1_function_declaration endlabel_opt '''
795 if(parse_debug): print('function_declaration_1', list(p))
796 # { // Last step: check any closing name.
797 # if (p[11]) {
798 # if (strcmp(p[4],p[11]) != 0) {
799 # yyerror(@11, "error: End label doesn't match "
800 # "function name");
801 # }
802 # if (! gn_system_verilog()) {
803 # yyerror(@11, "error: Function end labels require "
804 # "SystemVerilog.");
805 # }
806 # delete[]p[11];
807 # }
808 # delete[]p[4];
809 # }
810 ()
811 def p_function_declaration_2(p):
812 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER _embed2_function_declaration '(' tf_port_list_opt ')' ';' block_item_decls_opt statement_or_null_list_opt K_endfunction _embed3_function_declaration endlabel_opt '''
813 if(parse_debug): print('function_declaration_2', list(p))
814 # { // Last step: check any closing name.
815 # if (p[14]) {
816 # if (strcmp(p[4],p[14]) != 0) {
817 # yyerror(@14, "error: End label doesn't match "
818 # "function name");
819 # }
820 # if (! gn_system_verilog()) {
821 # yyerror(@14, "error: Function end labels require "
822 # "SystemVerilog.");
823 # }
824 # delete[]p[14];
825 # }
826 # delete[]p[4];
827 # }
828 ()
829 def p_function_declaration_3(p):
830 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER error K_endfunction _embed4_function_declaration endlabel_opt '''
831 if(parse_debug): print('function_declaration_3', list(p))
832 # { // Last step: check any closing name.
833 # if (p[8]) {
834 # if (strcmp(p[4],p[8]) != 0) {
835 # yyerror(@8, "error: End label doesn't match function name");
836 # }
837 # if (! gn_system_verilog()) {
838 # yyerror(@8, "error: Function end labels require "
839 # "SystemVerilog.");
840 # }
841 # delete[]p[8];
842 # }
843 # delete[]p[4];
844 # }
845 ()
846 def p__embed0_function_declaration(p):
847 '''_embed0_function_declaration : '''
848 # { assert(current_function == 0);
849 # current_function = pform_push_function_scope(@1, p[4], p[2]);
850 # }
851 ()
852 def p__embed1_function_declaration(p):
853 '''_embed1_function_declaration : '''
854 # { current_function->set_ports(p[7]);
855 # current_function->set_return(p[3]);
856 # current_function_set_statement(p[8]? @8 : @4, p[8]);
857 # pform_set_this_class(@4, current_function);
858 # pform_pop_scope();
859 # current_function = 0;
860 # }
861 ()
862 def p__embed2_function_declaration(p):
863 '''_embed2_function_declaration : '''
864 # { assert(current_function == 0);
865 # current_function = pform_push_function_scope(@1, p[4], p[2]);
866 # }
867 ()
868 def p__embed3_function_declaration(p):
869 '''_embed3_function_declaration : '''
870 # { current_function->set_ports(p[7]);
871 # current_function->set_return(p[3]);
872 # current_function_set_statement(p[11]? @11 : @4, p[11]);
873 # pform_set_this_class(@4, current_function);
874 # pform_pop_scope();
875 # current_function = 0;
876 # if (p[7]==0 && !gn_system_verilog()) {
877 # yyerror(@4, "error: Empty parenthesis syntax requires SystemVerilog.");
878 # }
879 # }
880 ()
881 def p__embed4_function_declaration(p):
882 '''_embed4_function_declaration : '''
883 # { /* */
884 # if (current_function) {
885 # pform_pop_scope();
886 # current_function = 0;
887 # }
888 # assert(current_function == 0);
889 # yyerror(@1, "error: Syntax error defining function.");
890 # yyerrok;
891 # }
892 ()
893 def p_import_export_1(p):
894 '''import_export : K_import '''
895 if(parse_debug): print('import_export_1', list(p))
896 p[0] = True
897 ()
898 def p_import_export_2(p):
899 '''import_export : K_export '''
900 if(parse_debug): print('import_export_2', list(p))
901 p[0] = False
902 ()
903 def p_implicit_class_handle_1(p):
904 '''implicit_class_handle : K_this '''
905 if(parse_debug): print('implicit_class_handle_1', list(p))
906 # { p[0] = pform_create_this(); }
907 ()
908 def p_implicit_class_handle_2(p):
909 '''implicit_class_handle : K_super '''
910 if(parse_debug): print('implicit_class_handle_2', list(p))
911 # { p[0] = pform_create_super(); }
912 ()
913 def p_inc_or_dec_expression_1(p):
914 '''inc_or_dec_expression : K_INCR lpvalue %prec UNARY_PREC '''
915 if(parse_debug): print('inc_or_dec_expression_1', list(p))
916 # { PEUnary*tmp = new PEUnary('I', p[2]);
917 # FILE_NAME(tmp, @2);
918 # p[0] = tmp;
919 # }
920 ()
921 def p_inc_or_dec_expression_2(p):
922 '''inc_or_dec_expression : lpvalue K_INCR %prec UNARY_PREC '''
923 if(parse_debug): print('inc_or_dec_expression_2', list(p))
924 # { PEUnary*tmp = new PEUnary('i', p[1]);
925 # FILE_NAME(tmp, @1);
926 # p[0] = tmp;
927 # }
928 ()
929 def p_inc_or_dec_expression_3(p):
930 '''inc_or_dec_expression : K_DECR lpvalue %prec UNARY_PREC '''
931 if(parse_debug): print('inc_or_dec_expression_3', list(p))
932 # { PEUnary*tmp = new PEUnary('D', p[2]);
933 # FILE_NAME(tmp, @2);
934 # p[0] = tmp;
935 # }
936 ()
937 def p_inc_or_dec_expression_4(p):
938 '''inc_or_dec_expression : lpvalue K_DECR %prec UNARY_PREC '''
939 if(parse_debug): print('inc_or_dec_expression_4', list(p))
940 # { PEUnary*tmp = new PEUnary('d', p[1]);
941 # FILE_NAME(tmp, @1);
942 # p[0] = tmp;
943 # }
944 ()
945 def p_inside_expression_1(p):
946 '''inside_expression : expression K_inside '{' open_range_list '}' '''
947 if(parse_debug): print('inside_expression_1', list(p))
948 # { yyerror(@2, "sorry: \"inside\" expressions not supported yet.");
949 # p[0] = None
950 # }
951 ()
952 def p_integer_vector_type_1(p):
953 '''integer_vector_type : K_reg '''
954 if(parse_debug): print('integer_vector_type_1', list(p))
955 p[0] = IVL_VT_NO_TYPE
956 ()
957 def p_integer_vector_type_2(p):
958 '''integer_vector_type : K_bit '''
959 if(parse_debug): print('integer_vector_type_2', list(p))
960 p[0] = IVL_VT_BOOL
961 ()
962 def p_integer_vector_type_3(p):
963 '''integer_vector_type : K_logic '''
964 if(parse_debug): print('integer_vector_type_3', list(p))
965 p[0] = IVL_VT_LOGIC
966 ()
967 def p_integer_vector_type_4(p):
968 '''integer_vector_type : K_bool '''
969 if(parse_debug): print('integer_vector_type_4', list(p))
970 # { p[0] = IVL_VT_BOOL; }
971 ()
972 def p_join_keyword_1(p):
973 '''join_keyword : K_join '''
974 if(parse_debug): print('join_keyword_1', list(p))
975 # { p[0] = PBlock::BL_PAR; }
976 ()
977 def p_join_keyword_2(p):
978 '''join_keyword : K_join_none '''
979 if(parse_debug): print('join_keyword_2', list(p))
980 # { p[0] = PBlock::BL_JOIN_NONE; }
981 ()
982 def p_join_keyword_3(p):
983 '''join_keyword : K_join_any '''
984 if(parse_debug): print('join_keyword_3', list(p))
985 # { p[0] = PBlock::BL_JOIN_ANY; }
986 ()
987 def p_jump_statement_1(p):
988 '''jump_statement : K_break ';' '''
989 if(parse_debug): print('jump_statement_1', list(p))
990 # { yyerror(@1, "sorry: break statements not supported.");
991 # p[0] = None
992 # }
993 ()
994 def p_jump_statement_2(p):
995 '''jump_statement : K_return ';' '''
996 if(parse_debug): print('jump_statement_2', list(p))
997 # { PReturn*tmp = new PReturn(0);
998 # FILE_NAME(tmp, @1);
999 # p[0] = tmp;
1000 # }
1001 ()
1002 def p_jump_statement_3(p):
1003 '''jump_statement : K_return expression ';' '''
1004 if(parse_debug): print('jump_statement_3', list(p))
1005 # { PReturn*tmp = new PReturn(p[2]);
1006 # FILE_NAME(tmp, @1);
1007 # p[0] = tmp;
1008 # }
1009 ()
1010 def p_lifetime_1(p):
1011 '''lifetime : K_automatic '''
1012 if(parse_debug): print('lifetime_1', list(p))
1013 # { p[0] = LexicalScope::AUTOMATIC; }
1014 ()
1015 def p_lifetime_2(p):
1016 '''lifetime : K_static '''
1017 if(parse_debug): print('lifetime_2', list(p))
1018 # { p[0] = LexicalScope::STATIC; }
1019 ()
1020 def p_lifetime_opt_1(p):
1021 '''lifetime_opt : lifetime '''
1022 if(parse_debug): print('lifetime_opt_1', list(p))
1023 p[0] = p[1]
1024 ()
1025 def p_lifetime_opt_2(p):
1026 '''lifetime_opt : '''
1027 if(parse_debug>2): print('lifetime_opt_2', list(p))
1028 # { p[0] = LexicalScope::INHERITED; }
1029 ()
1030 def p_loop_statement_1(p):
1031 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' for_step ')' statement_or_null '''
1032 if(parse_debug): print('loop_statement_1', list(p))
1033 # { PForStatement*tmp = new PForStatement(p[3], p[5], p[7], p[9], p[11]);
1034 # FILE_NAME(tmp, @1);
1035 # p[0] = tmp;
1036 # }
1037 ()
1038 def p_loop_statement_2(p):
1039 '''loop_statement : K_for '(' data_type IDENTIFIER '=' expression ';' expression ';' for_step ')' _embed0_loop_statement statement_or_null '''
1040 if(parse_debug): print('loop_statement_2', list(p))
1041 # { pform_name_t tmp_hident;
1042 # tmp_hident.push_back(name_component_t(lex_strings.make(p[4])));
1043 #
1044 # PEIdent*tmp_ident = pform_new_ident(tmp_hident);
1045 # FILE_NAME(tmp_ident, @4);
1046 #
1047 # PForStatement*tmp_for = new PForStatement(tmp_ident, p[6], p[8], p[10], p[13]);
1048 # FILE_NAME(tmp_for, @1);
1049 #
1050 # pform_pop_scope();
1051 # vector<Statement*>tmp_for_list (1);
1052 # tmp_for_list[0] = tmp_for;
1053 # PBlock*tmp_blk = current_block_stack.top();
1054 # current_block_stack.pop();
1055 # tmp_blk->set_statement(tmp_for_list);
1056 # p[0] = tmp_blk;
1057 # delete[]p[4];
1058 # }
1059 ()
1060 def p_loop_statement_3(p):
1061 '''loop_statement : K_forever statement_or_null '''
1062 if(parse_debug): print('loop_statement_3', list(p))
1063 # { PForever*tmp = new PForever(p[2]);
1064 # FILE_NAME(tmp, @1);
1065 # p[0] = tmp;
1066 # }
1067 ()
1068 def p_loop_statement_4(p):
1069 '''loop_statement : K_repeat '(' expression ')' statement_or_null '''
1070 if(parse_debug): print('loop_statement_4', list(p))
1071 # { PRepeat*tmp = new PRepeat(p[3], p[5]);
1072 # FILE_NAME(tmp, @1);
1073 # p[0] = tmp;
1074 # }
1075 ()
1076 def p_loop_statement_5(p):
1077 '''loop_statement : K_while '(' expression ')' statement_or_null '''
1078 if(parse_debug): print('loop_statement_5', list(p))
1079 # { PWhile*tmp = new PWhile(p[3], p[5]);
1080 # FILE_NAME(tmp, @1);
1081 # p[0] = tmp;
1082 # }
1083 ()
1084 def p_loop_statement_6(p):
1085 '''loop_statement : K_do statement_or_null K_while '(' expression ')' ';' '''
1086 if(parse_debug): print('loop_statement_6', list(p))
1087 # { PDoWhile*tmp = new PDoWhile(p[5], p[2]);
1088 # FILE_NAME(tmp, @1);
1089 # p[0] = tmp;
1090 # }
1091 ()
1092 def p_loop_statement_7(p):
1093 '''loop_statement : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' _embed1_loop_statement statement_or_null '''
1094 if(parse_debug): print('loop_statement_7', list(p))
1095 # { PForeach*tmp_for = pform_make_foreach(@1, p[3], p[5], p[9]);
1096 #
1097 # pform_pop_scope();
1098 # vector<Statement*>tmp_for_list(1);
1099 # tmp_for_list[0] = tmp_for;
1100 # PBlock*tmp_blk = current_block_stack.top();
1101 # current_block_stack.pop();
1102 # tmp_blk->set_statement(tmp_for_list);
1103 # p[0] = tmp_blk;
1104 # }
1105 ()
1106 def p_loop_statement_8(p):
1107 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' error ')' statement_or_null '''
1108 if(parse_debug): print('loop_statement_8', list(p))
1109 # { p[0] = None
1110 # yyerror(@1, "error: Error in for loop step assignment.");
1111 # }
1112 ()
1113 def p_loop_statement_9(p):
1114 '''loop_statement : K_for '(' lpvalue '=' expression ';' error ';' for_step ')' statement_or_null '''
1115 if(parse_debug): print('loop_statement_9', list(p))
1116 # { p[0] = None
1117 # yyerror(@1, "error: Error in for loop condition expression.");
1118 # }
1119 ()
1120 def p_loop_statement_10(p):
1121 '''loop_statement : K_for '(' error ')' statement_or_null '''
1122 if(parse_debug): print('loop_statement_10', list(p))
1123 # { p[0] = None
1124 # yyerror(@1, "error: Incomprehensible for loop.");
1125 # }
1126 ()
1127 def p_loop_statement_11(p):
1128 '''loop_statement : K_while '(' error ')' statement_or_null '''
1129 if(parse_debug): print('loop_statement_11', list(p))
1130 # { p[0] = None
1131 # yyerror(@1, "error: Error in while loop condition.");
1132 # }
1133 ()
1134 def p_loop_statement_12(p):
1135 '''loop_statement : K_do statement_or_null K_while '(' error ')' ';' '''
1136 if(parse_debug): print('loop_statement_12', list(p))
1137 # { p[0] = None
1138 # yyerror(@1, "error: Error in do/while loop condition.");
1139 # }
1140 ()
1141 def p_loop_statement_13(p):
1142 '''loop_statement : K_foreach '(' IDENTIFIER '[' error ']' ')' statement_or_null '''
1143 if(parse_debug): print('loop_statement_13', list(p))
1144 # { p[0] = None
1145 # yyerror(@4, "error: Errors in foreach loop variables list.");
1146 # }
1147 ()
1148 def p__embed0_loop_statement(p):
1149 '''_embed0_loop_statement : '''
1150 # { static unsigned for_counter = 0;
1151 # char for_block_name [64];
1152 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_for_loop%u", for_counter);
1153 # for_counter += 1;
1154 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1155 # FILE_NAME(tmp, @1);
1156 # current_block_stack.push(tmp);
1157 #
1158 # list<decl_assignment_t*>assign_list;
1159 # decl_assignment_t*tmp_assign = new decl_assignment_t;
1160 # tmp_assign->name = lex_strings.make(p[4]);
1161 # assign_list.push_back(tmp_assign);
1162 # pform_makewire(@4, 0, str_strength, &assign_list, NetNet::REG, p[3]);
1163 # }
1164 ()
1165 def p__embed1_loop_statement(p):
1166 '''_embed1_loop_statement : '''
1167 # { static unsigned foreach_counter = 0;
1168 # char for_block_name[64];
1169 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_foreach%u", foreach_counter);
1170 # foreach_counter += 1;
1171 #
1172 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1173 # FILE_NAME(tmp, @1);
1174 # current_block_stack.push(tmp);
1175 #
1176 # pform_make_foreach_declarations(@1, p[5]);
1177 # }
1178 ()
1179 def p_list_of_variable_decl_assignments_1(p):
1180 '''list_of_variable_decl_assignments : variable_decl_assignment '''
1181 if(parse_debug): print('list_of_variable_decl_assignments_1', list(p))
1182 # { list<decl_assignment_t*>*tmp = new list<decl_assignment_t*>;
1183 # tmp->push_back(p[1]);
1184 # p[0] = tmp;
1185 # }
1186 ()
1187 def p_list_of_variable_decl_assignments_2(p):
1188 '''list_of_variable_decl_assignments : list_of_variable_decl_assignments ',' variable_decl_assignment '''
1189 if(parse_debug): print('list_of_variable_decl_assignments_2', list(p))
1190 # { list<decl_assignment_t*>*tmp = p[1];
1191 # tmp->push_back(p[3]);
1192 # p[0] = tmp;
1193 # }
1194 ()
1195 def p_variable_decl_assignment_1(p):
1196 '''variable_decl_assignment : IDENTIFIER dimensions_opt '''
1197 if(parse_debug): print('variable_decl_assignment_1', list(p))
1198 # { decl_assignment_t*tmp = new decl_assignment_t;
1199 # tmp->name = lex_strings.make(p[1]);
1200 # if (p[2]) {
1201 # tmp->index = *p[2];
1202 # delete p[2];
1203 # }
1204 # delete[]p[1];
1205 # p[0] = tmp;
1206 # }
1207 ()
1208 def p_variable_decl_assignment_2(p):
1209 '''variable_decl_assignment : IDENTIFIER '=' expression '''
1210 if(parse_debug): print('variable_decl_assignment_2', list(p))
1211 # { decl_assignment_t*tmp = new decl_assignment_t;
1212 # tmp->name = lex_strings.make(p[1]);
1213 # tmp->expr .reset(p[3]);
1214 # delete[]p[1];
1215 # p[0] = tmp;
1216 # }
1217 ()
1218 def p_variable_decl_assignment_3(p):
1219 '''variable_decl_assignment : IDENTIFIER '=' K_new '(' ')' '''
1220 if(parse_debug): print('variable_decl_assignment_3', list(p))
1221 # { decl_assignment_t*tmp = new decl_assignment_t;
1222 # tmp->name = lex_strings.make(p[1]);
1223 # PENewClass*expr = new PENewClass;
1224 # FILE_NAME(expr, @3);
1225 # tmp->expr .reset(expr);
1226 # delete[]p[1];
1227 # p[0] = tmp;
1228 # }
1229 ()
1230 def p_loop_variables_1(p):
1231 '''loop_variables : loop_variables ',' IDENTIFIER '''
1232 if(parse_debug): print('loop_variables_1', list(p))
1233 # { list<perm_string>*tmp = p[1];
1234 # tmp->push_back(lex_strings.make(p[3]));
1235 # delete[]p[3];
1236 # p[0] = tmp;
1237 # }
1238 ()
1239 def p_loop_variables_2(p):
1240 '''loop_variables : IDENTIFIER '''
1241 if(parse_debug): print('loop_variables_2', list(p))
1242 # { list<perm_string>*tmp = new list<perm_string>;
1243 # tmp->push_back(lex_strings.make(p[1]));
1244 # delete[]p[1];
1245 # p[0] = tmp;
1246 # }
1247 ()
1248 def p_method_qualifier_1(p):
1249 '''method_qualifier : K_virtual '''
1250 if(parse_debug): print('method_qualifier_1', list(p))
1251 ()
1252 def p_method_qualifier_2(p):
1253 '''method_qualifier : class_item_qualifier '''
1254 if(parse_debug): print('method_qualifier_2', list(p))
1255 ()
1256 def p_method_qualifier_opt_1(p):
1257 '''method_qualifier_opt : method_qualifier '''
1258 if(parse_debug): print('method_qualifier_opt_1', list(p))
1259 ()
1260 def p_method_qualifier_opt_2(p):
1261 '''method_qualifier_opt : '''
1262 if(parse_debug): print('method_qualifier_opt_2', list(p))
1263 ()
1264 def p_modport_declaration_1(p):
1265 '''modport_declaration : K_modport _embed0_modport_declaration modport_item_list ';' '''
1266 if(parse_debug): print('modport_declaration_1', list(p))
1267 ()
1268 def p__embed0_modport_declaration(p):
1269 '''_embed0_modport_declaration : '''
1270 # { if (!pform_in_interface())
1271 # yyerror(@1, "error: modport declarations are only allowed "
1272 # "in interfaces.");
1273 # }
1274 ()
1275 def p_modport_item_list_1(p):
1276 '''modport_item_list : modport_item '''
1277 if(parse_debug): print('modport_item_list_1', list(p))
1278 ()
1279 def p_modport_item_list_2(p):
1280 '''modport_item_list : modport_item_list ',' modport_item '''
1281 if(parse_debug): print('modport_item_list_2', list(p))
1282 ()
1283 def p_modport_item_1(p):
1284 '''modport_item : IDENTIFIER _embed0_modport_item '(' modport_ports_list ')' '''
1285 if(parse_debug): print('modport_item_1', list(p))
1286 # { pform_end_modport_item(@1); }
1287 ()
1288 def p__embed0_modport_item(p):
1289 '''_embed0_modport_item : '''
1290 # { pform_start_modport_item(@1, p[1]); }
1291 ()
1292 def p_modport_ports_list_1(p):
1293 '''modport_ports_list : modport_ports_declaration '''
1294 if(parse_debug): print('modport_ports_list_1', list(p))
1295 ()
1296 def p_modport_ports_list_2(p):
1297 '''modport_ports_list : modport_ports_list ',' modport_ports_declaration '''
1298 if(parse_debug): print('modport_ports_list_2', list(p))
1299 ()
1300 def p_modport_ports_list_3(p):
1301 '''modport_ports_list : modport_ports_list ',' modport_simple_port '''
1302 if(parse_debug): print('modport_ports_list_3', list(p))
1303 # { if (last_modport_port.type == MP_SIMPLE) {
1304 # pform_add_modport_port(@3, last_modport_port.direction,
1305 # p[3]->name, p[3]->parm);
1306 # } else {
1307 # yyerror(@3, "error: modport expression not allowed here.");
1308 # }
1309 # delete p[3];
1310 # }
1311 ()
1312 def p_modport_ports_list_4(p):
1313 '''modport_ports_list : modport_ports_list ',' modport_tf_port '''
1314 if(parse_debug): print('modport_ports_list_4', list(p))
1315 # { if (last_modport_port.type != MP_TF)
1316 # yyerror(@3, "error: task/function declaration not allowed here.");
1317 # }
1318 ()
1319 def p_modport_ports_list_5(p):
1320 '''modport_ports_list : modport_ports_list ',' IDENTIFIER '''
1321 if(parse_debug): print('modport_ports_list_5', list(p))
1322 # { if (last_modport_port.type == MP_SIMPLE) {
1323 # pform_add_modport_port(@3, last_modport_port.direction,
1324 # lex_strings.make(p[3]), 0);
1325 # } else if (last_modport_port.type != MP_TF) {
1326 # yyerror(@3, "error: list of identifiers not allowed here.");
1327 # }
1328 # delete[] p[3];
1329 # }
1330 ()
1331 def p_modport_ports_list_6(p):
1332 '''modport_ports_list : modport_ports_list ',' '''
1333 if(parse_debug): print('modport_ports_list_6', list(p))
1334 # { yyerror(@2, "error: NULL port declarations are not allowed"); }
1335 ()
1336 def p_modport_ports_declaration_1(p):
1337 '''modport_ports_declaration : attribute_list_opt port_direction IDENTIFIER '''
1338 if(parse_debug): print('modport_ports_declaration_1', list(p))
1339 # { last_modport_port.type = MP_SIMPLE;
1340 # last_modport_port.direction = p[2];
1341 # pform_add_modport_port(@3, p[2], lex_strings.make(p[3]), 0);
1342 # delete[] p[3];
1343 # delete p[1];
1344 # }
1345 ()
1346 def p_modport_ports_declaration_2(p):
1347 '''modport_ports_declaration : attribute_list_opt port_direction modport_simple_port '''
1348 if(parse_debug): print('modport_ports_declaration_2', list(p))
1349 # { last_modport_port.type = MP_SIMPLE;
1350 # last_modport_port.direction = p[2];
1351 # pform_add_modport_port(@3, p[2], p[3]->name, p[3]->parm);
1352 # delete p[3];
1353 # delete p[1];
1354 # }
1355 ()
1356 def p_modport_ports_declaration_3(p):
1357 '''modport_ports_declaration : attribute_list_opt import_export IDENTIFIER '''
1358 if(parse_debug): print('modport_ports_declaration_3', list(p))
1359 # { last_modport_port.type = MP_TF;
1360 # last_modport_port.is_import = p[2];
1361 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
1362 # delete[] p[3];
1363 # delete p[1];
1364 # }
1365 ()
1366 def p_modport_ports_declaration_4(p):
1367 '''modport_ports_declaration : attribute_list_opt import_export modport_tf_port '''
1368 if(parse_debug): print('modport_ports_declaration_4', list(p))
1369 # { last_modport_port.type = MP_TF;
1370 # last_modport_port.is_import = p[2];
1371 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
1372 # delete p[1];
1373 # }
1374 ()
1375 def p_modport_ports_declaration_5(p):
1376 '''modport_ports_declaration : attribute_list_opt K_clocking IDENTIFIER '''
1377 if(parse_debug): print('modport_ports_declaration_5', list(p))
1378 # { last_modport_port.type = MP_CLOCKING;
1379 # last_modport_port.direction = NetNet::NOT_A_PORT;
1380 # yyerror(@3, "sorry: modport clocking declaration is not yet supported.");
1381 # delete[] p[3];
1382 # delete p[1];
1383 # }
1384 ()
1385 def p_modport_simple_port_1(p):
1386 '''modport_simple_port : '.' IDENTIFIER '(' expression ')' '''
1387 if(parse_debug): print('modport_simple_port_1', list(p))
1388 # { named_pexpr_t*tmp = new named_pexpr_t;
1389 # tmp->name = lex_strings.make(p[2]);
1390 # tmp->parm = p[4];
1391 # delete[]p[2];
1392 # p[0] = tmp;
1393 # }
1394 ()
1395 def p_modport_tf_port_1(p):
1396 '''modport_tf_port : K_task IDENTIFIER '''
1397 if(parse_debug): print('modport_tf_port_1', list(p))
1398 ()
1399 def p_modport_tf_port_2(p):
1400 '''modport_tf_port : K_task IDENTIFIER '(' tf_port_list_opt ')' '''
1401 if(parse_debug): print('modport_tf_port_2', list(p))
1402 ()
1403 def p_modport_tf_port_3(p):
1404 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '''
1405 if(parse_debug): print('modport_tf_port_3', list(p))
1406 ()
1407 def p_modport_tf_port_4(p):
1408 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' '''
1409 if(parse_debug): print('modport_tf_port_4', list(p))
1410 ()
1411 def p_non_integer_type_1(p):
1412 '''non_integer_type : K_real '''
1413 if(parse_debug): print('non_integer_type_1', list(p))
1414 # { p[0] = real_type_t::REAL; }
1415 ()
1416 def p_non_integer_type_2(p):
1417 '''non_integer_type : K_realtime '''
1418 if(parse_debug): print('non_integer_type_2', list(p))
1419 # { p[0] = real_type_t::REAL; }
1420 ()
1421 def p_non_integer_type_3(p):
1422 '''non_integer_type : K_shortreal '''
1423 if(parse_debug): print('non_integer_type_3', list(p))
1424 # { p[0] = real_type_t::SHORTREAL; }
1425 ()
1426 def p_number_1(p):
1427 '''number : BASED_NUMBER '''
1428 if(parse_debug): print('number_1', list(p))
1429 # { p[0] = p[1]; based_size = 0;}
1430 ()
1431 def p_number_2(p):
1432 '''number : DEC_NUMBER '''
1433 if(parse_debug): print('number_2', list(p))
1434 num = Leaf(token.NUMBER, "%s" % (p[1]))
1435 p[0] = num
1436 # { p[0] = p[1]; based_size = 0;}
1437 ()
1438 def p_number_3(p):
1439 '''number : DEC_NUMBER BASED_NUMBER '''
1440 if(parse_debug): print('number_3', list(p))
1441 num = Leaf(token.NUMBER, "%s:%s" % (p[1], p[2]))
1442 p[0] = num
1443 # { p[0] = pform_verinum_with_size(p[1],p[2], @2.text, @2.first_line);
1444 # based_size = 0; }
1445 ()
1446 def p_number_4(p):
1447 '''number : UNBASED_NUMBER '''
1448 if(parse_debug): print('number_4', list(p))
1449 # { p[0] = p[1]; based_size = 0;}
1450 ()
1451 def p_number_5(p):
1452 '''number : DEC_NUMBER UNBASED_NUMBER '''
1453 if(parse_debug): print('number_5', list(p))
1454 # { yyerror(@1, "error: Unbased SystemVerilog literal cannot have "
1455 # "a size.");
1456 # p[0] = p[1]; based_size = 0;}
1457 ()
1458 def p_open_range_list_1(p):
1459 '''open_range_list : open_range_list ',' value_range '''
1460 if(parse_debug): print('open_range_list_1', list(p))
1461 ()
1462 def p_open_range_list_2(p):
1463 '''open_range_list : value_range '''
1464 if(parse_debug): print('open_range_list_2', list(p))
1465 ()
1466 def p_package_declaration_1(p):
1467 '''package_declaration : K_package lifetime_opt IDENTIFIER ';' _embed0_package_declaration timeunits_declaration_opt _embed1_package_declaration package_item_list_opt K_endpackage endlabel_opt '''
1468 if(parse_debug): print('package_declaration_1', list(p))
1469 # { pform_end_package_declaration(@1);
1470 # // If an end label is present make sure it match the package name.
1471 # if (p[10]) {
1472 # if (strcmp(p[3],p[10]) != 0) {
1473 # yyerror(@10, "error: End label doesn't match package name");
1474 # }
1475 # delete[]p[10];
1476 # }
1477 # delete[]p[3];
1478 # }
1479 ()
1480 def p__embed0_package_declaration(p):
1481 '''_embed0_package_declaration : '''
1482 # { pform_start_package_declaration(@1, p[3], p[2]); }
1483 ()
1484 def p__embed1_package_declaration(p):
1485 '''_embed1_package_declaration : '''
1486 # { pform_set_scope_timescale(@1); }
1487 ()
1488 def p_module_package_import_list_opt_1(p):
1489 '''module_package_import_list_opt : '''
1490 if(parse_debug>1): print('module_package_import_list_opt_1', list(p))
1491 ()
1492 def p_module_package_import_list_opt_2(p):
1493 '''module_package_import_list_opt : package_import_list '''
1494 if(parse_debug): print('module_package_import_list_opt_2', list(p))
1495 ()
1496 def p_package_import_list_1(p):
1497 '''package_import_list : package_import_declaration '''
1498 if(parse_debug): print('package_import_list_1', list(p))
1499 ()
1500 def p_package_import_list_2(p):
1501 '''package_import_list : package_import_list package_import_declaration '''
1502 if(parse_debug): print('package_import_list_2', list(p))
1503 ()
1504 def p_package_import_declaration_1(p):
1505 '''package_import_declaration : K_import package_import_item_list ';' '''
1506 if(parse_debug): print('package_import_declaration_1', list(p))
1507 # { }
1508 ()
1509 def p_package_import_item_1(p):
1510 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '''
1511 if(parse_debug): print('package_import_item_1', list(p))
1512 # { pform_package_import(@2, p[1], p[3]);
1513 # delete[]p[3];
1514 # }
1515 ()
1516 def p_package_import_item_2(p):
1517 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES '*' '''
1518 if(parse_debug): print('package_import_item_2', list(p))
1519 # { pform_package_import(@2, p[1], 0);
1520 # }
1521 ()
1522 def p_package_import_item_list_1(p):
1523 '''package_import_item_list : package_import_item_list ',' package_import_item '''
1524 if(parse_debug): print('package_import_item_list_1', list(p))
1525 ()
1526 def p_package_import_item_list_2(p):
1527 '''package_import_item_list : package_import_item '''
1528 if(parse_debug): print('package_import_item_list_2', list(p))
1529 ()
1530 def p_package_item_1(p):
1531 '''package_item : timeunits_declaration '''
1532 if(parse_debug): print('package_item_1', list(p))
1533 ()
1534 def p_package_item_2(p):
1535 '''package_item : K_parameter param_type parameter_assign_list ';' '''
1536 if(parse_debug): print('package_item_2', list(p))
1537 ()
1538 def p_package_item_3(p):
1539 '''package_item : K_localparam param_type localparam_assign_list ';' '''
1540 if(parse_debug): print('package_item_3', list(p))
1541 ()
1542 def p_package_item_4(p):
1543 '''package_item : type_declaration '''
1544 if(parse_debug): print('package_item_4', list(p))
1545 ()
1546 def p_package_item_5(p):
1547 '''package_item : function_declaration '''
1548 if(parse_debug): print('package_item_5', list(p))
1549 ()
1550 def p_package_item_6(p):
1551 '''package_item : task_declaration '''
1552 if(parse_debug): print('package_item_6', list(p))
1553 ()
1554 def p_package_item_7(p):
1555 '''package_item : data_declaration '''
1556 if(parse_debug): print('package_item_7', list(p))
1557 ()
1558 def p_package_item_8(p):
1559 '''package_item : class_declaration '''
1560 if(parse_debug): print('package_item_8', list(p))
1561 ()
1562 def p_package_item_list_1(p):
1563 '''package_item_list : package_item_list package_item '''
1564 if(parse_debug): print('package_item_list_1', list(p))
1565 ()
1566 def p_package_item_list_2(p):
1567 '''package_item_list : package_item '''
1568 if(parse_debug): print('package_item_list_2', list(p))
1569 ()
1570 def p_package_item_list_opt_1(p):
1571 '''package_item_list_opt : package_item_list '''
1572 if(parse_debug): print('package_item_list_opt_1', list(p))
1573 ()
1574 def p_package_item_list_opt_2(p):
1575 '''package_item_list_opt : '''
1576 if(parse_debug): print('package_item_list_opt_2', list(p))
1577 ()
1578 def p_port_direction_1(p):
1579 '''port_direction : K_input '''
1580 if(parse_debug): print('port_direction_1', list(p))
1581 # { p[0] = NetNet::PINPUT; }
1582 ()
1583 def p_port_direction_2(p):
1584 '''port_direction : K_output '''
1585 if(parse_debug): print('port_direction_2', list(p))
1586 # { p[0] = NetNet::POUTPUT; }
1587 ()
1588 def p_port_direction_3(p):
1589 '''port_direction : K_inout '''
1590 if(parse_debug): print('port_direction_3', list(p))
1591 # { p[0] = NetNet::PINOUT; }
1592 ()
1593 def p_port_direction_4(p):
1594 '''port_direction : K_ref '''
1595 if(parse_debug): print('port_direction_4', list(p))
1596 # { p[0] = NetNet::PREF;
1597 # if (!gn_system_verilog()) {
1598 # yyerror(@1, "error: Reference ports (ref) require SystemVerilog.");
1599 # p[0] = NetNet::PINPUT;
1600 # }
1601 # }
1602 ()
1603 def p_port_direction_opt_1(p):
1604 '''port_direction_opt : port_direction '''
1605 if(parse_debug): print('port_direction_opt_1', list(p))
1606 p[0] = p[1]
1607 ()
1608 def p_port_direction_opt_2(p):
1609 '''port_direction_opt : '''
1610 if(parse_debug): print('port_direction_opt_2', list(p))
1611 # { p[0] = NetNet::PIMPLICIT; }
1612 ()
1613 def p_property_expr_1(p):
1614 '''property_expr : expression '''
1615 if(parse_debug): print('property_expr_1', list(p))
1616 ()
1617 def p_procedural_assertion_statement_1(p):
1618 '''procedural_assertion_statement : K_assert '(' expression ')' statement %prec less_than_K_else '''
1619 if(parse_debug): print('procedural_assertion_statement_1', list(p))
1620 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
1621 # p[0] = None
1622 # }
1623 ()
1624 def p_procedural_assertion_statement_2(p):
1625 '''procedural_assertion_statement : K_assert '(' expression ')' K_else statement '''
1626 if(parse_debug): print('procedural_assertion_statement_2', list(p))
1627 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
1628 # p[0] = None
1629 # }
1630 ()
1631 def p_procedural_assertion_statement_3(p):
1632 '''procedural_assertion_statement : K_assert '(' expression ')' statement K_else statement '''
1633 if(parse_debug): print('procedural_assertion_statement_3', list(p))
1634 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
1635 # p[0] = None
1636 # }
1637 ()
1638 def p_property_qualifier_1(p):
1639 '''property_qualifier : class_item_qualifier '''
1640 if(parse_debug): print('property_qualifier_1', list(p))
1641 ()
1642 def p_property_qualifier_2(p):
1643 '''property_qualifier : random_qualifier '''
1644 if(parse_debug): print('property_qualifier_2', list(p))
1645 ()
1646 def p_property_qualifier_opt_1(p):
1647 '''property_qualifier_opt : property_qualifier_list '''
1648 if(parse_debug): print('property_qualifier_opt_1', list(p))
1649 p[0] = p[1]
1650 ()
1651 def p_property_qualifier_opt_2(p):
1652 '''property_qualifier_opt : '''
1653 if(parse_debug): print('property_qualifier_opt_2', list(p))
1654 # { p[0] = property_qualifier_t::make_none(); }
1655 ()
1656 def p_property_qualifier_list_1(p):
1657 '''property_qualifier_list : property_qualifier_list property_qualifier '''
1658 if(parse_debug): print('property_qualifier_list_1', list(p))
1659 # { p[0] = p[1] | p[2]; }
1660 ()
1661 def p_property_qualifier_list_2(p):
1662 '''property_qualifier_list : property_qualifier '''
1663 if(parse_debug): print('property_qualifier_list_2', list(p))
1664 p[0] = p[1]
1665 ()
1666 def p_property_spec_1(p):
1667 '''property_spec : clocking_event_opt property_spec_disable_iff_opt property_expr '''
1668 if(parse_debug): print('property_spec_1', list(p))
1669 ()
1670 def p_property_spec_disable_iff_opt_1(p):
1671 '''property_spec_disable_iff_opt : K_disable K_iff '(' expression ')' '''
1672 if(parse_debug): print('property_spec_disable_iff_opt_1', list(p))
1673 ()
1674 def p_property_spec_disable_iff_opt_2(p):
1675 '''property_spec_disable_iff_opt : '''
1676 if(parse_debug): print('property_spec_disable_iff_opt_2', list(p))
1677 ()
1678 def p_random_qualifier_1(p):
1679 '''random_qualifier : K_rand '''
1680 if(parse_debug): print('random_qualifier_1', list(p))
1681 # { p[0] = property_qualifier_t::make_rand(); }
1682 ()
1683 def p_random_qualifier_2(p):
1684 '''random_qualifier : K_randc '''
1685 if(parse_debug): print('random_qualifier_2', list(p))
1686 # { p[0] = property_qualifier_t::make_randc(); }
1687 ()
1688 def p_real_or_realtime_1(p):
1689 '''real_or_realtime : K_real '''
1690 if(parse_debug): print('real_or_realtime_1', list(p))
1691 ()
1692 def p_real_or_realtime_2(p):
1693 '''real_or_realtime : K_realtime '''
1694 if(parse_debug): print('real_or_realtime_2', list(p))
1695 ()
1696 def p_signing_1(p):
1697 '''signing : K_signed '''
1698 if(parse_debug): print('signing_1', list(p))
1699 p[0] = True
1700 ()
1701 def p_signing_2(p):
1702 '''signing : K_unsigned '''
1703 if(parse_debug): print('signing_2', list(p))
1704 p[0] = False
1705 ()
1706 def p_simple_type_or_string_1(p):
1707 '''simple_type_or_string : integer_vector_type '''
1708 if(parse_debug): print('simple_type_or_string_1', list(p))
1709 # { ivl_variable_type_t use_vtype = p[1];
1710 # bool reg_flag = false;
1711 # if (use_vtype == IVL_VT_NO_TYPE) {
1712 # use_vtype = IVL_VT_LOGIC;
1713 # reg_flag = true;
1714 # }
1715 # vector_type_t*tmp = new vector_type_t(use_vtype, false, 0);
1716 # tmp->reg_flag = reg_flag;
1717 # FILE_NAME(tmp, @1);
1718 # p[0] = tmp;
1719 # }
1720 ()
1721 def p_simple_type_or_string_2(p):
1722 '''simple_type_or_string : non_integer_type '''
1723 if(parse_debug): print('simple_type_or_string_2', list(p))
1724 # { real_type_t*tmp = new real_type_t(p[1]);
1725 # FILE_NAME(tmp, @1);
1726 # p[0] = tmp;
1727 # }
1728 ()
1729 def p_simple_type_or_string_3(p):
1730 '''simple_type_or_string : atom2_type '''
1731 if(parse_debug): print('simple_type_or_string_3', list(p))
1732 # { atom2_type_t*tmp = new atom2_type_t(p[1], true);
1733 # FILE_NAME(tmp, @1);
1734 # p[0] = tmp;
1735 # }
1736 ()
1737 def p_simple_type_or_string_4(p):
1738 '''simple_type_or_string : K_integer '''
1739 if(parse_debug): print('simple_type_or_string_4', list(p))
1740 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
1741 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, true, pd);
1742 # tmp->reg_flag = true;
1743 # tmp->integer_flag = true;
1744 # p[0] = tmp;
1745 # }
1746 ()
1747 def p_simple_type_or_string_5(p):
1748 '''simple_type_or_string : K_time '''
1749 if(parse_debug): print('simple_type_or_string_5', list(p))
1750 # { list<pform_range_t>*pd = make_range_from_width(64);
1751 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
1752 # tmp->reg_flag = !gn_system_verilog();
1753 # p[0] = tmp;
1754 # }
1755 ()
1756 def p_simple_type_or_string_6(p):
1757 '''simple_type_or_string : TYPE_IDENTIFIER '''
1758 if(parse_debug): print('simple_type_or_string_6', list(p))
1759 # { p[0] = p[1].type;
1760 # delete[]p[1].text;
1761 # }
1762 ()
1763 def p_simple_type_or_string_7(p):
1764 '''simple_type_or_string : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_simple_type_or_string TYPE_IDENTIFIER '''
1765 if(parse_debug): print('simple_type_or_string_7', list(p))
1766 # { lex_in_package_scope(0);
1767 # p[0] = p[4].type;
1768 # delete[]p[4].text;
1769 # }
1770 ()
1771 def p_simple_type_or_string_8(p):
1772 '''simple_type_or_string : K_string '''
1773 if(parse_debug): print('simple_type_or_string_8', list(p))
1774 # { string_type_t*tmp = new string_type_t;
1775 # FILE_NAME(tmp, @1);
1776 # p[0] = tmp;
1777 # }
1778 ()
1779 def p__embed0_simple_type_or_string(p):
1780 '''_embed0_simple_type_or_string : '''
1781 # { lex_in_package_scope(p[1]); }
1782 ()
1783 def p_statement_1(p):
1784 '''statement : attribute_list_opt statement_item '''
1785 if(parse_debug): print('statement_1', list(p))
1786 # { pform_bind_attributes(p[2]->attributes, p[1]);
1787 # p[0] = p[2];
1788 # }
1789 ()
1790 def p_statement_or_null_1(p):
1791 '''statement_or_null : statement '''
1792 if(parse_debug): print('statement_or_null_1', list(p))
1793 p[0] = p[1]
1794 ()
1795 def p_statement_or_null_2(p):
1796 '''statement_or_null : attribute_list_opt ';' '''
1797 if(parse_debug): print('statement_or_null_2', list(p))
1798 # { p[0] = None }
1799 ()
1800 def p_stream_expression_1(p):
1801 '''stream_expression : expression '''
1802 if(parse_debug): print('stream_expression_1', list(p))
1803 ()
1804 def p_stream_expression_list_1(p):
1805 '''stream_expression_list : stream_expression_list ',' stream_expression '''
1806 if(parse_debug): print('stream_expression_list_1', list(p))
1807 ()
1808 def p_stream_expression_list_2(p):
1809 '''stream_expression_list : stream_expression '''
1810 if(parse_debug): print('stream_expression_list_2', list(p))
1811 ()
1812 def p_stream_operator_1(p):
1813 '''stream_operator : K_LS '''
1814 if(parse_debug): print('stream_operator_1', list(p))
1815 ()
1816 def p_stream_operator_2(p):
1817 '''stream_operator : K_RS '''
1818 if(parse_debug): print('stream_operator_2', list(p))
1819 ()
1820 def p_streaming_concatenation_1(p):
1821 '''streaming_concatenation : '{' stream_operator '{' stream_expression_list '}' '}' '''
1822 if(parse_debug): print('streaming_concatenation_1', list(p))
1823 # { /* streaming concatenation is a SystemVerilog thing. */
1824 # if (gn_system_verilog()) {
1825 # yyerror(@2, "sorry: Streaming concatenation not supported.");
1826 # p[0] = None
1827 # } else {
1828 # yyerror(@2, "error: Streaming concatenation requires SystemVerilog");
1829 # p[0] = None
1830 # }
1831 # }
1832 ()
1833 def p_task_declaration_1(p):
1834 '''task_declaration : K_task lifetime_opt IDENTIFIER ';' _embed0_task_declaration task_item_list_opt statement_or_null_list_opt K_endtask _embed1_task_declaration endlabel_opt '''
1835 if(parse_debug): print('task_declaration_1', list(p))
1836 # { // Last step: check any closing name. This is done late so
1837 # // that the parser can look ahead to detect the present
1838 # // endlabel_opt but still have the pform_endmodule() called
1839 # // early enough that the lexor can know we are outside the
1840 # // module.
1841 # if (p[10]) {
1842 # if (strcmp(p[3],p[10]) != 0) {
1843 # yyerror(@10, "error: End label doesn't match task name");
1844 # }
1845 # if (! gn_system_verilog()) {
1846 # yyerror(@10, "error: Task end labels require "
1847 # "SystemVerilog.");
1848 # }
1849 # delete[]p[10];
1850 # }
1851 # delete[]p[3];
1852 # }
1853 ()
1854 def p_task_declaration_2(p):
1855 '''task_declaration : K_task lifetime_opt IDENTIFIER '(' _embed2_task_declaration tf_port_list ')' ';' block_item_decls_opt statement_or_null_list_opt K_endtask _embed3_task_declaration endlabel_opt '''
1856 if(parse_debug): print('task_declaration_2', list(p))
1857 # { // Last step: check any closing name. This is done late so
1858 # // that the parser can look ahead to detect the present
1859 # // endlabel_opt but still have the pform_endmodule() called
1860 # // early enough that the lexor can know we are outside the
1861 # // module.
1862 # if (p[13]) {
1863 # if (strcmp(p[3],p[13]) != 0) {
1864 # yyerror(@13, "error: End label doesn't match task name");
1865 # }
1866 # if (! gn_system_verilog()) {
1867 # yyerror(@13, "error: Task end labels require "
1868 # "SystemVerilog.");
1869 # }
1870 # delete[]p[13];
1871 # }
1872 # delete[]p[3];
1873 # }
1874 ()
1875 def p_task_declaration_3(p):
1876 '''task_declaration : K_task lifetime_opt IDENTIFIER '(' ')' ';' _embed4_task_declaration block_item_decls_opt statement_or_null_list K_endtask _embed5_task_declaration endlabel_opt '''
1877 if(parse_debug): print('task_declaration_3', list(p))
1878 # { // Last step: check any closing name. This is done late so
1879 # // that the parser can look ahead to detect the present
1880 # // endlabel_opt but still have the pform_endmodule() called
1881 # // early enough that the lexor can know we are outside the
1882 # // module.
1883 # if (p[12]) {
1884 # if (strcmp(p[3],p[12]) != 0) {
1885 # yyerror(@12, "error: End label doesn't match task name");
1886 # }
1887 # if (! gn_system_verilog()) {
1888 # yyerror(@12, "error: Task end labels require "
1889 # "SystemVerilog.");
1890 # }
1891 # delete[]p[12];
1892 # }
1893 # delete[]p[3];
1894 # }
1895 ()
1896 def p_task_declaration_4(p):
1897 '''task_declaration : K_task lifetime_opt IDENTIFIER error K_endtask _embed6_task_declaration endlabel_opt '''
1898 if(parse_debug): print('task_declaration_4', list(p))
1899 # { // Last step: check any closing name. This is done late so
1900 # // that the parser can look ahead to detect the present
1901 # // endlabel_opt but still have the pform_endmodule() called
1902 # // early enough that the lexor can know we are outside the
1903 # // module.
1904 # if (p[7]) {
1905 # if (strcmp(p[3],p[7]) != 0) {
1906 # yyerror(@7, "error: End label doesn't match task name");
1907 # }
1908 # if (! gn_system_verilog()) {
1909 # yyerror(@7, "error: Task end labels require "
1910 # "SystemVerilog.");
1911 # }
1912 # delete[]p[7];
1913 # }
1914 # delete[]p[3];
1915 # }
1916 ()
1917 def p__embed0_task_declaration(p):
1918 '''_embed0_task_declaration : '''
1919 # { assert(current_task == 0);
1920 # current_task = pform_push_task_scope(@1, p[3], p[2]);
1921 # }
1922 ()
1923 def p__embed1_task_declaration(p):
1924 '''_embed1_task_declaration : '''
1925 # { current_task->set_ports(p[6]);
1926 # current_task_set_statement(@3, p[7]);
1927 # pform_set_this_class(@3, current_task);
1928 # pform_pop_scope();
1929 # current_task = 0;
1930 # if (p[7] && p[7]->size() > 1 && !gn_system_verilog()) {
1931 # yyerror(@7, "error: Task body with multiple statements requires SystemVerilog.");
1932 # }
1933 # delete p[7];
1934 # }
1935 ()
1936 def p__embed2_task_declaration(p):
1937 '''_embed2_task_declaration : '''
1938 # { assert(current_task == 0);
1939 # current_task = pform_push_task_scope(@1, p[3], p[2]);
1940 # }
1941 ()
1942 def p__embed3_task_declaration(p):
1943 '''_embed3_task_declaration : '''
1944 # { current_task->set_ports(p[6]);
1945 # current_task_set_statement(@3, p[10]);
1946 # pform_set_this_class(@3, current_task);
1947 # pform_pop_scope();
1948 # current_task = 0;
1949 # if (p[10]) delete p[10];
1950 # }
1951 ()
1952 def p__embed4_task_declaration(p):
1953 '''_embed4_task_declaration : '''
1954 # { assert(current_task == 0);
1955 # current_task = pform_push_task_scope(@1, p[3], p[2]);
1956 # }
1957 ()
1958 def p__embed5_task_declaration(p):
1959 '''_embed5_task_declaration : '''
1960 # { current_task->set_ports(0);
1961 # current_task_set_statement(@3, p[9]);
1962 # pform_set_this_class(@3, current_task);
1963 # if (! current_task->method_of()) {
1964 # cerr << @3 << ": warning: task definition for \"" << p[3]
1965 # << "\" has an empty port declaration list!" << endl;
1966 # }
1967 # pform_pop_scope();
1968 # current_task = 0;
1969 # if (p[9]->size() > 1 && !gn_system_verilog()) {
1970 # yyerror(@9, "error: Task body with multiple statements requires SystemVerilog.");
1971 # }
1972 # delete p[9];
1973 # }
1974 ()
1975 def p__embed6_task_declaration(p):
1976 '''_embed6_task_declaration : '''
1977 # {
1978 # if (current_task) {
1979 # pform_pop_scope();
1980 # current_task = 0;
1981 # }
1982 # }
1983 ()
1984 def p_tf_port_declaration_1(p):
1985 '''tf_port_declaration : port_direction K_reg_opt unsigned_signed_opt dimensions_opt list_of_identifiers ';' '''
1986 if(parse_debug): print('tf_port_declaration_1', list(p))
1987 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1],
1988 # p[2] ? IVL_VT_LOGIC :
1989 # IVL_VT_NO_TYPE,
1990 # p[3], p[4], p[5]);
1991 # p[0] = tmp;
1992 # }
1993 ()
1994 def p_tf_port_declaration_2(p):
1995 '''tf_port_declaration : port_direction K_integer list_of_identifiers ';' '''
1996 if(parse_debug): print('tf_port_declaration_2', list(p))
1997 # { list<pform_range_t>*range_stub = make_range_from_width(integer_width);
1998 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, true,
1999 # range_stub, p[3], true);
2000 # p[0] = tmp;
2001 # }
2002 ()
2003 def p_tf_port_declaration_3(p):
2004 '''tf_port_declaration : port_direction K_time list_of_identifiers ';' '''
2005 if(parse_debug): print('tf_port_declaration_3', list(p))
2006 # { list<pform_range_t>*range_stub = make_range_from_width(64);
2007 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, false,
2008 # range_stub, p[3]);
2009 # p[0] = tmp;
2010 # }
2011 ()
2012 def p_tf_port_declaration_4(p):
2013 '''tf_port_declaration : port_direction real_or_realtime list_of_identifiers ';' '''
2014 if(parse_debug): print('tf_port_declaration_4', list(p))
2015 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_REAL, true,
2016 # 0, p[3]);
2017 # p[0] = tmp;
2018 # }
2019 ()
2020 def p_tf_port_declaration_5(p):
2021 '''tf_port_declaration : port_direction K_string list_of_identifiers ';' '''
2022 if(parse_debug): print('tf_port_declaration_5', list(p))
2023 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_STRING, true,
2024 # 0, p[3]);
2025 # p[0] = tmp;
2026 # }
2027 ()
2028 def p_tf_port_item_1(p):
2029 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER dimensions_opt tf_port_item_expr_opt '''
2030 if(parse_debug): print('tf_port_item_1', list(p))
2031 # { vector<pform_tf_port_t>*tmp;
2032 # NetNet::PortType use_port_type = p[1];
2033 # if ((use_port_type == NetNet::PIMPLICIT) && (gn_system_verilog() || (p[2] == 0)))
2034 # use_port_type = port_declaration_context.port_type;
2035 # perm_string name = lex_strings.make(p[3]);
2036 # list<perm_string>* ilist = list_from_identifier(p[3]);
2037 #
2038 # if (use_port_type == NetNet::PIMPLICIT) {
2039 # yyerror(@1, "error: missing task/function port direction.");
2040 # use_port_type = NetNet::PINPUT; // for error recovery
2041 # }
2042 # if ((p[2] == 0) && (p[1]==NetNet::PIMPLICIT)) {
2043 # // Detect special case this is an undecorated
2044 # // identifier and we need to get the declaration from
2045 # // left context.
2046 # if (p[4] != 0) {
2047 # yyerror(@4, "internal error: How can there be an unpacked range here?\n");
2048 # }
2049 # tmp = pform_make_task_ports(@3, use_port_type,
2050 # port_declaration_context.data_type,
2051 # ilist);
2052 #
2053 # } else {
2054 # // Otherwise, the decorations for this identifier
2055 # // indicate the type. Save the type for any right
2056 # // context that may come later.
2057 # port_declaration_context.port_type = use_port_type;
2058 # if (p[2] == 0) {
2059 # p[2] = new vector_type_t(IVL_VT_LOGIC, false, 0);
2060 # FILE_NAME(p[2], @3);
2061 # }
2062 # port_declaration_context.data_type = p[2];
2063 # tmp = pform_make_task_ports(@3, use_port_type, p[2], ilist);
2064 # }
2065 # if (p[4] != 0) {
2066 # pform_set_reg_idx(name, p[4]);
2067 # }
2068 #
2069 # p[0] = tmp;
2070 # if (p[5]) {
2071 # assert(tmp->size()==1);
2072 # tmp->front().defe = p[5];
2073 # }
2074 # }
2075 ()
2076 def p_tf_port_item_2(p):
2077 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER error '''
2078 if(parse_debug): print('tf_port_item_2', list(p))
2079 # { yyerror(@3, "error: Error in task/function port item after port name %s.", p[3]);
2080 # yyerrok;
2081 # p[0] = None
2082 # }
2083 ()
2084 def p_tf_port_item_expr_opt_1(p):
2085 '''tf_port_item_expr_opt : '=' expression '''
2086 if(parse_debug): print('tf_port_item_expr_opt_1', list(p))
2087 # { if (! gn_system_verilog()) {
2088 # yyerror(@1, "error: Task/function default arguments require "
2089 # "SystemVerilog.");
2090 # }
2091 # p[0] = p[2];
2092 # }
2093 ()
2094 def p_tf_port_item_expr_opt_2(p):
2095 '''tf_port_item_expr_opt : '''
2096 if(parse_debug): print('tf_port_item_expr_opt_2', list(p))
2097 # { p[0] = None }
2098 ()
2099 def p_tf_port_list_1(p):
2100 '''tf_port_list : _embed0_tf_port_list tf_port_item_list '''
2101 if(parse_debug): print('tf_port_list_1', list(p))
2102 p[0] = p[2]
2103 ()
2104 def p__embed0_tf_port_list(p):
2105 '''_embed0_tf_port_list : '''
2106 # { port_declaration_context.port_type = gn_system_verilog() ? NetNet::PINPUT : NetNet::PIMPLICIT;
2107 # port_declaration_context.data_type = 0;
2108 # }
2109 ()
2110 def p_tf_port_item_list_1(p):
2111 '''tf_port_item_list : tf_port_item_list ',' tf_port_item '''
2112 if(parse_debug): print('tf_port_item_list_1', list(p))
2113 # { vector<pform_tf_port_t>*tmp;
2114 # if (p[1] && p[3]) {
2115 # size_t s1 = p[1]->size();
2116 # tmp = p[1];
2117 # tmp->resize(tmp->size()+p[3]->size());
2118 # for (size_t idx = 0 ; idx < p[3]->size() ; idx += 1)
2119 # tmp->at(s1+idx) = p[3]->at(idx);
2120 # delete p[3];
2121 # } else if (p[1]) {
2122 # tmp = p[1];
2123 # } else {
2124 # tmp = p[3];
2125 # }
2126 # p[0] = tmp;
2127 # }
2128 ()
2129 def p_tf_port_item_list_2(p):
2130 '''tf_port_item_list : tf_port_item '''
2131 if(parse_debug): print('tf_port_item_list_2', list(p))
2132 p[0] = p[1]
2133 ()
2134 def p_tf_port_item_list_3(p):
2135 '''tf_port_item_list : error ',' tf_port_item '''
2136 if(parse_debug): print('tf_port_item_list_3', list(p))
2137 # { yyerror(@2, "error: Syntax error in task/function port declaration.");
2138 # p[0] = p[3];
2139 # }
2140 ()
2141 def p_tf_port_item_list_4(p):
2142 '''tf_port_item_list : tf_port_item_list ',' '''
2143 if(parse_debug): print('tf_port_item_list_4', list(p))
2144 # { yyerror(@2, "error: NULL port declarations are not allowed.");
2145 # p[0] = p[1];
2146 # }
2147 ()
2148 def p_tf_port_item_list_5(p):
2149 '''tf_port_item_list : tf_port_item_list ';' '''
2150 if(parse_debug): print('tf_port_item_list_5', list(p))
2151 # { yyerror(@2, "error: ';' is an invalid port declaration separator.");
2152 # p[0] = p[1];
2153 # }
2154 ()
2155 def p_timeunits_declaration_1(p):
2156 '''timeunits_declaration : K_timeunit TIME_LITERAL ';' '''
2157 if(parse_debug): print('timeunits_declaration_1', list(p))
2158 # { pform_set_timeunit(p[2], allow_timeunit_decl); }
2159 ()
2160 def p_timeunits_declaration_2(p):
2161 '''timeunits_declaration : K_timeunit TIME_LITERAL '/' TIME_LITERAL ';' '''
2162 if(parse_debug): print('timeunits_declaration_2', list(p))
2163 # { bool initial_decl = allow_timeunit_decl && allow_timeprec_decl;
2164 # pform_set_timeunit(p[2], initial_decl);
2165 # pform_set_timeprec(p[4], initial_decl);
2166 # }
2167 ()
2168 def p_timeunits_declaration_3(p):
2169 '''timeunits_declaration : K_timeprecision TIME_LITERAL ';' '''
2170 if(parse_debug): print('timeunits_declaration_3', list(p))
2171 # { pform_set_timeprec(p[2], allow_timeprec_decl); }
2172 ()
2173 def p_timeunits_declaration_opt_1(p):
2174 '''timeunits_declaration_opt : %prec no_timeunits_declaration '''
2175 if(parse_debug>2): print('timeunits_declaration_opt_1', list(p))
2176 ()
2177 def p_timeunits_declaration_opt_2(p):
2178 '''timeunits_declaration_opt : timeunits_declaration %prec one_timeunits_declaration '''
2179 if(parse_debug): print('timeunits_declaration_opt_2', list(p))
2180 ()
2181 def p_timeunits_declaration_opt_3(p):
2182 '''timeunits_declaration_opt : timeunits_declaration timeunits_declaration '''
2183 if(parse_debug): print('timeunits_declaration_opt_3', list(p))
2184 ()
2185 def p_value_range_1(p):
2186 '''value_range : expression '''
2187 if(parse_debug): print('value_range_1', list(p))
2188 # { }
2189 ()
2190 def p_value_range_2(p):
2191 '''value_range : '[' expression ':' expression ']' '''
2192 if(parse_debug): print('value_range_2', list(p))
2193 # { }
2194 ()
2195 def p_variable_dimension_1(p):
2196 '''variable_dimension : '[' expression ':' expression ']' '''
2197 if(parse_debug): print('variable_dimension_1', list(p))
2198 # { list<pform_range_t> *tmp = new list<pform_range_t>;
2199 # pform_range_t index (p[2],p[4]);
2200 # tmp->push_back(index);
2201 # p[0] = tmp;
2202 # }
2203 # XXX TODO: subscriptlist
2204 start = str(p[4])
2205 end = str(p[2])
2206 if end.endswith("-1"):
2207 end = end[:-2]
2208 elif end.isdigit():
2209 end = str(int(end)+1)
2210 else:
2211 end = "1+%s" % end
2212 p[0] = '[%s:%s]' % (start, end) # python slice is LO:HI+1
2213 ()
2214 def p_variable_dimension_2(p):
2215 '''variable_dimension : '[' expression ']' '''
2216 if(parse_debug): print('variable_dimension_2', list(p))
2217 # { // SystemVerilog canonical range
2218 # if (!gn_system_verilog()) {
2219 # warn_count += 1;
2220 # cerr << @2 << ": warning: Use of SystemVerilog [size] dimension. "
2221 # << "Use at least -g2005-sv to remove this warning." << endl;
2222 # }
2223 # list<pform_range_t> *tmp = new list<pform_range_t>;
2224 # pform_range_t index;
2225 # index.first = new PENumber(new verinum((uint64_t)0, integer_width));
2226 # index.second = new PEBinary('-', p[2], new PENumber(new verinum((uint64_t)1, integer_width)));
2227 # tmp->push_back(index);
2228 # p[0] = tmp;
2229 # }
2230 ()
2231 def p_variable_dimension_3(p):
2232 '''variable_dimension : '[' ']' '''
2233 if(parse_debug): print('variable_dimension_3', list(p))
2234 # { list<pform_range_t> *tmp = new list<pform_range_t>;
2235 # pform_range_t index (0,0);
2236 # tmp->push_back(index);
2237 # p[0] = tmp;
2238 # }
2239 ()
2240 def p_variable_dimension_4(p):
2241 '''variable_dimension : '[' '$' ']' '''
2242 if(parse_debug): print('variable_dimension_4', list(p))
2243 # { // SystemVerilog queue
2244 # list<pform_range_t> *tmp = new list<pform_range_t>;
2245 # pform_range_t index (new PENull,0);
2246 # if (!gn_system_verilog()) {
2247 # yyerror("error: Queue declarations require SystemVerilog.");
2248 # }
2249 # tmp->push_back(index);
2250 # p[0] = tmp;
2251 # }
2252 ()
2253 def p_variable_lifetime_1(p):
2254 '''variable_lifetime : lifetime '''
2255 if(parse_debug): print('variable_lifetime_1', list(p))
2256 # { if (!gn_system_verilog()) {
2257 # yyerror(@1, "error: overriding the default variable lifetime "
2258 # "requires SystemVerilog.");
2259 # } else if (p[1] != pform_peek_scope()->default_lifetime) {
2260 # yyerror(@1, "sorry: overriding the default variable lifetime "
2261 # "is not yet supported.");
2262 # }
2263 # var_lifetime = p[1];
2264 # }
2265 ()
2266 def p_attribute_list_opt_1(p):
2267 '''attribute_list_opt : attribute_instance_list '''
2268 if(parse_debug): print('attribute_list_opt_1', list(p))
2269 p[0] = p[1]
2270 ()
2271 def p_attribute_list_opt_2(p):
2272 '''attribute_list_opt : '''
2273 if(parse_debug > 2): print('attribute_list_opt_2', list(p))
2274 # { p[0] = None }
2275 ()
2276 def p_attribute_instance_list_1(p):
2277 '''attribute_instance_list : K_PSTAR K_STARP '''
2278 if(parse_debug): print('attribute_instance_list_1', list(p))
2279 # { p[0] = None }
2280 ()
2281 def p_attribute_instance_list_2(p):
2282 '''attribute_instance_list : K_PSTAR attribute_list K_STARP '''
2283 if(parse_debug): print('attribute_instance_list_2', list(p))
2284 p[0] = p[2]
2285 ()
2286 def p_attribute_instance_list_3(p):
2287 '''attribute_instance_list : attribute_instance_list K_PSTAR K_STARP '''
2288 if(parse_debug): print('attribute_instance_list_3', list(p))
2289 p[0] = p[1]
2290 ()
2291 def p_attribute_instance_list_4(p):
2292 '''attribute_instance_list : attribute_instance_list K_PSTAR attribute_list K_STARP '''
2293 if(parse_debug): print('attribute_instance_list_4', list(p))
2294 # { list<named_pexpr_t>*tmp = p[1];
2295 # if (tmp) {
2296 # tmp->splice(tmp->end(), *p[3]);
2297 # delete p[3];
2298 # p[0] = tmp;
2299 # } else p[0] = p[3];
2300 # }
2301 ()
2302 def p_attribute_list_1(p):
2303 '''attribute_list : attribute_list ',' attribute '''
2304 if(parse_debug): print('attribute_list_1', list(p))
2305 # { list<named_pexpr_t>*tmp = p[1];
2306 # tmp->push_back(*p[3]);
2307 # delete p[3];
2308 # p[0] = tmp;
2309 # }
2310 ()
2311 def p_attribute_list_2(p):
2312 '''attribute_list : attribute '''
2313 if(parse_debug): print('attribute_list_2', list(p))
2314 # { list<named_pexpr_t>*tmp = new list<named_pexpr_t>;
2315 # tmp->push_back(*p[1]);
2316 # delete p[1];
2317 # p[0] = tmp;
2318 # }
2319 ()
2320 def p_attribute_1(p):
2321 '''attribute : IDENTIFIER '''
2322 if(parse_debug): print('attribute_1', list(p))
2323 # { named_pexpr_t*tmp = new named_pexpr_t;
2324 # tmp->name = lex_strings.make(p[1]);
2325 # tmp->parm = 0;
2326 # delete[]p[1];
2327 # p[0] = tmp;
2328 # }
2329 ()
2330 def p_attribute_2(p):
2331 '''attribute : IDENTIFIER '=' expression '''
2332 if(parse_debug): print('attribute_2', list(p))
2333 # { PExpr*tmp = p[3];
2334 # named_pexpr_t*tmp2 = new named_pexpr_t;
2335 # tmp2->name = lex_strings.make(p[1]);
2336 # tmp2->parm = tmp;
2337 # delete[]p[1];
2338 # p[0] = tmp2;
2339 # }
2340 ()
2341 def p_block_item_decl_1(p):
2342 '''block_item_decl : data_type register_variable_list ';' '''
2343 if(parse_debug): print('block_item_decl_1', list(p))
2344 # { if (p[1]) pform_set_data_type(@1, p[1], p[2], NetNet::REG, attributes_in_context);
2345 # }
2346 ()
2347 def p_block_item_decl_2(p):
2348 '''block_item_decl : variable_lifetime data_type register_variable_list ';' '''
2349 if(parse_debug): print('block_item_decl_2', list(p))
2350 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
2351 # var_lifetime = LexicalScope::INHERITED;
2352 # }
2353 ()
2354 def p_block_item_decl_3(p):
2355 '''block_item_decl : K_reg data_type register_variable_list ';' '''
2356 if(parse_debug): print('block_item_decl_3', list(p))
2357 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
2358 # }
2359 ()
2360 def p_block_item_decl_4(p):
2361 '''block_item_decl : variable_lifetime K_reg data_type register_variable_list ';' '''
2362 if(parse_debug): print('block_item_decl_4', list(p))
2363 # { if (p[3]) pform_set_data_type(@3, p[3], p[4], NetNet::REG, attributes_in_context);
2364 # var_lifetime = LexicalScope::INHERITED;
2365 # }
2366 ()
2367 def p_block_item_decl_5(p):
2368 '''block_item_decl : K_event event_variable_list ';' '''
2369 if(parse_debug): print('block_item_decl_5', list(p))
2370 # { if (p[2]) pform_make_events(p[2], @1.text, @1.first_line);
2371 # }
2372 ()
2373 def p_block_item_decl_6(p):
2374 '''block_item_decl : K_parameter param_type parameter_assign_list ';' '''
2375 if(parse_debug): print('block_item_decl_6', list(p))
2376 ()
2377 def p_block_item_decl_7(p):
2378 '''block_item_decl : K_localparam param_type localparam_assign_list ';' '''
2379 if(parse_debug): print('block_item_decl_7', list(p))
2380 ()
2381 def p_block_item_decl_8(p):
2382 '''block_item_decl : type_declaration '''
2383 if(parse_debug): print('block_item_decl_8', list(p))
2384 ()
2385 def p_block_item_decl_9(p):
2386 '''block_item_decl : K_integer error ';' '''
2387 if(parse_debug): print('block_item_decl_9', list(p))
2388 # { yyerror(@1, "error: syntax error in integer variable list.");
2389 # yyerrok;
2390 # }
2391 ()
2392 def p_block_item_decl_10(p):
2393 '''block_item_decl : K_time error ';' '''
2394 if(parse_debug): print('block_item_decl_10', list(p))
2395 # { yyerror(@1, "error: syntax error in time variable list.");
2396 # yyerrok;
2397 # }
2398 ()
2399 def p_block_item_decl_11(p):
2400 '''block_item_decl : K_parameter error ';' '''
2401 if(parse_debug): print('block_item_decl_11', list(p))
2402 # { yyerror(@1, "error: syntax error in parameter list.");
2403 # yyerrok;
2404 # }
2405 ()
2406 def p_block_item_decl_12(p):
2407 '''block_item_decl : K_localparam error ';' '''
2408 if(parse_debug): print('block_item_decl_12', list(p))
2409 # { yyerror(@1, "error: syntax error localparam list.");
2410 # yyerrok;
2411 # }
2412 ()
2413 def p_block_item_decls_1(p):
2414 '''block_item_decls : block_item_decl '''
2415 if(parse_debug): print('block_item_decls_1', list(p))
2416 ()
2417 def p_block_item_decls_2(p):
2418 '''block_item_decls : block_item_decls block_item_decl '''
2419 if(parse_debug): print('block_item_decls_2', list(p))
2420 ()
2421 def p_block_item_decls_opt_1(p):
2422 '''block_item_decls_opt : block_item_decls '''
2423 if(parse_debug): print('block_item_decls_opt_1', list(p))
2424 p[0] = True
2425 ()
2426 def p_block_item_decls_opt_2(p):
2427 '''block_item_decls_opt : '''
2428 if(parse_debug): print('block_item_decls_opt_2', list(p))
2429 p[0] = False
2430 ()
2431 def p_type_declaration_1(p):
2432 '''type_declaration : K_typedef data_type IDENTIFIER dimensions_opt ';' '''
2433 if(parse_debug): print('type_declaration_1', list(p))
2434 # { perm_string name = lex_strings.make(p[3]);
2435 # pform_set_typedef(name, p[2], p[4]);
2436 # delete[]p[3];
2437 # }
2438 ()
2439 def p_type_declaration_2(p):
2440 '''type_declaration : K_typedef data_type TYPE_IDENTIFIER ';' '''
2441 if(parse_debug): print('type_declaration_2', list(p))
2442 # { perm_string name = lex_strings.make(p[3].text);
2443 # if (pform_test_type_identifier_local(name)) {
2444 # yyerror(@3, "error: Typedef identifier \"%s\" is already a type name.", p[3].text);
2445 #
2446 # } else {
2447 # pform_set_typedef(name, p[2], NULL);
2448 # }
2449 # delete[]p[3].text;
2450 # }
2451 ()
2452 def p_type_declaration_3(p):
2453 '''type_declaration : K_typedef K_class IDENTIFIER ';' '''
2454 if(parse_debug): print('type_declaration_3', list(p))
2455 # { // Create a synthetic typedef for the class name so that the
2456 # // lexor detects the name as a type.
2457 # perm_string name = lex_strings.make(p[3]);
2458 # class_type_t*tmp = new class_type_t(name);
2459 # FILE_NAME(tmp, @3);
2460 # pform_set_typedef(name, tmp, NULL);
2461 # delete[]p[3];
2462 # }
2463 ()
2464 def p_type_declaration_4(p):
2465 '''type_declaration : K_typedef K_enum IDENTIFIER ';' '''
2466 if(parse_debug): print('type_declaration_4', list(p))
2467 # { yyerror(@1, "sorry: Enum forward declarations not supported yet."); }
2468 ()
2469 def p_type_declaration_5(p):
2470 '''type_declaration : K_typedef K_struct IDENTIFIER ';' '''
2471 if(parse_debug): print('type_declaration_5', list(p))
2472 # { yyerror(@1, "sorry: Struct forward declarations not supported yet."); }
2473 ()
2474 def p_type_declaration_6(p):
2475 '''type_declaration : K_typedef K_union IDENTIFIER ';' '''
2476 if(parse_debug): print('type_declaration_6', list(p))
2477 # { yyerror(@1, "sorry: Union forward declarations not supported yet."); }
2478 ()
2479 def p_type_declaration_7(p):
2480 '''type_declaration : K_typedef IDENTIFIER ';' '''
2481 if(parse_debug): print('type_declaration_7', list(p))
2482 # { // Create a synthetic typedef for the class name so that the
2483 # // lexor detects the name as a type.
2484 # perm_string name = lex_strings.make(p[2]);
2485 # class_type_t*tmp = new class_type_t(name);
2486 # FILE_NAME(tmp, @2);
2487 # pform_set_typedef(name, tmp, NULL);
2488 # delete[]p[2];
2489 # }
2490 ()
2491 def p_type_declaration_8(p):
2492 '''type_declaration : K_typedef error ';' '''
2493 if(parse_debug): print('type_declaration_8', list(p))
2494 # { yyerror(@2, "error: Syntax error in typedef clause.");
2495 # yyerrok;
2496 # }
2497 ()
2498 def p_enum_data_type_1(p):
2499 '''enum_data_type : K_enum '{' enum_name_list '}' '''
2500 if(parse_debug): print('enum_data_type_1', list(p))
2501 # { enum_type_t*enum_type = new enum_type_t;
2502 # FILE_NAME(enum_type, @1);
2503 # enum_type->names .reset(p[3]);
2504 # enum_type->base_type = IVL_VT_BOOL;
2505 # enum_type->signed_flag = true;
2506 # enum_type->integer_flag = false;
2507 # enum_type->range.reset(make_range_from_width(32));
2508 # p[0] = enum_type;
2509 # }
2510 ()
2511 def p_enum_data_type_2(p):
2512 '''enum_data_type : K_enum atom2_type signed_unsigned_opt '{' enum_name_list '}' '''
2513 if(parse_debug): print('enum_data_type_2', list(p))
2514 # { enum_type_t*enum_type = new enum_type_t;
2515 # FILE_NAME(enum_type, @1);
2516 # enum_type->names .reset(p[5]);
2517 # enum_type->base_type = IVL_VT_BOOL;
2518 # enum_type->signed_flag = p[3];
2519 # enum_type->integer_flag = false;
2520 # enum_type->range.reset(make_range_from_width(p[2]));
2521 # p[0] = enum_type;
2522 # }
2523 ()
2524 def p_enum_data_type_3(p):
2525 '''enum_data_type : K_enum K_integer signed_unsigned_opt '{' enum_name_list '}' '''
2526 if(parse_debug): print('enum_data_type_3', list(p))
2527 # { enum_type_t*enum_type = new enum_type_t;
2528 # FILE_NAME(enum_type, @1);
2529 # enum_type->names .reset(p[5]);
2530 # enum_type->base_type = IVL_VT_LOGIC;
2531 # enum_type->signed_flag = p[3];
2532 # enum_type->integer_flag = true;
2533 # enum_type->range.reset(make_range_from_width(integer_width));
2534 # p[0] = enum_type;
2535 # }
2536 ()
2537 def p_enum_data_type_4(p):
2538 '''enum_data_type : K_enum K_logic unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
2539 if(parse_debug): print('enum_data_type_4', list(p))
2540 # { enum_type_t*enum_type = new enum_type_t;
2541 # FILE_NAME(enum_type, @1);
2542 # enum_type->names .reset(p[6]);
2543 # enum_type->base_type = IVL_VT_LOGIC;
2544 # enum_type->signed_flag = p[3];
2545 # enum_type->integer_flag = false;
2546 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
2547 # p[0] = enum_type;
2548 # }
2549 ()
2550 def p_enum_data_type_5(p):
2551 '''enum_data_type : K_enum K_reg unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
2552 if(parse_debug): print('enum_data_type_5', list(p))
2553 # { enum_type_t*enum_type = new enum_type_t;
2554 # FILE_NAME(enum_type, @1);
2555 # enum_type->names .reset(p[6]);
2556 # enum_type->base_type = IVL_VT_LOGIC;
2557 # enum_type->signed_flag = p[3];
2558 # enum_type->integer_flag = false;
2559 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
2560 # p[0] = enum_type;
2561 # }
2562 ()
2563 def p_enum_data_type_6(p):
2564 '''enum_data_type : K_enum K_bit unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
2565 if(parse_debug): print('enum_data_type_6', list(p))
2566 # { enum_type_t*enum_type = new enum_type_t;
2567 # FILE_NAME(enum_type, @1);
2568 # enum_type->names .reset(p[6]);
2569 # enum_type->base_type = IVL_VT_BOOL;
2570 # enum_type->signed_flag = p[3];
2571 # enum_type->integer_flag = false;
2572 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
2573 # p[0] = enum_type;
2574 # }
2575 ()
2576 def p_enum_name_list_1(p):
2577 '''enum_name_list : enum_name '''
2578 if(parse_debug): print('enum_name_list_1', list(p))
2579 # { p[0] = p[1];
2580 # }
2581 ()
2582 def p_enum_name_list_2(p):
2583 '''enum_name_list : enum_name_list ',' enum_name '''
2584 if(parse_debug): print('enum_name_list_2', list(p))
2585 # { list<named_pexpr_t>*lst = p[1];
2586 # lst->splice(lst->end(), *p[3]);
2587 # delete p[3];
2588 # p[0] = lst;
2589 # }
2590 ()
2591 def p_pos_neg_number_1(p):
2592 '''pos_neg_number : number '''
2593 if(parse_debug): print('pos_neg_number_1', list(p))
2594 # { p[0] = p[1];
2595 # }
2596 ()
2597 def p_pos_neg_number_2(p):
2598 '''pos_neg_number : '-' number '''
2599 if(parse_debug): print('pos_neg_number_2', list(p))
2600 # { verinum tmp = -(*(p[2]));
2601 # *(p[2]) = tmp;
2602 # p[0] = p[2];
2603 # }
2604 ()
2605 def p_enum_name_1(p):
2606 '''enum_name : IDENTIFIER '''
2607 if(parse_debug): print('enum_name_1', list(p))
2608 # { perm_string name = lex_strings.make(p[1]);
2609 # delete[]p[1];
2610 # p[0] = make_named_number(name);
2611 # }
2612 ()
2613 def p_enum_name_2(p):
2614 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '''
2615 if(parse_debug): print('enum_name_2', list(p))
2616 # { perm_string name = lex_strings.make(p[1]);
2617 # long count = check_enum_seq_value(@1, p[3], false);
2618 # delete[]p[1];
2619 # p[0] = make_named_numbers(name, 0, count-1);
2620 # delete p[3];
2621 # }
2622 ()
2623 def p_enum_name_3(p):
2624 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '''
2625 if(parse_debug): print('enum_name_3', list(p))
2626 # { perm_string name = lex_strings.make(p[1]);
2627 # p[0] = make_named_numbers(name, check_enum_seq_value(@1, p[3], true),
2628 # check_enum_seq_value(@1, p[5], true));
2629 # delete[]p[1];
2630 # delete p[3];
2631 # delete p[5];
2632 # }
2633 ()
2634 def p_enum_name_4(p):
2635 '''enum_name : IDENTIFIER '=' expression '''
2636 if(parse_debug): print('enum_name_4', list(p))
2637 # { perm_string name = lex_strings.make(p[1]);
2638 # delete[]p[1];
2639 # p[0] = make_named_number(name, p[3]);
2640 # }
2641 ()
2642 def p_enum_name_5(p):
2643 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '=' expression '''
2644 if(parse_debug): print('enum_name_5', list(p))
2645 # { perm_string name = lex_strings.make(p[1]);
2646 # long count = check_enum_seq_value(@1, p[3], false);
2647 # p[0] = make_named_numbers(name, 0, count-1, p[6]);
2648 # delete[]p[1];
2649 # delete p[3];
2650 # }
2651 ()
2652 def p_enum_name_6(p):
2653 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '=' expression '''
2654 if(parse_debug): print('enum_name_6', list(p))
2655 # { perm_string name = lex_strings.make(p[1]);
2656 # p[0] = make_named_numbers(name, check_enum_seq_value(@1, p[3], true),
2657 # check_enum_seq_value(@1, p[5], true), p[8]);
2658 # delete[]p[1];
2659 # delete p[3];
2660 # delete p[5];
2661 # }
2662 ()
2663 def p_struct_data_type_1(p):
2664 '''struct_data_type : K_struct K_packed_opt '{' struct_union_member_list '}' '''
2665 if(parse_debug): print('struct_data_type_1', list(p))
2666 # { struct_type_t*tmp = new struct_type_t;
2667 # FILE_NAME(tmp, @1);
2668 # tmp->packed_flag = p[2];
2669 # tmp->union_flag = false;
2670 # tmp->members .reset(p[4]);
2671 # p[0] = tmp;
2672 # }
2673 ()
2674 def p_struct_data_type_2(p):
2675 '''struct_data_type : K_union K_packed_opt '{' struct_union_member_list '}' '''
2676 if(parse_debug): print('struct_data_type_2', list(p))
2677 # { struct_type_t*tmp = new struct_type_t;
2678 # FILE_NAME(tmp, @1);
2679 # tmp->packed_flag = p[2];
2680 # tmp->union_flag = true;
2681 # tmp->members .reset(p[4]);
2682 # p[0] = tmp;
2683 # }
2684 ()
2685 def p_struct_data_type_3(p):
2686 '''struct_data_type : K_struct K_packed_opt '{' error '}' '''
2687 if(parse_debug): print('struct_data_type_3', list(p))
2688 # { yyerror(@3, "error: Errors in struct member list.");
2689 # yyerrok;
2690 # struct_type_t*tmp = new struct_type_t;
2691 # FILE_NAME(tmp, @1);
2692 # tmp->packed_flag = p[2];
2693 # tmp->union_flag = false;
2694 # p[0] = tmp;
2695 # }
2696 ()
2697 def p_struct_data_type_4(p):
2698 '''struct_data_type : K_union K_packed_opt '{' error '}' '''
2699 if(parse_debug): print('struct_data_type_4', list(p))
2700 # { yyerror(@3, "error: Errors in union member list.");
2701 # yyerrok;
2702 # struct_type_t*tmp = new struct_type_t;
2703 # FILE_NAME(tmp, @1);
2704 # tmp->packed_flag = p[2];
2705 # tmp->union_flag = true;
2706 # p[0] = tmp;
2707 # }
2708 ()
2709 def p_struct_union_member_list_1(p):
2710 '''struct_union_member_list : struct_union_member_list struct_union_member '''
2711 if(parse_debug): print('struct_union_member_list_1', list(p))
2712 # { list<struct_member_t*>*tmp = p[1];
2713 # tmp->push_back(p[2]);
2714 # p[0] = tmp;
2715 # }
2716 ()
2717 def p_struct_union_member_list_2(p):
2718 '''struct_union_member_list : struct_union_member '''
2719 if(parse_debug): print('struct_union_member_list_2', list(p))
2720 # { list<struct_member_t*>*tmp = new list<struct_member_t*>;
2721 # tmp->push_back(p[1]);
2722 # p[0] = tmp;
2723 # }
2724 ()
2725 def p_struct_union_member_1(p):
2726 '''struct_union_member : attribute_list_opt data_type list_of_variable_decl_assignments ';' '''
2727 if(parse_debug): print('struct_union_member_1', list(p))
2728 # { struct_member_t*tmp = new struct_member_t;
2729 # FILE_NAME(tmp, @2);
2730 # tmp->type .reset(p[2]);
2731 # tmp->names .reset(p[3]);
2732 # p[0] = tmp;
2733 # }
2734 ()
2735 def p_struct_union_member_2(p):
2736 '''struct_union_member : error ';' '''
2737 if(parse_debug): print('struct_union_member_2', list(p))
2738 # { yyerror(@2, "Error in struct/union member.");
2739 # yyerrok;
2740 # p[0] = None
2741 # }
2742 ()
2743 def p_case_item_1(p):
2744 '''case_item : expression_list_proper ':' statement_or_null '''
2745 if(parse_debug): print('case_item_1', list(p))
2746 # { PCase::Item*tmp = new PCase::Item;
2747 # tmp->expr = *p[1];
2748 # tmp->stat = p[3];
2749 # delete p[1];
2750 # p[0] = tmp;
2751 # }
2752 ()
2753 def p_case_item_2(p):
2754 '''case_item : K_default ':' statement_or_null '''
2755 if(parse_debug): print('case_item_2', list(p))
2756 # { PCase::Item*tmp = new PCase::Item;
2757 # tmp->stat = p[3];
2758 # p[0] = tmp;
2759 # }
2760 ()
2761 def p_case_item_3(p):
2762 '''case_item : K_default statement_or_null '''
2763 if(parse_debug): print('case_item_3', list(p))
2764 # { PCase::Item*tmp = new PCase::Item;
2765 # tmp->stat = p[2];
2766 # p[0] = tmp;
2767 # }
2768 ()
2769 def p_case_item_4(p):
2770 '''case_item : error ':' statement_or_null '''
2771 if(parse_debug): print('case_item_4', list(p))
2772 # { yyerror(@2, "error: Incomprehensible case expression.");
2773 # yyerrok;
2774 # }
2775 ()
2776 def p_case_items_1(p):
2777 '''case_items : case_items case_item '''
2778 if(parse_debug): print('case_items_1', list(p))
2779 # { svector<PCase::Item*>*tmp;
2780 # tmp = new svector<PCase::Item*>(*p[1], p[2]);
2781 # delete p[1];
2782 # p[0] = tmp;
2783 # }
2784 ()
2785 def p_case_items_2(p):
2786 '''case_items : case_item '''
2787 if(parse_debug): print('case_items_2', list(p))
2788 # { svector<PCase::Item*>*tmp = new svector<PCase::Item*>(1);
2789 # (*tmp)[0] = p[1];
2790 # p[0] = tmp;
2791 # }
2792 ()
2793 def p_charge_strength_1(p):
2794 '''charge_strength : '(' K_small ')' '''
2795 if(parse_debug): print('charge_strength_1', list(p))
2796 ()
2797 def p_charge_strength_2(p):
2798 '''charge_strength : '(' K_medium ')' '''
2799 if(parse_debug): print('charge_strength_2', list(p))
2800 ()
2801 def p_charge_strength_3(p):
2802 '''charge_strength : '(' K_large ')' '''
2803 if(parse_debug): print('charge_strength_3', list(p))
2804 ()
2805 def p_charge_strength_opt_1(p):
2806 '''charge_strength_opt : charge_strength '''
2807 if(parse_debug): print('charge_strength_opt_1', list(p))
2808 ()
2809 def p_charge_strength_opt_2(p):
2810 '''charge_strength_opt : '''
2811 if(parse_debug): print('charge_strength_opt_2', list(p))
2812 ()
2813 def p_defparam_assign_1(p):
2814 '''defparam_assign : hierarchy_identifier '=' expression '''
2815 if(parse_debug): print('defparam_assign_1', list(p))
2816 # { pform_set_defparam(*p[1], p[3]);
2817 # delete p[1];
2818 # }
2819 ()
2820 def p_defparam_assign_list_1(p):
2821 '''defparam_assign_list : defparam_assign '''
2822 if(parse_debug): print('defparam_assign_list_1', list(p))
2823 ()
2824 def p_defparam_assign_list_2(p):
2825 '''defparam_assign_list : dimensions defparam_assign '''
2826 if(parse_debug): print('defparam_assign_list_2', list(p))
2827 # { yyerror(@1, "error: defparam may not include a range.");
2828 # delete p[1];
2829 # }
2830 ()
2831 def p_defparam_assign_list_3(p):
2832 '''defparam_assign_list : defparam_assign_list ',' defparam_assign '''
2833 if(parse_debug): print('defparam_assign_list_3', list(p))
2834 ()
2835 def p_delay1_1(p):
2836 '''delay1 : '#' delay_value_simple '''
2837 if(parse_debug): print('delay1_1', list(p))
2838 # { list<PExpr*>*tmp = new list<PExpr*>;
2839 # tmp->push_back(p[2]);
2840 # p[0] = tmp;
2841 # }
2842 ()
2843 def p_delay1_2(p):
2844 '''delay1 : '#' '(' delay_value ')' '''
2845 if(parse_debug): print('delay1_2', list(p))
2846 # { list<PExpr*>*tmp = new list<PExpr*>;
2847 # tmp->push_back(p[3]);
2848 # p[0] = tmp;
2849 # }
2850 ()
2851 def p_delay3_1(p):
2852 '''delay3 : '#' delay_value_simple '''
2853 if(parse_debug): print('delay3_1', list(p))
2854 # { list<PExpr*>*tmp = new list<PExpr*>;
2855 # tmp->push_back(p[2]);
2856 # p[0] = tmp;
2857 # }
2858 ()
2859 def p_delay3_2(p):
2860 '''delay3 : '#' '(' delay_value ')' '''
2861 if(parse_debug): print('delay3_2', list(p))
2862 # { list<PExpr*>*tmp = new list<PExpr*>;
2863 # tmp->push_back(p[3]);
2864 # p[0] = tmp;
2865 # }
2866 ()
2867 def p_delay3_3(p):
2868 '''delay3 : '#' '(' delay_value ',' delay_value ')' '''
2869 if(parse_debug): print('delay3_3', list(p))
2870 # { list<PExpr*>*tmp = new list<PExpr*>;
2871 # tmp->push_back(p[3]);
2872 # tmp->push_back(p[5]);
2873 # p[0] = tmp;
2874 # }
2875 ()
2876 def p_delay3_4(p):
2877 '''delay3 : '#' '(' delay_value ',' delay_value ',' delay_value ')' '''
2878 if(parse_debug): print('delay3_4', list(p))
2879 # { list<PExpr*>*tmp = new list<PExpr*>;
2880 # tmp->push_back(p[3]);
2881 # tmp->push_back(p[5]);
2882 # tmp->push_back(p[7]);
2883 # p[0] = tmp;
2884 # }
2885 ()
2886 def p_delay3_opt_1(p):
2887 '''delay3_opt : delay3 '''
2888 if(parse_debug): print('delay3_opt_1', list(p))
2889 p[0] = p[1]
2890 ()
2891 def p_delay3_opt_2(p):
2892 '''delay3_opt : '''
2893 if(parse_debug>2): print('delay3_opt_2', list(p))
2894 # { p[0] = None }
2895 ()
2896 def p_delay_value_list_1(p):
2897 '''delay_value_list : delay_value '''
2898 if(parse_debug): print('delay_value_list_1', list(p))
2899 # { list<PExpr*>*tmp = new list<PExpr*>;
2900 # tmp->push_back(p[1]);
2901 # p[0] = tmp;
2902 # }
2903 ()
2904 def p_delay_value_list_2(p):
2905 '''delay_value_list : delay_value_list ',' delay_value '''
2906 if(parse_debug): print('delay_value_list_2', list(p))
2907 # { list<PExpr*>*tmp = p[1];
2908 # tmp->push_back(p[3]);
2909 # p[0] = tmp;
2910 # }
2911 ()
2912 def p_delay_value_1(p):
2913 '''delay_value : expression '''
2914 if(parse_debug): print('delay_value_1', list(p))
2915 # { PExpr*tmp = p[1];
2916 # p[0] = tmp;
2917 # }
2918 ()
2919 def p_delay_value_2(p):
2920 '''delay_value : expression ':' expression ':' expression '''
2921 if(parse_debug): print('delay_value_2', list(p))
2922 # { p[0] = pform_select_mtm_expr(p[1], p[3], p[5]); }
2923 ()
2924 def p_delay_value_simple_1(p):
2925 '''delay_value_simple : DEC_NUMBER '''
2926 if(parse_debug): print('delay_value_simple_1', list(p))
2927 # { verinum*tmp = p[1];
2928 # if (tmp == 0) {
2929 # yyerror(@1, "internal error: delay.");
2930 # p[0] = None
2931 # } else {
2932 # p[0] = new PENumber(tmp);
2933 # FILE_NAME(p[0], @1);
2934 # }
2935 # based_size = 0;
2936 # }
2937 ()
2938 def p_delay_value_simple_2(p):
2939 '''delay_value_simple : REALTIME '''
2940 if(parse_debug): print('delay_value_simple_2', list(p))
2941 # { verireal*tmp = p[1];
2942 # if (tmp == 0) {
2943 # yyerror(@1, "internal error: delay.");
2944 # p[0] = None
2945 # } else {
2946 # p[0] = new PEFNumber(tmp);
2947 # FILE_NAME(p[0], @1);
2948 # }
2949 # }
2950 ()
2951 def p_delay_value_simple_3(p):
2952 '''delay_value_simple : IDENTIFIER '''
2953 if(parse_debug): print('delay_value_simple_3', list(p))
2954 # { PEIdent*tmp = new PEIdent(lex_strings.make(p[1]));
2955 # FILE_NAME(tmp, @1);
2956 # p[0] = tmp;
2957 # delete[]p[1];
2958 # }
2959 ()
2960 def p_delay_value_simple_4(p):
2961 '''delay_value_simple : TIME_LITERAL '''
2962 if(parse_debug): print('delay_value_simple_4', list(p))
2963 # { int unit;
2964 #
2965 # based_size = 0;
2966 # p[0] = 0;
2967 # if (p[1] == 0 || !get_time_unit(p[1], unit))
2968 # yyerror(@1, "internal error: delay.");
2969 # else {
2970 # double p = pow(10.0,
2971 # (double)(unit - pform_get_timeunit()));
2972 # double time = atof(p[1]) * p;
2973 #
2974 # verireal *v = new verireal(time);
2975 # p[0] = new PEFNumber(v);
2976 # FILE_NAME(p[0], @1);
2977 # }
2978 # }
2979 ()
2980 def p_optional_semicolon_1(p):
2981 '''optional_semicolon : ';' '''
2982 if(parse_debug): print('optional_semicolon_1', list(p))
2983 ()
2984 def p_optional_semicolon_2(p):
2985 '''optional_semicolon : '''
2986 if(parse_debug): print('optional_semicolon_2', list(p))
2987 ()
2988 def p_discipline_declaration_1(p):
2989 '''discipline_declaration : K_discipline IDENTIFIER optional_semicolon _embed0_discipline_declaration discipline_items K_enddiscipline '''
2990 if(parse_debug): print('discipline_declaration_1', list(p))
2991 # { pform_end_discipline(@1); delete[] p[2]; }
2992 ()
2993 def p__embed0_discipline_declaration(p):
2994 '''_embed0_discipline_declaration : '''
2995 # { pform_start_discipline(p[2]); }
2996 ()
2997 def p_discipline_items_1(p):
2998 '''discipline_items : discipline_items discipline_item '''
2999 if(parse_debug): print('discipline_items_1', list(p))
3000 ()
3001 def p_discipline_items_2(p):
3002 '''discipline_items : discipline_item '''
3003 if(parse_debug): print('discipline_items_2', list(p))
3004 ()
3005 def p_discipline_item_1(p):
3006 '''discipline_item : K_domain K_discrete ';' '''
3007 if(parse_debug): print('discipline_item_1', list(p))
3008 # { pform_discipline_domain(@1, IVL_DIS_DISCRETE); }
3009 ()
3010 def p_discipline_item_2(p):
3011 '''discipline_item : K_domain K_continuous ';' '''
3012 if(parse_debug): print('discipline_item_2', list(p))
3013 # { pform_discipline_domain(@1, IVL_DIS_CONTINUOUS); }
3014 ()
3015 def p_discipline_item_3(p):
3016 '''discipline_item : K_potential IDENTIFIER ';' '''
3017 if(parse_debug): print('discipline_item_3', list(p))
3018 # { pform_discipline_potential(@1, p[2]); delete[] p[2]; }
3019 ()
3020 def p_discipline_item_4(p):
3021 '''discipline_item : K_flow IDENTIFIER ';' '''
3022 if(parse_debug): print('discipline_item_4', list(p))
3023 # { pform_discipline_flow(@1, p[2]); delete[] p[2]; }
3024 ()
3025 def p_nature_declaration_1(p):
3026 '''nature_declaration : K_nature IDENTIFIER optional_semicolon _embed0_nature_declaration nature_items K_endnature '''
3027 if(parse_debug): print('nature_declaration_1', list(p))
3028 # { pform_end_nature(@1); delete[] p[2]; }
3029 ()
3030 def p__embed0_nature_declaration(p):
3031 '''_embed0_nature_declaration : '''
3032 # { pform_start_nature(p[2]); }
3033 ()
3034 def p_nature_items_1(p):
3035 '''nature_items : nature_items nature_item '''
3036 if(parse_debug): print('nature_items_1', list(p))
3037 ()
3038 def p_nature_items_2(p):
3039 '''nature_items : nature_item '''
3040 if(parse_debug): print('nature_items_2', list(p))
3041 ()
3042 def p_nature_item_1(p):
3043 '''nature_item : K_units '=' STRING ';' '''
3044 if(parse_debug): print('nature_item_1', list(p))
3045 # { delete[] p[3]; }
3046 ()
3047 def p_nature_item_2(p):
3048 '''nature_item : K_abstol '=' expression ';' '''
3049 if(parse_debug): print('nature_item_2', list(p))
3050 ()
3051 def p_nature_item_3(p):
3052 '''nature_item : K_access '=' IDENTIFIER ';' '''
3053 if(parse_debug): print('nature_item_3', list(p))
3054 # { pform_nature_access(@1, p[3]); delete[] p[3]; }
3055 ()
3056 def p_nature_item_4(p):
3057 '''nature_item : K_idt_nature '=' IDENTIFIER ';' '''
3058 if(parse_debug): print('nature_item_4', list(p))
3059 # { delete[] p[3]; }
3060 ()
3061 def p_nature_item_5(p):
3062 '''nature_item : K_ddt_nature '=' IDENTIFIER ';' '''
3063 if(parse_debug): print('nature_item_5', list(p))
3064 # { delete[] p[3]; }
3065 ()
3066 def p_config_declaration_1(p):
3067 '''config_declaration : K_config IDENTIFIER ';' K_design lib_cell_identifiers ';' list_of_config_rule_statements K_endconfig '''
3068 if(parse_debug): print('config_declaration_1', list(p))
3069 # { cerr << @1 << ": sorry: config declarations are not supported and "
3070 # "will be skipped." << endl;
3071 # delete[] p[2];
3072 # }
3073 ()
3074 def p_lib_cell_identifiers_1(p):
3075 '''lib_cell_identifiers : '''
3076 if(parse_debug): print('lib_cell_identifiers_1', list(p))
3077 ()
3078 def p_lib_cell_identifiers_2(p):
3079 '''lib_cell_identifiers : lib_cell_identifiers lib_cell_id '''
3080 if(parse_debug): print('lib_cell_identifiers_2', list(p))
3081 ()
3082 def p_list_of_config_rule_statements_1(p):
3083 '''list_of_config_rule_statements : '''
3084 if(parse_debug): print('list_of_config_rule_statements_1', list(p))
3085 ()
3086 def p_list_of_config_rule_statements_2(p):
3087 '''list_of_config_rule_statements : list_of_config_rule_statements config_rule_statement '''
3088 if(parse_debug): print('list_of_config_rule_statements_2', list(p))
3089 ()
3090 def p_config_rule_statement_1(p):
3091 '''config_rule_statement : K_default K_liblist list_of_libraries ';' '''
3092 if(parse_debug): print('config_rule_statement_1', list(p))
3093 ()
3094 def p_config_rule_statement_2(p):
3095 '''config_rule_statement : K_instance hierarchy_identifier K_liblist list_of_libraries ';' '''
3096 if(parse_debug): print('config_rule_statement_2', list(p))
3097 # { delete p[2]; }
3098 ()
3099 def p_config_rule_statement_3(p):
3100 '''config_rule_statement : K_instance hierarchy_identifier K_use lib_cell_id opt_config ';' '''
3101 if(parse_debug): print('config_rule_statement_3', list(p))
3102 # { delete p[2]; }
3103 ()
3104 def p_config_rule_statement_4(p):
3105 '''config_rule_statement : K_cell lib_cell_id K_liblist list_of_libraries ';' '''
3106 if(parse_debug): print('config_rule_statement_4', list(p))
3107 ()
3108 def p_config_rule_statement_5(p):
3109 '''config_rule_statement : K_cell lib_cell_id K_use lib_cell_id opt_config ';' '''
3110 if(parse_debug): print('config_rule_statement_5', list(p))
3111 ()
3112 def p_opt_config_1(p):
3113 '''opt_config : '''
3114 if(parse_debug): print('opt_config_1', list(p))
3115 ()
3116 def p_opt_config_2(p):
3117 '''opt_config : ':' K_config '''
3118 if(parse_debug): print('opt_config_2', list(p))
3119 ()
3120 def p_lib_cell_id_1(p):
3121 '''lib_cell_id : IDENTIFIER '''
3122 if(parse_debug): print('lib_cell_id_1', list(p))
3123 # { delete[] p[1]; }
3124 ()
3125 def p_lib_cell_id_2(p):
3126 '''lib_cell_id : IDENTIFIER '.' IDENTIFIER '''
3127 if(parse_debug): print('lib_cell_id_2', list(p))
3128 # { delete[] p[1]; delete[] p[3]; }
3129 ()
3130 def p_list_of_libraries_1(p):
3131 '''list_of_libraries : '''
3132 if(parse_debug): print('list_of_libraries_1', list(p))
3133 ()
3134 def p_list_of_libraries_2(p):
3135 '''list_of_libraries : list_of_libraries IDENTIFIER '''
3136 if(parse_debug): print('list_of_libraries_2', list(p))
3137 # { delete[] p[2]; }
3138 ()
3139 def p_drive_strength_1(p):
3140 '''drive_strength : '(' dr_strength0 ',' dr_strength1 ')' '''
3141 if(parse_debug): print('drive_strength_1', list(p))
3142 # { p[0].str0 = p[2].str0;
3143 # p[0].str1 = p[4].str1;
3144 # }
3145 ()
3146 def p_drive_strength_2(p):
3147 '''drive_strength : '(' dr_strength1 ',' dr_strength0 ')' '''
3148 if(parse_debug): print('drive_strength_2', list(p))
3149 # { p[0].str0 = p[4].str0;
3150 # p[0].str1 = p[2].str1;
3151 # }
3152 ()
3153 def p_drive_strength_3(p):
3154 '''drive_strength : '(' dr_strength0 ',' K_highz1 ')' '''
3155 if(parse_debug): print('drive_strength_3', list(p))
3156 # { p[0].str0 = p[2].str0;
3157 # p[0].str1 = IVL_DR_HiZ;
3158 # }
3159 ()
3160 def p_drive_strength_4(p):
3161 '''drive_strength : '(' dr_strength1 ',' K_highz0 ')' '''
3162 if(parse_debug): print('drive_strength_4', list(p))
3163 # { p[0].str0 = IVL_DR_HiZ;
3164 # p[0].str1 = p[2].str1;
3165 # }
3166 ()
3167 def p_drive_strength_5(p):
3168 '''drive_strength : '(' K_highz1 ',' dr_strength0 ')' '''
3169 if(parse_debug): print('drive_strength_5', list(p))
3170 # { p[0].str0 = p[4].str0;
3171 # p[0].str1 = IVL_DR_HiZ;
3172 # }
3173 ()
3174 def p_drive_strength_6(p):
3175 '''drive_strength : '(' K_highz0 ',' dr_strength1 ')' '''
3176 if(parse_debug): print('drive_strength_6', list(p))
3177 # { p[0].str0 = IVL_DR_HiZ;
3178 # p[0].str1 = p[4].str1;
3179 # }
3180 ()
3181 def p_drive_strength_opt_1(p):
3182 '''drive_strength_opt : drive_strength '''
3183 if(parse_debug): print('drive_strength_opt_1', list(p))
3184 p[0] = p[1]
3185 ()
3186 def p_drive_strength_opt_2(p):
3187 '''drive_strength_opt : '''
3188 if(parse_debug>2): print('drive_strength_opt_2', list(p))
3189 # { p[0].str0 = IVL_DR_STRONG; p[0].str1 = IVL_DR_STRONG; }
3190 ()
3191 def p_dr_strength0_1(p):
3192 '''dr_strength0 : K_supply0 '''
3193 if(parse_debug): print('dr_strength0_1', list(p))
3194 # { p[0].str0 = IVL_DR_SUPPLY; }
3195 ()
3196 def p_dr_strength0_2(p):
3197 '''dr_strength0 : K_strong0 '''
3198 if(parse_debug): print('dr_strength0_2', list(p))
3199 # { p[0].str0 = IVL_DR_STRONG; }
3200 ()
3201 def p_dr_strength0_3(p):
3202 '''dr_strength0 : K_pull0 '''
3203 if(parse_debug): print('dr_strength0_3', list(p))
3204 # { p[0].str0 = IVL_DR_PULL; }
3205 ()
3206 def p_dr_strength0_4(p):
3207 '''dr_strength0 : K_weak0 '''
3208 if(parse_debug): print('dr_strength0_4', list(p))
3209 # { p[0].str0 = IVL_DR_WEAK; }
3210 ()
3211 def p_dr_strength1_1(p):
3212 '''dr_strength1 : K_supply1 '''
3213 if(parse_debug): print('dr_strength1_1', list(p))
3214 # { p[0].str1 = IVL_DR_SUPPLY; }
3215 ()
3216 def p_dr_strength1_2(p):
3217 '''dr_strength1 : K_strong1 '''
3218 if(parse_debug): print('dr_strength1_2', list(p))
3219 # { p[0].str1 = IVL_DR_STRONG; }
3220 ()
3221 def p_dr_strength1_3(p):
3222 '''dr_strength1 : K_pull1 '''
3223 if(parse_debug): print('dr_strength1_3', list(p))
3224 # { p[0].str1 = IVL_DR_PULL; }
3225 ()
3226 def p_dr_strength1_4(p):
3227 '''dr_strength1 : K_weak1 '''
3228 if(parse_debug): print('dr_strength1_4', list(p))
3229 # { p[0].str1 = IVL_DR_WEAK; }
3230 ()
3231 def p_clocking_event_opt_1(p):
3232 '''clocking_event_opt : event_control '''
3233 if(parse_debug): print('clocking_event_opt_1', list(p))
3234 ()
3235 def p_clocking_event_opt_2(p):
3236 '''clocking_event_opt : '''
3237 if(parse_debug): print('clocking_event_opt_2', list(p))
3238 ()
3239 def p_event_control_1(p):
3240 '''event_control : '@' hierarchy_identifier '''
3241 if(parse_debug): print('event_control_1', list(p))
3242 # { PEIdent*tmpi = new PEIdent(*p[2]);
3243 # PEEvent*tmpe = new PEEvent(PEEvent::ANYEDGE, tmpi);
3244 # PEventStatement*tmps = new PEventStatement(tmpe);
3245 # FILE_NAME(tmps, @1);
3246 # p[0] = tmps;
3247 # delete p[2];
3248 # }
3249 ()
3250 def p_event_control_2(p):
3251 '''event_control : '@' '(' event_expression_list ')' '''
3252 if(parse_debug): print('event_control_2', list(p))
3253 # { PEventStatement*tmp = new PEventStatement(*p[3]);
3254 # FILE_NAME(tmp, @1);
3255 # delete p[3];
3256 # p[0] = tmp;
3257 # }
3258 ()
3259 def p_event_control_3(p):
3260 '''event_control : '@' '(' error ')' '''
3261 if(parse_debug): print('event_control_3', list(p))
3262 # { yyerror(@1, "error: Malformed event control expression.");
3263 # p[0] = None