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