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