convert binary and unary operators
[sv2nmigen.git] / parse_sv.py
1 # %{
2 # /*
3 # * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com)
4 # * Copyright CERN 2012-2013 / Stephen Williams (steve@icarus.com)
5 # *
6 # * This source code is free software; you can redistribute it
7 # * and/or modify it in source code form under the terms of the GNU
8 # * General Public License as published by the Free Software
9 # * Foundation; either version 2 of the License, or (at your option)
10 # * any later version.
11 # *
12 # * This program is distributed in the hope that it will be useful,
13 # * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # * GNU General Public License for more details.
16 # *
17 # * You should have received a copy of the GNU General Public License
18 # * along with this program; if not, write to the Free Software
19 # * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # */
21
22 import lexor
23 from ply import yacc, lex
24 from lib2to3.pytree import Node, Leaf
25 from lib2to3.pgen2 import token
26 from lib2to3.pygram import python_symbols as syms
27
28 yacc1_debug = 0
29 yacc2_debug = 0
30 parse_debug = 1
31
32
33 #from parse_tokens import tokens
34 tokens = lexor.tokens # list(set(lexor.tokens).union(set(tokens)))
35 literals = lexor.literals
36
37 precedence = [
38 ('right', 'K_PLUS_EQ', 'K_MINUS_EQ', 'K_MUL_EQ', 'K_DIV_EQ',
39 'K_MOD_EQ', 'K_AND_EQ', 'K_OR_EQ'),
40 ('right', 'K_XOR_EQ', 'K_LS_EQ', 'K_RS_EQ', 'K_RSS_EQ'),
41 ('right', '?', ':', 'K_inside'),
42 ('left', 'K_LOR'),
43 ('left', 'K_LAND'),
44 ('left', '|'),
45 ('left', '^', 'K_NXOR', 'K_NOR'),
46 ('left', '&', 'K_NAND'),
47 ('left', 'K_EQ', 'K_NE', 'K_CEQ', 'K_CNE', 'K_WEQ', 'K_WNE'),
48 ('left', 'K_GE', 'K_LE', '<', '>'),
49 ('left', 'K_LS', 'K_RS', 'K_RSS'),
50 ('left', '+', '-'),
51 ('left', '*', '/', '%'),
52 ('left', 'K_POW'),
53 ('left', 'UNARY_PREC'),
54 ('nonassoc', 'less_than_K_else'),
55 ('nonassoc', 'K_else'),
56 ('nonassoc', '('),
57 ('nonassoc', 'K_exclude'),
58 ('nonassoc', 'no_timeunits_declaration'),
59 ('nonassoc', 'one_timeunits_declaration'),
60 ('nonassoc', 'K_timeunit', 'K_timeprecision')
61 ]
62
63
64 IVL_VT_NO_TYPE = 'VT_NO_TYPE'
65 IVL_VT_BOOL = 'VT_BOOL'
66 IVL_VT_LOGIC = 'VT_LOGIC'
67 """
68 IVL_VT_VOID = 0, /* Not used */
69 IVL_VT_NO_TYPE = 1, /* Place holder for missing/unknown type. */
70 IVL_VT_REAL = 2,
71 IVL_VT_BOOL = 3,
72 IVL_VT_LOGIC = 4,
73 IVL_VT_STRING = 5,
74 IVL_VT_DARRAY = 6, /* Array (esp. dynamic array) */
75 IVL_VT_CLASS = 7, /* SystemVerilog class instances */
76 IVL_VT_QUEUE = 8, /* SystemVerilog queue instances */
77 IVL_VT_VECTOR = IVL_VT_LOGIC /* For compatibility */
78 """
79
80 NN_NONE = 'NONE'
81 NN_IMPLICIT = 'IMPLICIT'
82 NN_IMPLICIT_REG = 'IMPLICIT_REG'
83 NN_INTEGER = 'INTEGER'
84 NN_WIRE = 'WIRE'
85 NN_TRI = 'TRI'
86 NN_TRI1 = 'TRI1'
87 NN_SUPPLY0 = 'SUPPLY0'
88 NN_SUPPLY1 = 'SUPPLY1'
89 NN_WAND = 'WAND'
90 NN_TRIAND = 'TRIAND'
91 NN_TRI0 = 'TRI0'
92 NN_WOR = 'WOR'
93 NN_TRIOR = 'TRIOR'
94 NN_REG = 'REG'
95 NN_UNRESOLVED_WIRE = 'UNRESOLVED_WIRE'
96
97 NP_NOT_A_PORT = 'NOT_A_PORT'
98 NP_PIMPLICIT = 'PIMPLICIT'
99 NP_PINPUT = 'PINPUT'
100 NP_POUTPUT = 'POUTPUT'
101 NP_PINOUT = 'PINOUT'
102 NP_PREF = 'PREF'
103
104
105 class DataType:
106 def __init__(self, typ, signed):
107 self.typ = typ
108 self.signed = signed
109
110
111 # -------------- RULES ----------------
112 ()
113
114
115 def p_source_text_1(p):
116 '''source_text : timeunits_declaration_opt _embed0_source_text description_list '''
117 if(parse_debug > 2):
118 print('source_text', list(p))
119
120
121 ()
122
123
124 def p_source_text_2(p):
125 '''source_text : '''
126 if(parse_debug):
127 print('source_text', list(p))
128
129
130 ()
131
132
133 def p__embed0_source_text(p):
134 '''_embed0_source_text : '''
135
136 # { pform_set_scope_timescale(yyloc); }
137 ()
138
139
140 def p_assertion_item_1(p):
141 '''assertion_item : concurrent_assertion_item '''
142 if(parse_debug):
143 print('assertion_item_1', list(p))
144
145
146 ()
147
148
149 def p_assignment_pattern_1(p):
150 '''assignment_pattern : K_LP expression_list_proper '}' '''
151 if(parse_debug):
152 print('assignment_pattern_1', list(p))
153
154 # { PEAssignPattern*tmp = new PEAssignPattern(*p[2]);
155 # FILE_NAME(tmp, @1);
156 # delete p[2];
157 # p[0] = tmp;
158 # }
159 ()
160
161
162 def p_assignment_pattern_2(p):
163 '''assignment_pattern : K_LP '}' '''
164 if(parse_debug):
165 print('assignment_pattern_2', list(p))
166
167 # { PEAssignPattern*tmp = new PEAssignPattern;
168 # FILE_NAME(tmp, @1);
169 # p[0] = tmp;
170 # }
171 ()
172
173
174 def p_block_identifier_opt_1(p):
175 '''block_identifier_opt : IDENTIFIER ':' '''
176 if(parse_debug):
177 print('block_identifier_opt_1', list(p))
178
179
180 ()
181
182
183 def p_block_identifier_opt_2(p):
184 '''block_identifier_opt : '''
185 if(parse_debug):
186 print('block_identifier_opt_2', list(p))
187
188
189 ()
190
191
192 def p_class_declaration_1(p):
193 '''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 '''
194 if(parse_debug):
195 print('class_declaration_1', list(p))
196
197 # { // Wrap up the class.
198 # if (p[11] && p[4] && p[4]->name != p[11]) {
199 # yyerror(@11, "error: Class end label doesn't match class name.");
200 # delete[]p[11];
201 # }
202 # }
203 ()
204
205
206 def p__embed0_class_declaration(p):
207 '''_embed0_class_declaration : '''
208
209 # { pform_start_class_declaration(@2, p[4], p[5].type, p[5].exprs, p[3]); }
210 ()
211
212
213 def p__embed1_class_declaration(p):
214 '''_embed1_class_declaration : '''
215
216 # { // Process a class.
217 # pform_end_class_declaration(@9);
218 # }
219 ()
220
221
222 def p_class_constraint_1(p):
223 '''class_constraint : constraint_prototype '''
224 if(parse_debug):
225 print('class_constraint_1', list(p))
226
227
228 ()
229
230
231 def p_class_constraint_2(p):
232 '''class_constraint : constraint_declaration '''
233 if(parse_debug):
234 print('class_constraint_2', list(p))
235
236
237 ()
238
239
240 def p_class_identifier_1(p):
241 '''class_identifier : IDENTIFIER '''
242 if(parse_debug):
243 print('class_identifier_1', list(p))
244
245 # { // Create a synthetic typedef for the class name so that the
246 # // lexor detects the name as a type.
247 # perm_string name = lex_strings.make(p[1]);
248 # class_type_t*tmp = new class_type_t(name);
249 # FILE_NAME(tmp, @1);
250 # pform_set_typedef(name, tmp, NULL);
251 # delete[]p[1];
252 # p[0] = tmp;
253 # }
254 ()
255
256
257 def p_class_identifier_2(p):
258 '''class_identifier : TYPE_IDENTIFIER '''
259 if(parse_debug):
260 print('class_identifier_2', list(p))
261
262 # { class_type_t*tmp = dynamic_cast<class_type_t*>(p[1].type);
263 # if (tmp == 0) {
264 # yyerror(@1, "Type name \"%s\"is not a predeclared class name.", p[1].text);
265 # }
266 # delete[]p[1].text;
267 # p[0] = tmp;
268 # }
269 ()
270
271
272 def p_class_declaration_endlabel_opt_1(p):
273 '''class_declaration_endlabel_opt : ':' TYPE_IDENTIFIER '''
274 if(parse_debug):
275 print('class_declaration_endlabel_opt_1', list(p))
276
277 # { class_type_t*tmp = dynamic_cast<class_type_t*> (p[2].type);
278 # if (tmp == 0) {
279 # yyerror(@2, "error: class declaration endlabel \"%s\" is not a class name\n", p[2].text);
280 # p[0] = None
281 # } else {
282 # p[0] = strdupnew(tmp->name.str());
283 # }
284 # delete[]p[2].text;
285 # }
286 ()
287
288
289 def p_class_declaration_endlabel_opt_2(p):
290 '''class_declaration_endlabel_opt : ':' IDENTIFIER '''
291 if(parse_debug):
292 print('class_declaration_endlabel_opt_2', list(p))
293 p[0] = p[2]
294
295
296 ()
297
298
299 def p_class_declaration_endlabel_opt_3(p):
300 '''class_declaration_endlabel_opt : '''
301 if(parse_debug):
302 print('class_declaration_endlabel_opt_3', list(p))
303
304 # { p[0] = None }
305 ()
306
307
308 def p_class_declaration_extends_opt_1(p):
309 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '''
310 if(parse_debug):
311 print('class_declaration_extends_opt_1', list(p))
312
313 # { p[0].type = p[2].type;
314 # p[0].exprs= 0;
315 # delete[]p[2].text;
316 # }
317 ()
318
319
320 def p_class_declaration_extends_opt_2(p):
321 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '(' expression_list_with_nuls ')' '''
322 if(parse_debug):
323 print('class_declaration_extends_opt_2', list(p))
324
325 # { p[0].type = p[2].type;
326 # p[0].exprs = p[4];
327 # delete[]p[2].text;
328 # }
329 ()
330
331
332 def p_class_declaration_extends_opt_3(p):
333 '''class_declaration_extends_opt : '''
334 if(parse_debug):
335 print('class_declaration_extends_opt_3', list(p))
336
337 # { p[0].type = 0; p[0].exprs = 0; }
338 ()
339
340
341 def p_class_items_opt_1(p):
342 '''class_items_opt : class_items '''
343 if(parse_debug):
344 print('class_items_opt_1', list(p))
345
346
347 ()
348
349
350 def p_class_items_opt_2(p):
351 '''class_items_opt : '''
352 if(parse_debug):
353 print('class_items_opt_2', list(p))
354
355
356 ()
357
358
359 def p_class_items_1(p):
360 '''class_items : class_items class_item '''
361 if(parse_debug):
362 print('class_items_1', list(p))
363
364
365 ()
366
367
368 def p_class_items_2(p):
369 '''class_items : class_item '''
370 if(parse_debug):
371 print('class_items_2', list(p))
372
373
374 ()
375
376
377 def p_class_item_1(p):
378 '''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 '''
379 if(parse_debug):
380 print('class_item_1', list(p))
381
382 # { current_function->set_ports(p[6]);
383 # pform_set_constructor_return(current_function);
384 # pform_set_this_class(@3, current_function);
385 # current_function_set_statement(@3, p[10]);
386 # pform_pop_scope();
387 # current_function = 0;
388 # }
389 ()
390
391
392 def p_class_item_2(p):
393 '''class_item : property_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
394 if(parse_debug):
395 print('class_item_2', list(p))
396
397 # { pform_class_property(@2, p[1], p[2], p[3]); }
398 ()
399
400
401 def p_class_item_3(p):
402 '''class_item : K_const class_item_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
403 if(parse_debug):
404 print('class_item_3', list(p))
405
406 # { pform_class_property(@1, p[2] | property_qualifier_t::make_const(), p[3], p[4]); }
407 ()
408
409
410 def p_class_item_4(p):
411 '''class_item : method_qualifier_opt task_declaration '''
412 if(parse_debug):
413 print('class_item_4', list(p))
414
415 # { /* The task_declaration rule puts this into the class */ }
416 ()
417
418
419 def p_class_item_5(p):
420 '''class_item : method_qualifier_opt function_declaration '''
421 if(parse_debug):
422 print('class_item_5', list(p))
423
424 # { /* The function_declaration rule puts this into the class */ }
425 ()
426
427
428 def p_class_item_6(p):
429 '''class_item : K_extern method_qualifier_opt K_function K_new ';' '''
430 if(parse_debug):
431 print('class_item_6', list(p))
432
433 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
434 ()
435
436
437 def p_class_item_7(p):
438 '''class_item : K_extern method_qualifier_opt K_function K_new '(' tf_port_list_opt ')' ';' '''
439 if(parse_debug):
440 print('class_item_7', list(p))
441
442 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
443 ()
444
445
446 def p_class_item_8(p):
447 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER ';' '''
448 if(parse_debug):
449 print('class_item_8', list(p))
450
451 # { yyerror(@1, "sorry: External methods are not yet supported.");
452 # delete[] p[5];
453 # }
454 ()
455
456
457 def p_class_item_9(p):
458 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' ';' '''
459 if(parse_debug):
460 print('class_item_9', list(p))
461
462 # { yyerror(@1, "sorry: External methods are not yet supported.");
463 # delete[] p[5];
464 # }
465 ()
466
467
468 def p_class_item_10(p):
469 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER ';' '''
470 if(parse_debug):
471 print('class_item_10', list(p))
472
473 # { yyerror(@1, "sorry: External methods are not yet supported.");
474 # delete[] p[4];
475 # }
476 ()
477
478
479 def p_class_item_11(p):
480 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER '(' tf_port_list_opt ')' ';' '''
481 if(parse_debug):
482 print('class_item_11', list(p))
483
484 # { yyerror(@1, "sorry: External methods are not yet supported.");
485 # delete[] p[4];
486 # }
487 ()
488
489
490 def p_class_item_12(p):
491 '''class_item : class_constraint '''
492 if(parse_debug):
493 print('class_item_12', list(p))
494
495
496 ()
497
498
499 def p_class_item_13(p):
500 '''class_item : property_qualifier_opt data_type error ';' '''
501 if(parse_debug):
502 print('class_item_13', list(p))
503
504 # { yyerror(@3, "error: Errors in variable names after data type.");
505 # yyerrok;
506 # }
507 ()
508
509
510 def p_class_item_14(p):
511 '''class_item : property_qualifier_opt IDENTIFIER error ';' '''
512 if(parse_debug):
513 print('class_item_14', list(p))
514
515 # { yyerror(@3, "error: %s doesn't name a type.", p[2]);
516 # yyerrok;
517 # }
518 ()
519
520
521 def p_class_item_15(p):
522 '''class_item : method_qualifier_opt K_function K_new error K_endfunction endnew_opt '''
523 if(parse_debug):
524 print('class_item_15', list(p))
525
526 # { yyerror(@1, "error: I give up on this class constructor declaration.");
527 # yyerrok;
528 # }
529 ()
530
531
532 def p_class_item_16(p):
533 '''class_item : error ';' '''
534 if(parse_debug):
535 print('class_item_16', list(p))
536
537 # { yyerror(@2, "error: invalid class item.");
538 # yyerrok;
539 # }
540 ()
541
542
543 def p__embed0_class_item(p):
544 '''_embed0_class_item : '''
545
546 # { assert(current_function==0);
547 # current_function = pform_push_constructor_scope(@3);
548 # }
549 ()
550
551
552 def p_class_item_qualifier_1(p):
553 '''class_item_qualifier : K_static '''
554 if(parse_debug):
555 print('class_item_qualifier_1', list(p))
556
557 # { p[0] = property_qualifier_t::make_static(); }
558 ()
559
560
561 def p_class_item_qualifier_2(p):
562 '''class_item_qualifier : K_protected '''
563 if(parse_debug):
564 print('class_item_qualifier_2', list(p))
565
566 # { p[0] = property_qualifier_t::make_protected(); }
567 ()
568
569
570 def p_class_item_qualifier_3(p):
571 '''class_item_qualifier : K_local '''
572 if(parse_debug):
573 print('class_item_qualifier_3', list(p))
574
575 # { p[0] = property_qualifier_t::make_local(); }
576 ()
577
578
579 def p_class_item_qualifier_list_1(p):
580 '''class_item_qualifier_list : class_item_qualifier_list class_item_qualifier '''
581 if(parse_debug):
582 print('class_item_qualifier_list_1', list(p))
583
584 # { p[0] = p[1] | p[2]; }
585 ()
586
587
588 def p_class_item_qualifier_list_2(p):
589 '''class_item_qualifier_list : class_item_qualifier '''
590 if(parse_debug):
591 print('class_item_qualifier_list_2', list(p))
592 p[0] = p[1]
593
594
595 ()
596
597
598 def p_class_item_qualifier_opt_1(p):
599 '''class_item_qualifier_opt : class_item_qualifier_list '''
600 if(parse_debug):
601 print('class_item_qualifier_opt_1', list(p))
602 p[0] = p[1]
603
604
605 ()
606
607
608 def p_class_item_qualifier_opt_2(p):
609 '''class_item_qualifier_opt : '''
610 if(parse_debug):
611 print('class_item_qualifier_opt_2', list(p))
612
613 # { p[0] = property_qualifier_t::make_none(); }
614 ()
615
616
617 def p_class_new_1(p):
618 '''class_new : K_new '(' expression_list_with_nuls ')' '''
619 if(parse_debug):
620 print('class_new_1', list(p))
621
622 # { list<PExpr*>*expr_list = p[3];
623 # strip_tail_items(expr_list);
624 # PENewClass*tmp = new PENewClass(*expr_list);
625 # FILE_NAME(tmp, @1);
626 # delete p[3];
627 # p[0] = tmp;
628 # }
629 ()
630
631
632 def p_class_new_2(p):
633 '''class_new : K_new hierarchy_identifier '''
634 if(parse_debug):
635 print('class_new_2', list(p))
636
637 # { PEIdent*tmpi = new PEIdent(*p[2]);
638 # FILE_NAME(tmpi, @2);
639 # PENewCopy*tmp = new PENewCopy(tmpi);
640 # FILE_NAME(tmp, @1);
641 # delete p[2];
642 # p[0] = tmp;
643 # }
644 ()
645
646
647 def p_class_new_3(p):
648 '''class_new : K_new '''
649 if(parse_debug):
650 print('class_new_3', list(p))
651
652 # { PENewClass*tmp = new PENewClass;
653 # FILE_NAME(tmp, @1);
654 # p[0] = tmp;
655 # }
656 ()
657
658
659 def p_concurrent_assertion_item_1(p):
660 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' property_spec ')' statement_or_null '''
661 if(parse_debug):
662 print('concurrent_assertion_item_1', list(p))
663
664 # { /* */
665 # if (gn_assertions_flag) {
666 # yyerror(@2, "sorry: concurrent_assertion_item not supported."
667 # " Try -gno-assertion to turn this message off.");
668 # }
669 # }
670 ()
671
672
673 def p_concurrent_assertion_item_2(p):
674 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' error ')' statement_or_null '''
675 if(parse_debug):
676 print('concurrent_assertion_item_2', list(p))
677
678 # { yyerrok;
679 # yyerror(@2, "error: Error in property_spec of concurrent assertion item.");
680 # }
681 ()
682
683
684 def p_constraint_block_item_1(p):
685 '''constraint_block_item : constraint_expression '''
686 if(parse_debug):
687 print('constraint_block_item_1', list(p))
688
689
690 ()
691
692
693 def p_constraint_block_item_list_1(p):
694 '''constraint_block_item_list : constraint_block_item_list constraint_block_item '''
695 if(parse_debug):
696 print('constraint_block_item_list_1', list(p))
697
698
699 ()
700
701
702 def p_constraint_block_item_list_2(p):
703 '''constraint_block_item_list : constraint_block_item '''
704 if(parse_debug):
705 print('constraint_block_item_list_2', list(p))
706
707
708 ()
709
710
711 def p_constraint_block_item_list_opt_1(p):
712 '''constraint_block_item_list_opt : '''
713 if(parse_debug):
714 print('constraint_block_item_list_opt_1', list(p))
715
716
717 ()
718
719
720 def p_constraint_block_item_list_opt_2(p):
721 '''constraint_block_item_list_opt : constraint_block_item_list '''
722 if(parse_debug):
723 print('constraint_block_item_list_opt_2', list(p))
724
725
726 ()
727
728
729 def p_constraint_declaration_1(p):
730 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' constraint_block_item_list_opt '}' '''
731 if(parse_debug):
732 print('constraint_declaration_1', list(p))
733
734 # { yyerror(@2, "sorry: Constraint declarations not supported."); }
735 ()
736
737
738 def p_constraint_declaration_2(p):
739 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' error '}' '''
740 if(parse_debug):
741 print('constraint_declaration_2', list(p))
742
743 # { yyerror(@4, "error: Errors in the constraint block item list."); }
744 ()
745
746
747 def p_constraint_expression_1(p):
748 '''constraint_expression : expression ';' '''
749 if(parse_debug):
750 print('constraint_expression_1', list(p))
751
752
753 ()
754
755
756 def p_constraint_expression_2(p):
757 '''constraint_expression : expression K_dist '{' '}' ';' '''
758 if(parse_debug):
759 print('constraint_expression_2', list(p))
760
761
762 ()
763
764
765 def p_constraint_expression_3(p):
766 '''constraint_expression : expression K_TRIGGER constraint_set '''
767 if(parse_debug):
768 print('constraint_expression_3', list(p))
769
770
771 ()
772
773
774 def p_constraint_expression_4(p):
775 '''constraint_expression : K_if '(' expression ')' constraint_set %prec less_than_K_else '''
776 if(parse_debug):
777 print('constraint_expression_4', list(p))
778
779
780 ()
781
782
783 def p_constraint_expression_5(p):
784 '''constraint_expression : K_if '(' expression ')' constraint_set K_else constraint_set '''
785 if(parse_debug):
786 print('constraint_expression_5', list(p))
787
788
789 ()
790
791
792 def p_constraint_expression_6(p):
793 '''constraint_expression : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' constraint_set '''
794 if(parse_debug):
795 print('constraint_expression_6', list(p))
796
797
798 ()
799
800
801 def p_constraint_expression_list_1(p):
802 '''constraint_expression_list : constraint_expression_list constraint_expression '''
803 if(parse_debug):
804 print('constraint_expression_list_1', list(p))
805
806
807 ()
808
809
810 def p_constraint_expression_list_2(p):
811 '''constraint_expression_list : constraint_expression '''
812 if(parse_debug):
813 print('constraint_expression_list_2', list(p))
814
815
816 ()
817
818
819 def p_constraint_prototype_1(p):
820 '''constraint_prototype : K_static_opt K_constraint IDENTIFIER ';' '''
821 if(parse_debug):
822 print('constraint_prototype_1', list(p))
823
824 # { yyerror(@2, "sorry: Constraint prototypes not supported."); }
825 ()
826
827
828 def p_constraint_set_1(p):
829 '''constraint_set : constraint_expression '''
830 if(parse_debug):
831 print('constraint_set_1', list(p))
832
833
834 ()
835
836
837 def p_constraint_set_2(p):
838 '''constraint_set : '{' constraint_expression_list '}' '''
839 if(parse_debug):
840 print('constraint_set_2', list(p))
841
842
843 ()
844
845
846 def p_data_declaration_1(p):
847 '''data_declaration : attribute_list_opt data_type_or_implicit list_of_variable_decl_assignments ';' '''
848 if(parse_debug):
849 print('data_declaration_1', list(p))
850
851 # { data_type_t*data_type = p[2];
852 # if (data_type == 0) {
853 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
854 # FILE_NAME(data_type, @2);
855 # }
856 # pform_makewire(@2, 0, str_strength, p[3], NetNet::IMPLICIT_REG, data_type);
857 # }
858 ()
859
860
861 def p_data_type_1(p):
862 '''data_type : integer_vector_type unsigned_signed_opt dimensions_opt '''
863 if(parse_debug):
864 print('data_type_1', list(p))
865 use_vtype = p[1]
866 reg_flag = False
867 if (use_vtype == IVL_VT_NO_TYPE):
868 use_vtype = IVL_VT_LOGIC
869 reg_flag = True
870 dt = DataType(use_vtype, signed=p[2])
871 dt.dims = p[3]
872 dt.reg_flag = reg_flag
873 p[0] = dt
874
875 # { ivl_variable_type_t use_vtype = p[1];
876 # bool reg_flag = false;
877 # if (use_vtype == IVL_VT_NO_TYPE) {
878 # use_vtype = IVL_VT_LOGIC;
879 # reg_flag = true;
880 # }
881 # vector_type_t*tmp = new vector_type_t(use_vtype, p[2], p[3]);
882 # tmp->reg_flag = reg_flag;
883 # FILE_NAME(tmp, @1);
884 # p[0] = tmp;
885 # }
886 ()
887
888
889 def p_data_type_2(p):
890 '''data_type : non_integer_type '''
891 if(parse_debug):
892 print('data_type_2', list(p))
893 p[0] = p[1]
894
895 # { real_type_t*tmp = new real_type_t(p[1]);
896 # FILE_NAME(tmp, @1);
897 # p[0] = tmp;
898 # }
899 ()
900
901
902 def p_data_type_3(p):
903 '''data_type : struct_data_type '''
904 if(parse_debug):
905 print('data_type_3', list(p))
906 p[0] = p[1]
907
908 # { if (!p[1]->packed_flag) {
909 # yyerror(@1, "sorry: Unpacked structs not supported.");
910 # }
911 # p[0] = p[1];
912 # }
913 ()
914
915
916 def p_data_type_4(p):
917 '''data_type : enum_data_type '''
918 if(parse_debug):
919 print('data_type_4', list(p))
920 p[0] = p[1]
921
922
923 ()
924
925
926 def p_data_type_5(p):
927 '''data_type : atom2_type signed_unsigned_opt '''
928 if(parse_debug):
929 print('data_type_5', list(p))
930
931 # { atom2_type_t*tmp = new atom2_type_t(p[1], p[2]);
932 # FILE_NAME(tmp, @1);
933 # p[0] = tmp;
934 # }
935 ()
936
937
938 def p_data_type_6(p):
939 '''data_type : K_integer signed_unsigned_opt '''
940 if(parse_debug):
941 print('data_type_6', list(p))
942
943 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
944 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[2], pd);
945 # tmp->reg_flag = true;
946 # tmp->integer_flag = true;
947 # p[0] = tmp;
948 # }
949 ()
950
951
952 def p_data_type_7(p):
953 '''data_type : K_time '''
954 if(parse_debug):
955 print('data_type_7', list(p))
956
957 # { list<pform_range_t>*pd = make_range_from_width(64);
958 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
959 # tmp->reg_flag = !gn_system_verilog();
960 # p[0] = tmp;
961 # }
962 ()
963
964
965 def p_data_type_8(p):
966 '''data_type : TYPE_IDENTIFIER dimensions_opt '''
967 if(parse_debug):
968 print('data_type_8', list(p))
969
970 # { if (p[2]) {
971 # parray_type_t*tmp = new parray_type_t(p[1].type, p[2]);
972 # FILE_NAME(tmp, @1);
973 # p[0] = tmp;
974 # } else p[0] = p[1].type;
975 # delete[]p[1].text;
976 # }
977 ()
978
979
980 def p_data_type_9(p):
981 '''data_type : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_data_type TYPE_IDENTIFIER '''
982 if(parse_debug):
983 print('data_type_9', list(p))
984
985 # { lex_in_package_scope(0);
986 # p[0] = p[4].type;
987 # delete[]p[4].text;
988 # }
989 ()
990
991
992 def p_data_type_10(p):
993 '''data_type : K_string '''
994 if(parse_debug):
995 print('data_type_10', list(p))
996
997 # { string_type_t*tmp = new string_type_t;
998 # FILE_NAME(tmp, @1);
999 # p[0] = tmp;
1000 # }
1001 ()
1002
1003
1004 def p__embed0_data_type(p):
1005 '''_embed0_data_type : '''
1006
1007 # { lex_in_package_scope(p[1]); }
1008 ()
1009
1010
1011 def p_data_type_or_implicit_1(p):
1012 '''data_type_or_implicit : data_type '''
1013 if(parse_debug):
1014 print('data_type_or_implicit_1', list(p))
1015 p[0] = p[1]
1016
1017
1018 ()
1019
1020
1021 def p_data_type_or_implicit_2(p):
1022 '''data_type_or_implicit : signing dimensions_opt '''
1023 if(parse_debug):
1024 print('data_type_or_implicit_2', list(p))
1025
1026 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[1], p[2]);
1027 # tmp->implicit_flag = true;
1028 # FILE_NAME(tmp, @1);
1029 # p[0] = tmp;
1030 # }
1031 ()
1032
1033
1034 def p_data_type_or_implicit_3(p):
1035 '''data_type_or_implicit : dimensions '''
1036 if(parse_debug):
1037 print('data_type_or_implicit_3', list(p))
1038 p[0] = list(p)
1039
1040 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, p[1]);
1041 # tmp->implicit_flag = true;
1042 # FILE_NAME(tmp, @1);
1043 # p[0] = tmp;
1044 # }
1045 ()
1046
1047
1048 def p_data_type_or_implicit_4(p):
1049 '''data_type_or_implicit : '''
1050 if(parse_debug > 2):
1051 print('data_type_or_implicit_4', list(p))
1052
1053 # { p[0] = None }
1054 ()
1055
1056
1057 def p_data_type_or_implicit_or_void_1(p):
1058 '''data_type_or_implicit_or_void : data_type_or_implicit '''
1059 if(parse_debug):
1060 print('data_type_or_implicit_or_void_1', list(p))
1061 p[0] = p[1]
1062
1063
1064 ()
1065
1066
1067 def p_data_type_or_implicit_or_void_2(p):
1068 '''data_type_or_implicit_or_void : K_void '''
1069 if(parse_debug):
1070 print('data_type_or_implicit_or_void_2', list(p))
1071
1072 # { void_type_t*tmp = new void_type_t;
1073 # FILE_NAME(tmp, @1);
1074 # p[0] = tmp;
1075 # }
1076 ()
1077
1078
1079 def p_description_1(p):
1080 '''description : module '''
1081 if(parse_debug > 2):
1082 print('description_1', list(p))
1083
1084
1085 ()
1086
1087
1088 def p_description_2(p):
1089 '''description : udp_primitive '''
1090 if(parse_debug):
1091 print('description_2', list(p))
1092
1093
1094 ()
1095
1096
1097 def p_description_3(p):
1098 '''description : config_declaration '''
1099 if(parse_debug):
1100 print('description_3', list(p))
1101
1102
1103 ()
1104
1105
1106 def p_description_4(p):
1107 '''description : nature_declaration '''
1108 if(parse_debug):
1109 print('description_4', list(p))
1110
1111
1112 ()
1113
1114
1115 def p_description_5(p):
1116 '''description : package_declaration '''
1117 if(parse_debug):
1118 print('description_5', list(p))
1119
1120
1121 ()
1122
1123
1124 def p_description_6(p):
1125 '''description : discipline_declaration '''
1126 if(parse_debug):
1127 print('description_6', list(p))
1128
1129
1130 ()
1131
1132
1133 def p_description_7(p):
1134 '''description : package_item '''
1135 if(parse_debug):
1136 print('description_7', list(p))
1137
1138
1139 ()
1140
1141
1142 def p_description_8(p):
1143 '''description : KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' '''
1144 if(parse_debug):
1145 print('description_8', list(p))
1146
1147 # { perm_string tmp3 = lex_strings.make(p[3]);
1148 # pform_set_type_attrib(tmp3, p[5], p[7]);
1149 # delete[] p[3];
1150 # delete[] p[5];
1151 # }
1152 ()
1153
1154
1155 def p_description_list_1(p):
1156 '''description_list : description '''
1157 if(parse_debug > 2):
1158 print('description_list_1', list(p))
1159
1160
1161 ()
1162
1163
1164 def p_description_list_2(p):
1165 '''description_list : description_list description '''
1166 if(parse_debug):
1167 print('description_list_2', list(p))
1168
1169
1170 ()
1171
1172
1173 def p_endnew_opt_1(p):
1174 '''endnew_opt : ':' K_new '''
1175 if(parse_debug):
1176 print('endnew_opt_1', list(p))
1177
1178
1179 ()
1180
1181
1182 def p_endnew_opt_2(p):
1183 '''endnew_opt : '''
1184 if(parse_debug):
1185 print('endnew_opt_2', list(p))
1186
1187
1188 ()
1189
1190
1191 def p_dynamic_array_new_1(p):
1192 '''dynamic_array_new : K_new '[' expression ']' '''
1193 if(parse_debug):
1194 print('dynamic_array_new_1', list(p))
1195
1196 # { p[0] = new PENewArray(p[3], 0);
1197 # FILE_NAME(p[0], @1);
1198 # }
1199 ()
1200
1201
1202 def p_dynamic_array_new_2(p):
1203 '''dynamic_array_new : K_new '[' expression ']' '(' expression ')' '''
1204 if(parse_debug):
1205 print('dynamic_array_new_2', list(p))
1206
1207 # { p[0] = new PENewArray(p[3], p[6]);
1208 # FILE_NAME(p[0], @1);
1209 # }
1210 ()
1211
1212
1213 def p_for_step_1(p):
1214 '''for_step : lpvalue '=' expression '''
1215 if(parse_debug):
1216 print('for_step_1', list(p))
1217
1218 # { PAssign*tmp = new PAssign(p[1],p[3]);
1219 # FILE_NAME(tmp, @1);
1220 # p[0] = tmp;
1221 # }
1222 ()
1223
1224
1225 def p_for_step_2(p):
1226 '''for_step : inc_or_dec_expression '''
1227 if(parse_debug):
1228 print('for_step_2', list(p))
1229
1230 # { p[0] = pform_compressed_assign_from_inc_dec(@1, p[1]); }
1231 ()
1232
1233
1234 def p_for_step_3(p):
1235 '''for_step : compressed_statement '''
1236 if(parse_debug):
1237 print('for_step_3', list(p))
1238 p[0] = p[1]
1239
1240
1241 ()
1242
1243
1244 def p_function_declaration_1(p):
1245 '''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 '''
1246 if(parse_debug):
1247 print('function_declaration_1', list(p))
1248
1249 # { // Last step: check any closing name.
1250 # if (p[11]) {
1251 # if (strcmp(p[4],p[11]) != 0) {
1252 # yyerror(@11, "error: End label doesn't match "
1253 # "function name");
1254 # }
1255 # if (! gn_system_verilog()) {
1256 # yyerror(@11, "error: Function end labels require "
1257 # "SystemVerilog.");
1258 # }
1259 # delete[]p[11];
1260 # }
1261 # delete[]p[4];
1262 # }
1263 ()
1264
1265
1266 def p_function_declaration_2(p):
1267 '''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 '''
1268 if(parse_debug):
1269 print('function_declaration_2', list(p))
1270
1271 # { // Last step: check any closing name.
1272 # if (p[14]) {
1273 # if (strcmp(p[4],p[14]) != 0) {
1274 # yyerror(@14, "error: End label doesn't match "
1275 # "function name");
1276 # }
1277 # if (! gn_system_verilog()) {
1278 # yyerror(@14, "error: Function end labels require "
1279 # "SystemVerilog.");
1280 # }
1281 # delete[]p[14];
1282 # }
1283 # delete[]p[4];
1284 # }
1285 ()
1286
1287
1288 def p_function_declaration_3(p):
1289 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER error K_endfunction _embed4_function_declaration endlabel_opt '''
1290 if(parse_debug):
1291 print('function_declaration_3', list(p))
1292
1293 # { // Last step: check any closing name.
1294 # if (p[8]) {
1295 # if (strcmp(p[4],p[8]) != 0) {
1296 # yyerror(@8, "error: End label doesn't match function name");
1297 # }
1298 # if (! gn_system_verilog()) {
1299 # yyerror(@8, "error: Function end labels require "
1300 # "SystemVerilog.");
1301 # }
1302 # delete[]p[8];
1303 # }
1304 # delete[]p[4];
1305 # }
1306 ()
1307
1308
1309 def p__embed0_function_declaration(p):
1310 '''_embed0_function_declaration : '''
1311
1312 # { assert(current_function == 0);
1313 # current_function = pform_push_function_scope(@1, p[4], p[2]);
1314 # }
1315 ()
1316
1317
1318 def p__embed1_function_declaration(p):
1319 '''_embed1_function_declaration : '''
1320
1321 # { current_function->set_ports(p[7]);
1322 # current_function->set_return(p[3]);
1323 # current_function_set_statement(p[8]? @8 : @4, p[8]);
1324 # pform_set_this_class(@4, current_function);
1325 # pform_pop_scope();
1326 # current_function = 0;
1327 # }
1328 ()
1329
1330
1331 def p__embed2_function_declaration(p):
1332 '''_embed2_function_declaration : '''
1333
1334 # { assert(current_function == 0);
1335 # current_function = pform_push_function_scope(@1, p[4], p[2]);
1336 # }
1337 ()
1338
1339
1340 def p__embed3_function_declaration(p):
1341 '''_embed3_function_declaration : '''
1342
1343 # { current_function->set_ports(p[7]);
1344 # current_function->set_return(p[3]);
1345 # current_function_set_statement(p[11]? @11 : @4, p[11]);
1346 # pform_set_this_class(@4, current_function);
1347 # pform_pop_scope();
1348 # current_function = 0;
1349 # if (p[7]==0 && !gn_system_verilog()) {
1350 # yyerror(@4, "error: Empty parenthesis syntax requires SystemVerilog.");
1351 # }
1352 # }
1353 ()
1354
1355
1356 def p__embed4_function_declaration(p):
1357 '''_embed4_function_declaration : '''
1358
1359 # { /* */
1360 # if (current_function) {
1361 # pform_pop_scope();
1362 # current_function = 0;
1363 # }
1364 # assert(current_function == 0);
1365 # yyerror(@1, "error: Syntax error defining function.");
1366 # yyerrok;
1367 # }
1368 ()
1369
1370
1371 def p_import_export_1(p):
1372 '''import_export : K_import '''
1373 if(parse_debug):
1374 print('import_export_1', list(p))
1375 p[0] = True
1376
1377
1378 ()
1379
1380
1381 def p_import_export_2(p):
1382 '''import_export : K_export '''
1383 if(parse_debug):
1384 print('import_export_2', list(p))
1385 p[0] = False
1386
1387
1388 ()
1389
1390
1391 def p_implicit_class_handle_1(p):
1392 '''implicit_class_handle : K_this '''
1393 if(parse_debug):
1394 print('implicit_class_handle_1', list(p))
1395
1396 # { p[0] = pform_create_this(); }
1397 ()
1398
1399
1400 def p_implicit_class_handle_2(p):
1401 '''implicit_class_handle : K_super '''
1402 if(parse_debug):
1403 print('implicit_class_handle_2', list(p))
1404
1405 # { p[0] = pform_create_super(); }
1406 ()
1407
1408
1409 def p_inc_or_dec_expression_1(p):
1410 '''inc_or_dec_expression : K_INCR lpvalue %prec UNARY_PREC '''
1411 if(parse_debug):
1412 print('inc_or_dec_expression_1', list(p))
1413
1414 # { PEUnary*tmp = new PEUnary('I', p[2]);
1415 # FILE_NAME(tmp, @2);
1416 # p[0] = tmp;
1417 # }
1418 ()
1419
1420
1421 def p_inc_or_dec_expression_2(p):
1422 '''inc_or_dec_expression : lpvalue K_INCR %prec UNARY_PREC '''
1423 if(parse_debug):
1424 print('inc_or_dec_expression_2', list(p))
1425
1426 # { PEUnary*tmp = new PEUnary('i', p[1]);
1427 # FILE_NAME(tmp, @1);
1428 # p[0] = tmp;
1429 # }
1430 ()
1431
1432
1433 def p_inc_or_dec_expression_3(p):
1434 '''inc_or_dec_expression : K_DECR lpvalue %prec UNARY_PREC '''
1435 if(parse_debug):
1436 print('inc_or_dec_expression_3', list(p))
1437
1438 # { PEUnary*tmp = new PEUnary('D', p[2]);
1439 # FILE_NAME(tmp, @2);
1440 # p[0] = tmp;
1441 # }
1442 ()
1443
1444
1445 def p_inc_or_dec_expression_4(p):
1446 '''inc_or_dec_expression : lpvalue K_DECR %prec UNARY_PREC '''
1447 if(parse_debug):
1448 print('inc_or_dec_expression_4', list(p))
1449
1450 # { PEUnary*tmp = new PEUnary('d', p[1]);
1451 # FILE_NAME(tmp, @1);
1452 # p[0] = tmp;
1453 # }
1454 ()
1455
1456
1457 def p_inside_expression_1(p):
1458 '''inside_expression : expression K_inside '{' open_range_list '}' '''
1459 if(parse_debug):
1460 print('inside_expression_1', list(p))
1461
1462 # { yyerror(@2, "sorry: \"inside\" expressions not supported yet.");
1463 # p[0] = None
1464 # }
1465 ()
1466
1467
1468 def p_integer_vector_type_1(p):
1469 '''integer_vector_type : K_reg '''
1470 if(parse_debug):
1471 print('integer_vector_type_1', list(p))
1472 p[0] = IVL_VT_NO_TYPE
1473
1474
1475 ()
1476
1477
1478 def p_integer_vector_type_2(p):
1479 '''integer_vector_type : K_bit '''
1480 if(parse_debug):
1481 print('integer_vector_type_2', list(p))
1482 p[0] = IVL_VT_BOOL
1483
1484
1485 ()
1486
1487
1488 def p_integer_vector_type_3(p):
1489 '''integer_vector_type : K_logic '''
1490 if(parse_debug):
1491 print('integer_vector_type_3', list(p))
1492 p[0] = IVL_VT_LOGIC
1493
1494
1495 ()
1496
1497
1498 def p_integer_vector_type_4(p):
1499 '''integer_vector_type : K_bool '''
1500 if(parse_debug):
1501 print('integer_vector_type_4', list(p))
1502
1503 # { p[0] = IVL_VT_BOOL; }
1504 ()
1505
1506
1507 def p_join_keyword_1(p):
1508 '''join_keyword : K_join '''
1509 if(parse_debug):
1510 print('join_keyword_1', list(p))
1511
1512 # { p[0] = PBlock::BL_PAR; }
1513 ()
1514
1515
1516 def p_join_keyword_2(p):
1517 '''join_keyword : K_join_none '''
1518 if(parse_debug):
1519 print('join_keyword_2', list(p))
1520
1521 # { p[0] = PBlock::BL_JOIN_NONE; }
1522 ()
1523
1524
1525 def p_join_keyword_3(p):
1526 '''join_keyword : K_join_any '''
1527 if(parse_debug):
1528 print('join_keyword_3', list(p))
1529
1530 # { p[0] = PBlock::BL_JOIN_ANY; }
1531 ()
1532
1533
1534 def p_jump_statement_1(p):
1535 '''jump_statement : K_break ';' '''
1536 if(parse_debug):
1537 print('jump_statement_1', list(p))
1538
1539 # { yyerror(@1, "sorry: break statements not supported.");
1540 # p[0] = None
1541 # }
1542 ()
1543
1544
1545 def p_jump_statement_2(p):
1546 '''jump_statement : K_return ';' '''
1547 if(parse_debug):
1548 print('jump_statement_2', list(p))
1549
1550 # { PReturn*tmp = new PReturn(0);
1551 # FILE_NAME(tmp, @1);
1552 # p[0] = tmp;
1553 # }
1554 ()
1555
1556
1557 def p_jump_statement_3(p):
1558 '''jump_statement : K_return expression ';' '''
1559 if(parse_debug):
1560 print('jump_statement_3', list(p))
1561
1562 # { PReturn*tmp = new PReturn(p[2]);
1563 # FILE_NAME(tmp, @1);
1564 # p[0] = tmp;
1565 # }
1566 ()
1567
1568
1569 def p_lifetime_1(p):
1570 '''lifetime : K_automatic '''
1571 if(parse_debug):
1572 print('lifetime_1', list(p))
1573
1574 # { p[0] = LexicalScope::AUTOMATIC; }
1575 ()
1576
1577
1578 def p_lifetime_2(p):
1579 '''lifetime : K_static '''
1580 if(parse_debug):
1581 print('lifetime_2', list(p))
1582
1583 # { p[0] = LexicalScope::STATIC; }
1584 ()
1585
1586
1587 def p_lifetime_opt_1(p):
1588 '''lifetime_opt : lifetime '''
1589 if(parse_debug):
1590 print('lifetime_opt_1', list(p))
1591 p[0] = p[1]
1592
1593
1594 ()
1595
1596
1597 def p_lifetime_opt_2(p):
1598 '''lifetime_opt : '''
1599 if(parse_debug > 2):
1600 print('lifetime_opt_2', list(p))
1601
1602 # { p[0] = LexicalScope::INHERITED; }
1603 ()
1604
1605
1606 def p_loop_statement_1(p):
1607 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' for_step ')' statement_or_null '''
1608 if(parse_debug):
1609 print('loop_statement_1', list(p))
1610
1611 # { PForStatement*tmp = new PForStatement(p[3], p[5], p[7], p[9], p[11]);
1612 # FILE_NAME(tmp, @1);
1613 # p[0] = tmp;
1614 # }
1615 ()
1616
1617
1618 def p_loop_statement_2(p):
1619 '''loop_statement : K_for '(' data_type IDENTIFIER '=' expression ';' expression ';' for_step ')' _embed0_loop_statement statement_or_null '''
1620 if(parse_debug):
1621 print('loop_statement_2', list(p))
1622
1623 # { pform_name_t tmp_hident;
1624 # tmp_hident.push_back(name_component_t(lex_strings.make(p[4])));
1625 #
1626 # PEIdent*tmp_ident = pform_new_ident(tmp_hident);
1627 # FILE_NAME(tmp_ident, @4);
1628 #
1629 # PForStatement*tmp_for = new PForStatement(tmp_ident, p[6], p[8], p[10], p[13]);
1630 # FILE_NAME(tmp_for, @1);
1631 #
1632 # pform_pop_scope();
1633 # vector<Statement*>tmp_for_list (1);
1634 # tmp_for_list[0] = tmp_for;
1635 # PBlock*tmp_blk = current_block_stack.top();
1636 # current_block_stack.pop();
1637 # tmp_blk->set_statement(tmp_for_list);
1638 # p[0] = tmp_blk;
1639 # delete[]p[4];
1640 # }
1641 ()
1642
1643
1644 def p_loop_statement_3(p):
1645 '''loop_statement : K_forever statement_or_null '''
1646 if(parse_debug):
1647 print('loop_statement_3', list(p))
1648
1649 # { PForever*tmp = new PForever(p[2]);
1650 # FILE_NAME(tmp, @1);
1651 # p[0] = tmp;
1652 # }
1653 ()
1654
1655
1656 def p_loop_statement_4(p):
1657 '''loop_statement : K_repeat '(' expression ')' statement_or_null '''
1658 if(parse_debug):
1659 print('loop_statement_4', list(p))
1660
1661 # { PRepeat*tmp = new PRepeat(p[3], p[5]);
1662 # FILE_NAME(tmp, @1);
1663 # p[0] = tmp;
1664 # }
1665 ()
1666
1667
1668 def p_loop_statement_5(p):
1669 '''loop_statement : K_while '(' expression ')' statement_or_null '''
1670 if(parse_debug):
1671 print('loop_statement_5', list(p))
1672
1673 # { PWhile*tmp = new PWhile(p[3], p[5]);
1674 # FILE_NAME(tmp, @1);
1675 # p[0] = tmp;
1676 # }
1677 ()
1678
1679
1680 def p_loop_statement_6(p):
1681 '''loop_statement : K_do statement_or_null K_while '(' expression ')' ';' '''
1682 if(parse_debug):
1683 print('loop_statement_6', list(p))
1684
1685 # { PDoWhile*tmp = new PDoWhile(p[5], p[2]);
1686 # FILE_NAME(tmp, @1);
1687 # p[0] = tmp;
1688 # }
1689 ()
1690
1691
1692 def p_loop_statement_7(p):
1693 '''loop_statement : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' _embed1_loop_statement statement_or_null '''
1694 if(parse_debug):
1695 print('loop_statement_7', list(p))
1696
1697 # { PForeach*tmp_for = pform_make_foreach(@1, p[3], p[5], p[9]);
1698 #
1699 # pform_pop_scope();
1700 # vector<Statement*>tmp_for_list(1);
1701 # tmp_for_list[0] = tmp_for;
1702 # PBlock*tmp_blk = current_block_stack.top();
1703 # current_block_stack.pop();
1704 # tmp_blk->set_statement(tmp_for_list);
1705 # p[0] = tmp_blk;
1706 # }
1707 ()
1708
1709
1710 def p_loop_statement_8(p):
1711 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' error ')' statement_or_null '''
1712 if(parse_debug):
1713 print('loop_statement_8', list(p))
1714
1715 # { p[0] = None
1716 # yyerror(@1, "error: Error in for loop step assignment.");
1717 # }
1718 ()
1719
1720
1721 def p_loop_statement_9(p):
1722 '''loop_statement : K_for '(' lpvalue '=' expression ';' error ';' for_step ')' statement_or_null '''
1723 if(parse_debug):
1724 print('loop_statement_9', list(p))
1725
1726 # { p[0] = None
1727 # yyerror(@1, "error: Error in for loop condition expression.");
1728 # }
1729 ()
1730
1731
1732 def p_loop_statement_10(p):
1733 '''loop_statement : K_for '(' error ')' statement_or_null '''
1734 if(parse_debug):
1735 print('loop_statement_10', list(p))
1736
1737 # { p[0] = None
1738 # yyerror(@1, "error: Incomprehensible for loop.");
1739 # }
1740 ()
1741
1742
1743 def p_loop_statement_11(p):
1744 '''loop_statement : K_while '(' error ')' statement_or_null '''
1745 if(parse_debug):
1746 print('loop_statement_11', list(p))
1747
1748 # { p[0] = None
1749 # yyerror(@1, "error: Error in while loop condition.");
1750 # }
1751 ()
1752
1753
1754 def p_loop_statement_12(p):
1755 '''loop_statement : K_do statement_or_null K_while '(' error ')' ';' '''
1756 if(parse_debug):
1757 print('loop_statement_12', list(p))
1758
1759 # { p[0] = None
1760 # yyerror(@1, "error: Error in do/while loop condition.");
1761 # }
1762 ()
1763
1764
1765 def p_loop_statement_13(p):
1766 '''loop_statement : K_foreach '(' IDENTIFIER '[' error ']' ')' statement_or_null '''
1767 if(parse_debug):
1768 print('loop_statement_13', list(p))
1769
1770 # { p[0] = None
1771 # yyerror(@4, "error: Errors in foreach loop variables list.");
1772 # }
1773 ()
1774
1775
1776 def p__embed0_loop_statement(p):
1777 '''_embed0_loop_statement : '''
1778
1779 # { static unsigned for_counter = 0;
1780 # char for_block_name [64];
1781 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_for_loop%u", for_counter);
1782 # for_counter += 1;
1783 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1784 # FILE_NAME(tmp, @1);
1785 # current_block_stack.push(tmp);
1786 #
1787 # list<decl_assignment_t*>assign_list;
1788 # decl_assignment_t*tmp_assign = new decl_assignment_t;
1789 # tmp_assign->name = lex_strings.make(p[4]);
1790 # assign_list.push_back(tmp_assign);
1791 # pform_makewire(@4, 0, str_strength, &assign_list, NetNet::REG, p[3]);
1792 # }
1793 ()
1794
1795
1796 def p__embed1_loop_statement(p):
1797 '''_embed1_loop_statement : '''
1798
1799 # { static unsigned foreach_counter = 0;
1800 # char for_block_name[64];
1801 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_foreach%u", foreach_counter);
1802 # foreach_counter += 1;
1803 #
1804 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1805 # FILE_NAME(tmp, @1);
1806 # current_block_stack.push(tmp);
1807 #
1808 # pform_make_foreach_declarations(@1, p[5]);
1809 # }
1810 ()
1811
1812
1813 def p_list_of_variable_decl_assignments_1(p):
1814 '''list_of_variable_decl_assignments : variable_decl_assignment '''
1815 if(parse_debug):
1816 print('list_of_variable_decl_assignments_1', list(p))
1817
1818 # { list<decl_assignment_t*>*tmp = new list<decl_assignment_t*>;
1819 # tmp->push_back(p[1]);
1820 # p[0] = tmp;
1821 # }
1822 ()
1823
1824
1825 def p_list_of_variable_decl_assignments_2(p):
1826 '''list_of_variable_decl_assignments : list_of_variable_decl_assignments ',' variable_decl_assignment '''
1827 if(parse_debug):
1828 print('list_of_variable_decl_assignments_2', list(p))
1829
1830 # { list<decl_assignment_t*>*tmp = p[1];
1831 # tmp->push_back(p[3]);
1832 # p[0] = tmp;
1833 # }
1834 ()
1835
1836
1837 def p_variable_decl_assignment_1(p):
1838 '''variable_decl_assignment : IDENTIFIER dimensions_opt '''
1839 if(parse_debug):
1840 print('variable_decl_assignment_1', list(p))
1841
1842 # { decl_assignment_t*tmp = new decl_assignment_t;
1843 # tmp->name = lex_strings.make(p[1]);
1844 # if (p[2]) {
1845 # tmp->index = *p[2];
1846 # delete p[2];
1847 # }
1848 # delete[]p[1];
1849 # p[0] = tmp;
1850 # }
1851 ()
1852
1853
1854 def p_variable_decl_assignment_2(p):
1855 '''variable_decl_assignment : IDENTIFIER '=' expression '''
1856 if(parse_debug):
1857 print('variable_decl_assignment_2', list(p))
1858
1859 # { decl_assignment_t*tmp = new decl_assignment_t;
1860 # tmp->name = lex_strings.make(p[1]);
1861 # tmp->expr .reset(p[3]);
1862 # delete[]p[1];
1863 # p[0] = tmp;
1864 # }
1865 ()
1866
1867
1868 def p_variable_decl_assignment_3(p):
1869 '''variable_decl_assignment : IDENTIFIER '=' K_new '(' ')' '''
1870 if(parse_debug):
1871 print('variable_decl_assignment_3', list(p))
1872
1873 # { decl_assignment_t*tmp = new decl_assignment_t;
1874 # tmp->name = lex_strings.make(p[1]);
1875 # PENewClass*expr = new PENewClass;
1876 # FILE_NAME(expr, @3);
1877 # tmp->expr .reset(expr);
1878 # delete[]p[1];
1879 # p[0] = tmp;
1880 # }
1881 ()
1882
1883
1884 def p_loop_variables_1(p):
1885 '''loop_variables : loop_variables ',' IDENTIFIER '''
1886 if(parse_debug):
1887 print('loop_variables_1', list(p))
1888
1889 # { list<perm_string>*tmp = p[1];
1890 # tmp->push_back(lex_strings.make(p[3]));
1891 # delete[]p[3];
1892 # p[0] = tmp;
1893 # }
1894 ()
1895
1896
1897 def p_loop_variables_2(p):
1898 '''loop_variables : IDENTIFIER '''
1899 if(parse_debug):
1900 print('loop_variables_2', list(p))
1901
1902 # { list<perm_string>*tmp = new list<perm_string>;
1903 # tmp->push_back(lex_strings.make(p[1]));
1904 # delete[]p[1];
1905 # p[0] = tmp;
1906 # }
1907 ()
1908
1909
1910 def p_method_qualifier_1(p):
1911 '''method_qualifier : K_virtual '''
1912 if(parse_debug):
1913 print('method_qualifier_1', list(p))
1914
1915
1916 ()
1917
1918
1919 def p_method_qualifier_2(p):
1920 '''method_qualifier : class_item_qualifier '''
1921 if(parse_debug):
1922 print('method_qualifier_2', list(p))
1923
1924
1925 ()
1926
1927
1928 def p_method_qualifier_opt_1(p):
1929 '''method_qualifier_opt : method_qualifier '''
1930 if(parse_debug):
1931 print('method_qualifier_opt_1', list(p))
1932
1933
1934 ()
1935
1936
1937 def p_method_qualifier_opt_2(p):
1938 '''method_qualifier_opt : '''
1939 if(parse_debug):
1940 print('method_qualifier_opt_2', list(p))
1941
1942
1943 ()
1944
1945
1946 def p_modport_declaration_1(p):
1947 '''modport_declaration : K_modport _embed0_modport_declaration modport_item_list ';' '''
1948 if(parse_debug):
1949 print('modport_declaration_1', list(p))
1950
1951
1952 ()
1953
1954
1955 def p__embed0_modport_declaration(p):
1956 '''_embed0_modport_declaration : '''
1957
1958 # { if (!pform_in_interface())
1959 # yyerror(@1, "error: modport declarations are only allowed "
1960 # "in interfaces.");
1961 # }
1962 ()
1963
1964
1965 def p_modport_item_list_1(p):
1966 '''modport_item_list : modport_item '''
1967 if(parse_debug):
1968 print('modport_item_list_1', list(p))
1969
1970
1971 ()
1972
1973
1974 def p_modport_item_list_2(p):
1975 '''modport_item_list : modport_item_list ',' modport_item '''
1976 if(parse_debug):
1977 print('modport_item_list_2', list(p))
1978
1979
1980 ()
1981
1982
1983 def p_modport_item_1(p):
1984 '''modport_item : IDENTIFIER _embed0_modport_item '(' modport_ports_list ')' '''
1985 if(parse_debug):
1986 print('modport_item_1', list(p))
1987
1988 # { pform_end_modport_item(@1); }
1989 ()
1990
1991
1992 def p__embed0_modport_item(p):
1993 '''_embed0_modport_item : '''
1994
1995 # { pform_start_modport_item(@1, p[1]); }
1996 ()
1997
1998
1999 def p_modport_ports_list_1(p):
2000 '''modport_ports_list : modport_ports_declaration '''
2001 if(parse_debug):
2002 print('modport_ports_list_1', list(p))
2003
2004
2005 ()
2006
2007
2008 def p_modport_ports_list_2(p):
2009 '''modport_ports_list : modport_ports_list ',' modport_ports_declaration '''
2010 if(parse_debug):
2011 print('modport_ports_list_2', list(p))
2012
2013
2014 ()
2015
2016
2017 def p_modport_ports_list_3(p):
2018 '''modport_ports_list : modport_ports_list ',' modport_simple_port '''
2019 if(parse_debug):
2020 print('modport_ports_list_3', list(p))
2021
2022 # { if (last_modport_port.type == MP_SIMPLE) {
2023 # pform_add_modport_port(@3, last_modport_port.direction,
2024 # p[3]->name, p[3]->parm);
2025 # } else {
2026 # yyerror(@3, "error: modport expression not allowed here.");
2027 # }
2028 # delete p[3];
2029 # }
2030 ()
2031
2032
2033 def p_modport_ports_list_4(p):
2034 '''modport_ports_list : modport_ports_list ',' modport_tf_port '''
2035 if(parse_debug):
2036 print('modport_ports_list_4', list(p))
2037
2038 # { if (last_modport_port.type != MP_TF)
2039 # yyerror(@3, "error: task/function declaration not allowed here.");
2040 # }
2041 ()
2042
2043
2044 def p_modport_ports_list_5(p):
2045 '''modport_ports_list : modport_ports_list ',' IDENTIFIER '''
2046 if(parse_debug):
2047 print('modport_ports_list_5', list(p))
2048
2049 # { if (last_modport_port.type == MP_SIMPLE) {
2050 # pform_add_modport_port(@3, last_modport_port.direction,
2051 # lex_strings.make(p[3]), 0);
2052 # } else if (last_modport_port.type != MP_TF) {
2053 # yyerror(@3, "error: list of identifiers not allowed here.");
2054 # }
2055 # delete[] p[3];
2056 # }
2057 ()
2058
2059
2060 def p_modport_ports_list_6(p):
2061 '''modport_ports_list : modport_ports_list ',' '''
2062 if(parse_debug):
2063 print('modport_ports_list_6', list(p))
2064
2065 # { yyerror(@2, "error: NULL port declarations are not allowed"); }
2066 ()
2067
2068
2069 def p_modport_ports_declaration_1(p):
2070 '''modport_ports_declaration : attribute_list_opt port_direction IDENTIFIER '''
2071 if(parse_debug):
2072 print('modport_ports_declaration_1', list(p))
2073
2074 # { last_modport_port.type = MP_SIMPLE;
2075 # last_modport_port.direction = p[2];
2076 # pform_add_modport_port(@3, p[2], lex_strings.make(p[3]), 0);
2077 # delete[] p[3];
2078 # delete p[1];
2079 # }
2080 ()
2081
2082
2083 def p_modport_ports_declaration_2(p):
2084 '''modport_ports_declaration : attribute_list_opt port_direction modport_simple_port '''
2085 if(parse_debug):
2086 print('modport_ports_declaration_2', list(p))
2087
2088 # { last_modport_port.type = MP_SIMPLE;
2089 # last_modport_port.direction = p[2];
2090 # pform_add_modport_port(@3, p[2], p[3]->name, p[3]->parm);
2091 # delete p[3];
2092 # delete p[1];
2093 # }
2094 ()
2095
2096
2097 def p_modport_ports_declaration_3(p):
2098 '''modport_ports_declaration : attribute_list_opt import_export IDENTIFIER '''
2099 if(parse_debug):
2100 print('modport_ports_declaration_3', list(p))
2101
2102 # { last_modport_port.type = MP_TF;
2103 # last_modport_port.is_import = p[2];
2104 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
2105 # delete[] p[3];
2106 # delete p[1];
2107 # }
2108 ()
2109
2110
2111 def p_modport_ports_declaration_4(p):
2112 '''modport_ports_declaration : attribute_list_opt import_export modport_tf_port '''
2113 if(parse_debug):
2114 print('modport_ports_declaration_4', list(p))
2115
2116 # { last_modport_port.type = MP_TF;
2117 # last_modport_port.is_import = p[2];
2118 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
2119 # delete p[1];
2120 # }
2121 ()
2122
2123
2124 def p_modport_ports_declaration_5(p):
2125 '''modport_ports_declaration : attribute_list_opt K_clocking IDENTIFIER '''
2126 if(parse_debug):
2127 print('modport_ports_declaration_5', list(p))
2128
2129 # { last_modport_port.type = MP_CLOCKING;
2130 # last_modport_port.direction = NetNet::NOT_A_PORT;
2131 # yyerror(@3, "sorry: modport clocking declaration is not yet supported.");
2132 # delete[] p[3];
2133 # delete p[1];
2134 # }
2135 ()
2136
2137
2138 def p_modport_simple_port_1(p):
2139 '''modport_simple_port : '.' IDENTIFIER '(' expression ')' '''
2140 if(parse_debug):
2141 print('modport_simple_port_1', list(p))
2142
2143 # { named_pexpr_t*tmp = new named_pexpr_t;
2144 # tmp->name = lex_strings.make(p[2]);
2145 # tmp->parm = p[4];
2146 # delete[]p[2];
2147 # p[0] = tmp;
2148 # }
2149 ()
2150
2151
2152 def p_modport_tf_port_1(p):
2153 '''modport_tf_port : K_task IDENTIFIER '''
2154 if(parse_debug):
2155 print('modport_tf_port_1', list(p))
2156
2157
2158 ()
2159
2160
2161 def p_modport_tf_port_2(p):
2162 '''modport_tf_port : K_task IDENTIFIER '(' tf_port_list_opt ')' '''
2163 if(parse_debug):
2164 print('modport_tf_port_2', list(p))
2165
2166
2167 ()
2168
2169
2170 def p_modport_tf_port_3(p):
2171 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '''
2172 if(parse_debug):
2173 print('modport_tf_port_3', list(p))
2174
2175
2176 ()
2177
2178
2179 def p_modport_tf_port_4(p):
2180 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' '''
2181 if(parse_debug):
2182 print('modport_tf_port_4', list(p))
2183
2184
2185 ()
2186
2187
2188 def p_non_integer_type_1(p):
2189 '''non_integer_type : K_real '''
2190 if(parse_debug):
2191 print('non_integer_type_1', list(p))
2192
2193 # { p[0] = real_type_t::REAL; }
2194 ()
2195
2196
2197 def p_non_integer_type_2(p):
2198 '''non_integer_type : K_realtime '''
2199 if(parse_debug):
2200 print('non_integer_type_2', list(p))
2201
2202 # { p[0] = real_type_t::REAL; }
2203 ()
2204
2205
2206 def p_non_integer_type_3(p):
2207 '''non_integer_type : K_shortreal '''
2208 if(parse_debug):
2209 print('non_integer_type_3', list(p))
2210
2211 # { p[0] = real_type_t::SHORTREAL; }
2212 ()
2213
2214
2215 def p_number_1(p):
2216 '''number : BASED_NUMBER '''
2217 if(parse_debug):
2218 print('number_1', list(p))
2219
2220 # { p[0] = p[1]; based_size = 0;}
2221 ()
2222
2223
2224 def p_number_2(p):
2225 '''number : DEC_NUMBER '''
2226 if(parse_debug):
2227 print('number_2', list(p))
2228 num = Leaf(token.NUMBER, "%s" % (p[1]))
2229 p[0] = num
2230
2231 # { p[0] = p[1]; based_size = 0;}
2232 ()
2233
2234
2235 def p_number_3(p):
2236 '''number : DEC_NUMBER BASED_NUMBER '''
2237 if(parse_debug):
2238 print('number_3', list(p))
2239 num = Leaf(token.NUMBER, "%s:%s" % (p[1], p[2]))
2240 p[0] = num
2241
2242 # { p[0] = pform_verinum_with_size(p[1],p[2], @2.text, @2.first_line);
2243 # based_size = 0; }
2244 ()
2245
2246
2247 def p_number_4(p):
2248 '''number : UNBASED_NUMBER '''
2249 if(parse_debug):
2250 print('number_4', list(p))
2251
2252 # { p[0] = p[1]; based_size = 0;}
2253 ()
2254
2255
2256 def p_number_5(p):
2257 '''number : DEC_NUMBER UNBASED_NUMBER '''
2258 if(parse_debug):
2259 print('number_5', list(p))
2260
2261 # { yyerror(@1, "error: Unbased SystemVerilog literal cannot have "
2262 # "a size.");
2263 # p[0] = p[1]; based_size = 0;}
2264 ()
2265
2266
2267 def p_open_range_list_1(p):
2268 '''open_range_list : open_range_list ',' value_range '''
2269 if(parse_debug):
2270 print('open_range_list_1', list(p))
2271
2272
2273 ()
2274
2275
2276 def p_open_range_list_2(p):
2277 '''open_range_list : value_range '''
2278 if(parse_debug):
2279 print('open_range_list_2', list(p))
2280
2281
2282 ()
2283
2284
2285 def p_package_declaration_1(p):
2286 '''package_declaration : K_package lifetime_opt IDENTIFIER ';' _embed0_package_declaration timeunits_declaration_opt _embed1_package_declaration package_item_list_opt K_endpackage endlabel_opt '''
2287 if(parse_debug):
2288 print('package_declaration_1', list(p))
2289
2290 # { pform_end_package_declaration(@1);
2291 # // If an end label is present make sure it match the package name.
2292 # if (p[10]) {
2293 # if (strcmp(p[3],p[10]) != 0) {
2294 # yyerror(@10, "error: End label doesn't match package name");
2295 # }
2296 # delete[]p[10];
2297 # }
2298 # delete[]p[3];
2299 # }
2300 ()
2301
2302
2303 def p__embed0_package_declaration(p):
2304 '''_embed0_package_declaration : '''
2305
2306 # { pform_start_package_declaration(@1, p[3], p[2]); }
2307 ()
2308
2309
2310 def p__embed1_package_declaration(p):
2311 '''_embed1_package_declaration : '''
2312
2313 # { pform_set_scope_timescale(@1); }
2314 ()
2315
2316
2317 def p_module_package_import_list_opt_1(p):
2318 '''module_package_import_list_opt : '''
2319 if(parse_debug > 1):
2320 print('module_package_import_list_opt_1', list(p))
2321
2322
2323 ()
2324
2325
2326 def p_module_package_import_list_opt_2(p):
2327 '''module_package_import_list_opt : package_import_list '''
2328 if(parse_debug):
2329 print('module_package_import_list_opt_2', list(p))
2330
2331
2332 ()
2333
2334
2335 def p_package_import_list_1(p):
2336 '''package_import_list : package_import_declaration '''
2337 if(parse_debug):
2338 print('package_import_list_1', list(p))
2339
2340
2341 ()
2342
2343
2344 def p_package_import_list_2(p):
2345 '''package_import_list : package_import_list package_import_declaration '''
2346 if(parse_debug):
2347 print('package_import_list_2', list(p))
2348
2349
2350 ()
2351
2352
2353 def p_package_import_declaration_1(p):
2354 '''package_import_declaration : K_import package_import_item_list ';' '''
2355 if(parse_debug):
2356 print('package_import_declaration_1', list(p))
2357
2358 # { }
2359 ()
2360
2361
2362 def p_package_import_item_1(p):
2363 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '''
2364 if(parse_debug):
2365 print('package_import_item_1', list(p))
2366
2367 # { pform_package_import(@2, p[1], p[3]);
2368 # delete[]p[3];
2369 # }
2370 ()
2371
2372
2373 def p_package_import_item_2(p):
2374 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES '*' '''
2375 if(parse_debug):
2376 print('package_import_item_2', list(p))
2377
2378 # { pform_package_import(@2, p[1], 0);
2379 # }
2380 ()
2381
2382
2383 def p_package_import_item_list_1(p):
2384 '''package_import_item_list : package_import_item_list ',' package_import_item '''
2385 if(parse_debug):
2386 print('package_import_item_list_1', list(p))
2387
2388
2389 ()
2390
2391
2392 def p_package_import_item_list_2(p):
2393 '''package_import_item_list : package_import_item '''
2394 if(parse_debug):
2395 print('package_import_item_list_2', list(p))
2396
2397
2398 ()
2399
2400
2401 def p_package_item_1(p):
2402 '''package_item : timeunits_declaration '''
2403 if(parse_debug):
2404 print('package_item_1', list(p))
2405
2406
2407 ()
2408
2409
2410 def p_package_item_2(p):
2411 '''package_item : K_parameter param_type parameter_assign_list ';' '''
2412 if(parse_debug):
2413 print('package_item_2', list(p))
2414
2415
2416 ()
2417
2418
2419 def p_package_item_3(p):
2420 '''package_item : K_localparam param_type localparam_assign_list ';' '''
2421 if(parse_debug):
2422 print('package_item_3', list(p))
2423
2424
2425 ()
2426
2427
2428 def p_package_item_4(p):
2429 '''package_item : type_declaration '''
2430 if(parse_debug):
2431 print('package_item_4', list(p))
2432
2433
2434 ()
2435
2436
2437 def p_package_item_5(p):
2438 '''package_item : function_declaration '''
2439 if(parse_debug):
2440 print('package_item_5', list(p))
2441
2442
2443 ()
2444
2445
2446 def p_package_item_6(p):
2447 '''package_item : task_declaration '''
2448 if(parse_debug):
2449 print('package_item_6', list(p))
2450
2451
2452 ()
2453
2454
2455 def p_package_item_7(p):
2456 '''package_item : data_declaration '''
2457 if(parse_debug):
2458 print('package_item_7', list(p))
2459
2460
2461 ()
2462
2463
2464 def p_package_item_8(p):
2465 '''package_item : class_declaration '''
2466 if(parse_debug):
2467 print('package_item_8', list(p))
2468
2469
2470 ()
2471
2472
2473 def p_package_item_list_1(p):
2474 '''package_item_list : package_item_list package_item '''
2475 if(parse_debug):
2476 print('package_item_list_1', list(p))
2477
2478
2479 ()
2480
2481
2482 def p_package_item_list_2(p):
2483 '''package_item_list : package_item '''
2484 if(parse_debug):
2485 print('package_item_list_2', list(p))
2486
2487
2488 ()
2489
2490
2491 def p_package_item_list_opt_1(p):
2492 '''package_item_list_opt : package_item_list '''
2493 if(parse_debug):
2494 print('package_item_list_opt_1', list(p))
2495
2496
2497 ()
2498
2499
2500 def p_package_item_list_opt_2(p):
2501 '''package_item_list_opt : '''
2502 if(parse_debug):
2503 print('package_item_list_opt_2', list(p))
2504
2505
2506 ()
2507
2508
2509 def p_port_direction_1(p):
2510 '''port_direction : K_input '''
2511 if(parse_debug):
2512 print('port_direction_1', list(p))
2513
2514 # { p[0] = NetNet::PINPUT; }
2515 ()
2516
2517
2518 def p_port_direction_2(p):
2519 '''port_direction : K_output '''
2520 if(parse_debug):
2521 print('port_direction_2', list(p))
2522
2523 # { p[0] = NetNet::POUTPUT; }
2524 ()
2525
2526
2527 def p_port_direction_3(p):
2528 '''port_direction : K_inout '''
2529 if(parse_debug):
2530 print('port_direction_3', list(p))
2531
2532 # { p[0] = NetNet::PINOUT; }
2533 ()
2534
2535
2536 def p_port_direction_4(p):
2537 '''port_direction : K_ref '''
2538 if(parse_debug):
2539 print('port_direction_4', list(p))
2540
2541 # { p[0] = NetNet::PREF;
2542 # if (!gn_system_verilog()) {
2543 # yyerror(@1, "error: Reference ports (ref) require SystemVerilog.");
2544 # p[0] = NetNet::PINPUT;
2545 # }
2546 # }
2547 ()
2548
2549
2550 def p_port_direction_opt_1(p):
2551 '''port_direction_opt : port_direction '''
2552 if(parse_debug):
2553 print('port_direction_opt_1', list(p))
2554 p[0] = p[1]
2555
2556
2557 ()
2558
2559
2560 def p_port_direction_opt_2(p):
2561 '''port_direction_opt : '''
2562 if(parse_debug):
2563 print('port_direction_opt_2', list(p))
2564
2565 # { p[0] = NetNet::PIMPLICIT; }
2566 ()
2567
2568
2569 def p_property_expr_1(p):
2570 '''property_expr : expression '''
2571 if(parse_debug):
2572 print('property_expr_1', list(p))
2573
2574
2575 ()
2576
2577
2578 def p_procedural_assertion_statement_1(p):
2579 '''procedural_assertion_statement : K_assert '(' expression ')' statement %prec less_than_K_else '''
2580 if(parse_debug):
2581 print('procedural_assertion_statement_1', list(p))
2582
2583 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2584 # p[0] = None
2585 # }
2586 ()
2587
2588
2589 def p_procedural_assertion_statement_2(p):
2590 '''procedural_assertion_statement : K_assert '(' expression ')' K_else statement '''
2591 if(parse_debug):
2592 print('procedural_assertion_statement_2', list(p))
2593
2594 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2595 # p[0] = None
2596 # }
2597 ()
2598
2599
2600 def p_procedural_assertion_statement_3(p):
2601 '''procedural_assertion_statement : K_assert '(' expression ')' statement K_else statement '''
2602 if(parse_debug):
2603 print('procedural_assertion_statement_3', list(p))
2604
2605 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2606 # p[0] = None
2607 # }
2608 ()
2609
2610
2611 def p_property_qualifier_1(p):
2612 '''property_qualifier : class_item_qualifier '''
2613 if(parse_debug):
2614 print('property_qualifier_1', list(p))
2615
2616
2617 ()
2618
2619
2620 def p_property_qualifier_2(p):
2621 '''property_qualifier : random_qualifier '''
2622 if(parse_debug):
2623 print('property_qualifier_2', list(p))
2624
2625
2626 ()
2627
2628
2629 def p_property_qualifier_opt_1(p):
2630 '''property_qualifier_opt : property_qualifier_list '''
2631 if(parse_debug):
2632 print('property_qualifier_opt_1', list(p))
2633 p[0] = p[1]
2634
2635
2636 ()
2637
2638
2639 def p_property_qualifier_opt_2(p):
2640 '''property_qualifier_opt : '''
2641 if(parse_debug):
2642 print('property_qualifier_opt_2', list(p))
2643
2644 # { p[0] = property_qualifier_t::make_none(); }
2645 ()
2646
2647
2648 def p_property_qualifier_list_1(p):
2649 '''property_qualifier_list : property_qualifier_list property_qualifier '''
2650 if(parse_debug):
2651 print('property_qualifier_list_1', list(p))
2652
2653 # { p[0] = p[1] | p[2]; }
2654 ()
2655
2656
2657 def p_property_qualifier_list_2(p):
2658 '''property_qualifier_list : property_qualifier '''
2659 if(parse_debug):
2660 print('property_qualifier_list_2', list(p))
2661 p[0] = p[1]
2662
2663
2664 ()
2665
2666
2667 def p_property_spec_1(p):
2668 '''property_spec : clocking_event_opt property_spec_disable_iff_opt property_expr '''
2669 if(parse_debug):
2670 print('property_spec_1', list(p))
2671
2672
2673 ()
2674
2675
2676 def p_property_spec_disable_iff_opt_1(p):
2677 '''property_spec_disable_iff_opt : K_disable K_iff '(' expression ')' '''
2678 if(parse_debug):
2679 print('property_spec_disable_iff_opt_1', list(p))
2680
2681
2682 ()
2683
2684
2685 def p_property_spec_disable_iff_opt_2(p):
2686 '''property_spec_disable_iff_opt : '''
2687 if(parse_debug):
2688 print('property_spec_disable_iff_opt_2', list(p))
2689
2690
2691 ()
2692
2693
2694 def p_random_qualifier_1(p):
2695 '''random_qualifier : K_rand '''
2696 if(parse_debug):
2697 print('random_qualifier_1', list(p))
2698
2699 # { p[0] = property_qualifier_t::make_rand(); }
2700 ()
2701
2702
2703 def p_random_qualifier_2(p):
2704 '''random_qualifier : K_randc '''
2705 if(parse_debug):
2706 print('random_qualifier_2', list(p))
2707
2708 # { p[0] = property_qualifier_t::make_randc(); }
2709 ()
2710
2711
2712 def p_real_or_realtime_1(p):
2713 '''real_or_realtime : K_real '''
2714 if(parse_debug):
2715 print('real_or_realtime_1', list(p))
2716
2717
2718 ()
2719
2720
2721 def p_real_or_realtime_2(p):
2722 '''real_or_realtime : K_realtime '''
2723 if(parse_debug):
2724 print('real_or_realtime_2', list(p))
2725
2726
2727 ()
2728
2729
2730 def p_signing_1(p):
2731 '''signing : K_signed '''
2732 if(parse_debug):
2733 print('signing_1', list(p))
2734 p[0] = True
2735
2736
2737 ()
2738
2739
2740 def p_signing_2(p):
2741 '''signing : K_unsigned '''
2742 if(parse_debug):
2743 print('signing_2', list(p))
2744 p[0] = False
2745
2746
2747 ()
2748
2749
2750 def p_simple_type_or_string_1(p):
2751 '''simple_type_or_string : integer_vector_type '''
2752 if(parse_debug):
2753 print('simple_type_or_string_1', list(p))
2754
2755 # { ivl_variable_type_t use_vtype = p[1];
2756 # bool reg_flag = false;
2757 # if (use_vtype == IVL_VT_NO_TYPE) {
2758 # use_vtype = IVL_VT_LOGIC;
2759 # reg_flag = true;
2760 # }
2761 # vector_type_t*tmp = new vector_type_t(use_vtype, false, 0);
2762 # tmp->reg_flag = reg_flag;
2763 # FILE_NAME(tmp, @1);
2764 # p[0] = tmp;
2765 # }
2766 ()
2767
2768
2769 def p_simple_type_or_string_2(p):
2770 '''simple_type_or_string : non_integer_type '''
2771 if(parse_debug):
2772 print('simple_type_or_string_2', list(p))
2773
2774 # { real_type_t*tmp = new real_type_t(p[1]);
2775 # FILE_NAME(tmp, @1);
2776 # p[0] = tmp;
2777 # }
2778 ()
2779
2780
2781 def p_simple_type_or_string_3(p):
2782 '''simple_type_or_string : atom2_type '''
2783 if(parse_debug):
2784 print('simple_type_or_string_3', list(p))
2785
2786 # { atom2_type_t*tmp = new atom2_type_t(p[1], true);
2787 # FILE_NAME(tmp, @1);
2788 # p[0] = tmp;
2789 # }
2790 ()
2791
2792
2793 def p_simple_type_or_string_4(p):
2794 '''simple_type_or_string : K_integer '''
2795 if(parse_debug):
2796 print('simple_type_or_string_4', list(p))
2797
2798 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
2799 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, true, pd);
2800 # tmp->reg_flag = true;
2801 # tmp->integer_flag = true;
2802 # p[0] = tmp;
2803 # }
2804 ()
2805
2806
2807 def p_simple_type_or_string_5(p):
2808 '''simple_type_or_string : K_time '''
2809 if(parse_debug):
2810 print('simple_type_or_string_5', list(p))
2811
2812 # { list<pform_range_t>*pd = make_range_from_width(64);
2813 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
2814 # tmp->reg_flag = !gn_system_verilog();
2815 # p[0] = tmp;
2816 # }
2817 ()
2818
2819
2820 def p_simple_type_or_string_6(p):
2821 '''simple_type_or_string : TYPE_IDENTIFIER '''
2822 if(parse_debug):
2823 print('simple_type_or_string_6', list(p))
2824
2825 # { p[0] = p[1].type;
2826 # delete[]p[1].text;
2827 # }
2828 ()
2829
2830
2831 def p_simple_type_or_string_7(p):
2832 '''simple_type_or_string : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_simple_type_or_string TYPE_IDENTIFIER '''
2833 if(parse_debug):
2834 print('simple_type_or_string_7', list(p))
2835
2836 # { lex_in_package_scope(0);
2837 # p[0] = p[4].type;
2838 # delete[]p[4].text;
2839 # }
2840 ()
2841
2842
2843 def p_simple_type_or_string_8(p):
2844 '''simple_type_or_string : K_string '''
2845 if(parse_debug):
2846 print('simple_type_or_string_8', list(p))
2847
2848 # { string_type_t*tmp = new string_type_t;
2849 # FILE_NAME(tmp, @1);
2850 # p[0] = tmp;
2851 # }
2852 ()
2853
2854
2855 def p__embed0_simple_type_or_string(p):
2856 '''_embed0_simple_type_or_string : '''
2857
2858 # { lex_in_package_scope(p[1]); }
2859 ()
2860
2861
2862 def p_statement_1(p):
2863 '''statement : attribute_list_opt statement_item '''
2864 if(parse_debug):
2865 print('statement_1', list(p))
2866
2867 # { pform_bind_attributes(p[2]->attributes, p[1]);
2868 # p[0] = p[2];
2869 # }
2870 ()
2871
2872
2873 def p_statement_or_null_1(p):
2874 '''statement_or_null : statement '''
2875 if(parse_debug):
2876 print('statement_or_null_1', list(p))
2877 p[0] = p[1]
2878
2879
2880 ()
2881
2882
2883 def p_statement_or_null_2(p):
2884 '''statement_or_null : attribute_list_opt ';' '''
2885 if(parse_debug):
2886 print('statement_or_null_2', list(p))
2887
2888 # { p[0] = None }
2889 ()
2890
2891
2892 def p_stream_expression_1(p):
2893 '''stream_expression : expression '''
2894 if(parse_debug):
2895 print('stream_expression_1', list(p))
2896
2897
2898 ()
2899
2900
2901 def p_stream_expression_list_1(p):
2902 '''stream_expression_list : stream_expression_list ',' stream_expression '''
2903 if(parse_debug):
2904 print('stream_expression_list_1', list(p))
2905
2906
2907 ()
2908
2909
2910 def p_stream_expression_list_2(p):
2911 '''stream_expression_list : stream_expression '''
2912 if(parse_debug):
2913 print('stream_expression_list_2', list(p))
2914
2915
2916 ()
2917
2918
2919 def p_stream_operator_1(p):
2920 '''stream_operator : K_LS '''
2921 if(parse_debug):
2922 print('stream_operator_1', list(p))
2923
2924
2925 ()
2926
2927
2928 def p_stream_operator_2(p):
2929 '''stream_operator : K_RS '''
2930 if(parse_debug):
2931 print('stream_operator_2', list(p))
2932
2933
2934 ()
2935
2936
2937 def p_streaming_concatenation_1(p):
2938 '''streaming_concatenation : '{' stream_operator '{' stream_expression_list '}' '}' '''
2939 if(parse_debug):
2940 print('streaming_concatenation_1', list(p))
2941
2942 # { /* streaming concatenation is a SystemVerilog thing. */
2943 # if (gn_system_verilog()) {
2944 # yyerror(@2, "sorry: Streaming concatenation not supported.");
2945 # p[0] = None
2946 # } else {
2947 # yyerror(@2, "error: Streaming concatenation requires SystemVerilog");
2948 # p[0] = None
2949 # }
2950 # }
2951 ()
2952
2953
2954 def p_task_declaration_1(p):
2955 '''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 '''
2956 if(parse_debug):
2957 print('task_declaration_1', list(p))
2958
2959 # { // Last step: check any closing name. This is done late so
2960 # // that the parser can look ahead to detect the present
2961 # // endlabel_opt but still have the pform_endmodule() called
2962 # // early enough that the lexor can know we are outside the
2963 # // module.
2964 # if (p[10]) {
2965 # if (strcmp(p[3],p[10]) != 0) {
2966 # yyerror(@10, "error: End label doesn't match task name");
2967 # }
2968 # if (! gn_system_verilog()) {
2969 # yyerror(@10, "error: Task end labels require "
2970 # "SystemVerilog.");
2971 # }
2972 # delete[]p[10];
2973 # }
2974 # delete[]p[3];
2975 # }
2976 ()
2977
2978
2979 def p_task_declaration_2(p):
2980 '''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 '''
2981 if(parse_debug):
2982 print('task_declaration_2', list(p))
2983
2984 # { // Last step: check any closing name. This is done late so
2985 # // that the parser can look ahead to detect the present
2986 # // endlabel_opt but still have the pform_endmodule() called
2987 # // early enough that the lexor can know we are outside the
2988 # // module.
2989 # if (p[13]) {
2990 # if (strcmp(p[3],p[13]) != 0) {
2991 # yyerror(@13, "error: End label doesn't match task name");
2992 # }
2993 # if (! gn_system_verilog()) {
2994 # yyerror(@13, "error: Task end labels require "
2995 # "SystemVerilog.");
2996 # }
2997 # delete[]p[13];
2998 # }
2999 # delete[]p[3];
3000 # }
3001 ()
3002
3003
3004 def p_task_declaration_3(p):
3005 '''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 '''
3006 if(parse_debug):
3007 print('task_declaration_3', list(p))
3008
3009 # { // Last step: check any closing name. This is done late so
3010 # // that the parser can look ahead to detect the present
3011 # // endlabel_opt but still have the pform_endmodule() called
3012 # // early enough that the lexor can know we are outside the
3013 # // module.
3014 # if (p[12]) {
3015 # if (strcmp(p[3],p[12]) != 0) {
3016 # yyerror(@12, "error: End label doesn't match task name");
3017 # }
3018 # if (! gn_system_verilog()) {
3019 # yyerror(@12, "error: Task end labels require "
3020 # "SystemVerilog.");
3021 # }
3022 # delete[]p[12];
3023 # }
3024 # delete[]p[3];
3025 # }
3026 ()
3027
3028
3029 def p_task_declaration_4(p):
3030 '''task_declaration : K_task lifetime_opt IDENTIFIER error K_endtask _embed6_task_declaration endlabel_opt '''
3031 if(parse_debug):
3032 print('task_declaration_4', list(p))
3033
3034 # { // Last step: check any closing name. This is done late so
3035 # // that the parser can look ahead to detect the present
3036 # // endlabel_opt but still have the pform_endmodule() called
3037 # // early enough that the lexor can know we are outside the
3038 # // module.
3039 # if (p[7]) {
3040 # if (strcmp(p[3],p[7]) != 0) {
3041 # yyerror(@7, "error: End label doesn't match task name");
3042 # }
3043 # if (! gn_system_verilog()) {
3044 # yyerror(@7, "error: Task end labels require "
3045 # "SystemVerilog.");
3046 # }
3047 # delete[]p[7];
3048 # }
3049 # delete[]p[3];
3050 # }
3051 ()
3052
3053
3054 def p__embed0_task_declaration(p):
3055 '''_embed0_task_declaration : '''
3056
3057 # { assert(current_task == 0);
3058 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3059 # }
3060 ()
3061
3062
3063 def p__embed1_task_declaration(p):
3064 '''_embed1_task_declaration : '''
3065
3066 # { current_task->set_ports(p[6]);
3067 # current_task_set_statement(@3, p[7]);
3068 # pform_set_this_class(@3, current_task);
3069 # pform_pop_scope();
3070 # current_task = 0;
3071 # if (p[7] && p[7]->size() > 1 && !gn_system_verilog()) {
3072 # yyerror(@7, "error: Task body with multiple statements requires SystemVerilog.");
3073 # }
3074 # delete p[7];
3075 # }
3076 ()
3077
3078
3079 def p__embed2_task_declaration(p):
3080 '''_embed2_task_declaration : '''
3081
3082 # { assert(current_task == 0);
3083 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3084 # }
3085 ()
3086
3087
3088 def p__embed3_task_declaration(p):
3089 '''_embed3_task_declaration : '''
3090
3091 # { current_task->set_ports(p[6]);
3092 # current_task_set_statement(@3, p[10]);
3093 # pform_set_this_class(@3, current_task);
3094 # pform_pop_scope();
3095 # current_task = 0;
3096 # if (p[10]) delete p[10];
3097 # }
3098 ()
3099
3100
3101 def p__embed4_task_declaration(p):
3102 '''_embed4_task_declaration : '''
3103
3104 # { assert(current_task == 0);
3105 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3106 # }
3107 ()
3108
3109
3110 def p__embed5_task_declaration(p):
3111 '''_embed5_task_declaration : '''
3112
3113 # { current_task->set_ports(0);
3114 # current_task_set_statement(@3, p[9]);
3115 # pform_set_this_class(@3, current_task);
3116 # if (! current_task->method_of()) {
3117 # cerr << @3 << ": warning: task definition for \"" << p[3]
3118 # << "\" has an empty port declaration list!" << endl;
3119 # }
3120 # pform_pop_scope();
3121 # current_task = 0;
3122 # if (p[9]->size() > 1 && !gn_system_verilog()) {
3123 # yyerror(@9, "error: Task body with multiple statements requires SystemVerilog.");
3124 # }
3125 # delete p[9];
3126 # }
3127 ()
3128
3129
3130 def p__embed6_task_declaration(p):
3131 '''_embed6_task_declaration : '''
3132
3133 # {
3134 # if (current_task) {
3135 # pform_pop_scope();
3136 # current_task = 0;
3137 # }
3138 # }
3139 ()
3140
3141
3142 def p_tf_port_declaration_1(p):
3143 '''tf_port_declaration : port_direction K_reg_opt unsigned_signed_opt dimensions_opt list_of_identifiers ';' '''
3144 if(parse_debug):
3145 print('tf_port_declaration_1', list(p))
3146
3147 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1],
3148 # p[2] ? IVL_VT_LOGIC :
3149 # IVL_VT_NO_TYPE,
3150 # p[3], p[4], p[5]);
3151 # p[0] = tmp;
3152 # }
3153 ()
3154
3155
3156 def p_tf_port_declaration_2(p):
3157 '''tf_port_declaration : port_direction K_integer list_of_identifiers ';' '''
3158 if(parse_debug):
3159 print('tf_port_declaration_2', list(p))
3160
3161 # { list<pform_range_t>*range_stub = make_range_from_width(integer_width);
3162 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, true,
3163 # range_stub, p[3], true);
3164 # p[0] = tmp;
3165 # }
3166 ()
3167
3168
3169 def p_tf_port_declaration_3(p):
3170 '''tf_port_declaration : port_direction K_time list_of_identifiers ';' '''
3171 if(parse_debug):
3172 print('tf_port_declaration_3', list(p))
3173
3174 # { list<pform_range_t>*range_stub = make_range_from_width(64);
3175 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, false,
3176 # range_stub, p[3]);
3177 # p[0] = tmp;
3178 # }
3179 ()
3180
3181
3182 def p_tf_port_declaration_4(p):
3183 '''tf_port_declaration : port_direction real_or_realtime list_of_identifiers ';' '''
3184 if(parse_debug):
3185 print('tf_port_declaration_4', list(p))
3186
3187 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_REAL, true,
3188 # 0, p[3]);
3189 # p[0] = tmp;
3190 # }
3191 ()
3192
3193
3194 def p_tf_port_declaration_5(p):
3195 '''tf_port_declaration : port_direction K_string list_of_identifiers ';' '''
3196 if(parse_debug):
3197 print('tf_port_declaration_5', list(p))
3198
3199 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_STRING, true,
3200 # 0, p[3]);
3201 # p[0] = tmp;
3202 # }
3203 ()
3204
3205
3206 def p_tf_port_item_1(p):
3207 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER dimensions_opt tf_port_item_expr_opt '''
3208 if(parse_debug):
3209 print('tf_port_item_1', list(p))
3210
3211 # { vector<pform_tf_port_t>*tmp;
3212 # NetNet::PortType use_port_type = p[1];
3213 # if ((use_port_type == NetNet::PIMPLICIT) && (gn_system_verilog() || (p[2] == 0)))
3214 # use_port_type = port_declaration_context.port_type;
3215 # perm_string name = lex_strings.make(p[3]);
3216 # list<perm_string>* ilist = list_from_identifier(p[3]);
3217 #
3218 # if (use_port_type == NetNet::PIMPLICIT) {
3219 # yyerror(@1, "error: missing task/function port direction.");
3220 # use_port_type = NetNet::PINPUT; // for error recovery
3221 # }
3222 # if ((p[2] == 0) && (p[1]==NetNet::PIMPLICIT)) {
3223 # // Detect special case this is an undecorated
3224 # // identifier and we need to get the declaration from
3225 # // left context.
3226 # if (p[4] != 0) {
3227 # yyerror(@4, "internal error: How can there be an unpacked range here?\n");
3228 # }
3229 # tmp = pform_make_task_ports(@3, use_port_type,
3230 # port_declaration_context.data_type,
3231 # ilist);
3232 #
3233 # } else {
3234 # // Otherwise, the decorations for this identifier
3235 # // indicate the type. Save the type for any right
3236 # // context that may come later.
3237 # port_declaration_context.port_type = use_port_type;
3238 # if (p[2] == 0) {
3239 # p[2] = new vector_type_t(IVL_VT_LOGIC, false, 0);
3240 # FILE_NAME(p[2], @3);
3241 # }
3242 # port_declaration_context.data_type = p[2];
3243 # tmp = pform_make_task_ports(@3, use_port_type, p[2], ilist);
3244 # }
3245 # if (p[4] != 0) {
3246 # pform_set_reg_idx(name, p[4]);
3247 # }
3248 #
3249 # p[0] = tmp;
3250 # if (p[5]) {
3251 # assert(tmp->size()==1);
3252 # tmp->front().defe = p[5];
3253 # }
3254 # }
3255 ()
3256
3257
3258 def p_tf_port_item_2(p):
3259 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER error '''
3260 if(parse_debug):
3261 print('tf_port_item_2', list(p))
3262
3263 # { yyerror(@3, "error: Error in task/function port item after port name %s.", p[3]);
3264 # yyerrok;
3265 # p[0] = None
3266 # }
3267 ()
3268
3269
3270 def p_tf_port_item_expr_opt_1(p):
3271 '''tf_port_item_expr_opt : '=' expression '''
3272 if(parse_debug):
3273 print('tf_port_item_expr_opt_1', list(p))
3274
3275 # { if (! gn_system_verilog()) {
3276 # yyerror(@1, "error: Task/function default arguments require "
3277 # "SystemVerilog.");
3278 # }
3279 # p[0] = p[2];
3280 # }
3281 ()
3282
3283
3284 def p_tf_port_item_expr_opt_2(p):
3285 '''tf_port_item_expr_opt : '''
3286 if(parse_debug):
3287 print('tf_port_item_expr_opt_2', list(p))
3288
3289 # { p[0] = None }
3290 ()
3291
3292
3293 def p_tf_port_list_1(p):
3294 '''tf_port_list : _embed0_tf_port_list tf_port_item_list '''
3295 if(parse_debug):
3296 print('tf_port_list_1', list(p))
3297 p[0] = p[2]
3298
3299
3300 ()
3301
3302
3303 def p__embed0_tf_port_list(p):
3304 '''_embed0_tf_port_list : '''
3305
3306 # { port_declaration_context.port_type = gn_system_verilog() ? NetNet::PINPUT : NetNet::PIMPLICIT;
3307 # port_declaration_context.data_type = 0;
3308 # }
3309 ()
3310
3311
3312 def p_tf_port_item_list_1(p):
3313 '''tf_port_item_list : tf_port_item_list ',' tf_port_item '''
3314 if(parse_debug):
3315 print('tf_port_item_list_1', list(p))
3316
3317 # { vector<pform_tf_port_t>*tmp;
3318 # if (p[1] && p[3]) {
3319 # size_t s1 = p[1]->size();
3320 # tmp = p[1];
3321 # tmp->resize(tmp->size()+p[3]->size());
3322 # for (size_t idx = 0 ; idx < p[3]->size() ; idx += 1)
3323 # tmp->at(s1+idx) = p[3]->at(idx);
3324 # delete p[3];
3325 # } else if (p[1]) {
3326 # tmp = p[1];
3327 # } else {
3328 # tmp = p[3];
3329 # }
3330 # p[0] = tmp;
3331 # }
3332 ()
3333
3334
3335 def p_tf_port_item_list_2(p):
3336 '''tf_port_item_list : tf_port_item '''
3337 if(parse_debug):
3338 print('tf_port_item_list_2', list(p))
3339 p[0] = p[1]
3340
3341
3342 ()
3343
3344
3345 def p_tf_port_item_list_3(p):
3346 '''tf_port_item_list : error ',' tf_port_item '''
3347 if(parse_debug):
3348 print('tf_port_item_list_3', list(p))
3349
3350 # { yyerror(@2, "error: Syntax error in task/function port declaration.");
3351 # p[0] = p[3];
3352 # }
3353 ()
3354
3355
3356 def p_tf_port_item_list_4(p):
3357 '''tf_port_item_list : tf_port_item_list ',' '''
3358 if(parse_debug):
3359 print('tf_port_item_list_4', list(p))
3360
3361 # { yyerror(@2, "error: NULL port declarations are not allowed.");
3362 # p[0] = p[1];
3363 # }
3364 ()
3365
3366
3367 def p_tf_port_item_list_5(p):
3368 '''tf_port_item_list : tf_port_item_list ';' '''
3369 if(parse_debug):
3370 print('tf_port_item_list_5', list(p))
3371
3372 # { yyerror(@2, "error: ';' is an invalid port declaration separator.");
3373 # p[0] = p[1];
3374 # }
3375 ()
3376
3377
3378 def p_timeunits_declaration_1(p):
3379 '''timeunits_declaration : K_timeunit TIME_LITERAL ';' '''
3380 if(parse_debug):
3381 print('timeunits_declaration_1', list(p))
3382
3383 # { pform_set_timeunit(p[2], allow_timeunit_decl); }
3384 ()
3385
3386
3387 def p_timeunits_declaration_2(p):
3388 '''timeunits_declaration : K_timeunit TIME_LITERAL '/' TIME_LITERAL ';' '''
3389 if(parse_debug):
3390 print('timeunits_declaration_2', list(p))
3391
3392 # { bool initial_decl = allow_timeunit_decl && allow_timeprec_decl;
3393 # pform_set_timeunit(p[2], initial_decl);
3394 # pform_set_timeprec(p[4], initial_decl);
3395 # }
3396 ()
3397
3398
3399 def p_timeunits_declaration_3(p):
3400 '''timeunits_declaration : K_timeprecision TIME_LITERAL ';' '''
3401 if(parse_debug):
3402 print('timeunits_declaration_3', list(p))
3403
3404 # { pform_set_timeprec(p[2], allow_timeprec_decl); }
3405 ()
3406
3407
3408 def p_timeunits_declaration_opt_1(p):
3409 '''timeunits_declaration_opt : %prec no_timeunits_declaration '''
3410 if(parse_debug > 2):
3411 print('timeunits_declaration_opt_1', list(p))
3412
3413
3414 ()
3415
3416
3417 def p_timeunits_declaration_opt_2(p):
3418 '''timeunits_declaration_opt : timeunits_declaration %prec one_timeunits_declaration '''
3419 if(parse_debug):
3420 print('timeunits_declaration_opt_2', list(p))
3421
3422
3423 ()
3424
3425
3426 def p_timeunits_declaration_opt_3(p):
3427 '''timeunits_declaration_opt : timeunits_declaration timeunits_declaration '''
3428 if(parse_debug):
3429 print('timeunits_declaration_opt_3', list(p))
3430
3431
3432 ()
3433
3434
3435 def p_value_range_1(p):
3436 '''value_range : expression '''
3437 if(parse_debug):
3438 print('value_range_1', list(p))
3439
3440 # { }
3441 ()
3442
3443
3444 def p_value_range_2(p):
3445 '''value_range : '[' expression ':' expression ']' '''
3446 if(parse_debug):
3447 print('value_range_2', list(p))
3448
3449 # { }
3450 ()
3451
3452
3453 def p_variable_dimension_1(p):
3454 '''variable_dimension : '[' expression ':' expression ']' '''
3455 if(parse_debug):
3456 print('variable_dimension_1', list(p))
3457 # { list<pform_range_t> *tmp = new list<pform_range_t>;
3458 # pform_range_t index (p[2],p[4]);
3459 # tmp->push_back(index);
3460 # p[0] = tmp;
3461 # }
3462 # XXX TODO: subscriptlist
3463 start = str(p[4])
3464 end = str(p[2])
3465 if end.endswith("-1"):
3466 end = end[:-2]
3467 elif end.isdigit():
3468 end = str(int(end)+1)
3469 else:
3470 end = "1+%s" % end
3471 p[0] = '[%s:%s]' % (start, end) # python slice is LO:HI+1
3472
3473
3474 ()
3475
3476
3477 def p_variable_dimension_2(p):
3478 '''variable_dimension : '[' expression ']' '''
3479 if(parse_debug):
3480 print('variable_dimension_2', list(p))
3481
3482 # { // SystemVerilog canonical range
3483 # if (!gn_system_verilog()) {
3484 # warn_count += 1;
3485 # cerr << @2 << ": warning: Use of SystemVerilog [size] dimension. "
3486 # << "Use at least -g2005-sv to remove this warning." << endl;
3487 # }
3488 # list<pform_range_t> *tmp = new list<pform_range_t>;
3489 # pform_range_t index;
3490 # index.first = new PENumber(new verinum((uint64_t)0, integer_width));
3491 # index.second = new PEBinary('-', p[2], new PENumber(new verinum((uint64_t)1, integer_width)));
3492 # tmp->push_back(index);
3493 # p[0] = tmp;
3494 # }
3495 ()
3496
3497
3498 def p_variable_dimension_3(p):
3499 '''variable_dimension : '[' ']' '''
3500 if(parse_debug):
3501 print('variable_dimension_3', list(p))
3502
3503 # { list<pform_range_t> *tmp = new list<pform_range_t>;
3504 # pform_range_t index (0,0);
3505 # tmp->push_back(index);
3506 # p[0] = tmp;
3507 # }
3508 ()
3509
3510
3511 def p_variable_dimension_4(p):
3512 '''variable_dimension : '[' '$' ']' '''
3513 if(parse_debug):
3514 print('variable_dimension_4', list(p))
3515
3516 # { // SystemVerilog queue
3517 # list<pform_range_t> *tmp = new list<pform_range_t>;
3518 # pform_range_t index (new PENull,0);
3519 # if (!gn_system_verilog()) {
3520 # yyerror("error: Queue declarations require SystemVerilog.");
3521 # }
3522 # tmp->push_back(index);
3523 # p[0] = tmp;
3524 # }
3525 ()
3526
3527
3528 def p_variable_lifetime_1(p):
3529 '''variable_lifetime : lifetime '''
3530 if(parse_debug):
3531 print('variable_lifetime_1', list(p))
3532
3533 # { if (!gn_system_verilog()) {
3534 # yyerror(@1, "error: overriding the default variable lifetime "
3535 # "requires SystemVerilog.");
3536 # } else if (p[1] != pform_peek_scope()->default_lifetime) {
3537 # yyerror(@1, "sorry: overriding the default variable lifetime "
3538 # "is not yet supported.");
3539 # }
3540 # var_lifetime = p[1];
3541 # }
3542 ()
3543
3544
3545 def p_attribute_list_opt_1(p):
3546 '''attribute_list_opt : attribute_instance_list '''
3547 if(parse_debug):
3548 print('attribute_list_opt_1', list(p))
3549 p[0] = p[1]
3550
3551
3552 ()
3553
3554
3555 def p_attribute_list_opt_2(p):
3556 '''attribute_list_opt : '''
3557 if(parse_debug > 2):
3558 print('attribute_list_opt_2', list(p))
3559
3560 # { p[0] = None }
3561 ()
3562
3563
3564 def p_attribute_instance_list_1(p):
3565 '''attribute_instance_list : K_PSTAR K_STARP '''
3566 if(parse_debug):
3567 print('attribute_instance_list_1', list(p))
3568
3569 # { p[0] = None }
3570 ()
3571
3572
3573 def p_attribute_instance_list_2(p):
3574 '''attribute_instance_list : K_PSTAR attribute_list K_STARP '''
3575 if(parse_debug):
3576 print('attribute_instance_list_2', list(p))
3577 p[0] = p[2]
3578
3579
3580 ()
3581
3582
3583 def p_attribute_instance_list_3(p):
3584 '''attribute_instance_list : attribute_instance_list K_PSTAR K_STARP '''
3585 if(parse_debug):
3586 print('attribute_instance_list_3', list(p))
3587 p[0] = p[1]
3588
3589
3590 ()
3591
3592
3593 def p_attribute_instance_list_4(p):
3594 '''attribute_instance_list : attribute_instance_list K_PSTAR attribute_list K_STARP '''
3595 if(parse_debug):
3596 print('attribute_instance_list_4', list(p))
3597
3598 # { list<named_pexpr_t>*tmp = p[1];
3599 # if (tmp) {
3600 # tmp->splice(tmp->end(), *p[3]);
3601 # delete p[3];
3602 # p[0] = tmp;
3603 # } else p[0] = p[3];
3604 # }
3605 ()
3606
3607
3608 def p_attribute_list_1(p):
3609 '''attribute_list : attribute_list ',' attribute '''
3610 if(parse_debug):
3611 print('attribute_list_1', list(p))
3612
3613 # { list<named_pexpr_t>*tmp = p[1];
3614 # tmp->push_back(*p[3]);
3615 # delete p[3];
3616 # p[0] = tmp;
3617 # }
3618 ()
3619
3620
3621 def p_attribute_list_2(p):
3622 '''attribute_list : attribute '''
3623 if(parse_debug):
3624 print('attribute_list_2', list(p))
3625
3626 # { list<named_pexpr_t>*tmp = new list<named_pexpr_t>;
3627 # tmp->push_back(*p[1]);
3628 # delete p[1];
3629 # p[0] = tmp;
3630 # }
3631 ()
3632
3633
3634 def p_attribute_1(p):
3635 '''attribute : IDENTIFIER '''
3636 if(parse_debug):
3637 print('attribute_1', list(p))
3638
3639 # { named_pexpr_t*tmp = new named_pexpr_t;
3640 # tmp->name = lex_strings.make(p[1]);
3641 # tmp->parm = 0;
3642 # delete[]p[1];
3643 # p[0] = tmp;
3644 # }
3645 ()
3646
3647
3648 def p_attribute_2(p):
3649 '''attribute : IDENTIFIER '=' expression '''
3650 if(parse_debug):
3651 print('attribute_2', list(p))
3652
3653 # { PExpr*tmp = p[3];
3654 # named_pexpr_t*tmp2 = new named_pexpr_t;
3655 # tmp2->name = lex_strings.make(p[1]);
3656 # tmp2->parm = tmp;
3657 # delete[]p[1];
3658 # p[0] = tmp2;
3659 # }
3660 ()
3661
3662
3663 def p_block_item_decl_1(p):
3664 '''block_item_decl : data_type register_variable_list ';' '''
3665 if(parse_debug):
3666 print('block_item_decl_1', list(p))
3667
3668 # { if (p[1]) pform_set_data_type(@1, p[1], p[2], NetNet::REG, attributes_in_context);
3669 # }
3670 ()
3671
3672
3673 def p_block_item_decl_2(p):
3674 '''block_item_decl : variable_lifetime data_type register_variable_list ';' '''
3675 if(parse_debug):
3676 print('block_item_decl_2', list(p))
3677
3678 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
3679 # var_lifetime = LexicalScope::INHERITED;
3680 # }
3681 ()
3682
3683
3684 def p_block_item_decl_3(p):
3685 '''block_item_decl : K_reg data_type register_variable_list ';' '''
3686 if(parse_debug):
3687 print('block_item_decl_3', list(p))
3688
3689 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
3690 # }
3691 ()
3692
3693
3694 def p_block_item_decl_4(p):
3695 '''block_item_decl : variable_lifetime K_reg data_type register_variable_list ';' '''
3696 if(parse_debug):
3697 print('block_item_decl_4', list(p))
3698
3699 # { if (p[3]) pform_set_data_type(@3, p[3], p[4], NetNet::REG, attributes_in_context);
3700 # var_lifetime = LexicalScope::INHERITED;
3701 # }
3702 ()
3703
3704
3705 def p_block_item_decl_5(p):
3706 '''block_item_decl : K_event event_variable_list ';' '''
3707 if(parse_debug):
3708 print('block_item_decl_5', list(p))
3709
3710 # { if (p[2]) pform_make_events(p[2], @1.text, @1.first_line);
3711 # }
3712 ()
3713
3714
3715 def p_block_item_decl_6(p):
3716 '''block_item_decl : K_parameter param_type parameter_assign_list ';' '''
3717 if(parse_debug):
3718 print('block_item_decl_6', list(p))
3719
3720
3721 ()
3722
3723
3724 def p_block_item_decl_7(p):
3725 '''block_item_decl : K_localparam param_type localparam_assign_list ';' '''
3726 if(parse_debug):
3727 print('block_item_decl_7', list(p))
3728
3729
3730 ()
3731
3732
3733 def p_block_item_decl_8(p):
3734 '''block_item_decl : type_declaration '''
3735 if(parse_debug):
3736 print('block_item_decl_8', list(p))
3737
3738
3739 ()
3740
3741
3742 def p_block_item_decl_9(p):
3743 '''block_item_decl : K_integer error ';' '''
3744 if(parse_debug):
3745 print('block_item_decl_9', list(p))
3746
3747 # { yyerror(@1, "error: syntax error in integer variable list.");
3748 # yyerrok;
3749 # }
3750 ()
3751
3752
3753 def p_block_item_decl_10(p):
3754 '''block_item_decl : K_time error ';' '''
3755 if(parse_debug):
3756 print('block_item_decl_10', list(p))
3757
3758 # { yyerror(@1, "error: syntax error in time variable list.");
3759 # yyerrok;
3760 # }
3761 ()
3762
3763
3764 def p_block_item_decl_11(p):
3765 '''block_item_decl : K_parameter error ';' '''
3766 if(parse_debug):
3767 print('block_item_decl_11', list(p))
3768
3769 # { yyerror(@1, "error: syntax error in parameter list.");
3770 # yyerrok;
3771 # }
3772 ()
3773
3774
3775 def p_block_item_decl_12(p):
3776 '''block_item_decl : K_localparam error ';' '''
3777 if(parse_debug):
3778 print('block_item_decl_12', list(p))
3779
3780 # { yyerror(@1, "error: syntax error localparam list.");
3781 # yyerrok;
3782 # }
3783 ()
3784
3785
3786 def p_block_item_decls_1(p):
3787 '''block_item_decls : block_item_decl '''
3788 if(parse_debug):
3789 print('block_item_decls_1', list(p))
3790
3791
3792 ()
3793
3794
3795 def p_block_item_decls_2(p):
3796 '''block_item_decls : block_item_decls block_item_decl '''
3797 if(parse_debug):
3798 print('block_item_decls_2', list(p))
3799
3800
3801 ()
3802
3803
3804 def p_block_item_decls_opt_1(p):
3805 '''block_item_decls_opt : block_item_decls '''
3806 if(parse_debug):
3807 print('block_item_decls_opt_1', list(p))
3808 p[0] = True
3809
3810
3811 ()
3812
3813
3814 def p_block_item_decls_opt_2(p):
3815 '''block_item_decls_opt : '''
3816 if(parse_debug):
3817 print('block_item_decls_opt_2', list(p))
3818 p[0] = False
3819
3820
3821 ()
3822
3823
3824 def p_type_declaration_1(p):
3825 '''type_declaration : K_typedef data_type IDENTIFIER dimensions_opt ';' '''
3826 if(parse_debug):
3827 print('type_declaration_1', list(p))
3828
3829 # { perm_string name = lex_strings.make(p[3]);
3830 # pform_set_typedef(name, p[2], p[4]);
3831 # delete[]p[3];
3832 # }
3833 ()
3834
3835
3836 def p_type_declaration_2(p):
3837 '''type_declaration : K_typedef data_type TYPE_IDENTIFIER ';' '''
3838 if(parse_debug):
3839 print('type_declaration_2', list(p))
3840
3841 # { perm_string name = lex_strings.make(p[3].text);
3842 # if (pform_test_type_identifier_local(name)) {
3843 # yyerror(@3, "error: Typedef identifier \"%s\" is already a type name.", p[3].text);
3844 #
3845 # } else {
3846 # pform_set_typedef(name, p[2], NULL);
3847 # }
3848 # delete[]p[3].text;
3849 # }
3850 ()
3851
3852
3853 def p_type_declaration_3(p):
3854 '''type_declaration : K_typedef K_class IDENTIFIER ';' '''
3855 if(parse_debug):
3856 print('type_declaration_3', list(p))
3857
3858 # { // Create a synthetic typedef for the class name so that the
3859 # // lexor detects the name as a type.
3860 # perm_string name = lex_strings.make(p[3]);
3861 # class_type_t*tmp = new class_type_t(name);
3862 # FILE_NAME(tmp, @3);
3863 # pform_set_typedef(name, tmp, NULL);
3864 # delete[]p[3];
3865 # }
3866 ()
3867
3868
3869 def p_type_declaration_4(p):
3870 '''type_declaration : K_typedef K_enum IDENTIFIER ';' '''
3871 if(parse_debug):
3872 print('type_declaration_4', list(p))
3873
3874 # { yyerror(@1, "sorry: Enum forward declarations not supported yet."); }
3875 ()
3876
3877
3878 def p_type_declaration_5(p):
3879 '''type_declaration : K_typedef K_struct IDENTIFIER ';' '''
3880 if(parse_debug):
3881 print('type_declaration_5', list(p))
3882
3883 # { yyerror(@1, "sorry: Struct forward declarations not supported yet."); }
3884 ()
3885
3886
3887 def p_type_declaration_6(p):
3888 '''type_declaration : K_typedef K_union IDENTIFIER ';' '''
3889 if(parse_debug):
3890 print('type_declaration_6', list(p))
3891
3892 # { yyerror(@1, "sorry: Union forward declarations not supported yet."); }
3893 ()
3894
3895
3896 def p_type_declaration_7(p):
3897 '''type_declaration : K_typedef IDENTIFIER ';' '''
3898 if(parse_debug):
3899 print('type_declaration_7', list(p))
3900
3901 # { // Create a synthetic typedef for the class name so that the
3902 # // lexor detects the name as a type.
3903 # perm_string name = lex_strings.make(p[2]);
3904 # class_type_t*tmp = new class_type_t(name);
3905 # FILE_NAME(tmp, @2);
3906 # pform_set_typedef(name, tmp, NULL);
3907 # delete[]p[2];
3908 # }
3909 ()
3910
3911
3912 def p_type_declaration_8(p):
3913 '''type_declaration : K_typedef error ';' '''
3914 if(parse_debug):
3915 print('type_declaration_8', list(p))
3916
3917 # { yyerror(@2, "error: Syntax error in typedef clause.");
3918 # yyerrok;
3919 # }
3920 ()
3921
3922
3923 def p_enum_data_type_1(p):
3924 '''enum_data_type : K_enum '{' enum_name_list '}' '''
3925 if(parse_debug):
3926 print('enum_data_type_1', list(p))
3927
3928 # { enum_type_t*enum_type = new enum_type_t;
3929 # FILE_NAME(enum_type, @1);
3930 # enum_type->names .reset(p[3]);
3931 # enum_type->base_type = IVL_VT_BOOL;
3932 # enum_type->signed_flag = true;
3933 # enum_type->integer_flag = false;
3934 # enum_type->range.reset(make_range_from_width(32));
3935 # p[0] = enum_type;
3936 # }
3937 ()
3938
3939
3940 def p_enum_data_type_2(p):
3941 '''enum_data_type : K_enum atom2_type signed_unsigned_opt '{' enum_name_list '}' '''
3942 if(parse_debug):
3943 print('enum_data_type_2', list(p))
3944
3945 # { enum_type_t*enum_type = new enum_type_t;
3946 # FILE_NAME(enum_type, @1);
3947 # enum_type->names .reset(p[5]);
3948 # enum_type->base_type = IVL_VT_BOOL;
3949 # enum_type->signed_flag = p[3];
3950 # enum_type->integer_flag = false;
3951 # enum_type->range.reset(make_range_from_width(p[2]));
3952 # p[0] = enum_type;
3953 # }
3954 ()
3955
3956
3957 def p_enum_data_type_3(p):
3958 '''enum_data_type : K_enum K_integer signed_unsigned_opt '{' enum_name_list '}' '''
3959 if(parse_debug):
3960 print('enum_data_type_3', list(p))
3961
3962 # { enum_type_t*enum_type = new enum_type_t;
3963 # FILE_NAME(enum_type, @1);
3964 # enum_type->names .reset(p[5]);
3965 # enum_type->base_type = IVL_VT_LOGIC;
3966 # enum_type->signed_flag = p[3];
3967 # enum_type->integer_flag = true;
3968 # enum_type->range.reset(make_range_from_width(integer_width));
3969 # p[0] = enum_type;
3970 # }
3971 ()
3972
3973
3974 def p_enum_data_type_4(p):
3975 '''enum_data_type : K_enum K_logic unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
3976 if(parse_debug):
3977 print('enum_data_type_4', list(p))
3978
3979 # { enum_type_t*enum_type = new enum_type_t;
3980 # FILE_NAME(enum_type, @1);
3981 # enum_type->names .reset(p[6]);
3982 # enum_type->base_type = IVL_VT_LOGIC;
3983 # enum_type->signed_flag = p[3];
3984 # enum_type->integer_flag = false;
3985 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
3986 # p[0] = enum_type;
3987 # }
3988 ()
3989
3990
3991 def p_enum_data_type_5(p):
3992 '''enum_data_type : K_enum K_reg unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
3993 if(parse_debug):
3994 print('enum_data_type_5', list(p))
3995
3996 # { enum_type_t*enum_type = new enum_type_t;
3997 # FILE_NAME(enum_type, @1);
3998 # enum_type->names .reset(p[6]);
3999 # enum_type->base_type = IVL_VT_LOGIC;
4000 # enum_type->signed_flag = p[3];
4001 # enum_type->integer_flag = false;
4002 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
4003 # p[0] = enum_type;
4004 # }
4005 ()
4006
4007
4008 def p_enum_data_type_6(p):
4009 '''enum_data_type : K_enum K_bit unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
4010 if(parse_debug):
4011 print('enum_data_type_6', list(p))
4012
4013 # { enum_type_t*enum_type = new enum_type_t;
4014 # FILE_NAME(enum_type, @1);
4015 # enum_type->names .reset(p[6]);
4016 # enum_type->base_type = IVL_VT_BOOL;
4017 # enum_type->signed_flag = p[3];
4018 # enum_type->integer_flag = false;
4019 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
4020 # p[0] = enum_type;
4021 # }
4022 ()
4023
4024
4025 def p_enum_name_list_1(p):
4026 '''enum_name_list : enum_name '''
4027 if(parse_debug):
4028 print('enum_name_list_1', list(p))
4029
4030 # { p[0] = p[1];
4031 # }
4032 ()
4033
4034
4035 def p_enum_name_list_2(p):
4036 '''enum_name_list : enum_name_list ',' enum_name '''
4037 if(parse_debug):
4038 print('enum_name_list_2', list(p))
4039
4040 # { list<named_pexpr_t>*lst = p[1];
4041 # lst->splice(lst->end(), *p[3]);
4042 # delete p[3];
4043 # p[0] = lst;
4044 # }
4045 ()
4046
4047
4048 def p_pos_neg_number_1(p):
4049 '''pos_neg_number : number '''
4050 if(parse_debug):
4051 print('pos_neg_number_1', list(p))
4052
4053 # { p[0] = p[1];
4054 # }
4055 ()
4056
4057
4058 def p_pos_neg_number_2(p):
4059 '''pos_neg_number : '-' number '''
4060 if(parse_debug):
4061 print('pos_neg_number_2', list(p))
4062
4063 # { verinum tmp = -(*(p[2]));
4064 # *(p[2]) = tmp;
4065 # p[0] = p[2];
4066 # }
4067 ()
4068
4069
4070 def p_enum_name_1(p):
4071 '''enum_name : IDENTIFIER '''
4072 if(parse_debug):
4073 print('enum_name_1', list(p))
4074
4075 # { perm_string name = lex_strings.make(p[1]);
4076 # delete[]p[1];
4077 # p[0] = make_named_number(name);
4078 # }
4079 ()
4080
4081
4082 def p_enum_name_2(p):
4083 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '''
4084 if(parse_debug):
4085 print('enum_name_2', list(p))
4086
4087 # { perm_string name = lex_strings.make(p[1]);
4088 # long count = check_enum_seq_value(@1, p[3], false);
4089 # delete[]p[1];
4090 # p[0] = make_named_numbers(name, 0, count-1);
4091 # delete p[3];
4092 # }
4093 ()
4094
4095
4096 def p_enum_name_3(p):
4097 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '''
4098 if(parse_debug):
4099 print('enum_name_3', list(p))
4100
4101 # { perm_string name = lex_strings.make(p[1]);
4102 # p[0] = make_named_numbers(name, check_enum_seq_value(@1, p[3], true),
4103 # check_enum_seq_value(@1, p[5], true));
4104 # delete[]p[1];
4105 # delete p[3];
4106 # delete p[5];
4107 # }
4108 ()
4109
4110
4111 def p_enum_name_4(p):
4112 '''enum_name : IDENTIFIER '=' expression '''
4113 if(parse_debug):
4114 print('enum_name_4', list(p))
4115
4116 # { perm_string name = lex_strings.make(p[1]);
4117 # delete[]p[1];
4118 # p[0] = make_named_number(name, p[3]);
4119 # }
4120 ()
4121
4122
4123 def p_enum_name_5(p):
4124 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '=' expression '''
4125 if(parse_debug):
4126 print('enum_name_5', list(p))
4127
4128 # { perm_string name = lex_strings.make(p[1]);
4129 # long count = check_enum_seq_value(@1, p[3], false);
4130 # p[0] = make_named_numbers(name, 0, count-1, p[6]);
4131 # delete[]p[1];
4132 # delete p[3];
4133 # }
4134 ()
4135
4136
4137 def p_enum_name_6(p):
4138 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '=' expression '''
4139 if(parse_debug):
4140 print('enum_name_6', list(p))
4141
4142 # { perm_string name = lex_strings.make(p[1]);
4143 # p[0] = make_named_numbers(name, check_enum_seq_value(@1, p[3], true),
4144 # check_enum_seq_value(@1, p[5], true), p[8]);
4145 # delete[]p[1];
4146 # delete p[3];
4147 # delete p[5];
4148 # }
4149 ()
4150
4151
4152 def p_struct_data_type_1(p):
4153 '''struct_data_type : K_struct K_packed_opt '{' struct_union_member_list '}' '''
4154 if(parse_debug):
4155 print('struct_data_type_1', list(p))
4156
4157 # { struct_type_t*tmp = new struct_type_t;
4158 # FILE_NAME(tmp, @1);
4159 # tmp->packed_flag = p[2];
4160 # tmp->union_flag = false;
4161 # tmp->members .reset(p[4]);
4162 # p[0] = tmp;
4163 # }
4164 ()
4165
4166
4167 def p_struct_data_type_2(p):
4168 '''struct_data_type : K_union K_packed_opt '{' struct_union_member_list '}' '''
4169 if(parse_debug):
4170 print('struct_data_type_2', list(p))
4171
4172 # { struct_type_t*tmp = new struct_type_t;
4173 # FILE_NAME(tmp, @1);
4174 # tmp->packed_flag = p[2];
4175 # tmp->union_flag = true;
4176 # tmp->members .reset(p[4]);
4177 # p[0] = tmp;
4178 # }
4179 ()
4180
4181
4182 def p_struct_data_type_3(p):
4183 '''struct_data_type : K_struct K_packed_opt '{' error '}' '''
4184 if(parse_debug):
4185 print('struct_data_type_3', list(p))
4186
4187 # { yyerror(@3, "error: Errors in struct member list.");
4188 # yyerrok;
4189 # struct_type_t*tmp = new struct_type_t;
4190 # FILE_NAME(tmp, @1);
4191 # tmp->packed_flag = p[2];
4192 # tmp->union_flag = false;
4193 # p[0] = tmp;
4194 # }
4195 ()
4196
4197
4198 def p_struct_data_type_4(p):
4199 '''struct_data_type : K_union K_packed_opt '{' error '}' '''
4200 if(parse_debug):
4201 print('struct_data_type_4', list(p))
4202
4203 # { yyerror(@3, "error: Errors in union member list.");
4204 # yyerrok;
4205 # struct_type_t*tmp = new struct_type_t;
4206 # FILE_NAME(tmp, @1);
4207 # tmp->packed_flag = p[2];
4208 # tmp->union_flag = true;
4209 # p[0] = tmp;
4210 # }
4211 ()
4212
4213
4214 def p_struct_union_member_list_1(p):
4215 '''struct_union_member_list : struct_union_member_list struct_union_member '''
4216 if(parse_debug):
4217 print('struct_union_member_list_1', list(p))
4218
4219 # { list<struct_member_t*>*tmp = p[1];
4220 # tmp->push_back(p[2]);
4221 # p[0] = tmp;
4222 # }
4223 ()
4224
4225
4226 def p_struct_union_member_list_2(p):
4227 '''struct_union_member_list : struct_union_member '''
4228 if(parse_debug):
4229 print('struct_union_member_list_2', list(p))
4230
4231 # { list<struct_member_t*>*tmp = new list<struct_member_t*>;
4232 # tmp->push_back(p[1]);
4233 # p[0] = tmp;
4234 # }
4235 ()
4236
4237
4238 def p_struct_union_member_1(p):
4239 '''struct_union_member : attribute_list_opt data_type list_of_variable_decl_assignments ';' '''
4240 if(parse_debug):
4241 print('struct_union_member_1', list(p))
4242
4243 # { struct_member_t*tmp = new struct_member_t;
4244 # FILE_NAME(tmp, @2);
4245 # tmp->type .reset(p[2]);
4246 # tmp->names .reset(p[3]);
4247 # p[0] = tmp;
4248 # }
4249 ()
4250
4251
4252 def p_struct_union_member_2(p):
4253 '''struct_union_member : error ';' '''
4254 if(parse_debug):
4255 print('struct_union_member_2', list(p))
4256
4257 # { yyerror(@2, "Error in struct/union member.");
4258 # yyerrok;
4259 # p[0] = None
4260 # }
4261 ()
4262
4263
4264 def p_case_item_1(p):
4265 '''case_item : expression_list_proper ':' statement_or_null '''
4266 if(parse_debug):
4267 print('case_item_1', list(p))
4268
4269 # { PCase::Item*tmp = new PCase::Item;
4270 # tmp->expr = *p[1];
4271 # tmp->stat = p[3];
4272 # delete p[1];
4273 # p[0] = tmp;
4274 # }
4275 ()
4276
4277
4278 def p_case_item_2(p):
4279 '''case_item : K_default ':' statement_or_null '''
4280 if(parse_debug):
4281 print('case_item_2', list(p))
4282
4283 # { PCase::Item*tmp = new PCase::Item;
4284 # tmp->stat = p[3];
4285 # p[0] = tmp;
4286 # }
4287 ()
4288
4289
4290 def p_case_item_3(p):
4291 '''case_item : K_default statement_or_null '''
4292 if(parse_debug):
4293 print('case_item_3', list(p))
4294
4295 # { PCase::Item*tmp = new PCase::Item;
4296 # tmp->stat = p[2];
4297 # p[0] = tmp;
4298 # }
4299 ()
4300
4301
4302 def p_case_item_4(p):
4303 '''case_item : error ':' statement_or_null '''
4304 if(parse_debug):
4305 print('case_item_4', list(p))
4306
4307 # { yyerror(@2, "error: Incomprehensible case expression.");
4308 # yyerrok;
4309 # }
4310 ()
4311
4312
4313 def p_case_items_1(p):
4314 '''case_items : case_items case_item '''
4315 if(parse_debug):
4316 print('case_items_1', list(p))
4317
4318 # { svector<PCase::Item*>*tmp;
4319 # tmp = new svector<PCase::Item*>(*p[1], p[2]);
4320 # delete p[1];
4321 # p[0] = tmp;
4322 # }
4323 ()
4324
4325
4326 def p_case_items_2(p):
4327 '''case_items : case_item '''
4328 if(parse_debug):
4329 print('case_items_2', list(p))
4330
4331 # { svector<PCase::Item*>*tmp = new svector<PCase::Item*>(1);
4332 # (*tmp)[0] = p[1];
4333 # p[0] = tmp;
4334 # }
4335 ()
4336
4337
4338 def p_charge_strength_1(p):
4339 '''charge_strength : '(' K_small ')' '''
4340 if(parse_debug):
4341 print('charge_strength_1', list(p))
4342
4343
4344 ()
4345
4346
4347 def p_charge_strength_2(p):
4348 '''charge_strength : '(' K_medium ')' '''
4349 if(parse_debug):
4350 print('charge_strength_2', list(p))
4351
4352
4353 ()
4354
4355
4356 def p_charge_strength_3(p):
4357 '''charge_strength : '(' K_large ')' '''
4358 if(parse_debug):
4359 print('charge_strength_3', list(p))
4360
4361
4362 ()
4363
4364
4365 def p_charge_strength_opt_1(p):
4366 '''charge_strength_opt : charge_strength '''
4367 if(parse_debug):
4368 print('charge_strength_opt_1', list(p))
4369
4370
4371 ()
4372
4373
4374 def p_charge_strength_opt_2(p):
4375 '''charge_strength_opt : '''
4376 if(parse_debug):
4377 print('charge_strength_opt_2', list(p))
4378
4379
4380 ()
4381
4382
4383 def p_defparam_assign_1(p):
4384 '''defparam_assign : hierarchy_identifier '=' expression '''
4385 if(parse_debug):
4386 print('defparam_assign_1', list(p))
4387
4388 # { pform_set_defparam(*p[1], p[3]);
4389 # delete p[1];
4390 # }
4391 ()
4392
4393
4394 def p_defparam_assign_list_1(p):
4395 '''defparam_assign_list : defparam_assign '''
4396 if(parse_debug):
4397 print('defparam_assign_list_1', list(p))
4398
4399
4400 ()
4401
4402
4403 def p_defparam_assign_list_2(p):
4404 '''defparam_assign_list : dimensions defparam_assign '''
4405 if(parse_debug):
4406 print('defparam_assign_list_2', list(p))
4407
4408 # { yyerror(@1, "error: defparam may not include a range.");
4409 # delete p[1];
4410 # }
4411 ()
4412
4413
4414 def p_defparam_assign_list_3(p):
4415 '''defparam_assign_list : defparam_assign_list ',' defparam_assign '''
4416 if(parse_debug):
4417 print('defparam_assign_list_3', list(p))
4418
4419
4420 ()
4421
4422
4423 def p_delay1_1(p):
4424 '''delay1 : '#' delay_value_simple '''
4425 if(parse_debug):
4426 print('delay1_1', list(p))
4427
4428 # { list<PExpr*>*tmp = new list<PExpr*>;
4429 # tmp->push_back(p[2]);
4430 # p[0] = tmp;
4431 # }
4432 ()
4433
4434
4435 def p_delay1_2(p):
4436 '''delay1 : '#' '(' delay_value ')' '''
4437 if(parse_debug):
4438 print('delay1_2', list(p))
4439
4440 # { list<PExpr*>*tmp = new list<PExpr*>;
4441 # tmp->push_back(p[3]);
4442 # p[0] = tmp;
4443 # }
4444 ()
4445
4446
4447 def p_delay3_1(p):
4448 '''delay3 : '#' delay_value_simple '''
4449 if(parse_debug):
4450 print('delay3_1', list(p))
4451
4452 # { list<PExpr*>*tmp = new list<PExpr*>;
4453 # tmp->push_back(p[2]);
4454 # p[0] = tmp;
4455 # }
4456 ()
4457
4458
4459 def p_delay3_2(p):
4460 '''delay3 : '#' '(' delay_value ')' '''
4461 if(parse_debug):
4462 print('delay3_2', list(p))
4463
4464 # { list<PExpr*>*tmp = new list<PExpr*>;
4465 # tmp->push_back(p[3]);
4466 # p[0] = tmp;
4467 # }
4468 ()
4469
4470
4471 def p_delay3_3(p):
4472 '''delay3 : '#' '(' delay_value ',' delay_value ')' '''
4473 if(parse_debug):
4474 print('delay3_3', list(p))
4475
4476 # { list<PExpr*>*tmp = new list<PExpr*>;
4477 # tmp->push_back(p[3]);
4478 # tmp->push_back(p[5]);
4479 # p[0] = tmp;
4480 # }
4481 ()
4482
4483
4484 def p_delay3_4(p):
4485 '''delay3 : '#' '(' delay_value ',' delay_value ',' delay_value ')' '''
4486 if(parse_debug):
4487 print('delay3_4', list(p))
4488
4489 # { list<PExpr*>*tmp = new list<PExpr*>;
4490 # tmp->push_back(p[3]);
4491 # tmp->push_back(p[5]);
4492 # tmp->push_back(p[7]);
4493 # p[0] = tmp;
4494 # }
4495 ()
4496
4497
4498 def p_delay3_opt_1(p):
4499 '''delay3_opt : delay3 '''
4500 if(parse_debug):
4501 print('delay3_opt_1', list(p))
4502 p[0] = p[1]
4503
4504
4505 ()
4506
4507
4508 def p_delay3_opt_2(p):
4509 '''delay3_opt : '''
4510 if(parse_debug > 2):
4511 print('delay3_opt_2', list(p))
4512
4513 # { p[0] = None }
4514 ()
4515
4516
4517 def p_delay_value_list_1(p):
4518 '''delay_value_list : delay_value '''
4519 if(parse_debug):
4520 print('delay_value_list_1', list(p))
4521
4522 # { list<PExpr*>*tmp = new list<PExpr*>;
4523 # tmp->push_back(p[1]);
4524 # p[0] = tmp;
4525 # }
4526 ()
4527
4528
4529 def p_delay_value_list_2(p):
4530 '''delay_value_list : delay_value_list ',' delay_value '''
4531 if(parse_debug):
4532 print('delay_value_list_2', list(p))
4533
4534 # { list<PExpr*>*tmp = p[1];
4535 # tmp->push_back(p[3]);
4536 # p[0] = tmp;
4537 # }
4538 ()
4539
4540
4541 def p_delay_value_1(p):
4542 '''delay_value : expression '''
4543 if(parse_debug):
4544 print('delay_value_1', list(p))
4545
4546 # { PExpr*tmp = p[1];
4547 # p[0] = tmp;
4548 # }
4549 ()
4550
4551
4552 def p_delay_value_2(p):
4553 '''delay_value : expression ':' expression ':' expression '''
4554 if(parse_debug):
4555 print('delay_value_2', list(p))
4556
4557 # { p[0] = pform_select_mtm_expr(p[1], p[3], p[5]); }
4558 ()
4559
4560
4561 def p_delay_value_simple_1(p):
4562 '''delay_value_simple : DEC_NUMBER '''
4563 if(parse_debug):
4564 print('delay_value_simple_1', list(p))
4565
4566 # { verinum*tmp = p[1];
4567 # if (tmp == 0) {
4568 # yyerror(@1, "internal error: delay.");
4569 # p[0] = None
4570 # } else {
4571 # p[0] = new PENumber(tmp);
4572 # FILE_NAME(p[0], @1);
4573 # }
4574 # based_size = 0;
4575 # }
4576 ()
4577
4578
4579 def p_delay_value_simple_2(p):
4580 '''delay_value_simple : REALTIME '''
4581 if(parse_debug):
4582 print('delay_value_simple_2', list(p))
4583
4584 # { verireal*tmp = p[1];
4585 # if (tmp == 0) {
4586 # yyerror(@1, "internal error: delay.");
4587 # p[0] = None
4588 # } else {
4589 # p[0] = new PEFNumber(tmp);
4590 # FILE_NAME(p[0], @1);
4591 # }
4592 # }
4593 ()
4594
4595
4596 def p_delay_value_simple_3(p):
4597 '''delay_value_simple : IDENTIFIER '''
4598 if(parse_debug):
4599 print('delay_value_simple_3', list(p))
4600
4601 # { PEIdent*tmp = new PEIdent(lex_strings.make(p[1]));
4602 # FILE_NAME(tmp, @1);
4603 # p[0] = tmp;
4604 # delete[]p[1];
4605 # }
4606 ()
4607
4608
4609 def p_delay_value_simple_4(p):
4610 '''delay_value_simple : TIME_LITERAL '''
4611 if(parse_debug):
4612 print('delay_value_simple_4', list(p))
4613
4614 # { int unit;
4615 #
4616 # based_size = 0;
4617 # p[0] = 0;
4618 # if (p[1] == 0 || !get_time_unit(p[1], unit))
4619 # yyerror(@1, "internal error: delay.");
4620 # else {
4621 # double p = pow(10.0,
4622 # (double)(unit - pform_get_timeunit()));
4623 # double time = atof(p[1]) * p;
4624 #
4625 # verireal *v = new verireal(time);
4626 # p[0] = new PEFNumber(v);
4627 # FILE_NAME(p[0], @1);
4628 # }
4629 # }
4630 ()
4631
4632
4633 def p_optional_semicolon_1(p):
4634 '''optional_semicolon : ';' '''
4635 if(parse_debug):
4636 print('optional_semicolon_1', list(p))
4637
4638
4639 ()
4640
4641
4642 def p_optional_semicolon_2(p):
4643 '''optional_semicolon : '''
4644 if(parse_debug):
4645 print('optional_semicolon_2', list(p))
4646
4647
4648 ()
4649
4650
4651 def p_discipline_declaration_1(p):
4652 '''discipline_declaration : K_discipline IDENTIFIER optional_semicolon _embed0_discipline_declaration discipline_items K_enddiscipline '''
4653 if(parse_debug):
4654 print('discipline_declaration_1', list(p))
4655
4656 # { pform_end_discipline(@1); delete[] p[2]; }
4657 ()
4658
4659
4660 def p__embed0_discipline_declaration(p):
4661 '''_embed0_discipline_declaration : '''
4662
4663 # { pform_start_discipline(p[2]); }
4664 ()
4665
4666
4667 def p_discipline_items_1(p):
4668 '''discipline_items : discipline_items discipline_item '''
4669 if(parse_debug):
4670 print('discipline_items_1', list(p))
4671
4672
4673 ()
4674
4675
4676 def p_discipline_items_2(p):
4677 '''discipline_items : discipline_item '''
4678 if(parse_debug):
4679 print('discipline_items_2', list(p))
4680
4681
4682 ()
4683
4684
4685 def p_discipline_item_1(p):
4686 '''discipline_item : K_domain K_discrete ';' '''
4687 if(parse_debug):
4688 print('discipline_item_1', list(p))
4689
4690 # { pform_discipline_domain(@1, IVL_DIS_DISCRETE); }
4691 ()
4692
4693
4694 def p_discipline_item_2(p):
4695 '''discipline_item : K_domain K_continuous ';' '''
4696 if(parse_debug):
4697 print('discipline_item_2', list(p))
4698
4699 # { pform_discipline_domain(@1, IVL_DIS_CONTINUOUS); }
4700 ()
4701
4702
4703 def p_discipline_item_3(p):
4704 '''discipline_item : K_potential IDENTIFIER ';' '''
4705 if(parse_debug):
4706 print('discipline_item_3', list(p))
4707
4708 # { pform_discipline_potential(@1, p[2]); delete[] p[2]; }
4709 ()
4710
4711
4712 def p_discipline_item_4(p):
4713 '''discipline_item : K_flow IDENTIFIER ';' '''
4714 if(parse_debug):
4715 print('discipline_item_4', list(p))
4716
4717 # { pform_discipline_flow(@1, p[2]); delete[] p[2]; }
4718 ()
4719
4720
4721 def p_nature_declaration_1(p):
4722 '''nature_declaration : K_nature IDENTIFIER optional_semicolon _embed0_nature_declaration nature_items K_endnature '''
4723 if(parse_debug):
4724 print('nature_declaration_1', list(p))
4725
4726 # { pform_end_nature(@1); delete[] p[2]; }
4727 ()
4728
4729
4730 def p__embed0_nature_declaration(p):
4731 '''_embed0_nature_declaration : '''
4732
4733 # { pform_start_nature(p[2]); }
4734 ()
4735
4736
4737 def p_nature_items_1(p):
4738 '''nature_items : nature_items nature_item '''
4739 if(parse_debug):
4740 print('nature_items_1', list(p))
4741
4742
4743 ()
4744
4745
4746 def p_nature_items_2(p):
4747 '''nature_items : nature_item '''
4748 if(parse_debug):
4749 print('nature_items_2', list(p))
4750
4751
4752 ()
4753
4754
4755 def p_nature_item_1(p):
4756 '''nature_item : K_units '=' STRING ';' '''
4757 if(parse_debug):
4758 print('nature_item_1', list(p))
4759
4760 # { delete[] p[3]; }
4761 ()
4762
4763
4764 def p_nature_item_2(p):
4765 '''nature_item : K_abstol '=' expression ';' '''
4766 if(parse_debug):
4767 print('nature_item_2', list(p))
4768
4769
4770 ()
4771
4772
4773 def p_nature_item_3(p):
4774 '''nature_item : K_access '=' IDENTIFIER ';' '''
4775 if(parse_debug):
4776 print('nature_item_3', list(p))
4777
4778 # { pform_nature_access(@1, p[3]); delete[] p[3]; }
4779 ()
4780
4781
4782 def p_nature_item_4(p):
4783 '''nature_item : K_idt_nature '=' IDENTIFIER ';' '''
4784 if(parse_debug):
4785 print('nature_item_4', list(p))
4786
4787 # { delete[] p[3]; }
4788 ()
4789
4790
4791 def p_nature_item_5(p):
4792 '''nature_item : K_ddt_nature '=' IDENTIFIER ';' '''
4793 if(parse_debug):
4794 print('nature_item_5', list(p))
4795
4796 # { delete[] p[3]; }
4797 ()
4798
4799
4800 def p_config_declaration_1(p):
4801 '''config_declaration : K_config IDENTIFIER ';' K_design lib_cell_identifiers ';' list_of_config_rule_statements K_endconfig '''
4802 if(parse_debug):
4803 print('config_declaration_1', list(p))
4804
4805 # { cerr << @1 << ": sorry: config declarations are not supported and "
4806 # "will be skipped." << endl;
4807 # delete[] p[2];
4808 # }
4809 ()
4810
4811
4812 def p_lib_cell_identifiers_1(p):
4813 '''lib_cell_identifiers : '''
4814 if(parse_debug):
4815 print('lib_cell_identifiers_1', list(p))
4816
4817
4818 ()
4819
4820
4821 def p_lib_cell_identifiers_2(p):
4822 '''lib_cell_identifiers : lib_cell_identifiers lib_cell_id '''
4823 if(parse_debug):
4824 print('lib_cell_identifiers_2', list(p))
4825
4826
4827 ()
4828
4829
4830 def p_list_of_config_rule_statements_1(p):
4831 '''list_of_config_rule_statements : '''
4832 if(parse_debug):
4833 print('list_of_config_rule_statements_1', list(p))
4834
4835
4836 ()
4837
4838
4839 def p_list_of_config_rule_statements_2(p):
4840 '''list_of_config_rule_statements : list_of_config_rule_statements config_rule_statement '''
4841 if(parse_debug):
4842 print('list_of_config_rule_statements_2', list(p))
4843
4844
4845 ()
4846
4847
4848 def p_config_rule_statement_1(p):
4849 '''config_rule_statement : K_default K_liblist list_of_libraries ';' '''
4850 if(parse_debug):
4851 print('config_rule_statement_1', list(p))
4852
4853
4854 ()
4855
4856
4857 def p_config_rule_statement_2(p):
4858 '''config_rule_statement : K_instance hierarchy_identifier K_liblist list_of_libraries ';' '''
4859 if(parse_debug):
4860 print('config_rule_statement_2', list(p))
4861
4862 # { delete p[2]; }
4863 ()
4864
4865
4866 def p_config_rule_statement_3(p):
4867 '''config_rule_statement : K_instance hierarchy_identifier K_use lib_cell_id opt_config ';' '''
4868 if(parse_debug):
4869 print('config_rule_statement_3', list(p))
4870
4871 # { delete p[2]; }
4872 ()
4873
4874
4875 def p_config_rule_statement_4(p):
4876 '''config_rule_statement : K_cell lib_cell_id K_liblist list_of_libraries ';' '''
4877 if(parse_debug):
4878 print('config_rule_statement_4', list(p))
4879
4880
4881 ()
4882
4883
4884 def p_config_rule_statement_5(p):
4885 '''config_rule_statement : K_cell lib_cell_id K_use lib_cell_id opt_config ';' '''
4886 if(parse_debug):
4887 print('config_rule_statement_5', list(p))
4888
4889
4890 ()
4891
4892
4893 def p_opt_config_1(p):
4894 '''opt_config : '''
4895 if(parse_debug):
4896 print('opt_config_1', list(p))
4897
4898
4899 ()
4900
4901
4902 def p_opt_config_2(p):
4903 '''opt_config : ':' K_config '''
4904 if(parse_debug):
4905 print('opt_config_2', list(p))
4906
4907
4908 ()
4909
4910
4911 def p_lib_cell_id_1(p):
4912 '''lib_cell_id : IDENTIFIER '''
4913 if(parse_debug):
4914 print('lib_cell_id_1', list(p))
4915
4916 # { delete[] p[1]; }
4917 ()
4918
4919
4920 def p_lib_cell_id_2(p):
4921 '''lib_cell_id : IDENTIFIER '.' IDENTIFIER '''
4922 if(parse_debug):
4923 print('lib_cell_id_2', list(p))
4924
4925 # { delete[] p[1]; delete[] p[3]; }
4926 ()
4927
4928
4929 def p_list_of_libraries_1(p):
4930 '''list_of_libraries : '''
4931 if(parse_debug):
4932 print('list_of_libraries_1', list(p))
4933
4934
4935 ()
4936
4937
4938 def p_list_of_libraries_2(p):
4939 '''list_of_libraries : list_of_libraries IDENTIFIER '''
4940 if(parse_debug):
4941 print('list_of_libraries_2', list(p))
4942
4943 # { delete[] p[2]; }
4944 ()
4945
4946
4947 def p_drive_strength_1(p):
4948 '''drive_strength : '(' dr_strength0 ',' dr_strength1 ')' '''
4949 if(parse_debug):
4950 print('drive_strength_1', list(p))
4951
4952 # { p[0].str0 = p[2].str0;
4953 # p[0].str1 = p[4].str1;
4954 # }
4955 ()
4956
4957
4958 def p_drive_strength_2(p):
4959 '''drive_strength : '(' dr_strength1 ',' dr_strength0 ')' '''
4960 if(parse_debug):
4961 print('drive_strength_2', list(p))
4962
4963 # { p[0].str0 = p[4].str0;
4964 # p[0].str1 = p[2].str1;
4965 # }
4966 ()
4967
4968
4969 def p_drive_strength_3(p):
4970 '''drive_strength : '(' dr_strength0 ',' K_highz1 ')' '''
4971 if(parse_debug):
4972 print('drive_strength_3', list(p))
4973
4974 # { p[0].str0 = p[2].str0;
4975 # p[0].str1 = IVL_DR_HiZ;
4976 # }
4977 ()
4978
4979
4980 def p_drive_strength_4(p):
4981 '''drive_strength : '(' dr_strength1 ',' K_highz0 ')' '''
4982 if(parse_debug):
4983 print('drive_strength_4', list(p))
4984
4985 # { p[0].str0 = IVL_DR_HiZ;
4986 # p[0].str1 = p[2].str1;
4987 # }
4988 ()
4989
4990
4991 def p_drive_strength_5(p):
4992 '''drive_strength : '(' K_highz1 ',' dr_strength0 ')' '''
4993 if(parse_debug):
4994 print('drive_strength_5', list(p))
4995
4996 # { p[0].str0 = p[4].str0;
4997 # p[0].str1 = IVL_DR_HiZ;
4998 # }
4999 ()
5000
5001
5002 def p_drive_strength_6(p):
5003 '''drive_strength : '(' K_highz0 ',' dr_strength1 ')' '''
5004 if(parse_debug):
5005 print('drive_strength_6', list(p))
5006
5007 # { p[0].str0 = IVL_DR_HiZ;
5008 # p[0].str1 = p[4].str1;
5009 # }
5010 ()
5011
5012
5013 def p_drive_strength_opt_1(p):
5014 '''drive_strength_opt : drive_strength '''
5015 if(parse_debug):
5016 print('drive_strength_opt_1', list(p))
5017 p[0] = p[1]
5018
5019
5020 ()
5021
5022
5023 def p_drive_strength_opt_2(p):
5024 '''drive_strength_opt : '''
5025 if(parse_debug > 2):
5026 print('drive_strength_opt_2', list(p))
5027
5028 # { p[0].str0 = IVL_DR_STRONG; p[0].str1 = IVL_DR_STRONG; }
5029 ()
5030
5031
5032 def p_dr_strength0_1(p):
5033 '''dr_strength0 : K_supply0 '''
5034 if(parse_debug):
5035 print('dr_strength0_1', list(p))
5036
5037 # { p[0].str0 = IVL_DR_SUPPLY; }
5038 ()
5039
5040
5041 def p_dr_strength0_2(p):
5042 '''dr_strength0 : K_strong0 '''
5043 if(parse_debug):
5044 print('dr_strength0_2', list(p))
5045
5046 # { p[0].str0 = IVL_DR_STRONG; }
5047 ()
5048
5049
5050 def p_dr_strength0_3(p):
5051 '''dr_strength0 : K_pull0 '''
5052 if(parse_debug):
5053 print('dr_strength0_3', list(p))
5054
5055 # { p[0].str0 = IVL_DR_PULL; }
5056 ()
5057
5058
5059 def p_dr_strength0_4(p):
5060 '''dr_strength0 : K_weak0 '''
5061 if(parse_debug):
5062 print('dr_strength0_4', list(p))
5063
5064 # { p[0].str0 = IVL_DR_WEAK; }
5065 ()
5066
5067
5068 def p_dr_strength1_1(p):
5069 '''dr_strength1 : K_supply1 '''
5070 if(parse_debug):
5071 print('dr_strength1_1', list(p))
5072
5073 # { p[0].str1 = IVL_DR_SUPPLY; }
5074 ()
5075
5076
5077 def p_dr_strength1_2(p):
5078 '''dr_strength1 : K_strong1 '''
5079 if(parse_debug):
5080 print('dr_strength1_2', list(p))
5081
5082 # { p[0].str1 = IVL_DR_STRONG; }
5083 ()
5084
5085
5086 def p_dr_strength1_3(p):
5087 '''dr_strength1 : K_pull1 '''
5088 if(parse_debug):
5089 print('dr_strength1_3', list(p))
5090
5091 # { p[0].str1 = IVL_DR_PULL; }
5092 ()
5093
5094
5095 def p_dr_strength1_4(p):
5096 '''dr_strength1 : K_weak1 '''
5097 if(parse_debug):
5098 print('dr_strength1_4', list(p))
5099
5100 # { p[0].str1 = IVL_DR_WEAK; }
5101 ()
5102
5103
5104 def p_clocking_event_opt_1(p):
5105 '''clocking_event_opt : event_control '''
5106 if(parse_debug):
5107 print('clocking_event_opt_1', list(p))
5108
5109
5110 ()
5111
5112
5113 def p_clocking_event_opt_2(p):
5114 '''clocking_event_opt : '''
5115 if(parse_debug):
5116 print('clocking_event_opt_2', list(p))
5117
5118
5119 ()
5120
5121
5122 def p_event_control_1(p):
5123 '''event_control : '@' hierarchy_identifier '''
5124 if(parse_debug):
5125 print('event_control_1', list(p))
5126
5127 # { PEIdent*tmpi = new PEIdent(*p[2]);
5128 # PEEvent*tmpe = new PEEvent(PEEvent::ANYEDGE, tmpi);
5129 # PEventStatement*tmps = new PEventStatement(tmpe);
5130 # FILE_NAME(tmps, @1);
5131 # p[0] = tmps;
5132 # delete p[2];
5133 # }
5134 ()
5135
5136
5137 def p_event_control_2(p):
5138 '''event_control : '@' '(' event_expression_list ')' '''
5139 if(parse_debug):
5140 print('event_control_2', list(p))
5141
5142 # { PEventStatement*tmp = new PEventStatement(*p[3]);
5143 # FILE_NAME(tmp, @1);
5144 # delete p[3];
5145 # p[0] = tmp;
5146 # }
5147 ()
5148
5149
5150 def p_event_control_3(p):
5151 '''event_control : '@' '(' error ')' '''
5152 if(parse_debug):
5153 print('event_control_3', list(p))
5154
5155 # { yyerror(@1, "error: Malformed event control expression.");
5156 # p[0] = None
5157 # }
5158 ()
5159
5160
5161 def p_event_expression_list_1(p):
5162 '''event_expression_list : event_expression '''
5163 if(parse_debug):
5164 print('event_expression_list_1', list(p))
5165 p[0] = p[1]
5166
5167
5168 ()
5169
5170
5171 def p_event_expression_list_2(p):
5172 '''event_expression_list : event_expression_list K_or event_expression '''
5173 if(parse_debug):
5174 print('event_expression_list_2', list(p))
5175
5176 # { svector<PEEvent*>*tmp = new svector<PEEvent*>(*p[1], *p[3]);
5177 # delete p[1];
5178 # delete p[3];
5179 # p[0] = tmp;
5180 # }
5181 ()
5182
5183
5184 def p_event_expression_list_3(p):
5185 '''event_expression_list : event_expression_list ',' event_expression '''
5186 if(parse_debug):
5187 print('event_expression_list_3', list(p))
5188
5189 # { svector<PEEvent*>*tmp = new svector<PEEvent*>(*p[1], *p[3]);
5190 # delete p[1];
5191 # delete p[3];
5192 # p[0] = tmp;
5193 # }
5194 ()
5195
5196
5197 def p_event_expression_1(p):
5198 '''event_expression : K_posedge expression '''
5199 if(parse_debug):
5200 print('event_expression_1', list(p))
5201
5202 # { PEEvent*tmp = new PEEvent(PEEvent::POSEDGE, p[2]);
5203 # FILE_NAME(tmp, @1);
5204 # svector<PEEvent*>*tl = new svector<PEEvent*>(1);
5205 # (*tl)[0] = tmp;
5206 # p[0] = tl;
5207 # }
5208 ()
5209
5210
5211 def p_event_expression_2(p):
5212 '''event_expression : K_negedge expression '''
5213 if(parse_debug):
5214 print('event_expression_2', list(p))
5215
5216 # { PEEvent*tmp = new PEEvent(PEEvent::NEGEDGE, p[2]);
5217 # FILE_NAME(tmp, @1);
5218 # svector<PEEvent*>*tl = new svector<PEEvent*>(1);
5219 # (*tl)[0] = tmp;
5220 # p[0] = tl;
5221 # }
5222 ()
5223
5224
5225 def p_event_expression_3(p):
5226 '''event_expression : expression '''
5227 if(parse_debug):
5228 print('event_expression_3', list(p))
5229
5230 # { PEEvent*tmp = new PEEvent(PEEvent::ANYEDGE, p[1]);
5231 # FILE_NAME(tmp, @1);
5232 # svector<PEEvent*>*tl = new svector<PEEvent*>(1);
5233 # (*tl)[0] = tmp;
5234 # p[0] = tl;
5235 # }
5236 ()
5237
5238
5239 def p_branch_probe_expression_1(p):
5240 '''branch_probe_expression : IDENTIFIER '(' IDENTIFIER ',' IDENTIFIER ')' '''
5241 if(parse_debug):
5242 print('branch_probe_expression_1', list(p))
5243
5244 # { p[0] = pform_make_branch_probe_expression(@1, p[1], p[3], p[5]); }
5245 ()
5246
5247
5248 def p_branch_probe_expression_2(p):
5249 '''branch_probe_expression : IDENTIFIER '(' IDENTIFIER ')' '''
5250 if(parse_debug):
5251 print('branch_probe_expression_2', list(p))
5252
5253 # { p[0] = pform_make_branch_probe_expression(@1, p[1], p[3]); }
5254 ()
5255
5256
5257 def p_expression_1(p):
5258 '''expression : expr_primary_or_typename '''
5259 if(parse_debug > 2):
5260 print('expression_1', list(p))
5261 p[0] = p[1]
5262
5263
5264 ()
5265
5266
5267 def p_expression_2(p):
5268 '''expression : inc_or_dec_expression '''
5269 if(parse_debug):
5270 print('expression_2', list(p))
5271 p[0] = p[1]
5272
5273
5274 ()
5275
5276
5277 def p_expression_3(p):
5278 '''expression : inside_expression '''
5279 if(parse_debug):
5280 print('expression_3', list(p))
5281 p[0] = p[1]
5282
5283
5284 ()
5285
5286
5287 def p_expression_4(p):
5288 '''expression : '+' attribute_list_opt expr_primary %prec UNARY_PREC '''
5289 if(parse_debug):
5290 print('expression_4', list(p))
5291 p[0] = p[3]
5292
5293
5294 ()
5295
5296
5297 def PEUnary(op, o1):
5298 #Leaf(token.STRING, ' ')
5299 try:
5300 return Node(syms.atom, [op, o1])
5301 except:
5302 return "error in PEUnary: "+str(op)+","+str(o1)
5303
5304
5305 def PEBinary(op, o1, o2):
5306 try:
5307 return Node(syms.atom, [o1, Leaf(token.STRING, ' '), op, Leaf(token.STRING, ' '), o2])
5308 except:
5309 return "error in PEBinary: "+str(op)+","+str(o1)+","+str(o2)
5310
5311 # unary minus
5312
5313
5314 def p_expression_5(p):
5315 '''expression : '-' attribute_list_opt expr_primary %prec UNARY_PREC '''
5316 if(parse_debug):
5317 print('expression_5', list(p))
5318
5319 p[0] = PEUnary(Leaf(token.MINUS, '-'), p[3])
5320
5321 # { PEUnary*tmp = new PEUnary('-', p[3]);
5322 # FILE_NAME(tmp, @3);
5323 # p[0] = tmp;
5324 # }
5325 ()
5326
5327
5328 def p_expression_6(p):
5329 '''expression : '~' attribute_list_opt expr_primary %prec UNARY_PREC '''
5330 if(parse_debug):
5331 print('expression_6', list(p))
5332
5333 p[0] = PEUnary(Leaf(token.TILDE, '~'), p[3])
5334
5335 # { PEUnary*tmp = new PEUnary('~', p[3]);
5336 # FILE_NAME(tmp, @3);
5337 # p[0] = tmp;
5338 # }
5339 ()
5340
5341
5342 def p_expression_7(p):
5343 '''expression : '&' attribute_list_opt expr_primary %prec UNARY_PREC '''
5344 if(parse_debug):
5345 print('expression_7', list(p))
5346
5347 p[0] = PEUnary(Leaf(token.AMPER, '&'), p[3])
5348
5349 # { PEUnary*tmp = new PEUnary('&', p[3]);
5350 # FILE_NAME(tmp, @3);
5351 # p[0] = tmp;
5352 # }
5353 ()
5354
5355
5356 def p_expression_8(p):
5357 '''expression : '!' attribute_list_opt expr_primary %prec UNARY_PREC '''
5358 if(parse_debug):
5359 print('expression_8', list(p))
5360
5361 p[0] = PEUnary(Leaf(token.STRING, '!'), p[3])
5362
5363 # { PEUnary*tmp = new PEUnary('!', p[3]);
5364 # FILE_NAME(tmp, @3);
5365 # p[0] = tmp;
5366 # }
5367 ()
5368
5369
5370 def p_expression_9(p):
5371 '''expression : '|' attribute_list_opt expr_primary %prec UNARY_PREC '''
5372 if(parse_debug):
5373 print('expression_9', list(p))
5374
5375 p[0] = PEUnary(Leaf(token.STRING, '|'), p[3])
5376
5377 # { PEUnary*tmp = new PEUnary('|', p[3]);
5378 # FILE_NAME(tmp, @3);
5379 # p[0] = tmp;
5380 # }
5381 ()
5382
5383
5384 def p_expression_10(p):
5385 '''expression : '^' attribute_list_opt expr_primary %prec UNARY_PREC '''
5386 if(parse_debug):
5387 print('expression_10', list(p))
5388
5389 p[0] = PEUnary(Leaf(token.STRING, '^'), p[3])
5390
5391 # { PEUnary*tmp = new PEUnary('^', p[3]);
5392 # FILE_NAME(tmp, @3);
5393 # p[0] = tmp;
5394 # }
5395 ()
5396
5397
5398 def p_expression_11(p):
5399 '''expression : '~' '&' attribute_list_opt expr_primary %prec UNARY_PREC '''
5400 if(parse_debug):
5401 print('expression_11', list(p))
5402
5403 # { yyerror(@1, "error: '~' '&' is not a valid expression. "
5404 # "Please use operator '~&' instead.");
5405 # p[0] = None
5406 # }
5407 ()
5408
5409
5410 def p_expression_12(p):
5411 '''expression : '~' '|' attribute_list_opt expr_primary %prec UNARY_PREC '''
5412 if(parse_debug):
5413 print('expression_12', list(p))
5414
5415 # { yyerror(@1, "error: '~' '|' is not a valid expression. "
5416 # "Please use operator '~|' instead.");
5417 # p[0] = None
5418 # }
5419 ()
5420
5421
5422 def p_expression_13(p):
5423 '''expression : '~' '^' attribute_list_opt expr_primary %prec UNARY_PREC '''
5424 if(parse_debug):
5425 print('expression_13', list(p))
5426
5427 # { yyerror(@1, "error: '~' '^' is not a valid expression. "
5428 # "Please use operator '~^' instead.");
5429 # p[0] = None
5430 # }
5431 ()
5432
5433
5434 def p_expression_14(p):
5435 '''expression : K_NAND attribute_list_opt expr_primary %prec UNARY_PREC '''
5436 if(parse_debug):
5437 print('expression_14', list(p))
5438
5439 p[0] = PEUnary(Leaf(token.STRING, 'K_NAND'), p[3])
5440
5441 # { PEUnary*tmp = new PEUnary('A', p[3]);
5442 # FILE_NAME(tmp, @3);
5443 # p[0] = tmp;
5444 # }
5445 ()
5446
5447
5448 def p_expression_15(p):
5449 '''expression : K_NOR attribute_list_opt expr_primary %prec UNARY_PREC '''
5450 if(parse_debug):
5451 print('expression_15', list(p))
5452
5453 p[0] = PEUnary(Leaf(token.STRING, 'K_NOR'), p[3])
5454
5455 # { PEUnary*tmp = new PEUnary('N', p[3]);
5456 # FILE_NAME(tmp, @3);
5457 # p[0] = tmp;
5458 # }
5459 ()
5460
5461
5462 def p_expression_16(p):
5463 '''expression : K_NXOR attribute_list_opt expr_primary %prec UNARY_PREC '''
5464 if(parse_debug):
5465 print('expression_16', list(p))
5466
5467 p[0] = PEUnary(Leaf(token.STRING, 'K_NXOR'), p[3])
5468
5469 # { PEUnary*tmp = new PEUnary('X', p[3]);
5470 # FILE_NAME(tmp, @3);
5471 # p[0] = tmp;
5472 # }
5473 ()
5474
5475
5476 def p_expression_17(p):
5477 '''expression : '!' error %prec UNARY_PREC '''
5478 if(parse_debug):
5479 print('expression_17', list(p))
5480
5481 # { yyerror(@1, "error: Operand of unary ! "
5482 # "is not a primary expression.");
5483 # p[0] = None
5484 # }
5485 ()
5486
5487
5488 def p_expression_18(p):
5489 '''expression : '^' error %prec UNARY_PREC '''
5490 if(parse_debug):
5491 print('expression_18', list(p))
5492
5493 # { yyerror(@1, "error: Operand of reduction ^ "
5494 # "is not a primary expression.");
5495 # p[0] = None
5496 # }
5497 ()
5498
5499
5500 def p_expression_19(p):
5501 '''expression : expression '^' attribute_list_opt expression '''
5502 if(parse_debug):
5503 print('expression_19', list(p))
5504
5505 p[0] = PEBinary(Leaf(token.STRING, '^'), p[1], p[4])
5506
5507 # { PEBinary*tmp = new PEBinary('^', p[1], p[4]);
5508 # FILE_NAME(tmp, @2);
5509 # p[0] = tmp;
5510 # }
5511 ()
5512
5513
5514 def p_expression_20(p):
5515 '''expression : expression K_POW attribute_list_opt expression '''
5516 if(parse_debug):
5517 print('expression_20', list(p))
5518
5519 p[0] = PEBinary(Leaf(token.STRING, '**'), p[1], p[4])
5520
5521 # { PEBinary*tmp = new PEBPower('p', p[1], p[4]);
5522 # FILE_NAME(tmp, @2);
5523 # p[0] = tmp;
5524 # }
5525 ()
5526
5527
5528 def p_expression_21(p):
5529 '''expression : expression '*' attribute_list_opt expression '''
5530 if(parse_debug):
5531 print('expression_21', list(p))
5532
5533 p[0] = PEBinary(Leaf(token.STRING, '*'), p[1], p[4])
5534
5535 # { PEBinary*tmp = new PEBinary('*', p[1], p[4]);
5536 # FILE_NAME(tmp, @2);
5537 # p[0] = tmp;
5538 # }
5539 ()
5540
5541
5542 def p_expression_22(p):
5543 '''expression : expression '/' attribute_list_opt expression '''
5544 if(parse_debug):
5545 print('expression_22', list(p))
5546
5547 p[0] = PEBinary(Leaf(token.STRING, '/'), p[1], p[4])
5548
5549 # { PEBinary*tmp = new PEBinary('/', p[1], p[4]);
5550 # FILE_NAME(tmp, @2);
5551 # p[0] = tmp;
5552 # }
5553 ()
5554
5555
5556 def p_expression_23(p):
5557 '''expression : expression '%' attribute_list_opt expression '''
5558 if(parse_debug):
5559 print('expression_23', list(p))
5560
5561 p[0] = PEBinary(Leaf(token.STRING, '%'), p[1], p[4])
5562
5563 # { PEBinary*tmp = new PEBinary('%', p[1], p[4]);
5564 # FILE_NAME(tmp, @2);
5565 # p[0] = tmp;
5566 # }
5567 ()
5568
5569
5570 def p_expression_24(p):
5571 '''expression : expression '+' attribute_list_opt expression '''
5572 if(parse_debug):
5573 print('expression_24', list(p))
5574
5575 # { PEBinary*tmp = new PEBinary('+', p[1], p[4]);
5576 # FILE_NAME(tmp, @2);
5577 # p[0] = tmp;
5578 # }
5579 p[0] = PEBinary(Leaf(token.PLUS, '+'), p[1], p[4])
5580
5581
5582 ()
5583
5584
5585 def p_expression_25(p):
5586 '''expression : expression '-' attribute_list_opt expression '''
5587 if(parse_debug > 2):
5588 print('expression_25', list(p))
5589 # { PEBinary*tmp = new PEBinary('-', p[1], p[4]);
5590 # FILE_NAME(tmp, @2);
5591 # p[0] = tmp;
5592 # }
5593 p[0] = PEBinary(Leaf(token.MINUS, '-'), p[1], p[4])
5594
5595
5596 ()
5597
5598
5599 def p_expression_26(p):
5600 '''expression : expression '&' attribute_list_opt expression '''
5601 if(parse_debug > 2):
5602 print('expression_26', list(p))
5603
5604 p[0] = PEBinary(Leaf(token.AMPER, '&'), p[1], p[4])
5605
5606 # { PEBinary*tmp = new PEBinary('&', p[1], p[4]);
5607 # FILE_NAME(tmp, @2);
5608 # p[0] = tmp;
5609 # }
5610 ()
5611
5612
5613 def p_expression_27(p):
5614 '''expression : expression '|' attribute_list_opt expression '''
5615 if(parse_debug > 2):
5616 print('expression_27', list(p))
5617
5618 p[0] = PEBinary(Leaf(token.VBAR, '|'), p[1], p[4])
5619
5620
5621 # { PEBinary*tmp = new PEBinary('|', p[1], p[4]);
5622 # FILE_NAME(tmp, @2);
5623 # p[0] = tmp;
5624 # }
5625 ()
5626
5627
5628 def p_expression_28(p):
5629 '''expression : expression K_NAND attribute_list_opt expression '''
5630 if(parse_debug):
5631 print('expression_28', list(p))
5632
5633 p[0] = PEBinary(Leaf(token.STRING, '~&'), p[1], p[4])
5634
5635 # { PEBinary*tmp = new PEBinary('A', p[1], p[4]);
5636 # FILE_NAME(tmp, @2);
5637 # p[0] = tmp;
5638 # }
5639 ()
5640
5641
5642 def p_expression_29(p):
5643 '''expression : expression K_NOR attribute_list_opt expression '''
5644 if(parse_debug):
5645 print('expression_29', list(p))
5646
5647 p[0] = PEBinary(Leaf(token.STRING, '~|'), p[1], p[4])
5648
5649 # { PEBinary*tmp = new PEBinary('O', p[1], p[4]);
5650 # FILE_NAME(tmp, @2);
5651 # p[0] = tmp;
5652 # }
5653 ()
5654
5655
5656 def p_expression_30(p):
5657 '''expression : expression K_NXOR attribute_list_opt expression '''
5658 if(parse_debug):
5659 print('expression_30', list(p))
5660
5661 p[0] = PEBinary(Leaf(token.STRING, 'K_XNOR'), p[1], p[4])
5662
5663 # { PEBinary*tmp = new PEBinary('X', p[1], p[4]);
5664 # FILE_NAME(tmp, @2);
5665 # p[0] = tmp;
5666 # }
5667 ()
5668
5669
5670 def p_expression_31(p):
5671 '''expression : expression '<' attribute_list_opt expression '''
5672 if(parse_debug):
5673 print('expression_31', list(p))
5674
5675 p[0] = PEBinary(Leaf(token.STRING, '<'), p[1], p[4])
5676
5677 # { PEBinary*tmp = new PEBComp('<', p[1], p[4]);
5678 # FILE_NAME(tmp, @2);
5679 # p[0] = tmp;
5680 # }
5681 ()
5682
5683
5684 def p_expression_32(p):
5685 '''expression : expression '>' attribute_list_opt expression '''
5686 if(parse_debug):
5687 print('expression_32', list(p))
5688
5689 p[0] = PEBinary(Leaf(token.STRING, '>'), p[1], p[4])
5690
5691 # { PEBinary*tmp = new PEBComp('>', p[1], p[4]);
5692 # FILE_NAME(tmp, @2);
5693 # p[0] = tmp;
5694 # }
5695 ()
5696
5697
5698 def p_expression_33(p):
5699 '''expression : expression K_LS attribute_list_opt expression '''
5700 if(parse_debug):
5701 print('expression_33', list(p))
5702
5703 p[0] = PEBinary(Leaf(token.STRING, 'K_LS'), p[1], p[4])
5704
5705 # { PEBinary*tmp = new PEBShift('l', p[1], p[4]);
5706 # FILE_NAME(tmp, @2);
5707 # p[0] = tmp;
5708 # }
5709 ()
5710
5711
5712 def p_expression_34(p):
5713 '''expression : expression K_RS attribute_list_opt expression '''
5714 if(parse_debug):
5715 print('expression_34', list(p))
5716
5717 p[0] = PEBinary(Leaf(token.STRING, 'K_RS'), p[1], p[4])
5718
5719 # { PEBinary*tmp = new PEBShift('r', p[1], p[4]);
5720 # FILE_NAME(tmp, @2);
5721 # p[0] = tmp;
5722 # }
5723 ()
5724
5725
5726 def p_expression_35(p):
5727 '''expression : expression K_RSS attribute_list_opt expression '''
5728 if(parse_debug):
5729 print('expression_35', list(p))
5730
5731 p[0] = PEBinary(Leaf(token.STRING, 'K_RSS'), p[1], p[4])
5732
5733 # { PEBinary*tmp = new PEBShift('R', p[1], p[4]);
5734 # FILE_NAME(tmp, @2);
5735 # p[0] = tmp;
5736 # }
5737 ()
5738
5739
5740 def p_expression_36(p):
5741 '''expression : expression K_EQ attribute_list_opt expression '''
5742 if(parse_debug):
5743 print('expression_36', list(p))
5744
5745 p[0] = PEBinary(Leaf(token.STRING, '=='), p[1], p[4])
5746
5747 # { PEBinary*tmp = new PEBComp('e', p[1], p[4]);
5748 # FILE_NAME(tmp, @2);
5749 # p[0] = tmp;
5750 # }
5751 ()
5752
5753
5754 def p_expression_37(p):
5755 '''expression : expression K_CEQ attribute_list_opt expression '''
5756 if(parse_debug):
5757 print('expression_37', list(p))
5758
5759 p[0] = PEBinary(Leaf(token.STRING, 'K_CEQ'), p[1], p[4])
5760
5761 # { PEBinary*tmp = new PEBComp('E', p[1], p[4]);
5762 # FILE_NAME(tmp, @2);
5763 # p[0] = tmp;
5764 # }
5765 ()
5766
5767
5768 def p_expression_38(p):
5769 '''expression : expression K_WEQ attribute_list_opt expression '''
5770 if(parse_debug):
5771 print('expression_38', list(p))
5772
5773 p[0] = PEBinary(Leaf(token.STRING, 'K_WEQ'), p[1], p[4])
5774
5775 # { PEBinary*tmp = new PEBComp('w', p[1], p[4]);
5776 # FILE_NAME(tmp, @2);
5777 # p[0] = tmp;
5778 # }
5779 ()
5780
5781
5782 def p_expression_39(p):
5783 '''expression : expression K_LE attribute_list_opt expression '''
5784 if(parse_debug):
5785 print('expression_39', list(p))
5786
5787 p[0] = PEBinary(Leaf(token.STRING, '<='), p[1], p[4])
5788
5789 # { PEBinary*tmp = new PEBComp('L', p[1], p[4]);
5790 # FILE_NAME(tmp, @2);
5791 # p[0] = tmp;
5792 # }
5793 ()
5794
5795
5796 def p_expression_40(p):
5797 '''expression : expression K_GE attribute_list_opt expression '''
5798 if(parse_debug):
5799 print('expression_40', list(p))
5800
5801 p[0] = PEBinary(Leaf(token.STRING, '>='), p[1], p[4])
5802
5803 # { PEBinary*tmp = new PEBComp('G', p[1], p[4]);
5804 # FILE_NAME(tmp, @2);
5805 # p[0] = tmp;
5806 # }
5807 ()
5808
5809
5810 def p_expression_41(p):
5811 '''expression : expression K_NE attribute_list_opt expression '''
5812 if(parse_debug):
5813 print('expression_41', list(p))
5814
5815 p[0] = PEBinary(Leaf(token.STRING, '!='), p[1], p[4])
5816
5817 # { PEBinary*tmp = new PEBComp('n', p[1], p[4]);
5818 # FILE_NAME(tmp, @2);
5819 # p[0] = tmp;
5820 # }
5821 ()
5822
5823
5824 def p_expression_42(p):
5825 '''expression : expression K_CNE attribute_list_opt expression '''
5826 if(parse_debug):
5827 print('expression_42', list(p))
5828
5829 p[0] = PEBinary(Leaf(token.STRING, 'K_CNE'), p[1], p[4])
5830
5831 # { PEBinary*tmp = new PEBComp('N', p[1], p[4]);
5832 # FILE_NAME(tmp, @2);
5833 # p[0] = tmp;
5834 # }
5835 ()
5836
5837
5838 def p_expression_43(p):
5839 '''expression : expression K_WNE attribute_list_opt expression '''
5840 if(parse_debug):
5841 print('expression_43', list(p))
5842
5843 p[0] = PEBinary(Leaf(token.STRING, 'K_WNE'), p[1], p[4])
5844
5845 # { PEBinary*tmp = new PEBComp('W', p[1], p[4]);
5846 # FILE_NAME(tmp, @2);
5847 # p[0] = tmp;
5848 # }
5849 ()
5850
5851
5852 def p_expression_44(p):
5853 '''expression : expression K_LOR attribute_list_opt expression '''
5854 if(parse_debug):
5855 print('expression_44', list(p))
5856
5857 p[0] = PEBinary(Leaf(token.STRING, '||'), p[1], p[4])
5858
5859 # { PEBinary*tmp = new PEBLogic('o', p[1], p[4]);
5860 # FILE_NAME(tmp, @2);
5861 # p[0] = tmp;
5862 # }
5863 ()
5864
5865
5866 def p_expression_45(p):
5867 '''expression : expression K_LAND attribute_list_opt expression '''
5868 if(parse_debug):
5869 print('expression_45', list(p))
5870
5871 p[0] = PEBinary(Leaf(token.STRING, '&&'), p[1], p[4])
5872
5873 # { PEBinary*tmp = new PEBLogic('a', p[1], p[4]);
5874 # FILE_NAME(tmp, @2);
5875 # p[0] = tmp;
5876 # }
5877 ()
5878
5879
5880 def p_expression_46(p):
5881 '''expression : expression '?' attribute_list_opt expression ':' expression '''
5882 if(parse_debug):
5883 print('expression_46', list(p))
5884
5885 p[0] = Node(syms.atom, [p[1], Leaf(token.STRING, ' ? '),
5886 p[4], Leaf(token.STRING, ' : '), p[6]])
5887
5888 # { PETernary*tmp = new PETernary(p[1], p[4], p[6]);
5889 # FILE_NAME(tmp, @2);
5890 # p[0] = tmp;
5891 # }
5892 ()
5893
5894
5895 def p_expr_mintypmax_1(p):
5896 '''expr_mintypmax : expression '''
5897 if(parse_debug):
5898 print('expr_mintypmax_1', list(p))
5899 p[0] = p[1]
5900
5901
5902 ()
5903
5904
5905 def p_expr_mintypmax_2(p):
5906 '''expr_mintypmax : expression ':' expression ':' expression '''
5907 if(parse_debug):
5908 print('expr_mintypmax_2', list(p))
5909
5910 # { switch (min_typ_max_flag) {
5911 # case MIN:
5912 # p[0] = p[1];
5913 # delete p[3];
5914 # delete p[5];
5915 # break;
5916 # case TYP:
5917 # delete p[1];
5918 # p[0] = p[3];
5919 # delete p[5];
5920 # break;
5921 # case MAX:
5922 # delete p[1];
5923 # delete p[3];
5924 # p[0] = p[5];
5925 # break;
5926 # }
5927 # if (min_typ_max_warn > 0) {
5928 # cerr << p[0]->get_fileline() << ": warning: choosing ";
5929 # switch (min_typ_max_flag) {
5930 # case MIN:
5931 # cerr << "min";
5932 # break;
5933 # case TYP:
5934 # cerr << "typ";
5935 # break;
5936 # case MAX:
5937 # cerr << "max";
5938 # break;
5939 # }
5940 # cerr << " expression." << endl;
5941 # min_typ_max_warn -= 1;
5942 # }
5943 # }
5944 ()
5945
5946
5947 def p_expression_list_with_nuls_1(p):
5948 '''expression_list_with_nuls : expression_list_with_nuls ',' expression '''
5949 if(parse_debug):
5950 print('expression_list_with_nuls_1', list(p))
5951
5952 # { list<PExpr*>*tmp = p[1];
5953 # tmp->push_back(p[3]);
5954 # p[0] = tmp;
5955 # }
5956 ()
5957
5958
5959 def p_expression_list_with_nuls_2(p):
5960 '''expression_list_with_nuls : expression '''
5961 if(parse_debug):
5962 print('expression_list_with_nuls_2', list(p))
5963
5964 # { list<PExpr*>*tmp = new list<PExpr*>;
5965 # tmp->push_back(p[1]);
5966 # p[0] = tmp;
5967 # }
5968 ()
5969
5970
5971 def p_expression_list_with_nuls_3(p):
5972 '''expression_list_with_nuls : '''
5973 if(parse_debug):
5974 print('expression_list_with_nuls_3', list(p))
5975
5976 # { list<PExpr*>*tmp = new list<PExpr*>;
5977 # tmp->push_back(0);
5978 # p[0] = tmp;
5979 # }
5980 ()
5981
5982
5983 def p_expression_list_with_nuls_4(p):
5984 '''expression_list_with_nuls : expression_list_with_nuls ',' '''
5985 if(parse_debug):
5986 print('expression_list_with_nuls_4', list(p))
5987
5988 # { list<PExpr*>*tmp = p[1];
5989 # tmp->push_back(0);
5990 # p[0] = tmp;
5991 # }
5992 ()
5993
5994
5995 def p_expression_list_proper_1(p):
5996 '''expression_list_proper : expression_list_proper ',' expression '''
5997 if(parse_debug):
5998 print('expression_list_proper_1', list(p))
5999
6000 # { list<PExpr*>*tmp = p[1];
6001 # tmp->push_back(p[3]);
6002 # p[0] = tmp;
6003 # }
6004 ()
6005
6006
6007 def p_expression_list_proper_2(p):
6008 '''expression_list_proper : expression '''
6009 if(parse_debug):
6010 print('expression_list_proper_2', list(p))
6011
6012 # { list<PExpr*>*tmp = new list<PExpr*>;
6013 # tmp->push_back(p[1]);
6014 # p[0] = tmp;
6015 # }
6016 ()
6017
6018
6019 def p_expr_primary_or_typename_1(p):
6020 '''expr_primary_or_typename : expr_primary '''
6021 if(parse_debug > 2):
6022 print('expr_primary_or_typename_1', list(p))
6023 p[0] = p[1]
6024
6025
6026 ()
6027
6028
6029 def p_expr_primary_or_typename_2(p):
6030 '''expr_primary_or_typename : TYPE_IDENTIFIER '''
6031 if(parse_debug):
6032 print('expr_primary_or_typename_2', list(p))
6033 p[0] = p[1]
6034
6035 # { PETypename*tmp = new PETypename(p[1].type);
6036 # FILE_NAME(tmp,@1);
6037 # p[0] = tmp;
6038 # delete[]p[1].text;
6039 # }
6040 ()
6041
6042
6043 def p_expr_primary_1(p):
6044 '''expr_primary : number '''
6045 if(parse_debug):
6046 print('expr_primary_1', list(p))
6047 p[0] = p[1]
6048
6049 # { assert(p[1]);
6050 # PENumber*tmp = new PENumber(p[1]);
6051 # FILE_NAME(tmp, @1);
6052 # p[0] = tmp;
6053 # }
6054 ()
6055
6056
6057 def p_expr_primary_2(p):
6058 '''expr_primary : REALTIME '''
6059 if(parse_debug):
6060 print('expr_primary_2', list(p))
6061
6062 # { PEFNumber*tmp = new PEFNumber(p[1]);
6063 # FILE_NAME(tmp, @1);
6064 # p[0] = tmp;
6065 # }
6066 ()
6067
6068
6069 def p_expr_primary_3(p):
6070 '''expr_primary : STRING '''
6071 if(parse_debug):
6072 print('expr_primary_3', list(p))
6073
6074 # { PEString*tmp = new PEString(p[1]);
6075 # FILE_NAME(tmp, @1);
6076 # p[0] = tmp;
6077 # }
6078 ()
6079
6080
6081 def p_expr_primary_4(p):
6082 '''expr_primary : TIME_LITERAL '''
6083 if(parse_debug):
6084 print('expr_primary_4', list(p))
6085
6086 # { int unit;
6087 #
6088 # based_size = 0;
6089 # p[0] = 0;
6090 # if (p[1] == 0 || !get_time_unit(p[1], unit))
6091 # yyerror(@1, "internal error: delay.");
6092 # else {
6093 # double p = pow(10.0, (double)(unit - pform_get_timeunit()));
6094 # double time = atof(p[1]) * p;
6095 #
6096 # verireal *v = new verireal(time);
6097 # p[0] = new PEFNumber(v);
6098 # FILE_NAME(p[0], @1);
6099 # }
6100 # }
6101 ()
6102
6103
6104 def p_expr_primary_5(p):
6105 '''expr_primary : SYSTEM_IDENTIFIER '''
6106 if(parse_debug):
6107 print('expr_primary_5', list(p))
6108
6109 # { perm_string tn = lex_strings.make(p[1]);
6110 # PECallFunction*tmp = new PECallFunction(tn);
6111 # FILE_NAME(tmp, @1);
6112 # p[0] = tmp;
6113 # delete[]p[1];
6114 # }
6115 ()
6116
6117
6118 def p_expr_primary_6(p):
6119 '''expr_primary : hierarchy_identifier '''
6120 if(parse_debug > 2):
6121 print('expr_primary_6', list(p))
6122 p[0] = p[1]
6123
6124 # { PEIdent*tmp = pform_new_ident(*p[1]);
6125 # FILE_NAME(tmp, @1);
6126 # p[0] = tmp;
6127 # delete p[1];
6128 # }
6129 ()
6130
6131
6132 def p_expr_primary_7(p):
6133 '''expr_primary : PACKAGE_IDENTIFIER K_SCOPE_RES hierarchy_identifier '''
6134 if(parse_debug):
6135 print('expr_primary_7', list(p))
6136
6137 # { p[0] = pform_package_ident(@2, p[1], p[3]);
6138 # delete p[3];
6139 # }
6140 ()
6141
6142
6143 def p_expr_primary_8(p):
6144 '''expr_primary : hierarchy_identifier '(' expression_list_with_nuls ')' '''
6145 if(parse_debug):
6146 print('expr_primary_8', list(p))
6147
6148 # { list<PExpr*>*expr_list = p[3];
6149 # strip_tail_items(expr_list);
6150 # PECallFunction*tmp = pform_make_call_function(@1, *p[1], *expr_list);
6151 # delete p[1];
6152 # p[0] = tmp;
6153 # }
6154 ()
6155
6156
6157 def p_expr_primary_9(p):
6158 '''expr_primary : implicit_class_handle '.' hierarchy_identifier '(' expression_list_with_nuls ')' '''
6159 if(parse_debug):
6160 print('expr_primary_9', list(p))
6161
6162 # { pform_name_t*t_name = p[1];
6163 # while (! p[3]->empty()) {
6164 # t_name->push_back(p[3]->front());
6165 # p[3]->pop_front();
6166 # }
6167 # list<PExpr*>*expr_list = p[5];
6168 # strip_tail_items(expr_list);
6169 # PECallFunction*tmp = pform_make_call_function(@1, *t_name, *expr_list);
6170 # delete p[1];
6171 # delete p[3];
6172 # p[0] = tmp;
6173 # }
6174 ()
6175
6176
6177 def p_expr_primary_10(p):
6178 '''expr_primary : SYSTEM_IDENTIFIER '(' expression_list_proper ')' '''
6179 if(parse_debug):
6180 print('expr_primary_10', list(p))
6181
6182 # { perm_string tn = lex_strings.make(p[1]);
6183 # PECallFunction*tmp = new PECallFunction(tn, *p[3]);
6184 # FILE_NAME(tmp, @1);
6185 # delete[]p[1];
6186 # p[0] = tmp;
6187 # }
6188 ()
6189
6190
6191 def p_expr_primary_11(p):
6192 '''expr_primary : PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '(' expression_list_proper ')' '''
6193 if(parse_debug):
6194 print('expr_primary_11', list(p))
6195
6196 # { perm_string use_name = lex_strings.make(p[3]);
6197 # PECallFunction*tmp = new PECallFunction(p[1], use_name, *p[5]);
6198 # FILE_NAME(tmp, @3);
6199 # delete[]p[3];
6200 # p[0] = tmp;
6201 # }
6202 ()
6203
6204
6205 def p_expr_primary_12(p):
6206 '''expr_primary : SYSTEM_IDENTIFIER '(' ')' '''
6207 if(parse_debug):
6208 print('expr_primary_12', list(p))
6209
6210 # { perm_string tn = lex_strings.make(p[1]);
6211 # const vector<PExpr*>empty;
6212 # PECallFunction*tmp = new PECallFunction(tn, empty);
6213 # FILE_NAME(tmp, @1);
6214 # delete[]p[1];
6215 # p[0] = tmp;
6216 # if (!gn_system_verilog()) {
6217 # yyerror(@1, "error: Empty function argument list requires SystemVerilog.");
6218 # }
6219 # }
6220 ()
6221
6222
6223 def p_expr_primary_13(p):
6224 '''expr_primary : implicit_class_handle '''
6225 if(parse_debug):
6226 print('expr_primary_13', list(p))
6227
6228 # { PEIdent*tmp = new PEIdent(*p[1]);
6229 # FILE_NAME(tmp,@1);
6230 # delete p[1];
6231 # p[0] = tmp;
6232 # }
6233 ()
6234
6235
6236 def p_expr_primary_14(p):
6237 '''expr_primary : implicit_class_handle '.' hierarchy_identifier '''
6238 if(parse_debug):
6239 print('expr_primary_14', list(p))
6240
6241 # { pform_name_t*t_name = p[1];
6242 # while (! p[3]->empty()) {
6243 # t_name->push_back(p[3]->front());
6244 # p[3]->pop_front();
6245 # }
6246 # PEIdent*tmp = new PEIdent(*t_name);
6247 # FILE_NAME(tmp,@1);
6248 # delete p[1];
6249 # delete p[3];
6250 # p[0] = tmp;
6251 # }
6252 ()
6253
6254
6255 def p_expr_primary_15(p):
6256 '''expr_primary : K_acos '(' expression ')' '''
6257 if(parse_debug):
6258 print('expr_primary_15', list(p))
6259
6260 # { perm_string tn = perm_string::literal("$acos");
6261 # PECallFunction*tmp = make_call_function(tn, p[3]);
6262 # FILE_NAME(tmp,@1);
6263 # p[0] = tmp;
6264 # }
6265 ()
6266
6267
6268 def p_expr_primary_16(p):
6269 '''expr_primary : K_acosh '(' expression ')' '''
6270 if(parse_debug):
6271 print('expr_primary_16', list(p))
6272
6273 # { perm_string tn = perm_string::literal("$acosh");
6274 # PECallFunction*tmp = make_call_function(tn, p[3]);
6275 # FILE_NAME(tmp,@1);
6276 # p[0] = tmp;
6277 # }
6278 ()
6279
6280
6281 def p_expr_primary_17(p):
6282 '''expr_primary : K_asin '(' expression ')' '''
6283 if(parse_debug):
6284 print('expr_primary_17', list(p))
6285
6286 # { perm_string tn = perm_string::literal("$asin");
6287 # PECallFunction*tmp = make_call_function(tn, p[3]);
6288 # FILE_NAME(tmp,@1);
6289 # p[0] = tmp;
6290 # }
6291 ()
6292
6293
6294 def p_expr_primary_18(p):
6295 '''expr_primary : K_asinh '(' expression ')' '''
6296 if(parse_debug):
6297 print('expr_primary_18', list(p))
6298
6299 # { perm_string tn = perm_string::literal("$asinh");
6300 # PECallFunction*tmp = make_call_function(tn, p[3]);
6301 # FILE_NAME(tmp,@1);
6302 # p[0] = tmp;
6303 # }
6304 ()
6305
6306
6307 def p_expr_primary_19(p):
6308 '''expr_primary : K_atan '(' expression ')' '''
6309 if(parse_debug):
6310 print('expr_primary_19', list(p))
6311
6312 # { perm_string tn = perm_string::literal("$atan");
6313 # PECallFunction*tmp = make_call_function(tn, p[3]);
6314 # FILE_NAME(tmp,@1);
6315 # p[0] = tmp;
6316 # }
6317 ()
6318
6319
6320 def p_expr_primary_20(p):
6321 '''expr_primary : K_atanh '(' expression ')' '''
6322 if(parse_debug):
6323 print('expr_primary_20', list(p))
6324
6325 # { perm_string tn = perm_string::literal("$atanh");
6326 # PECallFunction*tmp = make_call_function(tn, p[3]);
6327 # FILE_NAME(tmp,@1);
6328 # p[0] = tmp;
6329 # }
6330 ()
6331
6332
6333 def p_expr_primary_21(p):
6334 '''expr_primary : K_atan2 '(' expression ',' expression ')' '''
6335 if(parse_debug):
6336 print('expr_primary_21', list(p))
6337
6338 # { perm_string tn = perm_string::literal("$atan2");
6339 # PECallFunction*tmp = make_call_function(tn, p[3], p[5]);
6340 # FILE_NAME(tmp,@1);
6341 # p[0] = tmp;
6342 # }
6343 ()
6344
6345
6346 def p_expr_primary_22(p):
6347 '''expr_primary : K_ceil '(' expression ')' '''
6348 if(parse_debug):
6349 print('expr_primary_22', list(p))
6350
6351 # { perm_string tn = perm_string::literal("$ceil");
6352 # PECallFunction*tmp = make_call_function(tn, p[3]);
6353 # FILE_NAME(tmp,@1);
6354 # p[0] = tmp;
6355 # }
6356 ()
6357
6358
6359 def p_expr_primary_23(p):
6360 '''expr_primary : K_cos '(' expression ')' '''
6361 if(parse_debug):
6362 print('expr_primary_23', list(p))
6363
6364 # { perm_string tn = perm_string::literal("$cos");
6365 # PECallFunction*tmp = make_call_function(tn, p[3]);
6366 # FILE_NAME(tmp,@1);
6367 # p[0] = tmp;
6368 # }
6369 ()
6370
6371
6372 def p_expr_primary_24(p):
6373 '''expr_primary : K_cosh '(' expression ')' '''
6374 if(parse_debug):
6375 print('expr_primary_24', list(p))
6376
6377 # { perm_string tn = perm_string::literal("$cosh");
6378 # PECallFunction*tmp = make_call_function(tn, p[3]);
6379 # FILE_NAME(tmp,@1);
6380 # p[0] = tmp;
6381 # }
6382 ()
6383
6384
6385 def p_expr_primary_25(p):
6386 '''expr_primary : K_exp '(' expression ')' '''
6387 if(parse_debug):
6388 print('expr_primary_25', list(p))
6389
6390 # { perm_string tn = perm_string::literal("$exp");
6391 # PECallFunction*tmp = make_call_function(tn, p[3]);
6392 # FILE_NAME(tmp,@1);
6393 # p[0] = tmp;
6394 # }
6395 ()
6396
6397
6398 def p_expr_primary_26(p):
6399 '''expr_primary : K_floor '(' expression ')' '''
6400 if(parse_debug):
6401 print('expr_primary_26', list(p))
6402
6403 # { perm_string tn = perm_string::literal("$floor");
6404 # PECallFunction*tmp = make_call_function(tn, p[3]);
6405 # FILE_NAME(tmp,@1);
6406 # p[0] = tmp;
6407 # }
6408 ()
6409
6410
6411 def p_expr_primary_27(p):
6412 '''expr_primary : K_hypot '(' expression ',' expression ')' '''
6413 if(parse_debug):
6414 print('expr_primary_27', list(p))
6415
6416 # { perm_string tn = perm_string::literal("$hypot");
6417 # PECallFunction*tmp = make_call_function(tn, p[3], p[5]);
6418 # FILE_NAME(tmp,@1);
6419 # p[0] = tmp;
6420 # }
6421 ()
6422
6423
6424 def p_expr_primary_28(p):
6425 '''expr_primary : K_ln '(' expression ')' '''
6426 if(parse_debug):
6427 print('expr_primary_28', list(p))
6428
6429 # { perm_string tn = perm_string::literal("$ln");
6430 # PECallFunction*tmp = make_call_function(tn, p[3]);
6431 # FILE_NAME(tmp,@1);
6432 # p[0] = tmp;
6433 # }
6434 ()
6435
6436
6437 def p_expr_primary_29(p):
6438 '''expr_primary : K_log '(' expression ')' '''
6439 if(parse_debug):
6440 print('expr_primary_29', list(p))
6441
6442 # { perm_string tn = perm_string::literal("$log10");
6443 # PECallFunction*tmp = make_call_function(tn, p[3]);
6444 # FILE_NAME(tmp,@1);
6445 # p[0] = tmp;
6446 # }
6447 ()
6448
6449
6450 def p_expr_primary_30(p):
6451 '''expr_primary : K_pow '(' expression ',' expression ')' '''
6452 if(parse_debug):
6453 print('expr_primary_30', list(p))
6454
6455 # { perm_string tn = perm_string::literal("$pow");
6456 # PECallFunction*tmp = make_call_function(tn, p[3], p[5]);
6457 # FILE_NAME(tmp,@1);
6458 # p[0] = tmp;
6459 # }
6460 ()
6461
6462
6463 def p_expr_primary_31(p):
6464 '''expr_primary : K_sin '(' expression ')' '''
6465 if(parse_debug):
6466 print('expr_primary_31', list(p))
6467
6468 # { perm_string tn = perm_string::literal("$sin");
6469 # PECallFunction*tmp = make_call_function(tn, p[3]);
6470 # FILE_NAME(tmp,@1);
6471 # p[0] = tmp;
6472 # }
6473 ()
6474
6475
6476 def p_expr_primary_32(p):
6477 '''expr_primary : K_sinh '(' expression ')' '''
6478 if(parse_debug):
6479 print('expr_primary_32', list(p))
6480
6481 # { perm_string tn = perm_string::literal("$sinh");
6482 # PECallFunction*tmp = make_call_function(tn, p[3]);
6483 # FILE_NAME(tmp,@1);
6484 # p[0] = tmp;
6485 # }
6486 ()
6487
6488
6489 def p_expr_primary_33(p):
6490 '''expr_primary : K_sqrt '(' expression ')' '''
6491 if(parse_debug):
6492 print('expr_primary_33', list(p))
6493
6494 # { perm_string tn = perm_string::literal("$sqrt");
6495 # PECallFunction*tmp = make_call_function(tn, p[3]);
6496 # FILE_NAME(tmp,@1);
6497 # p[0] = tmp;
6498 # }
6499 ()
6500
6501
6502 def p_expr_primary_34(p):
6503 '''expr_primary : K_tan '(' expression ')' '''
6504 if(parse_debug):
6505 print('expr_primary_34', list(p))
6506
6507 # { perm_string tn = perm_string::literal("$tan");
6508 # PECallFunction*tmp = make_call_function(tn, p[3]);
6509 # FILE_NAME(tmp,@1);
6510 # p[0] = tmp;
6511 # }
6512 ()
6513
6514
6515 def p_expr_primary_35(p):
6516 '''expr_primary : K_tanh '(' expression ')' '''
6517 if(parse_debug):
6518 print('expr_primary_35', list(p))
6519
6520 # { perm_string tn = perm_string::literal("$tanh");
6521 # PECallFunction*tmp = make_call_function(tn, p[3]);
6522 # FILE_NAME(tmp,@1);
6523 # p[0] = tmp;
6524 # }
6525 ()
6526
6527
6528 def p_expr_primary_36(p):
6529 '''expr_primary : K_abs '(' expression ')' '''
6530 if(parse_debug):
6531 print('expr_primary_36', list(p))
6532
6533 # { PEUnary*tmp = new PEUnary('m', p[3]);
6534 # FILE_NAME(tmp,@1);
6535 # p[0] = tmp;
6536 # }
6537 ()
6538
6539
6540 def p_expr_primary_37(p):
6541 '''expr_primary : K_max '(' expression ',' expression ')' '''
6542 if(parse_debug):
6543 print('expr_primary_37', list(p))
6544
6545 # { PEBinary*tmp = new PEBinary('M', p[3], p[5]);
6546 # FILE_NAME(tmp,@1);
6547 # p[0] = tmp;
6548 # }
6549 ()
6550
6551
6552 def p_expr_primary_38(p):
6553 '''expr_primary : K_min '(' expression ',' expression ')' '''
6554 if(parse_debug):
6555 print('expr_primary_38', list(p))
6556
6557 # { PEBinary*tmp = new PEBinary('m', p[3], p[5]);
6558 # FILE_NAME(tmp,@1);
6559 # p[0] = tmp;
6560 # }
6561 ()
6562
6563
6564 def p_expr_primary_39(p):
6565 '''expr_primary : '(' expr_mintypmax ')' '''
6566 if(parse_debug):
6567 print('expr_primary_39', list(p))
6568 p[0] = p[2]
6569
6570
6571 ()
6572
6573
6574 def p_expr_primary_40(p):
6575 '''expr_primary : '{' expression_list_proper '}' '''
6576 if(parse_debug):
6577 print('expr_primary_40', list(p))
6578
6579 # { PEConcat*tmp = new PEConcat(*p[2]);
6580 # FILE_NAME(tmp, @1);
6581 # delete p[2];
6582 # p[0] = tmp;
6583 # }
6584 ()
6585
6586
6587 def p_expr_primary_41(p):
6588 '''expr_primary : '{' expression '{' expression_list_proper '}' '}' '''
6589 if(parse_debug):
6590 print('expr_primary_41', list(p))
6591
6592 # { PExpr*rep = p[2];
6593 # PEConcat*tmp = new PEConcat(*p[4], rep);
6594 # FILE_NAME(tmp, @1);
6595 # delete p[4];
6596 # p[0] = tmp;
6597 # }
6598 ()
6599
6600
6601 def p_expr_primary_42(p):
6602 '''expr_primary : '{' expression '{' expression_list_proper '}' error '}' '''
6603 if(parse_debug):
6604 print('expr_primary_42', list(p))
6605
6606 # { PExpr*rep = p[2];
6607 # PEConcat*tmp = new PEConcat(*p[4], rep);
6608 # FILE_NAME(tmp, @1);
6609 # delete p[4];
6610 # p[0] = tmp;
6611 # yyerror(@5, "error: Syntax error between internal '}' "
6612 # "and closing '}' of repeat concatenation.");
6613 # yyerrok;
6614 # }
6615 ()
6616
6617
6618 def p_expr_primary_43(p):
6619 '''expr_primary : '{' '}' '''
6620 if(parse_debug):
6621 print('expr_primary_43', list(p))
6622
6623 # { // This is the empty queue syntax.
6624 # if (gn_system_verilog()) {
6625 # list<PExpr*> empty_list;
6626 # PEConcat*tmp = new PEConcat(empty_list);
6627 # FILE_NAME(tmp, @1);
6628 # p[0] = tmp;
6629 # } else {
6630 # yyerror(@1, "error: Concatenations are not allowed to be empty.");
6631 # p[0] = None
6632 # }
6633 # }
6634 ()
6635
6636
6637 def p_expr_primary_44(p):
6638 '''expr_primary : expr_primary "'" '(' expression ')' '''
6639 if(parse_debug):
6640 print('expr_primary_44', list(p))
6641
6642 # { PExpr*base = p[4];
6643 # if (gn_system_verilog()) {
6644 # PECastSize*tmp = new PECastSize(p[1], base);
6645 # FILE_NAME(tmp, @1);
6646 # p[0] = tmp;
6647 # } else {
6648 # yyerror(@1, "error: Size cast requires SystemVerilog.");
6649 # p[0] = base;
6650 # }
6651 # }
6652 ()
6653
6654
6655 def p_expr_primary_45(p):
6656 '''expr_primary : simple_type_or_string "'" '(' expression ')' '''
6657 if(parse_debug):
6658 print('expr_primary_45', list(p))
6659
6660 # { PExpr*base = p[4];
6661 # if (gn_system_verilog()) {
6662 # PECastType*tmp = new PECastType(p[1], base);
6663 # FILE_NAME(tmp, @1);
6664 # p[0] = tmp;
6665 # } else {
6666 # yyerror(@1, "error: Type cast requires SystemVerilog.");
6667 # p[0] = base;
6668 # }
6669 # }
6670 ()
6671
6672
6673 def p_expr_primary_46(p):
6674 '''expr_primary : assignment_pattern '''
6675 if(parse_debug):
6676 print('expr_primary_46', list(p))
6677 p[0] = p[1]
6678
6679
6680 ()
6681
6682
6683 def p_expr_primary_47(p):
6684 '''expr_primary : streaming_concatenation '''
6685 if(parse_debug):
6686 print('expr_primary_47', list(p))
6687 p[0] = p[1]
6688
6689
6690 ()
6691
6692
6693 def p_expr_primary_48(p):
6694 '''expr_primary : K_null '''
6695 if(parse_debug):
6696 print('expr_primary_48', list(p))
6697
6698 # { PENull*tmp = new PENull;
6699 # FILE_NAME(tmp, @1);
6700 # p[0] = tmp;
6701 # }
6702 ()
6703
6704
6705 def p_function_item_list_opt_1(p):
6706 '''function_item_list_opt : function_item_list '''
6707 if(parse_debug):
6708 print('function_item_list_opt_1', list(p))
6709 p[0] = p[1]
6710
6711
6712 ()
6713
6714
6715 def p_function_item_list_opt_2(p):
6716 '''function_item_list_opt : '''
6717 if(parse_debug):
6718 print('function_item_list_opt_2', list(p))
6719
6720 # { p[0] = None }
6721 ()
6722
6723
6724 def p_function_item_list_1(p):
6725 '''function_item_list : function_item '''
6726 if(parse_debug):
6727 print('function_item_list_1', list(p))
6728 p[0] = p[1]
6729
6730
6731 ()
6732
6733
6734 def p_function_item_list_2(p):
6735 '''function_item_list : function_item_list function_item '''
6736 if(parse_debug):
6737 print('function_item_list_2', list(p))
6738
6739 # { /* */
6740 # if (p[1] && p[2]) {
6741 # vector<pform_tf_port_t>*tmp = p[1];
6742 # size_t s1 = tmp->size();
6743 # tmp->resize(s1 + p[2]->size());
6744 # for (size_t idx = 0 ; idx < p[2]->size() ; idx += 1)
6745 # tmp->at(s1+idx) = p[2]->at(idx);
6746 # delete p[2];
6747 # p[0] = tmp;
6748 # } else if (p[1]) {
6749 # p[0] = p[1];
6750 # } else {
6751 # p[0] = p[2];
6752 # }
6753 # }
6754 ()
6755
6756
6757 def p_function_item_1(p):
6758 '''function_item : tf_port_declaration '''
6759 if(parse_debug):
6760 print('function_item_1', list(p))
6761 p[0] = p[1]
6762
6763
6764 ()
6765
6766
6767 def p_function_item_2(p):
6768 '''function_item : block_item_decl '''
6769 if(parse_debug):
6770 print('function_item_2', list(p))
6771
6772 # { p[0] = None }
6773 ()
6774
6775
6776 def p_gate_instance_1(p):
6777 '''gate_instance : IDENTIFIER '(' expression_list_with_nuls ')' '''
6778 if(parse_debug):
6779 print('gate_instance_1', list(p))
6780
6781 # { lgate*tmp = new lgate;
6782 # tmp->name = p[1];
6783 # tmp->parms = p[3];
6784 # tmp->file = @1.text;
6785 # tmp->lineno = @1.first_line;
6786 # delete[]p[1];
6787 # p[0] = tmp;
6788 # }
6789 ()
6790
6791
6792 def p_gate_instance_2(p):
6793 '''gate_instance : IDENTIFIER dimensions '(' expression_list_with_nuls ')' '''
6794 if(parse_debug):
6795 print('gate_instance_2', list(p))
6796
6797 # { lgate*tmp = new lgate;
6798 # list<pform_range_t>*rng = p[2];
6799 # tmp->name = p[1];
6800 # tmp->parms = p[4];
6801 # tmp->range = rng->front();
6802 # rng->pop_front();
6803 # assert(rng->empty());
6804 # tmp->file = @1.text;
6805 # tmp->lineno = @1.first_line;
6806 # delete[]p[1];
6807 # delete rng;
6808 # p[0] = tmp;
6809 # }
6810 ()
6811
6812
6813 def p_gate_instance_3(p):
6814 '''gate_instance : '(' expression_list_with_nuls ')' '''
6815 if(parse_debug):
6816 print('gate_instance_3', list(p))
6817
6818 # { lgate*tmp = new lgate;
6819 # tmp->name = "";
6820 # tmp->parms = p[2];
6821 # tmp->file = @1.text;
6822 # tmp->lineno = @1.first_line;
6823 # p[0] = tmp;
6824 # }
6825 ()
6826
6827
6828 def p_gate_instance_4(p):
6829 '''gate_instance : IDENTIFIER dimensions '''
6830 if(parse_debug):
6831 print('gate_instance_4', list(p))
6832
6833 # { lgate*tmp = new lgate;
6834 # list<pform_range_t>*rng = p[2];
6835 # tmp->name = p[1];
6836 # tmp->parms = 0;
6837 # tmp->parms_by_name = 0;
6838 # tmp->range = rng->front();
6839 # rng->pop_front();
6840 # assert(rng->empty());
6841 # tmp->file = @1.text;
6842 # tmp->lineno = @1.first_line;
6843 # delete[]p[1];
6844 # delete rng;
6845 # p[0] = tmp;
6846 # }
6847 ()
6848
6849
6850 def p_gate_instance_5(p):
6851 '''gate_instance : IDENTIFIER '(' port_name_list ')' '''
6852 if(parse_debug):
6853 print('gate_instance_5', list(p))
6854
6855 # { lgate*tmp = new lgate;
6856 # tmp->name = p[1];
6857 # tmp->parms = 0;
6858 # tmp->parms_by_name = p[3];
6859 # tmp->file = @1.text;
6860 # tmp->lineno = @1.first_line;
6861 # delete[]p[1];
6862 # p[0] = tmp;
6863 # }
6864 ()
6865
6866
6867 def p_gate_instance_6(p):
6868 '''gate_instance : IDENTIFIER dimensions '(' port_name_list ')' '''
6869 if(parse_debug):
6870 print('gate_instance_6', list(p))
6871
6872 # { lgate*tmp = new lgate;
6873 # list<pform_range_t>*rng = p[2];
6874 # tmp->name = p[1];
6875 # tmp->parms = 0;
6876 # tmp->parms_by_name = p[4];
6877 # tmp->range = rng->front();
6878 # rng->pop_front();
6879 # assert(rng->empty());
6880 # tmp->file = @1.text;
6881 # tmp->lineno = @1.first_line;
6882 # delete[]p[1];
6883 # delete rng;
6884 # p[0] = tmp;
6885 # }
6886 ()
6887
6888
6889 def p_gate_instance_7(p):
6890 '''gate_instance : IDENTIFIER '(' error ')' '''
6891 if(parse_debug):
6892 print('gate_instance_7', list(p))
6893
6894 # { lgate*tmp = new lgate;
6895 # tmp->name = p[1];
6896 # tmp->parms = 0;
6897 # tmp->parms_by_name = 0;
6898 # tmp->file = @1.text;
6899 # tmp->lineno = @1.first_line;
6900 # yyerror(@2, "error: Syntax error in instance port "
6901 # "expression(s).");
6902 # delete[]p[1];
6903 # p[0] = tmp;
6904 # }
6905 ()
6906
6907
6908 def p_gate_instance_8(p):
6909 '''gate_instance : IDENTIFIER dimensions '(' error ')' '''
6910 if(parse_debug):
6911 print('gate_instance_8', list(p))
6912
6913 # { lgate*tmp = new lgate;
6914 # tmp->name = p[1];
6915 # tmp->parms = 0;
6916 # tmp->parms_by_name = 0;
6917 # tmp->file = @1.text;
6918 # tmp->lineno = @1.first_line;
6919 # yyerror(@3, "error: Syntax error in instance port "
6920 # "expression(s).");
6921 # delete[]p[1];
6922 # p[0] = tmp;
6923 # }
6924 ()
6925
6926
6927 def p_gate_instance_list_1(p):
6928 '''gate_instance_list : gate_instance_list ',' gate_instance '''
6929 if(parse_debug):
6930 print('gate_instance_list_1', list(p))
6931
6932 # { svector<lgate>*tmp1 = p[1];
6933 # lgate*tmp2 = p[3];
6934 # svector<lgate>*out = new svector<lgate> (*tmp1, *tmp2);
6935 # delete tmp1;
6936 # delete tmp2;
6937 # p[0] = out;
6938 # }
6939 ()
6940
6941
6942 def p_gate_instance_list_2(p):
6943 '''gate_instance_list : gate_instance '''
6944 if(parse_debug):
6945 print('gate_instance_list_2', list(p))
6946
6947 # { svector<lgate>*tmp = new svector<lgate>(1);
6948 # (*tmp)[0] = *p[1];
6949 # delete p[1];
6950 # p[0] = tmp;
6951 # }
6952 ()
6953
6954
6955 def p_gatetype_1(p):
6956 '''gatetype : K_and '''
6957 if(parse_debug):
6958 print('gatetype_1', list(p))
6959
6960 # { p[0] = PGBuiltin::AND; }
6961 ()
6962
6963
6964 def p_gatetype_2(p):
6965 '''gatetype : K_nand '''
6966 if(parse_debug):
6967 print('gatetype_2', list(p))
6968
6969 # { p[0] = PGBuiltin::NAND; }
6970 ()
6971
6972
6973 def p_gatetype_3(p):
6974 '''gatetype : K_or '''
6975 if(parse_debug):
6976 print('gatetype_3', list(p))
6977
6978 # { p[0] = PGBuiltin::OR; }
6979 ()
6980
6981
6982 def p_gatetype_4(p):
6983 '''gatetype : K_nor '''
6984 if(parse_debug):
6985 print('gatetype_4', list(p))
6986
6987 # { p[0] = PGBuiltin::NOR; }
6988 ()
6989
6990
6991 def p_gatetype_5(p):
6992 '''gatetype : K_xor '''
6993 if(parse_debug):
6994 print('gatetype_5', list(p))
6995
6996 # { p[0] = PGBuiltin::XOR; }
6997 ()
6998
6999
7000 def p_gatetype_6(p):
7001 '''gatetype : K_xnor '''
7002 if(parse_debug):
7003 print('gatetype_6', list(p))
7004
7005 # { p[0] = PGBuiltin::XNOR; }
7006 ()
7007
7008
7009 def p_gatetype_7(p):
7010 '''gatetype : K_buf '''
7011 if(parse_debug):
7012 print('gatetype_7', list(p))
7013
7014 # { p[0] = PGBuiltin::BUF; }
7015 ()
7016
7017
7018 def p_gatetype_8(p):
7019 '''gatetype : K_bufif0 '''
7020 if(parse_debug):
7021 print('gatetype_8', list(p))
7022
7023 # { p[0] = PGBuiltin::BUFIF0; }
7024 ()
7025
7026
7027 def p_gatetype_9(p):
7028 '''gatetype : K_bufif1 '''
7029 if(parse_debug):
7030 print('gatetype_9', list(p))
7031
7032 # { p[0] = PGBuiltin::BUFIF1; }
7033 ()
7034
7035
7036 def p_gatetype_10(p):
7037 '''gatetype : K_not '''
7038 if(parse_debug):
7039 print('gatetype_10', list(p))
7040
7041 # { p[0] = PGBuiltin::NOT; }
7042 ()
7043
7044
7045 def p_gatetype_11(p):
7046 '''gatetype : K_notif0 '''
7047 if(parse_debug):
7048 print('gatetype_11', list(p))
7049
7050 # { p[0] = PGBuiltin::NOTIF0; }
7051 ()
7052
7053
7054 def p_gatetype_12(p):
7055 '''gatetype : K_notif1 '''
7056 if(parse_debug):
7057 print('gatetype_12', list(p))
7058
7059 # { p[0] = PGBuiltin::NOTIF1; }
7060 ()
7061
7062
7063 def p_switchtype_1(p):
7064 '''switchtype : K_nmos '''
7065 if(parse_debug):
7066 print('switchtype_1', list(p))
7067
7068 # { p[0] = PGBuiltin::NMOS; }
7069 ()
7070
7071
7072 def p_switchtype_2(p):
7073 '''switchtype : K_rnmos '''
7074 if(parse_debug):
7075 print('switchtype_2', list(p))
7076
7077 # { p[0] = PGBuiltin::RNMOS; }
7078 ()
7079
7080
7081 def p_switchtype_3(p):
7082 '''switchtype : K_pmos '''
7083 if(parse_debug):
7084 print('switchtype_3', list(p))
7085
7086 # { p[0] = PGBuiltin::PMOS; }
7087 ()
7088
7089
7090 def p_switchtype_4(p):
7091 '''switchtype : K_rpmos '''
7092 if(parse_debug):
7093 print('switchtype_4', list(p))
7094
7095 # { p[0] = PGBuiltin::RPMOS; }
7096 ()
7097
7098
7099 def p_switchtype_5(p):
7100 '''switchtype : K_cmos '''
7101 if(parse_debug):
7102 print('switchtype_5', list(p))
7103
7104 # { p[0] = PGBuiltin::CMOS; }
7105 ()
7106
7107
7108 def p_switchtype_6(p):
7109 '''switchtype : K_rcmos '''
7110 if(parse_debug):
7111 print('switchtype_6', list(p))
7112
7113 # { p[0] = PGBuiltin::RCMOS; }
7114 ()
7115
7116
7117 def p_switchtype_7(p):
7118 '''switchtype : K_tran '''
7119 if(parse_debug):
7120 print('switchtype_7', list(p))
7121
7122 # { p[0] = PGBuiltin::TRAN; }
7123 ()
7124
7125
7126 def p_switchtype_8(p):
7127 '''switchtype : K_rtran '''
7128 if(parse_debug):
7129 print('switchtype_8', list(p))
7130
7131 # { p[0] = PGBuiltin::RTRAN; }
7132 ()
7133
7134
7135 def p_switchtype_9(p):
7136 '''switchtype : K_tranif0 '''
7137 if(parse_debug):
7138 print('switchtype_9', list(p))
7139
7140 # { p[0] = PGBuiltin::TRANIF0; }
7141 ()
7142
7143
7144 def p_switchtype_10(p):
7145 '''switchtype : K_tranif1 '''
7146 if(parse_debug):
7147 print('switchtype_10', list(p))
7148
7149 # { p[0] = PGBuiltin::TRANIF1; }
7150 ()
7151
7152
7153 def p_switchtype_11(p):
7154 '''switchtype : K_rtranif0 '''
7155 if(parse_debug):
7156 print('switchtype_11', list(p))
7157
7158 # { p[0] = PGBuiltin::RTRANIF0; }
7159 ()
7160
7161
7162 def p_switchtype_12(p):
7163 '''switchtype : K_rtranif1 '''
7164 if(parse_debug):
7165 print('switchtype_12', list(p))
7166
7167 # { p[0] = PGBuiltin::RTRANIF1; }
7168 ()
7169
7170
7171 def p_hierarchy_identifier_1(p):
7172 '''hierarchy_identifier : IDENTIFIER '''
7173 if(parse_debug):
7174 print('hierarchy_identifier_1 FIXME', list(p))
7175 lpvalue = Leaf(token.NAME, p[1])
7176 p[0] = lpvalue
7177
7178 # { p[0] = new pform_name_t;
7179 # p[0]->push_back(name_component_t(lex_strings.make(p[1])));
7180 # delete[]p[1];
7181 # }
7182 ()
7183
7184
7185 def p_hierarchy_identifier_2(p):
7186 '''hierarchy_identifier : hierarchy_identifier '.' IDENTIFIER '''
7187 if(parse_debug):
7188 print('hierarchy_identifier_2', list(p))
7189
7190 # { pform_name_t * tmp = p[1];
7191 # tmp->push_back(name_component_t(lex_strings.make(p[3])));
7192 # delete[]p[3];
7193 # p[0] = tmp;
7194 # }
7195 ()
7196
7197
7198 def p_hierarchy_identifier_3(p):
7199 '''hierarchy_identifier : hierarchy_identifier '[' expression ']' '''
7200 if(parse_debug):
7201 print('hierarchy_identifier_3', list(p))
7202
7203 # { pform_name_t * tmp = p[1];
7204 # name_component_t&tail = tmp->back();
7205 # index_component_t itmp;
7206 # itmp.sel = index_component_t::SEL_BIT;
7207 # itmp.msb = p[3];
7208 # tail.index.push_back(itmp);
7209 # p[0] = tmp;
7210 # }
7211 ()
7212
7213
7214 def p_hierarchy_identifier_4(p):
7215 '''hierarchy_identifier : hierarchy_identifier '[' '$' ']' '''
7216 if(parse_debug):
7217 print('hierarchy_identifier_4', list(p))
7218
7219 # { pform_name_t * tmp = p[1];
7220 # name_component_t&tail = tmp->back();
7221 # if (! gn_system_verilog()) {
7222 # yyerror(@3, "error: Last element expression ($) "
7223 # "requires SystemVerilog. Try enabling SystemVerilog.");
7224 # }
7225 # index_component_t itmp;
7226 # itmp.sel = index_component_t::SEL_BIT_LAST;
7227 # itmp.msb = 0;
7228 # itmp.lsb = 0;
7229 # tail.index.push_back(itmp);
7230 # p[0] = tmp;
7231 # }
7232 ()
7233
7234
7235 def p_hierarchy_identifier_5(p):
7236 '''hierarchy_identifier : hierarchy_identifier '[' expression ':' expression ']' '''
7237 if(parse_debug):
7238 print('hierarchy_identifier_5', list(p))
7239
7240 # { pform_name_t * tmp = p[1];
7241 # name_component_t&tail = tmp->back();
7242 # index_component_t itmp;
7243 # itmp.sel = index_component_t::SEL_PART;
7244 # itmp.msb = p[3];
7245 # itmp.lsb = p[5];
7246 # tail.index.push_back(itmp);
7247 # p[0] = tmp;
7248 # }
7249 ()
7250
7251
7252 def p_hierarchy_identifier_6(p):
7253 '''hierarchy_identifier : hierarchy_identifier '[' expression K_PO_POS expression ']' '''
7254 if(parse_debug):
7255 print('hierarchy_identifier_6', list(p))
7256
7257 # { pform_name_t * tmp = p[1];
7258 # name_component_t&tail = tmp->back();
7259 # index_component_t itmp;
7260 # itmp.sel = index_component_t::SEL_IDX_UP;
7261 # itmp.msb = p[3];
7262 # itmp.lsb = p[5];
7263 # tail.index.push_back(itmp);
7264 # p[0] = tmp;
7265 # }
7266 ()
7267
7268
7269 def p_hierarchy_identifier_7(p):
7270 '''hierarchy_identifier : hierarchy_identifier '[' expression K_PO_NEG expression ']' '''
7271 if(parse_debug):
7272 print('hierarchy_identifier_7', list(p))
7273
7274 # { pform_name_t * tmp = p[1];
7275 # name_component_t&tail = tmp->back();
7276 # index_component_t itmp;
7277 # itmp.sel = index_component_t::SEL_IDX_DO;
7278 # itmp.msb = p[3];
7279 # itmp.lsb = p[5];
7280 # tail.index.push_back(itmp);
7281 # p[0] = tmp;
7282 # }
7283 ()
7284
7285
7286 def p_list_of_identifiers_1(p):
7287 '''list_of_identifiers : IDENTIFIER '''
7288 if(parse_debug):
7289 print('list_of_identifiers_1', list(p))
7290
7291 # { p[0] = list_from_identifier(p[1]); }
7292 ()
7293
7294
7295 def p_list_of_identifiers_2(p):
7296 '''list_of_identifiers : list_of_identifiers ',' IDENTIFIER '''
7297 if(parse_debug):
7298 print('list_of_identifiers_2', list(p))
7299
7300 # { p[0] = list_from_identifier(p[1], p[3]); }
7301 ()
7302
7303
7304 def p_list_of_port_identifiers_1(p):
7305 '''list_of_port_identifiers : IDENTIFIER dimensions_opt '''
7306 if(parse_debug):
7307 print('list_of_port_identifiers_1', list(p))
7308
7309 # { p[0] = make_port_list(p[1], p[2], 0); }
7310 ()
7311
7312
7313 def p_list_of_port_identifiers_2(p):
7314 '''list_of_port_identifiers : list_of_port_identifiers ',' IDENTIFIER dimensions_opt '''
7315 if(parse_debug):
7316 print('list_of_port_identifiers_2', list(p))
7317
7318 # { p[0] = make_port_list(p[1], p[3], p[4], 0); }
7319 ()
7320
7321
7322 def p_list_of_variable_port_identifiers_1(p):
7323 '''list_of_variable_port_identifiers : IDENTIFIER dimensions_opt '''
7324 if(parse_debug):
7325 print('list_of_variable_port_identifiers_1', list(p))
7326
7327 # { p[0] = make_port_list(p[1], p[2], 0); }
7328 ()
7329
7330
7331 def p_list_of_variable_port_identifiers_2(p):
7332 '''list_of_variable_port_identifiers : IDENTIFIER dimensions_opt '=' expression '''
7333 if(parse_debug):
7334 print('list_of_variable_port_identifiers_2', list(p))
7335
7336 # { p[0] = make_port_list(p[1], p[2], p[4]); }
7337 ()
7338
7339
7340 def p_list_of_variable_port_identifiers_3(p):
7341 '''list_of_variable_port_identifiers : list_of_variable_port_identifiers ',' IDENTIFIER dimensions_opt '''
7342 if(parse_debug):
7343 print('list_of_variable_port_identifiers_3', list(p))
7344
7345 # { p[0] = make_port_list(p[1], p[3], p[4], 0); }
7346 ()
7347
7348
7349 def p_list_of_variable_port_identifiers_4(p):
7350 '''list_of_variable_port_identifiers : list_of_variable_port_identifiers ',' IDENTIFIER dimensions_opt '=' expression '''
7351 if(parse_debug):
7352 print('list_of_variable_port_identifiers_4', list(p))
7353
7354 # { p[0] = make_port_list(p[1], p[3], p[4], p[6]); }
7355 ()
7356
7357
7358 def p_list_of_ports_1(p):
7359 '''list_of_ports : port_opt '''
7360 if(parse_debug):
7361 print('list_of_ports_1', list(p))
7362
7363 # { vector<Module::port_t*>*tmp
7364 # = new vector<Module::port_t*>(1);
7365 # (*tmp)[0] = p[1];
7366 # p[0] = tmp;
7367 # }
7368 ()
7369
7370
7371 def p_list_of_ports_2(p):
7372 '''list_of_ports : list_of_ports ',' port_opt '''
7373 if(parse_debug):
7374 print('list_of_ports_2', list(p))
7375
7376 # { vector<Module::port_t*>*tmp = p[1];
7377 # tmp->push_back(p[3]);
7378 # p[0] = tmp;
7379 # }
7380 ()
7381
7382
7383 def p_list_of_port_declarations_1(p):
7384 '''list_of_port_declarations : port_declaration '''
7385 if(parse_debug > 1):
7386 print('list_of_port_declarations_1', list(p))
7387 p[0] = [p[1]]
7388
7389 # { vector<Module::port_t*>*tmp
7390 # = new vector<Module::port_t*>(1);
7391 # (*tmp)[0] = p[1];
7392 # p[0] = tmp;
7393 # }
7394 ()
7395
7396
7397 def p_list_of_port_declarations_2(p):
7398 '''list_of_port_declarations : list_of_port_declarations ',' port_declaration '''
7399 if(parse_debug):
7400 print('list_of_port_declarations_2 FIXME', list(p))
7401 # MOVE_TO absyn p[1].append(Leaf(token.NEWLINE, '\n')) # should be a comma
7402 # XXX p[3].prefix=' ' # add a space after the NL, must go in parameter
7403 p[1].append(p[3])
7404 p[0] = p[1]
7405
7406 # { vector<Module::port_t*>*tmp = p[1];
7407 # tmp->push_back(p[3]);
7408 # p[0] = tmp;
7409 # }
7410 ()
7411
7412
7413 def p_list_of_port_declarations_3(p):
7414 '''list_of_port_declarations : list_of_port_declarations ',' IDENTIFIER '''
7415 if(parse_debug):
7416 print('list_of_port_declarations_3', list(p))
7417
7418 # { Module::port_t*ptmp;
7419 # perm_string name = lex_strings.make(p[3]);
7420 # ptmp = pform_module_port_reference(name, @3.text,
7421 # @3.first_line);
7422 # vector<Module::port_t*>*tmp = p[1];
7423 # tmp->push_back(ptmp);
7424 #
7425 # /* Get the port declaration details, the port type
7426 # and what not, from context data stored by the
7427 # last port_declaration rule. */
7428 # pform_module_define_port(@3, name,
7429 # port_declaration_context.port_type,
7430 # port_declaration_context.port_net_type,
7431 # port_declaration_context.data_type, 0);
7432 # delete[]p[3];
7433 # p[0] = tmp;
7434 # }
7435 ()
7436
7437
7438 def p_list_of_port_declarations_4(p):
7439 '''list_of_port_declarations : list_of_port_declarations ',' '''
7440 if(parse_debug):
7441 print('list_of_port_declarations_4', list(p))
7442
7443 # {
7444 # yyerror(@2, "error: NULL port declarations are not "
7445 # "allowed.");
7446 # }
7447 ()
7448
7449
7450 def p_list_of_port_declarations_5(p):
7451 '''list_of_port_declarations : list_of_port_declarations ';' '''
7452 if(parse_debug):
7453 print('list_of_port_declarations_5', list(p))
7454
7455 # {
7456 # yyerror(@2, "error: ';' is an invalid port declaration "
7457 # "separator.");
7458 # }
7459 ()
7460
7461
7462 def p_port_declaration_1(p):
7463 '''port_declaration : attribute_list_opt K_input net_type_opt data_type_or_implicit IDENTIFIER dimensions_opt '''
7464 if(parse_debug):
7465 print('port_declaration_1 FIXME', list(p))
7466 comment, dt, name = p[2], p[4], p[5]
7467 p[0] = absyn.port_decl(comment, dt, name)
7468
7469 # { Module::port_t*ptmp;
7470 # perm_string name = lex_strings.make(p[5]);
7471 # data_type_t*use_type = p[4];
7472 # if (p[6]) use_type = new uarray_type_t(use_type, p[6]);
7473 # ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
7474 # pform_module_define_port(@2, name, NetNet::PINPUT, p[3], use_type, p[1]);
7475 # port_declaration_context.port_type = NetNet::PINPUT;
7476 # port_declaration_context.port_net_type = p[3];
7477 # port_declaration_context.data_type = p[4];
7478 # delete[]p[5];
7479 # p[0] = ptmp;
7480 # }
7481 ()
7482
7483
7484 def p_port_declaration_2(p):
7485 '''port_declaration : attribute_list_opt K_input K_wreal IDENTIFIER '''
7486 if(parse_debug):
7487 print('port_declaration_2', list(p))
7488
7489 # { Module::port_t*ptmp;
7490 # perm_string name = lex_strings.make(p[4]);
7491 # ptmp = pform_module_port_reference(name, @2.text,
7492 # @2.first_line);
7493 # real_type_t*real_type = new real_type_t(real_type_t::REAL);
7494 # FILE_NAME(real_type, @3);
7495 # pform_module_define_port(@2, name, NetNet::PINPUT,
7496 # NetNet::WIRE, real_type, p[1]);
7497 # port_declaration_context.port_type = NetNet::PINPUT;
7498 # port_declaration_context.port_net_type = NetNet::WIRE;
7499 # port_declaration_context.data_type = real_type;
7500 # delete[]p[4];
7501 # p[0] = ptmp;
7502 # }
7503 ()
7504
7505
7506 def p_port_declaration_3(p):
7507 '''port_declaration : attribute_list_opt K_inout net_type_opt data_type_or_implicit IDENTIFIER dimensions_opt '''
7508 if(parse_debug):
7509 print('port_declaration_3', list(p))
7510
7511 # { Module::port_t*ptmp;
7512 # perm_string name = lex_strings.make(p[5]);
7513 # ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
7514 # pform_module_define_port(@2, name, NetNet::PINOUT, p[3], p[4], p[1]);
7515 # port_declaration_context.port_type = NetNet::PINOUT;
7516 # port_declaration_context.port_net_type = p[3];
7517 # port_declaration_context.data_type = p[4];
7518 # delete[]p[5];
7519 # if (p[6]) {
7520 # yyerror(@6, "sorry: Inout ports with unpacked dimensions not supported.");
7521 # delete p[6];
7522 # }
7523 # p[0] = ptmp;
7524 # }
7525 ()
7526
7527
7528 def p_port_declaration_4(p):
7529 '''port_declaration : attribute_list_opt K_inout K_wreal IDENTIFIER '''
7530 if(parse_debug):
7531 print('port_declaration_4', list(p))
7532
7533 # { Module::port_t*ptmp;
7534 # perm_string name = lex_strings.make(p[4]);
7535 # ptmp = pform_module_port_reference(name, @2.text,
7536 # @2.first_line);
7537 # real_type_t*real_type = new real_type_t(real_type_t::REAL);
7538 # FILE_NAME(real_type, @3);
7539 # pform_module_define_port(@2, name, NetNet::PINOUT,
7540 # NetNet::WIRE, real_type, p[1]);
7541 # port_declaration_context.port_type = NetNet::PINOUT;
7542 # port_declaration_context.port_net_type = NetNet::WIRE;
7543 # port_declaration_context.data_type = real_type;
7544 # delete[]p[4];
7545 # p[0] = ptmp;
7546 # }
7547 ()
7548
7549
7550 def p_port_declaration_5(p):
7551 '''port_declaration : attribute_list_opt K_output net_type_opt data_type_or_implicit IDENTIFIER dimensions_opt '''
7552 if(parse_debug):
7553 print('port_declaration_5 FIXME', list(p))
7554 comment, dt, name = p[2], p[4], p[5]
7555 p[0] = absyn.port_decl(comment, dt, name)
7556
7557 # { Module::port_t*ptmp;
7558 # perm_string name = lex_strings.make(p[5]);
7559 # data_type_t*use_dtype = p[4];
7560 # if (p[6]) use_dtype = new uarray_type_t(use_dtype, p[6]);
7561 # NetNet::Type use_type = p[3];
7562 # if (use_type == NetNet::IMPLICIT) {
7563 # if (vector_type_t*dtype = dynamic_cast<vector_type_t*> (p[4])) {
7564 # if (dtype->reg_flag)
7565 # use_type = NetNet::REG;
7566 # else if (dtype->implicit_flag)
7567 # use_type = NetNet::IMPLICIT;
7568 # else
7569 # use_type = NetNet::IMPLICIT_REG;
7570 #
7571 # // The SystemVerilog types that can show up as
7572 # // output ports are implicitly (on the inside)
7573 # // variables because "reg" is not valid syntax
7574 # // here.
7575 # } else if (dynamic_cast<atom2_type_t*> (p[4])) {
7576 # use_type = NetNet::IMPLICIT_REG;
7577 # } else if (dynamic_cast<struct_type_t*> (p[4])) {
7578 # use_type = NetNet::IMPLICIT_REG;
7579 # } else if (enum_type_t*etype = dynamic_cast<enum_type_t*> (p[4])) {
7580 # if(etype->base_type == IVL_VT_LOGIC)
7581 # use_type = NetNet::IMPLICIT_REG;
7582 # }
7583 # }
7584 # ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
7585 # pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, use_dtype, p[1]);
7586 # port_declaration_context.port_type = NetNet::POUTPUT;
7587 # port_declaration_context.port_net_type = use_type;
7588 # port_declaration_context.data_type = p[4];
7589 # delete[]p[5];
7590 # p[0] = ptmp;
7591 # }
7592 ()
7593
7594
7595 def p_port_declaration_6(p):
7596 '''port_declaration : attribute_list_opt K_output K_wreal IDENTIFIER '''
7597 if(parse_debug):
7598 print('port_declaration_6', list(p))
7599
7600 # { Module::port_t*ptmp;
7601 # perm_string name = lex_strings.make(p[4]);
7602 # ptmp = pform_module_port_reference(name, @2.text,
7603 # @2.first_line);
7604 # real_type_t*real_type = new real_type_t(real_type_t::REAL);
7605 # FILE_NAME(real_type, @3);
7606 # pform_module_define_port(@2, name, NetNet::POUTPUT,
7607 # NetNet::WIRE, real_type, p[1]);
7608 # port_declaration_context.port_type = NetNet::POUTPUT;
7609 # port_declaration_context.port_net_type = NetNet::WIRE;
7610 # port_declaration_context.data_type = real_type;
7611 # delete[]p[4];
7612 # p[0] = ptmp;
7613 # }
7614 ()
7615
7616
7617 def p_port_declaration_7(p):
7618 '''port_declaration : attribute_list_opt K_output net_type_opt data_type_or_implicit IDENTIFIER '=' expression '''
7619 if(parse_debug):
7620 print('port_declaration_7', list(p))
7621
7622 # { Module::port_t*ptmp;
7623 # perm_string name = lex_strings.make(p[5]);
7624 # NetNet::Type use_type = p[3];
7625 # if (use_type == NetNet::IMPLICIT) {
7626 # if (vector_type_t*dtype = dynamic_cast<vector_type_t*> (p[4])) {
7627 # if (dtype->reg_flag)
7628 # use_type = NetNet::REG;
7629 # else
7630 # use_type = NetNet::IMPLICIT_REG;
7631 # } else {
7632 # use_type = NetNet::IMPLICIT_REG;
7633 # }
7634 # }
7635 # ptmp = pform_module_port_reference(name, @2.text, @2.first_line);
7636 # pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, p[4], p[1]);
7637 # port_declaration_context.port_type = NetNet::PINOUT;
7638 # port_declaration_context.port_net_type = use_type;
7639 # port_declaration_context.data_type = p[4];
7640 #
7641 # pform_make_var_init(@5, name, p[7]);
7642 #
7643 # delete[]p[5];
7644 # p[0] = ptmp;
7645 # }
7646 ()
7647
7648
7649 def p_net_type_opt_1(p):
7650 '''net_type_opt : net_type '''
7651 if(parse_debug):
7652 print('net_type_opt_1', list(p))
7653 p[0] = p[1]
7654
7655
7656 ()
7657
7658
7659 def p_net_type_opt_2(p):
7660 '''net_type_opt : '''
7661 if(parse_debug > 2):
7662 print('net_type_opt_2', list(p))
7663 p[0] = NN_IMPLICIT
7664
7665
7666 ()
7667
7668
7669 def p_unsigned_signed_opt_1(p):
7670 '''unsigned_signed_opt : K_signed '''
7671 if(parse_debug):
7672 print('unsigned_signed_opt_1', list(p))
7673 p[0] = True
7674
7675
7676 ()
7677
7678
7679 def p_unsigned_signed_opt_2(p):
7680 '''unsigned_signed_opt : K_unsigned '''
7681 if(parse_debug):
7682 print('unsigned_signed_opt_2', list(p))
7683 p[0] = False
7684
7685
7686 ()
7687
7688
7689 def p_unsigned_signed_opt_3(p):
7690 '''unsigned_signed_opt : '''
7691 if(parse_debug):
7692 print('unsigned_signed_opt_3', list(p))
7693 p[0] = False
7694
7695
7696 ()
7697
7698
7699 def p_signed_unsigned_opt_1(p):
7700 '''signed_unsigned_opt : K_signed '''
7701 if(parse_debug):
7702 print('signed_unsigned_opt_1', list(p))
7703 p[0] = True
7704
7705
7706 ()
7707
7708
7709 def p_signed_unsigned_opt_2(p):
7710 '''signed_unsigned_opt : K_unsigned '''
7711 if(parse_debug):
7712 print('signed_unsigned_opt_2', list(p))
7713 p[0] = False
7714
7715
7716 ()
7717
7718
7719 def p_signed_unsigned_opt_3(p):
7720 '''signed_unsigned_opt : '''
7721 if(parse_debug):
7722 print('signed_unsigned_opt_3', list(p))
7723 p[0] = True
7724
7725
7726 ()
7727
7728
7729 def p_atom2_type_1(p):
7730 '''atom2_type : K_byte '''
7731 if(parse_debug):
7732 print('atom2_type_1', list(p))
7733
7734 # { p[0] = 8; }
7735 ()
7736
7737
7738 def p_atom2_type_2(p):
7739 '''atom2_type : K_shortint '''
7740 if(parse_debug):
7741 print('atom2_type_2', list(p))
7742
7743 # { p[0] = 16; }
7744 ()
7745
7746
7747 def p_atom2_type_3(p):
7748 '''atom2_type : K_int '''
7749 if(parse_debug):
7750 print('atom2_type_3', list(p))
7751
7752 # { p[0] = 32; }
7753 ()
7754
7755
7756 def p_atom2_type_4(p):
7757 '''atom2_type : K_longint '''
7758 if(parse_debug):
7759 print('atom2_type_4', list(p))
7760
7761 # { p[0] = 64; }
7762 ()
7763
7764
7765 def p_lpvalue_1(p):
7766 '''lpvalue : hierarchy_identifier '''
7767 if(parse_debug > 2):
7768 print('lpvalue_1', list(p))
7769 p[0] = p[1]
7770
7771 # { PEIdent*tmp = pform_new_ident(*p[1]);
7772 # FILE_NAME(tmp, @1);
7773 # p[0] = tmp;
7774 # delete p[1];
7775 # }
7776 ()
7777
7778
7779 def p_lpvalue_2(p):
7780 '''lpvalue : implicit_class_handle '.' hierarchy_identifier '''
7781 if(parse_debug):
7782 print('lpvalue_2', list(p))
7783
7784 # { pform_name_t*t_name = p[1];
7785 # while (!p[3]->empty()) {
7786 # t_name->push_back(p[3]->front());
7787 # p[3]->pop_front();
7788 # }
7789 # PEIdent*tmp = new PEIdent(*t_name);
7790 # FILE_NAME(tmp, @1);
7791 # p[0] = tmp;
7792 # delete p[1];
7793 # delete p[3];
7794 # }
7795 ()
7796
7797
7798 def p_lpvalue_3(p):
7799 '''lpvalue : '{' expression_list_proper '}' '''
7800 if(parse_debug):
7801 print('lpvalue_3', list(p))
7802
7803 # { PEConcat*tmp = new PEConcat(*p[2]);
7804 # FILE_NAME(tmp, @1);
7805 # delete p[2];
7806 # p[0] = tmp;
7807 # }
7808 ()
7809
7810
7811 def p_lpvalue_4(p):
7812 '''lpvalue : streaming_concatenation '''
7813 if(parse_debug):
7814 print('lpvalue_4', list(p))
7815
7816 # { yyerror(@1, "sorry: streaming concatenation not supported in l-values.");
7817 # p[0] = None
7818 # }
7819 ()
7820
7821
7822 def p_cont_assign_1(p):
7823 '''cont_assign : lpvalue '=' expression '''
7824 if(parse_debug):
7825 print('cont_assign_1', list(p))
7826 absyn.cont_assign_1(p)
7827
7828 # { list<PExpr*>*tmp = new list<PExpr*>;
7829 # tmp->push_back(p[1]);
7830 # tmp->push_back(p[3]);
7831 # p[0] = tmp;
7832 # }
7833 ()
7834
7835
7836 def p_cont_assign_list_1(p):
7837 '''cont_assign_list : cont_assign_list ',' cont_assign '''
7838 if(parse_debug):
7839 print('cont_assign_list_1', list(p))
7840
7841 # { list<PExpr*>*tmp = p[1];
7842 # tmp->splice(tmp->end(), *p[3]);
7843 # delete p[3];
7844 # p[0] = tmp;
7845 # }
7846 ()
7847
7848
7849 def p_cont_assign_list_2(p):
7850 '''cont_assign_list : cont_assign '''
7851 if(parse_debug > 2):
7852 print('cont_assign_list_2', list(p))
7853 p[0] = p[1]
7854
7855
7856 ()
7857
7858
7859 def p_module_1(p):
7860 '''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 '''
7861 if(parse_debug > 2):
7862 print('module_1', list(p))
7863 clsdecl = absyn.module_1(p)
7864 p[0] = clsdecl
7865
7866
7867 ()
7868
7869
7870 def p__embed0_module(p):
7871 '''_embed0_module : '''
7872
7873 # { pform_startmodule(@2, p[4], p[2]==K_program, p[2]==K_interface, p[3], p[1]); }
7874 ()
7875
7876
7877 def p__embed1_module(p):
7878 '''_embed1_module : '''
7879
7880 # { pform_module_set_ports(p[8]); }
7881 ()
7882
7883
7884 def p__embed2_module(p):
7885 '''_embed2_module : '''
7886
7887 # { pform_set_scope_timescale(@2); }
7888 ()
7889
7890
7891 def p__embed3_module(p):
7892 '''_embed3_module : '''
7893
7894 # { Module::UCDriveType ucd;
7895 # // The lexor detected `unconnected_drive directives and
7896 # // marked what it found in the uc_drive variable. Use that
7897 # // to generate a UCD flag for the module.
7898 # switch (uc_drive) {
7899 # case UCD_NONE:
7900 # default:
7901 # ucd = Module::UCD_NONE;
7902 # break;
7903 # case UCD_PULL0:
7904 # ucd = Module::UCD_PULL0;
7905 # break;
7906 # case UCD_PULL1:
7907 # ucd = Module::UCD_PULL1;
7908 # break;
7909 # }
7910 # // Check that program/endprogram and module/endmodule
7911 # // keywords match.
7912 # if (p[2] != p[15]) {
7913 # switch (p[2]) {
7914 # case K_module:
7915 # yyerror(@15, "error: module not closed by endmodule.");
7916 # break;
7917 # case K_program:
7918 # yyerror(@15, "error: program not closed by endprogram.");
7919 # break;
7920 # case K_interface:
7921 # yyerror(@15, "error: interface not closed by endinterface.");
7922 # break;
7923 # default:
7924 # break;
7925 # }
7926 # }
7927 # pform_endmodule(p[4], in_celldefine, ucd);
7928 # }
7929 ()
7930
7931
7932 def p_module_start_1(p):
7933 '''module_start : K_module '''
7934 if(parse_debug > 1):
7935 print('module_start_1', list(p))
7936
7937 # { p[0] = K_module; }
7938 ()
7939
7940
7941 def p_module_start_2(p):
7942 '''module_start : K_macromodule '''
7943 if(parse_debug):
7944 print('module_start_2', list(p))
7945
7946 # { p[0] = K_module; }
7947 ()
7948
7949
7950 def p_module_start_3(p):
7951 '''module_start : K_program '''
7952 if(parse_debug):
7953 print('module_start_3', list(p))
7954
7955 # { p[0] = K_program; }
7956 ()
7957
7958
7959 def p_module_start_4(p):
7960 '''module_start : K_interface '''
7961 if(parse_debug):
7962 print('module_start_4', list(p))
7963
7964 # { p[0] = K_interface; }
7965 ()
7966
7967
7968 def p_module_end_1(p):
7969 '''module_end : K_endmodule '''
7970 if(parse_debug > 2):
7971 print('module_end_1', list(p))
7972
7973 # { p[0] = K_module; }
7974 ()
7975
7976
7977 def p_module_end_2(p):
7978 '''module_end : K_endprogram '''
7979 if(parse_debug):
7980 print('module_end_2', list(p))
7981
7982 # { p[0] = K_program; }
7983 ()
7984
7985
7986 def p_module_end_3(p):
7987 '''module_end : K_endinterface '''
7988 if(parse_debug):
7989 print('module_end_3', list(p))
7990
7991 # { p[0] = K_interface; }
7992 ()
7993
7994
7995 def p_endlabel_opt_1(p):
7996 '''endlabel_opt : ':' IDENTIFIER '''
7997 if(parse_debug):
7998 print('endlabel_opt_1', list(p))
7999 p[0] = p[2]
8000
8001
8002 ()
8003
8004
8005 def p_endlabel_opt_2(p):
8006 '''endlabel_opt : '''
8007 if(parse_debug > 2):
8008 print('endlabel_opt_2', list(p))
8009
8010 # { p[0] = None }
8011 ()
8012
8013
8014 def p_module_attribute_foreign_1(p):
8015 '''module_attribute_foreign : K_PSTAR IDENTIFIER K_integer IDENTIFIER '=' STRING ';' K_STARP '''
8016 if(parse_debug):
8017 print('module_attribute_foreign_1', list(p))
8018
8019 # { p[0] = None }
8020 ()
8021
8022
8023 def p_module_attribute_foreign_2(p):
8024 '''module_attribute_foreign : '''
8025 if(parse_debug > 2):
8026 print('module_attribute_foreign_2', list(p))
8027
8028 # { p[0] = None }
8029 ()
8030
8031
8032 def p_module_port_list_opt_1(p):
8033 '''module_port_list_opt : '(' list_of_ports ')' '''
8034 if(parse_debug):
8035 print('module_port_list_opt_1', list(p))
8036 p[0] = p[2]
8037
8038
8039 ()
8040
8041
8042 def p_module_port_list_opt_2(p):
8043 '''module_port_list_opt : '(' list_of_port_declarations ')' '''
8044 if(parse_debug > 2):
8045 print('module_port_list_opt_2', list(p))
8046 p[0] = p[2]
8047
8048
8049 ()
8050
8051
8052 def p_module_port_list_opt_3(p):
8053 '''module_port_list_opt : '''
8054 if(parse_debug):
8055 print('module_port_list_opt_3', list(p))
8056
8057 # { p[0] = None }
8058 ()
8059
8060
8061 def p_module_port_list_opt_4(p):
8062 '''module_port_list_opt : '(' error ')' '''
8063 if(parse_debug):
8064 print('module_port_list_opt_4', list(p))
8065
8066 # { yyerror(@2, "Errors in port declarations.");
8067 # yyerrok;
8068 # p[0] = None
8069 # }
8070 ()
8071
8072
8073 def p_module_parameter_port_list_opt_1(p):
8074 '''module_parameter_port_list_opt : '''
8075 if(parse_debug > 2):
8076 print('module_parameter_port_list_opt_1', list(p))
8077
8078
8079 ()
8080
8081
8082 def p_module_parameter_port_list_opt_2(p):
8083 '''module_parameter_port_list_opt : '#' '(' module_parameter_port_list ')' '''
8084 if(parse_debug):
8085 print('module_parameter_port_list_opt_2', list(p))
8086 p[0] = p[3]
8087
8088
8089 ()
8090
8091
8092 def p_module_parameter_port_list_1(p):
8093 '''module_parameter_port_list : K_parameter param_type parameter_assign '''
8094 if(parse_debug):
8095 print('module_parameter_port_list_1', list(p))
8096 p[0] = [p[3]]
8097
8098
8099 ()
8100
8101
8102 def p_module_parameter_port_list_2(p):
8103 '''module_parameter_port_list : module_parameter_port_list ',' parameter_assign '''
8104 if(parse_debug):
8105 print('module_parameter_port_list_2', list(p))
8106 p[0] = p[1].append(p[3])
8107
8108
8109 ()
8110
8111
8112 def p_module_parameter_port_list_3(p):
8113 '''module_parameter_port_list : module_parameter_port_list ',' K_parameter param_type parameter_assign '''
8114 if(parse_debug):
8115 print('module_parameter_port_list_3', list(p))
8116 p[1].append(Leaf(token.COMMA, ','))
8117 p[1].append(Leaf(token.NEWLINE, '\n'))
8118 p[5].prefix = ' ' # add space after newline
8119 p[1].append(p[5])
8120 p[0] = p[1]
8121
8122
8123 ()
8124
8125
8126 def p_module_item_1(p):
8127 '''module_item : module '''
8128 if(parse_debug):
8129 print('module_item_1', list(p))
8130
8131
8132 ()
8133
8134
8135 def p_module_item_2(p):
8136 '''module_item : attribute_list_opt net_type data_type_or_implicit delay3_opt net_variable_list ';' '''
8137 if(parse_debug):
8138 print('module_item_2', list(p))
8139
8140 p[0] = absyn.module_item_2(p[2], p[3], p[5])
8141 #p[0] = ["module_item_2"]+list(p)
8142
8143 # { data_type_t*data_type = p[3];
8144 # if (data_type == 0) {
8145 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
8146 # FILE_NAME(data_type, @2);
8147 # }
8148 # pform_set_data_type(@2, data_type, p[5], p[2], p[1]);
8149 # if (p[4] != 0) {
8150 # yyerror(@2, "sorry: net delays not supported.");
8151 # delete p[4];
8152 # }
8153 # delete p[1];
8154 # }
8155 ()
8156
8157
8158 def p_module_item_3(p):
8159 '''module_item : attribute_list_opt K_wreal delay3 net_variable_list ';' '''
8160 if(parse_debug):
8161 print('module_item_3', list(p))
8162
8163 # { real_type_t*tmpt = new real_type_t(real_type_t::REAL);
8164 # pform_set_data_type(@2, tmpt, p[4], NetNet::WIRE, p[1]);
8165 # if (p[3] != 0) {
8166 # yyerror(@3, "sorry: net delays not supported.");
8167 # delete p[3];
8168 # }
8169 # delete p[1];
8170 # }
8171 ()
8172
8173
8174 def p_module_item_4(p):
8175 '''module_item : attribute_list_opt K_wreal net_variable_list ';' '''
8176 if(parse_debug):
8177 print('module_item_4', list(p))
8178
8179 # { real_type_t*tmpt = new real_type_t(real_type_t::REAL);
8180 # pform_set_data_type(@2, tmpt, p[3], NetNet::WIRE, p[1]);
8181 # delete p[1];
8182 # }
8183 ()
8184
8185
8186 def p_module_item_5(p):
8187 '''module_item : attribute_list_opt net_type data_type_or_implicit delay3_opt net_decl_assigns ';' '''
8188 if(parse_debug):
8189 print('module_item_5', list(p))
8190
8191 # { data_type_t*data_type = p[3];
8192 # if (data_type == 0) {
8193 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
8194 # FILE_NAME(data_type, @2);
8195 # }
8196 # pform_makewire(@2, p[4], str_strength, p[5], p[2], data_type);
8197 # if (p[1]) {
8198 # yywarn(@2, "Attributes are not supported on net declaration "
8199 # "assignments and will be discarded.");
8200 # delete p[1];
8201 # }
8202 # }
8203 ()
8204
8205
8206 def p_module_item_6(p):
8207 '''module_item : attribute_list_opt net_type data_type_or_implicit drive_strength net_decl_assigns ';' '''
8208 if(parse_debug):
8209 print('module_item_6', list(p))
8210
8211 # { data_type_t*data_type = p[3];
8212 # if (data_type == 0) {
8213 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
8214 # FILE_NAME(data_type, @2);
8215 # }
8216 # pform_makewire(@2, 0, p[4], p[5], p[2], data_type);
8217 # if (p[1]) {
8218 # yywarn(@2, "Attributes are not supported on net declaration "
8219 # "assignments and will be discarded.");
8220 # delete p[1];
8221 # }
8222 # }
8223 ()
8224
8225
8226 def p_module_item_7(p):
8227 '''module_item : attribute_list_opt K_wreal net_decl_assigns ';' '''
8228 if(parse_debug):
8229 print('module_item_7', list(p))
8230
8231 # { real_type_t*data_type = new real_type_t(real_type_t::REAL);
8232 # pform_makewire(@2, 0, str_strength, p[3], NetNet::WIRE, data_type);
8233 # if (p[1]) {
8234 # yywarn(@2, "Attributes are not supported on net declaration "
8235 # "assignments and will be discarded.");
8236 # delete p[1];
8237 # }
8238 # }
8239 ()
8240
8241
8242 def p_module_item_8(p):
8243 '''module_item : K_trireg charge_strength_opt dimensions_opt delay3_opt list_of_identifiers ';' '''
8244 if(parse_debug):
8245 print('module_item_8', list(p))
8246
8247 # { yyerror(@1, "sorry: trireg nets not supported.");
8248 # delete p[3];
8249 # delete p[4];
8250 # }
8251 ()
8252
8253
8254 def p_module_item_9(p):
8255 '''module_item : attribute_list_opt port_direction net_type data_type_or_implicit list_of_port_identifiers ';' '''
8256 if(parse_debug):
8257 print('module_item_9', list(p))
8258
8259 # { pform_module_define_port(@2, p[5], p[2], p[3], p[4], p[1]); }
8260 ()
8261
8262
8263 def p_module_item_10(p):
8264 '''module_item : attribute_list_opt port_direction K_wreal list_of_port_identifiers ';' '''
8265 if(parse_debug):
8266 print('module_item_10', list(p))
8267
8268 # { real_type_t*real_type = new real_type_t(real_type_t::REAL);
8269 # pform_module_define_port(@2, p[4], p[2], NetNet::WIRE, real_type, p[1]);
8270 # }
8271 ()
8272
8273
8274 def p_module_item_11(p):
8275 '''module_item : attribute_list_opt K_inout data_type_or_implicit list_of_port_identifiers ';' '''
8276 if(parse_debug):
8277 print('module_item_11', list(p))
8278
8279 # { NetNet::Type use_type = p[3] ? NetNet::IMPLICIT : NetNet::NONE;
8280 # if (vector_type_t*dtype = dynamic_cast<vector_type_t*> (p[3])) {
8281 # if (dtype->implicit_flag)
8282 # use_type = NetNet::NONE;
8283 # }
8284 # if (use_type == NetNet::NONE)
8285 # pform_set_port_type(@2, p[4], NetNet::PINOUT, p[3], p[1]);
8286 # else
8287 # pform_module_define_port(@2, p[4], NetNet::PINOUT, use_type, p[3], p[1]);
8288 # }
8289 ()
8290
8291
8292 def p_module_item_12(p):
8293 '''module_item : attribute_list_opt K_input data_type_or_implicit list_of_port_identifiers ';' '''
8294 if(parse_debug):
8295 print('module_item_12', list(p))
8296
8297 # { NetNet::Type use_type = p[3] ? NetNet::IMPLICIT : NetNet::NONE;
8298 # if (vector_type_t*dtype = dynamic_cast<vector_type_t*> (p[3])) {
8299 # if (dtype->implicit_flag)
8300 # use_type = NetNet::NONE;
8301 # }
8302 # if (use_type == NetNet::NONE)
8303 # pform_set_port_type(@2, p[4], NetNet::PINPUT, p[3], p[1]);
8304 # else
8305 # pform_module_define_port(@2, p[4], NetNet::PINPUT, use_type, p[3], p[1]);
8306 # }
8307 ()
8308
8309
8310 def p_module_item_13(p):
8311 '''module_item : attribute_list_opt K_output data_type_or_implicit list_of_variable_port_identifiers ';' '''
8312 if(parse_debug):
8313 print('module_item_13', list(p))
8314
8315 # { NetNet::Type use_type = p[3] ? NetNet::IMPLICIT : NetNet::NONE;
8316 # if (vector_type_t*dtype = dynamic_cast<vector_type_t*> (p[3])) {
8317 # if (dtype->implicit_flag)
8318 # use_type = NetNet::NONE;
8319 # else if (dtype->reg_flag)
8320 # use_type = NetNet::REG;
8321 # else
8322 # use_type = NetNet::IMPLICIT_REG;
8323 #
8324 # // The SystemVerilog types that can show up as
8325 # // output ports are implicitly (on the inside)
8326 # // variables because "reg" is not valid syntax
8327 # // here.
8328 # } else if (dynamic_cast<atom2_type_t*> (p[3])) {
8329 # use_type = NetNet::IMPLICIT_REG;
8330 # } else if (dynamic_cast<struct_type_t*> (p[3])) {
8331 # use_type = NetNet::IMPLICIT_REG;
8332 # } else if (enum_type_t*etype = dynamic_cast<enum_type_t*> (p[3])) {
8333 # if(etype->base_type == IVL_VT_LOGIC)
8334 # use_type = NetNet::IMPLICIT_REG;
8335 # }
8336 # if (use_type == NetNet::NONE)
8337 # pform_set_port_type(@2, p[4], NetNet::POUTPUT, p[3], p[1]);
8338 # else
8339 # pform_module_define_port(@2, p[4], NetNet::POUTPUT, use_type, p[3], p[1]);
8340 # }
8341 ()
8342
8343
8344 def p_module_item_14(p):
8345 '''module_item : attribute_list_opt port_direction net_type data_type_or_implicit error ';' '''
8346 if(parse_debug):
8347 print('module_item_14', list(p))
8348
8349 # { yyerror(@2, "error: Invalid variable list in port declaration.");
8350 # if (p[1]) delete p[1];
8351 # if (p[4]) delete p[4];
8352 # yyerrok;
8353 # }
8354 ()
8355
8356
8357 def p_module_item_15(p):
8358 '''module_item : attribute_list_opt K_inout data_type_or_implicit error ';' '''
8359 if(parse_debug):
8360 print('module_item_15', list(p))
8361
8362 # { yyerror(@2, "error: Invalid variable list in port declaration.");
8363 # if (p[1]) delete p[1];
8364 # if (p[3]) delete p[3];
8365 # yyerrok;
8366 # }
8367 ()
8368
8369
8370 def p_module_item_16(p):
8371 '''module_item : attribute_list_opt K_input data_type_or_implicit error ';' '''
8372 if(parse_debug):
8373 print('module_item_16', list(p))
8374
8375 # { yyerror(@2, "error: Invalid variable list in port declaration.");
8376 # if (p[1]) delete p[1];
8377 # if (p[3]) delete p[3];
8378 # yyerrok;
8379 # }
8380 ()
8381
8382
8383 def p_module_item_17(p):
8384 '''module_item : attribute_list_opt K_output data_type_or_implicit error ';' '''
8385 if(parse_debug):
8386 print('module_item_17', list(p))
8387
8388 # { yyerror(@2, "error: Invalid variable list in port declaration.");
8389 # if (p[1]) delete p[1];
8390 # if (p[3]) delete p[3];
8391 # yyerrok;
8392 # }
8393 ()
8394
8395
8396 def p_module_item_18(p):
8397 '''module_item : DISCIPLINE_IDENTIFIER list_of_identifiers ';' '''
8398 if(parse_debug):
8399 print('module_item_18', list(p))
8400
8401 # { pform_attach_discipline(@1, p[1], p[2]); }
8402 ()
8403
8404
8405 def p_module_item_19(p):
8406 '''module_item : attribute_list_opt _embed0_module_item block_item_decl '''
8407 if(parse_debug):
8408 print('module_item_19', list(p))
8409
8410 # { delete attributes_in_context;
8411 # attributes_in_context = 0;
8412 # }
8413 ()
8414
8415
8416 def p_module_item_20(p):
8417 '''module_item : K_defparam _embed1_module_item defparam_assign_list ';' '''
8418 if(parse_debug):
8419 print('module_item_20', list(p))
8420
8421
8422 ()
8423
8424
8425 def p_module_item_21(p):
8426 '''module_item : attribute_list_opt gatetype gate_instance_list ';' '''
8427 if(parse_debug):
8428 print('module_item_21', list(p))
8429
8430 # { pform_makegates(@2, p[2], str_strength, 0, p[3], p[1]); }
8431 ()
8432
8433
8434 def p_module_item_22(p):
8435 '''module_item : attribute_list_opt gatetype delay3 gate_instance_list ';' '''
8436 if(parse_debug):
8437 print('module_item_22', list(p))
8438
8439 # { pform_makegates(@2, p[2], str_strength, p[3], p[4], p[1]); }
8440 ()
8441
8442
8443 def p_module_item_23(p):
8444 '''module_item : attribute_list_opt gatetype drive_strength gate_instance_list ';' '''
8445 if(parse_debug):
8446 print('module_item_23', list(p))
8447
8448 # { pform_makegates(@2, p[2], p[3], 0, p[4], p[1]); }
8449 ()
8450
8451
8452 def p_module_item_24(p):
8453 '''module_item : attribute_list_opt gatetype drive_strength delay3 gate_instance_list ';' '''
8454 if(parse_debug):
8455 print('module_item_24', list(p))
8456
8457 # { pform_makegates(@2, p[2], p[3], p[4], p[5], p[1]); }
8458 ()
8459
8460
8461 def p_module_item_25(p):
8462 '''module_item : attribute_list_opt switchtype gate_instance_list ';' '''
8463 if(parse_debug):
8464 print('module_item_25', list(p))
8465
8466 # { pform_makegates(@2, p[2], str_strength, 0, p[3], p[1]); }
8467 ()
8468
8469
8470 def p_module_item_26(p):
8471 '''module_item : attribute_list_opt switchtype delay3 gate_instance_list ';' '''
8472 if(parse_debug):
8473 print('module_item_26', list(p))
8474
8475 # { pform_makegates(@2, p[2], str_strength, p[3], p[4], p[1]); }
8476 ()
8477
8478
8479 def p_module_item_27(p):
8480 '''module_item : K_pullup gate_instance_list ';' '''
8481 if(parse_debug):
8482 print('module_item_27', list(p))
8483
8484 # { pform_makegates(@1, PGBuiltin::PULLUP, pull_strength, 0, p[2], 0); }
8485 ()
8486
8487
8488 def p_module_item_28(p):
8489 '''module_item : K_pulldown gate_instance_list ';' '''
8490 if(parse_debug):
8491 print('module_item_28', list(p))
8492
8493 # { pform_makegates(@1, PGBuiltin::PULLDOWN, pull_strength, 0, p[2], 0); }
8494 ()
8495
8496
8497 def p_module_item_29(p):
8498 '''module_item : K_pullup '(' dr_strength1 ')' gate_instance_list ';' '''
8499 if(parse_debug):
8500 print('module_item_29', list(p))
8501
8502 # { pform_makegates(@1, PGBuiltin::PULLUP, p[3], 0, p[5], 0); }
8503 ()
8504
8505
8506 def p_module_item_30(p):
8507 '''module_item : K_pullup '(' dr_strength1 ',' dr_strength0 ')' gate_instance_list ';' '''
8508 if(parse_debug):
8509 print('module_item_30', list(p))
8510
8511 # { pform_makegates(@1, PGBuiltin::PULLUP, p[3], 0, p[7], 0); }
8512 ()
8513
8514
8515 def p_module_item_31(p):
8516 '''module_item : K_pullup '(' dr_strength0 ',' dr_strength1 ')' gate_instance_list ';' '''
8517 if(parse_debug):
8518 print('module_item_31', list(p))
8519
8520 # { pform_makegates(@1, PGBuiltin::PULLUP, p[5], 0, p[7], 0); }
8521 ()
8522
8523
8524 def p_module_item_32(p):
8525 '''module_item : K_pulldown '(' dr_strength0 ')' gate_instance_list ';' '''
8526 if(parse_debug):
8527 print('module_item_32', list(p))
8528
8529 # { pform_makegates(@1, PGBuiltin::PULLDOWN, p[3], 0, p[5], 0); }
8530 ()
8531
8532
8533 def p_module_item_33(p):
8534 '''module_item : K_pulldown '(' dr_strength1 ',' dr_strength0 ')' gate_instance_list ';' '''
8535 if(parse_debug):
8536 print('module_item_33', list(p))
8537
8538 # { pform_makegates(@1, PGBuiltin::PULLDOWN, p[5], 0, p[7], 0); }
8539 ()
8540
8541
8542 def p_module_item_34(p):
8543 '''module_item : K_pulldown '(' dr_strength0 ',' dr_strength1 ')' gate_instance_list ';' '''
8544 if(parse_debug):
8545 print('module_item_34', list(p))
8546
8547 # { pform_makegates(@1, PGBuiltin::PULLDOWN, p[3], 0, p[7], 0); }
8548 ()
8549
8550
8551 def p_module_item_35(p):
8552 '''module_item : attribute_list_opt IDENTIFIER parameter_value_opt gate_instance_list ';' '''
8553 if(parse_debug):
8554 print('module_item_35', list(p))
8555
8556 # { perm_string tmp1 = lex_strings.make(p[2]);
8557 # pform_make_modgates(@2, tmp1, p[3], p[4], p[1]);
8558 # delete[]p[2];
8559 # }
8560 ()
8561
8562
8563 def p_module_item_36(p):
8564 '''module_item : attribute_list_opt IDENTIFIER parameter_value_opt error ';' '''
8565 if(parse_debug):
8566 print('module_item_36', list(p))
8567
8568 # { yyerror(@2, "error: Invalid module instantiation");
8569 # delete[]p[2];
8570 # if (p[1]) delete p[1];
8571 # }
8572 ()
8573
8574
8575 def p_module_item_37(p):
8576 '''module_item : K_assign drive_strength_opt delay3_opt cont_assign_list ';' '''
8577 if(parse_debug > 2):
8578 print('module_item_37', list(p))
8579
8580 # { pform_make_pgassign_list(p[4], p[3], p[2], @1.text, @1.first_line); }
8581 ()
8582
8583
8584 def p_module_item_38(p):
8585 '''module_item : attribute_list_opt K_always statement_item '''
8586 if(parse_debug):
8587 print('module_item_38', list(p))
8588
8589 # { PProcess*tmp = pform_make_behavior(IVL_PR_ALWAYS, p[3], p[1]);
8590 # FILE_NAME(tmp, @2);
8591 # }
8592 ()
8593
8594
8595 def p_module_item_39(p):
8596 '''module_item : attribute_list_opt K_always_comb statement_item '''
8597 if(parse_debug):
8598 print('module_item_39', list(p))
8599
8600 # { PProcess*tmp = pform_make_behavior(IVL_PR_ALWAYS_COMB, p[3], p[1]);
8601 # FILE_NAME(tmp, @2);
8602 # }
8603 ()
8604
8605
8606 def p_module_item_40(p):
8607 '''module_item : attribute_list_opt K_always_ff statement_item '''
8608 if(parse_debug):
8609 print('module_item_40', list(p))
8610
8611 # { PProcess*tmp = pform_make_behavior(IVL_PR_ALWAYS_FF, p[3], p[1]);
8612 # FILE_NAME(tmp, @2);
8613 # }
8614 ()
8615
8616
8617 def p_module_item_41(p):
8618 '''module_item : attribute_list_opt K_always_latch statement_item '''
8619 if(parse_debug):
8620 print('module_item_41', list(p))
8621
8622 # { PProcess*tmp = pform_make_behavior(IVL_PR_ALWAYS_LATCH, p[3], p[1]);
8623 # FILE_NAME(tmp, @2);
8624 # }
8625 ()
8626
8627
8628 def p_module_item_42(p):
8629 '''module_item : attribute_list_opt K_initial statement_item '''
8630 if(parse_debug):
8631 print('module_item_42', list(p))
8632
8633 # { PProcess*tmp = pform_make_behavior(IVL_PR_INITIAL, p[3], p[1]);
8634 # FILE_NAME(tmp, @2);
8635 # }
8636 ()
8637
8638
8639 def p_module_item_43(p):
8640 '''module_item : attribute_list_opt K_final statement_item '''
8641 if(parse_debug):
8642 print('module_item_43', list(p))
8643
8644 # { PProcess*tmp = pform_make_behavior(IVL_PR_FINAL, p[3], p[1]);
8645 # FILE_NAME(tmp, @2);
8646 # }
8647 ()
8648
8649
8650 def p_module_item_44(p):
8651 '''module_item : attribute_list_opt K_analog analog_statement '''
8652 if(parse_debug):
8653 print('module_item_44', list(p))
8654
8655 # { pform_make_analog_behavior(@2, IVL_PR_ALWAYS, p[3]); }
8656 ()
8657
8658
8659 def p_module_item_45(p):
8660 '''module_item : attribute_list_opt assertion_item '''
8661 if(parse_debug):
8662 print('module_item_45', list(p))
8663
8664
8665 ()
8666
8667
8668 def p_module_item_46(p):
8669 '''module_item : timeunits_declaration '''
8670 if(parse_debug):
8671 print('module_item_46', list(p))
8672
8673
8674 ()
8675
8676
8677 def p_module_item_47(p):
8678 '''module_item : class_declaration '''
8679 if(parse_debug):
8680 print('module_item_47', list(p))
8681
8682
8683 ()
8684
8685
8686 def p_module_item_48(p):
8687 '''module_item : task_declaration '''
8688 if(parse_debug):
8689 print('module_item_48', list(p))
8690
8691
8692 ()
8693
8694
8695 def p_module_item_49(p):
8696 '''module_item : function_declaration '''
8697 if(parse_debug):
8698 print('module_item_49', list(p))
8699
8700
8701 ()
8702
8703
8704 def p_module_item_50(p):
8705 '''module_item : K_generate generate_item_list_opt K_endgenerate '''
8706 if(parse_debug):
8707 print('module_item_50', list(p))
8708
8709 # { // Test for bad nesting. I understand it, but it is illegal.
8710 # if (pform_parent_generate()) {
8711 # cerr << @1 << ": error: Generate/endgenerate regions cannot nest." << endl;
8712 # cerr << @1 << ": : Try removing optional generate/endgenerate keywords," << endl;
8713 # cerr << @1 << ": : or move them to surround the parent generate scheme." << endl;
8714 # error_count += 1;
8715 # }
8716 # }
8717 ()
8718
8719
8720 def p_module_item_51(p):
8721 '''module_item : K_genvar list_of_identifiers ';' '''
8722 if(parse_debug):
8723 print('module_item_51', list(p))
8724
8725 # { pform_genvars(@1, p[2]); }
8726 ()
8727
8728
8729 def p_module_item_52(p):
8730 '''module_item : K_for '(' IDENTIFIER '=' expression ';' expression ';' IDENTIFIER '=' expression ')' _embed2_module_item generate_block '''
8731 if(parse_debug):
8732 print('module_item_52', list(p))
8733
8734 # { pform_endgenerate(); }
8735 ()
8736
8737
8738 def p_module_item_53(p):
8739 '''module_item : generate_if generate_block_opt K_else _embed3_module_item generate_block '''
8740 if(parse_debug):
8741 print('module_item_53', list(p))
8742
8743 # { pform_endgenerate(); }
8744 ()
8745
8746
8747 def p_module_item_54(p):
8748 '''module_item : generate_if generate_block_opt %prec less_than_K_else '''
8749 if(parse_debug):
8750 print('module_item_54', list(p))
8751
8752 # { pform_endgenerate(); }
8753 ()
8754
8755
8756 def p_module_item_55(p):
8757 '''module_item : K_case '(' expression ')' _embed4_module_item generate_case_items K_endcase '''
8758 if(parse_debug):
8759 print('module_item_55', list(p))
8760
8761 # { pform_endgenerate(); }
8762 ()
8763
8764
8765 def p_module_item_56(p):
8766 '''module_item : modport_declaration '''
8767 if(parse_debug):
8768 print('module_item_56', list(p))
8769
8770
8771 ()
8772
8773
8774 def p_module_item_57(p):
8775 '''module_item : package_import_declaration '''
8776 if(parse_debug):
8777 print('module_item_57', list(p))
8778
8779
8780 ()
8781
8782
8783 def p_module_item_58(p):
8784 '''module_item : attribute_list_opt K_specparam _embed5_module_item specparam_decl ';' '''
8785 if(parse_debug):
8786 print('module_item_58', list(p))
8787
8788
8789 ()
8790
8791
8792 def p_module_item_59(p):
8793 '''module_item : K_specify _embed6_module_item specify_item_list_opt K_endspecify '''
8794 if(parse_debug):
8795 print('module_item_59', list(p))
8796
8797
8798 ()
8799
8800
8801 def p_module_item_60(p):
8802 '''module_item : K_specify error K_endspecify '''
8803 if(parse_debug):
8804 print('module_item_60', list(p))
8805
8806 # { yyerror(@1, "error: syntax error in specify block");
8807 # yyerrok;
8808 # }
8809 ()
8810
8811
8812 def p_module_item_61(p):
8813 '''module_item : error ';' '''
8814 if(parse_debug):
8815 print('module_item_61', list(p))
8816
8817 # { yyerror(@2, "error: invalid module item.");
8818 # yyerrok;
8819 # }
8820 ()
8821
8822
8823 def p_module_item_62(p):
8824 '''module_item : K_assign error '=' expression ';' '''
8825 if(parse_debug):
8826 print('module_item_62', list(p))
8827
8828 # { yyerror(@1, "error: syntax error in left side "
8829 # "of continuous assignment.");
8830 # yyerrok;
8831 # }
8832 ()
8833
8834
8835 def p_module_item_63(p):
8836 '''module_item : K_assign error ';' '''
8837 if(parse_debug):
8838 print('module_item_63', list(p))
8839
8840 # { yyerror(@1, "error: syntax error in "
8841 # "continuous assignment");
8842 # yyerrok;
8843 # }
8844 ()
8845
8846
8847 def p_module_item_64(p):
8848 '''module_item : K_function error K_endfunction endlabel_opt '''
8849 if(parse_debug):
8850 print('module_item_64', list(p))
8851
8852 # { yyerror(@1, "error: I give up on this "
8853 # "function definition.");
8854 # if (p[4]) {
8855 # if (!gn_system_verilog()) {
8856 # yyerror(@4, "error: Function end names require "
8857 # "SystemVerilog.");
8858 # }
8859 # delete[]p[4];
8860 # }
8861 # yyerrok;
8862 # }
8863 ()
8864
8865
8866 def p_module_item_65(p):
8867 '''module_item : KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' ';' '''
8868 if(parse_debug):
8869 print('module_item_65', list(p))
8870
8871 # { perm_string tmp3 = lex_strings.make(p[3]);
8872 # perm_string tmp5 = lex_strings.make(p[5]);
8873 # pform_set_attrib(tmp3, tmp5, p[7]);
8874 # delete[] p[3];
8875 # delete[] p[5];
8876 # }
8877 ()
8878
8879
8880 def p_module_item_66(p):
8881 '''module_item : KK_attribute '(' error ')' ';' '''
8882 if(parse_debug):
8883 print('module_item_66', list(p))
8884
8885 # { yyerror(@1, "error: Malformed $attribute parameter list."); }
8886 ()
8887
8888
8889 def p__embed0_module_item(p):
8890 '''_embed0_module_item : '''
8891
8892 # { attributes_in_context = p[1]; }
8893 ()
8894
8895
8896 def p__embed1_module_item(p):
8897 '''_embed1_module_item : '''
8898
8899 # { if (pform_in_interface())
8900 # yyerror(@1, "error: Parameter overrides are not allowed "
8901 # "in interfaces.");
8902 # }
8903 ()
8904
8905
8906 def p__embed2_module_item(p):
8907 '''_embed2_module_item : '''
8908
8909 # { pform_start_generate_for(@1, p[3], p[5], p[7], p[9], p[11]); }
8910 ()
8911
8912
8913 def p__embed3_module_item(p):
8914 '''_embed3_module_item : '''
8915
8916 # { pform_start_generate_else(@1); }
8917 ()
8918
8919
8920 def p__embed4_module_item(p):
8921 '''_embed4_module_item : '''
8922
8923 # { pform_start_generate_case(@1, p[3]); }
8924 ()
8925
8926
8927 def p__embed5_module_item(p):
8928 '''_embed5_module_item : '''
8929
8930 # { if (pform_in_interface())
8931 # yyerror(@1, "error: specparam declarations are not allowed "
8932 # "in interfaces.");
8933 # }
8934 ()
8935
8936
8937 def p__embed6_module_item(p):
8938 '''_embed6_module_item : '''
8939
8940 # { if (pform_in_interface())
8941 # yyerror(@1, "error: specify blocks are not allowed "
8942 # "in interfaces.");
8943 # }
8944 ()
8945
8946
8947 def p_module_item_list_1(p):
8948 '''module_item_list : module_item_list module_item '''
8949 if(parse_debug):
8950 print('module_item_list_1', list(p))
8951
8952
8953 ()
8954
8955
8956 def p_module_item_list_2(p):
8957 '''module_item_list : module_item '''
8958 if(parse_debug > 2):
8959 print('module_item_list_2', list(p))
8960
8961
8962 ()
8963
8964
8965 def p_module_item_list_opt_1(p):
8966 '''module_item_list_opt : module_item_list '''
8967 if(parse_debug > 2):
8968 print('module_item_list_opt_1', list(p))
8969
8970
8971 ()
8972
8973
8974 def p_module_item_list_opt_2(p):
8975 '''module_item_list_opt : '''
8976 if(parse_debug):
8977 print('module_item_list_opt_2', list(p))
8978
8979
8980 ()
8981
8982
8983 def p_generate_if_1(p):
8984 '''generate_if : K_if '(' expression ')' '''
8985 if(parse_debug):
8986 print('generate_if_1', list(p))
8987
8988 # { pform_start_generate_if(@1, p[3]); }
8989 ()
8990
8991
8992 def p_generate_case_items_1(p):
8993 '''generate_case_items : generate_case_items generate_case_item '''
8994 if(parse_debug):
8995 print('generate_case_items_1', list(p))
8996
8997
8998 ()
8999
9000
9001 def p_generate_case_items_2(p):
9002 '''generate_case_items : generate_case_item '''
9003 if(parse_debug):
9004 print('generate_case_items_2', list(p))
9005
9006
9007 ()
9008
9009
9010 def p_generate_case_item_1(p):
9011 '''generate_case_item : expression_list_proper ':' _embed0_generate_case_item generate_block_opt '''
9012 if(parse_debug):
9013 print('generate_case_item_1', list(p))
9014
9015 # { pform_endgenerate(); }
9016 ()
9017
9018
9019 def p_generate_case_item_2(p):
9020 '''generate_case_item : K_default ':' _embed1_generate_case_item generate_block_opt '''
9021 if(parse_debug):
9022 print('generate_case_item_2', list(p))
9023
9024 # { pform_endgenerate(); }
9025 ()
9026
9027
9028 def p__embed0_generate_case_item(p):
9029 '''_embed0_generate_case_item : '''
9030
9031 # { pform_generate_case_item(@1, p[1]); }
9032 ()
9033
9034
9035 def p__embed1_generate_case_item(p):
9036 '''_embed1_generate_case_item : '''
9037
9038 # { pform_generate_case_item(@1, 0); }
9039 ()
9040
9041
9042 def p_generate_item_1(p):
9043 '''generate_item : module_item '''
9044 if(parse_debug):
9045 print('generate_item_1', list(p))
9046
9047
9048 ()
9049
9050
9051 def p_generate_item_2(p):
9052 '''generate_item : K_begin generate_item_list_opt K_end '''
9053 if(parse_debug):
9054 print('generate_item_2', list(p))
9055
9056 # { /* Detect and warn about anachronistic begin/end use */
9057 # if (generation_flag > GN_VER2001 && warn_anachronisms) {
9058 # warn_count += 1;
9059 # cerr << @1 << ": warning: Anachronistic use of begin/end to surround generate schemes." << endl;
9060 # }
9061 # }
9062 ()
9063
9064
9065 def p_generate_item_3(p):
9066 '''generate_item : K_begin ':' IDENTIFIER _embed0_generate_item generate_item_list_opt K_end '''
9067 if(parse_debug):
9068 print('generate_item_3', list(p))
9069
9070 # { /* Detect and warn about anachronistic named begin/end use */
9071 # if (generation_flag > GN_VER2001 && warn_anachronisms) {
9072 # warn_count += 1;
9073 # cerr << @1 << ": warning: Anachronistic use of named begin/end to surround generate schemes." << endl;
9074 # }
9075 # pform_endgenerate();
9076 # }
9077 ()
9078
9079
9080 def p__embed0_generate_item(p):
9081 '''_embed0_generate_item : '''
9082
9083 # {
9084 # pform_start_generate_nblock(@1, p[3]);
9085 # }
9086 ()
9087
9088
9089 def p_generate_item_list_1(p):
9090 '''generate_item_list : generate_item_list generate_item '''
9091 if(parse_debug):
9092 print('generate_item_list_1', list(p))
9093
9094
9095 ()
9096
9097
9098 def p_generate_item_list_2(p):
9099 '''generate_item_list : generate_item '''
9100 if(parse_debug):
9101 print('generate_item_list_2', list(p))
9102
9103
9104 ()
9105
9106
9107 def p_generate_item_list_opt_1(p):
9108 '''generate_item_list_opt : generate_item_list '''
9109 if(parse_debug):
9110 print('generate_item_list_opt_1', list(p))
9111
9112
9113 ()
9114
9115
9116 def p_generate_item_list_opt_2(p):
9117 '''generate_item_list_opt : '''
9118 if(parse_debug):
9119 print('generate_item_list_opt_2', list(p))
9120
9121
9122 ()
9123
9124
9125 def p_generate_block_1(p):
9126 '''generate_block : module_item '''
9127 if(parse_debug):
9128 print('generate_block_1', list(p))
9129
9130
9131 ()
9132
9133
9134 def p_generate_block_2(p):
9135 '''generate_block : K_begin generate_item_list_opt K_end '''
9136 if(parse_debug):
9137 print('generate_block_2', list(p))
9138
9139
9140 ()
9141
9142
9143 def p_generate_block_3(p):
9144 '''generate_block : K_begin ':' IDENTIFIER generate_item_list_opt K_end endlabel_opt '''
9145 if(parse_debug):
9146 print('generate_block_3', list(p))
9147
9148 # { pform_generate_block_name(p[3]);
9149 # if (p[6]) {
9150 # if (strcmp(p[3],p[6]) != 0) {
9151 # yyerror(@6, "error: End label doesn't match "
9152 # "begin name");
9153 # }
9154 # if (! gn_system_verilog()) {
9155 # yyerror(@6, "error: Begin end labels require "
9156 # "SystemVerilog.");
9157 # }
9158 # delete[]p[6];
9159 # }
9160 # delete[]p[3];
9161 # }
9162 ()
9163
9164
9165 def p_generate_block_opt_1(p):
9166 '''generate_block_opt : generate_block '''
9167 if(parse_debug):
9168 print('generate_block_opt_1', list(p))
9169
9170
9171 ()
9172
9173
9174 def p_generate_block_opt_2(p):
9175 '''generate_block_opt : ';' '''
9176 if(parse_debug):
9177 print('generate_block_opt_2', list(p))
9178
9179
9180 ()
9181
9182
9183 def p_net_decl_assign_1(p):
9184 '''net_decl_assign : IDENTIFIER '=' expression '''
9185 if(parse_debug):
9186 print('net_decl_assign_1', list(p))
9187
9188 # { net_decl_assign_t*tmp = new net_decl_assign_t;
9189 # tmp->next = tmp;
9190 # tmp->name = lex_strings.make(p[1]);
9191 # tmp->expr = p[3];
9192 # delete[]p[1];
9193 # p[0] = tmp;
9194 # }
9195 ()
9196
9197
9198 def p_net_decl_assigns_1(p):
9199 '''net_decl_assigns : net_decl_assigns ',' net_decl_assign '''
9200 if(parse_debug):
9201 print('net_decl_assigns_1', list(p))
9202
9203 # { net_decl_assign_t*tmp = p[1];
9204 # p[3]->next = tmp->next;
9205 # tmp->next = p[3];
9206 # p[0] = tmp;
9207 # }
9208 ()
9209
9210
9211 def p_net_decl_assigns_2(p):
9212 '''net_decl_assigns : net_decl_assign '''
9213 if(parse_debug):
9214 print('net_decl_assigns_2', list(p))
9215
9216 # { p[0] = p[1];
9217 # }
9218 ()
9219
9220
9221 def p_bit_logic_1(p):
9222 '''bit_logic : K_logic '''
9223 if(parse_debug):
9224 print('bit_logic_1', list(p))
9225
9226 # { p[0] = IVL_VT_LOGIC; }
9227 ()
9228
9229
9230 def p_bit_logic_2(p):
9231 '''bit_logic : K_bool '''
9232 if(parse_debug):
9233 print('bit_logic_2', list(p))
9234
9235 # { p[0] = IVL_VT_BOOL; /* Icarus misc */}
9236 ()
9237
9238
9239 def p_bit_logic_3(p):
9240 '''bit_logic : K_bit '''
9241 if(parse_debug):
9242 print('bit_logic_3', list(p))
9243
9244 # { p[0] = IVL_VT_BOOL; /* IEEE1800 / IEEE1364-2009 */}
9245 ()
9246
9247
9248 def p_bit_logic_opt_1(p):
9249 '''bit_logic_opt : bit_logic '''
9250 if(parse_debug):
9251 print('bit_logic_opt_1', list(p))
9252
9253
9254 ()
9255
9256
9257 def p_bit_logic_opt_2(p):
9258 '''bit_logic_opt : '''
9259 if(parse_debug):
9260 print('bit_logic_opt_2', list(p))
9261
9262 # { p[0] = IVL_VT_NO_TYPE; }
9263 ()
9264
9265
9266 def p_net_type_1(p):
9267 '''net_type : K_wire '''
9268 if(parse_debug > 2):
9269 print('net_type_1', list(p))
9270
9271 p[0] = "wire"
9272
9273
9274 ()
9275
9276
9277 def p_net_type_2(p):
9278 '''net_type : K_tri '''
9279 if(parse_debug):
9280 print('net_type_2', list(p))
9281
9282 # { p[0] = NetNet::TRI; }
9283 ()
9284
9285
9286 def p_net_type_3(p):
9287 '''net_type : K_tri1 '''
9288 if(parse_debug):
9289 print('net_type_3', list(p))
9290
9291 # { p[0] = NetNet::TRI1; }
9292 ()
9293
9294
9295 def p_net_type_4(p):
9296 '''net_type : K_supply0 '''
9297 if(parse_debug):
9298 print('net_type_4', list(p))
9299
9300 # { p[0] = NetNet::SUPPLY0; }
9301 ()
9302
9303
9304 def p_net_type_5(p):
9305 '''net_type : K_wand '''
9306 if(parse_debug):
9307 print('net_type_5', list(p))
9308
9309 # { p[0] = NetNet::WAND; }
9310 ()
9311
9312
9313 def p_net_type_6(p):
9314 '''net_type : K_triand '''
9315 if(parse_debug):
9316 print('net_type_6', list(p))
9317
9318 # { p[0] = NetNet::TRIAND; }
9319 ()
9320
9321
9322 def p_net_type_7(p):
9323 '''net_type : K_tri0 '''
9324 if(parse_debug):
9325 print('net_type_7', list(p))
9326
9327 # { p[0] = NetNet::TRI0; }
9328 ()
9329
9330
9331 def p_net_type_8(p):
9332 '''net_type : K_supply1 '''
9333 if(parse_debug):
9334 print('net_type_8', list(p))
9335
9336 # { p[0] = NetNet::SUPPLY1; }
9337 ()
9338
9339
9340 def p_net_type_9(p):
9341 '''net_type : K_wor '''
9342 if(parse_debug):
9343 print('net_type_9', list(p))
9344
9345 # { p[0] = NetNet::WOR; }
9346 ()
9347
9348
9349 def p_net_type_10(p):
9350 '''net_type : K_trior '''
9351 if(parse_debug):
9352 print('net_type_10', list(p))
9353
9354 # { p[0] = NetNet::TRIOR; }
9355 ()
9356
9357
9358 def p_net_type_11(p):
9359 '''net_type : K_wone '''
9360 if(parse_debug):
9361 print('net_type_11', list(p))
9362
9363 # { p[0] = NetNet::UNRESOLVED_WIRE;
9364 # cerr << @1.text << ":" << @1.first_line << ": warning: "
9365 # "'wone' is deprecated, please use 'uwire' "
9366 # "instead." << endl;
9367 # }
9368 ()
9369
9370
9371 def p_net_type_12(p):
9372 '''net_type : K_uwire '''
9373 if(parse_debug):
9374 print('net_type_12', list(p))
9375
9376 # { p[0] = NetNet::UNRESOLVED_WIRE; }
9377 ()
9378
9379
9380 def p_param_type_1(p):
9381 '''param_type : bit_logic_opt unsigned_signed_opt dimensions_opt '''
9382 if(parse_debug):
9383 print('param_type_1', list(p))
9384
9385 # { param_active_range = p[3];
9386 # param_active_signed = p[2];
9387 # if ((p[1] == IVL_VT_NO_TYPE) && (p[3] != 0))
9388 # param_active_type = IVL_VT_LOGIC;
9389 # else
9390 # param_active_type = p[1];
9391 # }
9392 ()
9393
9394
9395 def p_param_type_2(p):
9396 '''param_type : K_integer '''
9397 if(parse_debug):
9398 print('param_type_2', list(p))
9399
9400 # { param_active_range = make_range_from_width(integer_width);
9401 # param_active_signed = true;
9402 # param_active_type = IVL_VT_LOGIC;
9403 # }
9404 ()
9405
9406
9407 def p_param_type_3(p):
9408 '''param_type : K_time '''
9409 if(parse_debug):
9410 print('param_type_3', list(p))
9411
9412 # { param_active_range = make_range_from_width(64);
9413 # param_active_signed = false;
9414 # param_active_type = IVL_VT_LOGIC;
9415 # }
9416 ()
9417
9418
9419 def p_param_type_4(p):
9420 '''param_type : real_or_realtime '''
9421 if(parse_debug):
9422 print('param_type_4', list(p))
9423
9424 # { param_active_range = 0;
9425 # param_active_signed = true;
9426 # param_active_type = IVL_VT_REAL;
9427 # }
9428 ()
9429
9430
9431 def p_param_type_5(p):
9432 '''param_type : atom2_type '''
9433 if(parse_debug):
9434 print('param_type_5', list(p))
9435
9436 # { param_active_range = make_range_from_width(p[1]);
9437 # param_active_signed = true;
9438 # param_active_type = IVL_VT_BOOL;
9439 # }
9440 ()
9441
9442
9443 def p_param_type_6(p):
9444 '''param_type : TYPE_IDENTIFIER '''
9445 if(parse_debug):
9446 print('param_type_6', list(p))
9447
9448 # { pform_set_param_from_type(@1, p[1].type, p[1].text, param_active_range,
9449 # param_active_signed, param_active_type);
9450 # delete[]p[1].text;
9451 # }
9452 ()
9453
9454
9455 def p_parameter_assign_list_1(p):
9456 '''parameter_assign_list : parameter_assign '''
9457 if(parse_debug):
9458 print('parameter_assign_list_1', list(p))
9459
9460
9461 ()
9462
9463
9464 def p_parameter_assign_list_2(p):
9465 '''parameter_assign_list : parameter_assign_list ',' parameter_assign '''
9466 if(parse_debug):
9467 print('parameter_assign_list_2', list(p))
9468
9469
9470 ()
9471
9472
9473 def p_localparam_assign_list_1(p):
9474 '''localparam_assign_list : localparam_assign '''
9475 if(parse_debug):
9476 print('localparam_assign_list_1', list(p))
9477
9478
9479 ()
9480
9481
9482 def p_localparam_assign_list_2(p):
9483 '''localparam_assign_list : localparam_assign_list ',' localparam_assign '''
9484 if(parse_debug):
9485 print('localparam_assign_list_2', list(p))
9486
9487
9488 ()
9489
9490
9491 def p_parameter_assign_1(p):
9492 '''parameter_assign : IDENTIFIER '=' expression parameter_value_ranges_opt '''
9493 if(parse_debug):
9494 print('parameter_assign_1', list(p))
9495 tpname = Node(syms.tname, [Leaf(token.NAME, p[1])])
9496 expr = Node(syms.tfpdef, [tpname, Leaf(token.EQUAL, p[2]), p[3]])
9497 p[0] = expr
9498
9499 # { PExpr*tmp = p[3];
9500 # pform_set_parameter(@1, lex_strings.make(p[1]), param_active_type,
9501 # param_active_signed, param_active_range, tmp, p[4]);
9502 # delete[]p[1];
9503 # }
9504 ()
9505
9506
9507 def p_localparam_assign_1(p):
9508 '''localparam_assign : IDENTIFIER '=' expression '''
9509 if(parse_debug):
9510 print('localparam_assign_1', list(p))
9511
9512 # { PExpr*tmp = p[3];
9513 # pform_set_localparam(@1, lex_strings.make(p[1]), param_active_type,
9514 # param_active_signed, param_active_range, tmp);
9515 # delete[]p[1];
9516 # }
9517 ()
9518
9519
9520 def p_parameter_value_ranges_opt_1(p):
9521 '''parameter_value_ranges_opt : parameter_value_ranges '''
9522 if(parse_debug):
9523 print('parameter_value_ranges_opt_1', list(p))
9524 p[0] = p[1]
9525
9526
9527 ()
9528
9529
9530 def p_parameter_value_ranges_opt_2(p):
9531 '''parameter_value_ranges_opt : '''
9532 if(parse_debug):
9533 print('parameter_value_ranges_opt_2', list(p))
9534
9535 # { p[0] = None }
9536 ()
9537
9538
9539 def p_parameter_value_ranges_1(p):
9540 '''parameter_value_ranges : parameter_value_ranges parameter_value_range '''
9541 if(parse_debug):
9542 print('parameter_value_ranges_1', list(p))
9543
9544 # { p[0] = p[2]; p[0]->next = p[1]; }
9545 ()
9546
9547
9548 def p_parameter_value_ranges_2(p):
9549 '''parameter_value_ranges : parameter_value_range '''
9550 if(parse_debug):
9551 print('parameter_value_ranges_2', list(p))
9552
9553 # { p[0] = p[1]; p[0]->next = 0; }
9554 ()
9555
9556
9557 def p_parameter_value_range_1(p):
9558 '''parameter_value_range : from_exclude '[' value_range_expression ':' value_range_expression ']' '''
9559 if(parse_debug):
9560 print('parameter_value_range_1', list(p))
9561
9562 # { p[0] = pform_parameter_value_range(p[1], false, p[3], false, p[5]); }
9563 ()
9564
9565
9566 def p_parameter_value_range_2(p):
9567 '''parameter_value_range : from_exclude '[' value_range_expression ':' value_range_expression ')' '''
9568 if(parse_debug):
9569 print('parameter_value_range_2', list(p))
9570
9571 # { p[0] = pform_parameter_value_range(p[1], false, p[3], true, p[5]); }
9572 ()
9573
9574
9575 def p_parameter_value_range_3(p):
9576 '''parameter_value_range : from_exclude '(' value_range_expression ':' value_range_expression ']' '''
9577 if(parse_debug):
9578 print('parameter_value_range_3', list(p))
9579
9580 # { p[0] = pform_parameter_value_range(p[1], true, p[3], false, p[5]); }
9581 ()
9582
9583
9584 def p_parameter_value_range_4(p):
9585 '''parameter_value_range : from_exclude '(' value_range_expression ':' value_range_expression ')' '''
9586 if(parse_debug):
9587 print('parameter_value_range_4', list(p))
9588
9589 # { p[0] = pform_parameter_value_range(p[1], true, p[3], true, p[5]); }
9590 ()
9591
9592
9593 def p_parameter_value_range_5(p):
9594 '''parameter_value_range : K_exclude expression '''
9595 if(parse_debug):
9596 print('parameter_value_range_5', list(p))
9597
9598 # { p[0] = pform_parameter_value_range(true, false, p[2], false, p[2]); }
9599 ()
9600
9601
9602 def p_value_range_expression_1(p):
9603 '''value_range_expression : expression '''
9604 if(parse_debug):
9605 print('value_range_expression_1', list(p))
9606 p[0] = p[1]
9607
9608
9609 ()
9610
9611
9612 def p_value_range_expression_2(p):
9613 '''value_range_expression : K_inf '''
9614 if(parse_debug):
9615 print('value_range_expression_2', list(p))
9616
9617 # { p[0] = None }
9618 ()
9619
9620
9621 def p_value_range_expression_3(p):
9622 '''value_range_expression : '+' K_inf '''
9623 if(parse_debug):
9624 print('value_range_expression_3', list(p))
9625
9626 # { p[0] = None }
9627 ()
9628
9629
9630 def p_value_range_expression_4(p):
9631 '''value_range_expression : '-' K_inf '''
9632 if(parse_debug):
9633 print('value_range_expression_4', list(p))
9634
9635 # { p[0] = None }
9636 ()
9637
9638
9639 def p_from_exclude_1(p):
9640 '''from_exclude : K_from '''
9641 if(parse_debug):
9642 print('from_exclude_1', list(p))
9643 p[0] = False
9644
9645
9646 ()
9647
9648
9649 def p_from_exclude_2(p):
9650 '''from_exclude : K_exclude '''
9651 if(parse_debug):
9652 print('from_exclude_2', list(p))
9653 p[0] = True
9654
9655
9656 ()
9657
9658
9659 def p_parameter_value_opt_1(p):
9660 '''parameter_value_opt : '#' '(' expression_list_with_nuls ')' '''
9661 if(parse_debug):
9662 print('parameter_value_opt_1', list(p))
9663
9664 # { struct parmvalue_t*tmp = new struct parmvalue_t;
9665 # tmp->by_order = p[3];
9666 # tmp->by_name = 0;
9667 # p[0] = tmp;
9668 # }
9669 ()
9670
9671
9672 def p_parameter_value_opt_2(p):
9673 '''parameter_value_opt : '#' '(' parameter_value_byname_list ')' '''
9674 if(parse_debug):
9675 print('parameter_value_opt_2', list(p))
9676
9677 # { struct parmvalue_t*tmp = new struct parmvalue_t;
9678 # tmp->by_order = 0;
9679 # tmp->by_name = p[3];
9680 # p[0] = tmp;
9681 # }
9682 ()
9683
9684
9685 def p_parameter_value_opt_3(p):
9686 '''parameter_value_opt : '#' DEC_NUMBER '''
9687 if(parse_debug):
9688 print('parameter_value_opt_3', list(p))
9689
9690 # { assert(p[2]);
9691 # PENumber*tmp = new PENumber(p[2]);
9692 # FILE_NAME(tmp, @1);
9693 #
9694 # struct parmvalue_t*lst = new struct parmvalue_t;
9695 # lst->by_order = new list<PExpr*>;
9696 # lst->by_order->push_back(tmp);
9697 # lst->by_name = 0;
9698 # p[0] = lst;
9699 # based_size = 0;
9700 # }
9701 ()
9702
9703
9704 def p_parameter_value_opt_4(p):
9705 '''parameter_value_opt : '#' REALTIME '''
9706 if(parse_debug):
9707 print('parameter_value_opt_4', list(p))
9708
9709 # { assert(p[2]);
9710 # PEFNumber*tmp = new PEFNumber(p[2]);
9711 # FILE_NAME(tmp, @1);
9712 #
9713 # struct parmvalue_t*lst = new struct parmvalue_t;
9714 # lst->by_order = new list<PExpr*>;
9715 # lst->by_order->push_back(tmp);
9716 # lst->by_name = 0;
9717 # p[0] = lst;
9718 # }
9719 ()
9720
9721
9722 def p_parameter_value_opt_5(p):
9723 '''parameter_value_opt : '#' error '''
9724 if(parse_debug):
9725 print('parameter_value_opt_5', list(p))
9726
9727 # { yyerror(@1, "error: syntax error in parameter value "
9728 # "assignment list.");
9729 # p[0] = None
9730 # }
9731 ()
9732
9733
9734 def p_parameter_value_opt_6(p):
9735 '''parameter_value_opt : '''
9736 if(parse_debug):
9737 print('parameter_value_opt_6', list(p))
9738
9739 # { p[0] = None }
9740 ()
9741
9742
9743 def p_parameter_value_byname_1(p):
9744 '''parameter_value_byname : '.' IDENTIFIER '(' expression ')' '''
9745 if(parse_debug):
9746 print('parameter_value_byname_1', list(p))
9747
9748 # { named_pexpr_t*tmp = new named_pexpr_t;
9749 # tmp->name = lex_strings.make(p[2]);
9750 # tmp->parm = p[4];
9751 # delete[]p[2];
9752 # p[0] = tmp;
9753 # }
9754 ()
9755
9756
9757 def p_parameter_value_byname_2(p):
9758 '''parameter_value_byname : '.' IDENTIFIER '(' ')' '''
9759 if(parse_debug):
9760 print('parameter_value_byname_2', list(p))
9761
9762 # { named_pexpr_t*tmp = new named_pexpr_t;
9763 # tmp->name = lex_strings.make(p[2]);
9764 # tmp->parm = 0;
9765 # delete[]p[2];
9766 # p[0] = tmp;
9767 # }
9768 ()
9769
9770
9771 def p_parameter_value_byname_list_1(p):
9772 '''parameter_value_byname_list : parameter_value_byname '''
9773 if(parse_debug):
9774 print('parameter_value_byname_list_1', list(p))
9775
9776 # { list<named_pexpr_t>*tmp = new list<named_pexpr_t>;
9777 # tmp->push_back(*p[1]);
9778 # delete p[1];
9779 # p[0] = tmp;
9780 # }
9781 ()
9782
9783
9784 def p_parameter_value_byname_list_2(p):
9785 '''parameter_value_byname_list : parameter_value_byname_list ',' parameter_value_byname '''
9786 if(parse_debug):
9787 print('parameter_value_byname_list_2', list(p))
9788
9789 # { list<named_pexpr_t>*tmp = p[1];
9790 # tmp->push_back(*p[3]);
9791 # delete p[3];
9792 # p[0] = tmp;
9793 # }
9794 ()
9795
9796
9797 def p_port_1(p):
9798 '''port : port_reference '''
9799 if(parse_debug):
9800 print('port_1', list(p))
9801 p[0] = p[1]
9802
9803
9804 ()
9805
9806
9807 def p_port_2(p):
9808 '''port : '.' IDENTIFIER '(' port_reference ')' '''
9809 if(parse_debug):
9810 print('port_2', list(p))
9811
9812 # { Module::port_t*tmp = p[4];
9813 # tmp->name = lex_strings.make(p[2]);
9814 # delete[]p[2];
9815 # p[0] = tmp;
9816 # }
9817 ()
9818
9819
9820 def p_port_3(p):
9821 '''port : '{' port_reference_list '}' '''
9822 if(parse_debug):
9823 print('port_3', list(p))
9824
9825 # { Module::port_t*tmp = p[2];
9826 # tmp->name = perm_string();
9827 # p[0] = tmp;
9828 # }
9829 ()
9830
9831
9832 def p_port_4(p):
9833 '''port : '.' IDENTIFIER '(' '{' port_reference_list '}' ')' '''
9834 if(parse_debug):
9835 print('port_4', list(p))
9836
9837 # { Module::port_t*tmp = p[5];
9838 # tmp->name = lex_strings.make(p[2]);
9839 # delete[]p[2];
9840 # p[0] = tmp;
9841 # }
9842 ()
9843
9844
9845 def p_port_opt_1(p):
9846 '''port_opt : port '''
9847 if(parse_debug):
9848 print('port_opt_1', list(p))
9849 p[0] = p[1]
9850
9851
9852 ()
9853
9854
9855 def p_port_opt_2(p):
9856 '''port_opt : '''
9857 if(parse_debug):
9858 print('port_opt_2', list(p))
9859
9860 # { p[0] = None }
9861 ()
9862
9863
9864 def p_port_name_1(p):
9865 '''port_name : '.' IDENTIFIER '(' expression ')' '''
9866 if(parse_debug):
9867 print('port_name_1', list(p))
9868
9869 # { named_pexpr_t*tmp = new named_pexpr_t;
9870 # tmp->name = lex_strings.make(p[2]);
9871 # tmp->parm = p[4];
9872 # delete[]p[2];
9873 # p[0] = tmp;
9874 # }
9875 ()
9876
9877
9878 def p_port_name_2(p):
9879 '''port_name : '.' IDENTIFIER '(' error ')' '''
9880 if(parse_debug):
9881 print('port_name_2', list(p))
9882
9883 # { yyerror(@3, "error: invalid port connection expression.");
9884 # named_pexpr_t*tmp = new named_pexpr_t;
9885 # tmp->name = lex_strings.make(p[2]);
9886 # tmp->parm = 0;
9887 # delete[]p[2];
9888 # p[0] = tmp;
9889 # }
9890 ()
9891
9892
9893 def p_port_name_3(p):
9894 '''port_name : '.' IDENTIFIER '(' ')' '''
9895 if(parse_debug):
9896 print('port_name_3', list(p))
9897
9898 # { named_pexpr_t*tmp = new named_pexpr_t;
9899 # tmp->name = lex_strings.make(p[2]);
9900 # tmp->parm = 0;
9901 # delete[]p[2];
9902 # p[0] = tmp;
9903 # }
9904 ()
9905
9906
9907 def p_port_name_4(p):
9908 '''port_name : '.' IDENTIFIER '''
9909 if(parse_debug):
9910 print('port_name_4', list(p))
9911
9912 # { named_pexpr_t*tmp = new named_pexpr_t;
9913 # tmp->name = lex_strings.make(p[2]);
9914 # tmp->parm = new PEIdent(lex_strings.make(p[2]), true);
9915 # FILE_NAME(tmp->parm, @1);
9916 # delete[]p[2];
9917 # p[0] = tmp;
9918 # }
9919 ()
9920
9921
9922 def p_port_name_5(p):
9923 '''port_name : K_DOTSTAR '''
9924 if(parse_debug):
9925 print('port_name_5', list(p))
9926
9927 # { named_pexpr_t*tmp = new named_pexpr_t;
9928 # tmp->name = lex_strings.make("*");
9929 # tmp->parm = 0;
9930 # p[0] = tmp;
9931 # }
9932 ()
9933
9934
9935 def p_port_name_list_1(p):
9936 '''port_name_list : port_name_list ',' port_name '''
9937 if(parse_debug):
9938 print('port_name_list_1', list(p))
9939
9940 # { list<named_pexpr_t>*tmp = p[1];
9941 # tmp->push_back(*p[3]);
9942 # delete p[3];
9943 # p[0] = tmp;
9944 # }
9945 ()
9946
9947
9948 def p_port_name_list_2(p):
9949 '''port_name_list : port_name '''
9950 if(parse_debug):
9951 print('port_name_list_2', list(p))
9952
9953 # { list<named_pexpr_t>*tmp = new list<named_pexpr_t>;
9954 # tmp->push_back(*p[1]);
9955 # delete p[1];
9956 # p[0] = tmp;
9957 # }
9958 ()
9959
9960
9961 def p_port_reference_1(p):
9962 '''port_reference : IDENTIFIER '''
9963 if(parse_debug):
9964 print('port_reference_1', list(p))
9965
9966 # { Module::port_t*ptmp;
9967 # perm_string name = lex_strings.make(p[1]);
9968 # ptmp = pform_module_port_reference(name, @1.text, @1.first_line);
9969 # delete[]p[1];
9970 # p[0] = ptmp;
9971 # }
9972 ()
9973
9974
9975 def p_port_reference_2(p):
9976 '''port_reference : IDENTIFIER '[' expression ':' expression ']' '''
9977 if(parse_debug):
9978 print('port_reference_2', list(p))
9979
9980 # { index_component_t itmp;
9981 # itmp.sel = index_component_t::SEL_PART;
9982 # itmp.msb = p[3];
9983 # itmp.lsb = p[5];
9984 #
9985 # name_component_t ntmp (lex_strings.make(p[1]));
9986 # ntmp.index.push_back(itmp);
9987 #
9988 # pform_name_t pname;
9989 # pname.push_back(ntmp);
9990 #
9991 # PEIdent*wtmp = new PEIdent(pname);
9992 # FILE_NAME(wtmp, @1);
9993 #
9994 # Module::port_t*ptmp = new Module::port_t;
9995 # ptmp->name = perm_string();
9996 # ptmp->expr.push_back(wtmp);
9997 #
9998 # delete[]p[1];
9999 # p[0] = ptmp;
10000 # }
10001 ()
10002
10003
10004 def p_port_reference_3(p):
10005 '''port_reference : IDENTIFIER '[' expression ']' '''
10006 if(parse_debug):
10007 print('port_reference_3', list(p))
10008
10009 # { index_component_t itmp;
10010 # itmp.sel = index_component_t::SEL_BIT;
10011 # itmp.msb = p[3];
10012 # itmp.lsb = 0;
10013 #
10014 # name_component_t ntmp (lex_strings.make(p[1]));
10015 # ntmp.index.push_back(itmp);
10016 #
10017 # pform_name_t pname;
10018 # pname.push_back(ntmp);
10019 #
10020 # PEIdent*tmp = new PEIdent(pname);
10021 # FILE_NAME(tmp, @1);
10022 #
10023 # Module::port_t*ptmp = new Module::port_t;
10024 # ptmp->name = perm_string();
10025 # ptmp->expr.push_back(tmp);
10026 # delete[]p[1];
10027 # p[0] = ptmp;
10028 # }
10029 ()
10030
10031
10032 def p_port_reference_4(p):
10033 '''port_reference : IDENTIFIER '[' error ']' '''
10034 if(parse_debug):
10035 print('port_reference_4', list(p))
10036
10037 # { yyerror(@1, "error: invalid port bit select");
10038 # Module::port_t*ptmp = new Module::port_t;
10039 # PEIdent*wtmp = new PEIdent(lex_strings.make(p[1]));
10040 # FILE_NAME(wtmp, @1);
10041 # ptmp->name = lex_strings.make(p[1]);
10042 # ptmp->expr.push_back(wtmp);
10043 # delete[]p[1];
10044 # p[0] = ptmp;
10045 # }
10046 ()
10047
10048
10049 def p_port_reference_list_1(p):
10050 '''port_reference_list : port_reference '''
10051 if(parse_debug):
10052 print('port_reference_list_1', list(p))
10053 p[0] = p[1]
10054
10055
10056 ()
10057
10058
10059 def p_port_reference_list_2(p):
10060 '''port_reference_list : port_reference_list ',' port_reference '''
10061 if(parse_debug):
10062 print('port_reference_list_2', list(p))
10063
10064 # { Module::port_t*tmp = p[1];
10065 # append(tmp->expr, p[3]->expr);
10066 # delete p[3];
10067 # p[0] = tmp;
10068 # }
10069 ()
10070
10071
10072 def p_dimensions_opt_1(p):
10073 '''dimensions_opt : '''
10074 if(parse_debug > 2):
10075 print('dimensions_opt_1', list(p))
10076
10077 # { p[0] = None }
10078 ()
10079
10080
10081 def p_dimensions_opt_2(p):
10082 '''dimensions_opt : dimensions '''
10083 if(parse_debug):
10084 print('dimensions_opt_2', list(p))
10085 p[0] = p[1]
10086
10087
10088 ()
10089
10090
10091 def p_dimensions_1(p):
10092 '''dimensions : variable_dimension '''
10093 if(parse_debug):
10094 print('dimensions_1', list(p))
10095 p[0] = p[1]
10096
10097
10098 ()
10099
10100
10101 def p_dimensions_2(p):
10102 '''dimensions : dimensions variable_dimension '''
10103 if(parse_debug):
10104 print('dimensions_2', list(p))
10105
10106 # { list<pform_range_t> *tmp = p[1];
10107 # if (p[2]) {
10108 # tmp->splice(tmp->end(), *p[2]);
10109 # delete p[2];
10110 # }
10111 # p[0] = tmp;
10112 # }
10113 ()
10114
10115
10116 def p_register_variable_1(p):
10117 '''register_variable : IDENTIFIER dimensions_opt '''
10118 if(parse_debug):
10119 print('register_variable_1', list(p))
10120
10121 # { perm_string name = lex_strings.make(p[1]);
10122 # pform_makewire(@1, name, NetNet::REG,
10123 # NetNet::NOT_A_PORT, IVL_VT_NO_TYPE, 0);
10124 # pform_set_reg_idx(name, p[2]);
10125 # p[0] = p[1];
10126 # }
10127 ()
10128
10129
10130 def p_register_variable_2(p):
10131 '''register_variable : IDENTIFIER dimensions_opt '=' expression '''
10132 if(parse_debug):
10133 print('register_variable_2', list(p))
10134
10135 # { if (pform_peek_scope()->var_init_needs_explicit_lifetime()
10136 # && (var_lifetime == LexicalScope::INHERITED)) {
10137 # cerr << @3 << ": warning: Static variable initialization requires "
10138 # "explicit lifetime in this context." << endl;
10139 # warn_count += 1;
10140 # }
10141 # perm_string name = lex_strings.make(p[1]);
10142 # pform_makewire(@1, name, NetNet::REG,
10143 # NetNet::NOT_A_PORT, IVL_VT_NO_TYPE, 0);
10144 # pform_set_reg_idx(name, p[2]);
10145 # pform_make_var_init(@1, name, p[4]);
10146 # p[0] = p[1];
10147 # }
10148 ()
10149
10150
10151 def p_register_variable_list_1(p):
10152 '''register_variable_list : register_variable '''
10153 if(parse_debug):
10154 print('register_variable_list_1', list(p))
10155
10156 # { list<perm_string>*tmp = new list<perm_string>;
10157 # tmp->push_back(lex_strings.make(p[1]));
10158 # p[0] = tmp;
10159 # delete[]p[1];
10160 # }
10161 ()
10162
10163
10164 def p_register_variable_list_2(p):
10165 '''register_variable_list : register_variable_list ',' register_variable '''
10166 if(parse_debug):
10167 print('register_variable_list_2', list(p))
10168
10169 # { list<perm_string>*tmp = p[1];
10170 # tmp->push_back(lex_strings.make(p[3]));
10171 # p[0] = tmp;
10172 # delete[]p[3];
10173 # }
10174 ()
10175
10176
10177 def p_net_variable_1(p):
10178 '''net_variable : IDENTIFIER dimensions_opt '''
10179 if(parse_debug > 2):
10180 print('net_variable_1', list(p))
10181
10182 #p[0]= ('net_variable_1', list(p))
10183
10184 # { perm_string name = lex_strings.make(p[1]);
10185 # pform_makewire(@1, name, NetNet::IMPLICIT,
10186 # NetNet::NOT_A_PORT, IVL_VT_NO_TYPE, 0);
10187 # pform_set_reg_idx(name, p[2]);
10188 p[0] = [p[1], p[2]]
10189
10190
10191 # }
10192 ()
10193
10194
10195 def p_net_variable_list_1(p):
10196 '''net_variable_list : net_variable '''
10197 if(parse_debug > 2):
10198 print('net_variable_list_1', list(p))
10199 p[0] = [p[1]]
10200
10201 # { list<perm_string>*tmp = new list<perm_string>;
10202 # tmp->push_back(lex_strings.make(p[1]));
10203 # p[0] = tmp;
10204 # delete[]p[1];
10205 # }
10206 ()
10207
10208
10209 def p_net_variable_list_2(p):
10210 '''net_variable_list : net_variable_list ',' net_variable '''
10211 if(parse_debug > 2):
10212 print('net_variable_list_2', list(p))
10213 p[0] = p[1]+[p[3]]
10214
10215 # { list<perm_string>*tmp = p[1];
10216 # tmp->push_back(lex_strings.make(p[3]));
10217 # p[0] = tmp;
10218 # delete[]p[3];
10219 # }
10220 ()
10221
10222
10223 def p_event_variable_1(p):
10224 '''event_variable : IDENTIFIER dimensions_opt '''
10225 if(parse_debug):
10226 print('event_variable_1', list(p))
10227
10228 # { if (p[2]) {
10229 # yyerror(@2, "sorry: event arrays are not supported.");
10230 # delete p[2];
10231 # }
10232 # p[0] = p[1];
10233 # }
10234 ()
10235
10236
10237 def p_event_variable_list_1(p):
10238 '''event_variable_list : event_variable '''
10239 if(parse_debug):
10240 print('event_variable_list_1', list(p))
10241
10242 # { p[0] = list_from_identifier(p[1]); }
10243 ()
10244
10245
10246 def p_event_variable_list_2(p):
10247 '''event_variable_list : event_variable_list ',' event_variable '''
10248 if(parse_debug):
10249 print('event_variable_list_2', list(p))
10250
10251 # { p[0] = list_from_identifier(p[1], p[3]); }
10252 ()
10253
10254
10255 def p_specify_item_1(p):
10256 '''specify_item : K_specparam specparam_decl ';' '''
10257 if(parse_debug):
10258 print('specify_item_1', list(p))
10259
10260
10261 ()
10262
10263
10264 def p_specify_item_2(p):
10265 '''specify_item : specify_simple_path_decl ';' '''
10266 if(parse_debug):
10267 print('specify_item_2', list(p))
10268
10269 # { pform_module_specify_path(p[1]);
10270 # }
10271 ()
10272
10273
10274 def p_specify_item_3(p):
10275 '''specify_item : specify_edge_path_decl ';' '''
10276 if(parse_debug):
10277 print('specify_item_3', list(p))
10278
10279 # { pform_module_specify_path(p[1]);
10280 # }
10281 ()
10282
10283
10284 def p_specify_item_4(p):
10285 '''specify_item : K_if '(' expression ')' specify_simple_path_decl ';' '''
10286 if(parse_debug):
10287 print('specify_item_4', list(p))
10288
10289 # { PSpecPath*tmp = p[5];
10290 # if (tmp) {
10291 # tmp->conditional = true;
10292 # tmp->condition = p[3];
10293 # }
10294 # pform_module_specify_path(tmp);
10295 # }
10296 ()
10297
10298
10299 def p_specify_item_5(p):
10300 '''specify_item : K_if '(' expression ')' specify_edge_path_decl ';' '''
10301 if(parse_debug):
10302 print('specify_item_5', list(p))
10303
10304 # { PSpecPath*tmp = p[5];
10305 # if (tmp) {
10306 # tmp->conditional = true;
10307 # tmp->condition = p[3];
10308 # }
10309 # pform_module_specify_path(tmp);
10310 # }
10311 ()
10312
10313
10314 def p_specify_item_6(p):
10315 '''specify_item : K_ifnone specify_simple_path_decl ';' '''
10316 if(parse_debug):
10317 print('specify_item_6', list(p))
10318
10319 # { PSpecPath*tmp = p[2];
10320 # if (tmp) {
10321 # tmp->conditional = true;
10322 # tmp->condition = 0;
10323 # }
10324 # pform_module_specify_path(tmp);
10325 # }
10326 ()
10327
10328
10329 def p_specify_item_7(p):
10330 '''specify_item : K_ifnone specify_edge_path_decl ';' '''
10331 if(parse_debug):
10332 print('specify_item_7', list(p))
10333
10334 # { yyerror(@1, "Sorry: ifnone with an edge-sensitive path is "
10335 # "not supported.");
10336 # yyerrok;
10337 # }
10338 ()
10339
10340
10341 def p_specify_item_8(p):
10342 '''specify_item : K_Sfullskew '(' spec_reference_event ',' spec_reference_event ',' delay_value ',' delay_value spec_notifier_opt ')' ';' '''
10343 if(parse_debug):
10344 print('specify_item_8', list(p))
10345
10346 # { delete p[7];
10347 # delete p[9];
10348 # }
10349 ()
10350
10351
10352 def p_specify_item_9(p):
10353 '''specify_item : K_Shold '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
10354 if(parse_debug):
10355 print('specify_item_9', list(p))
10356
10357 # { delete p[7];
10358 # }
10359 ()
10360
10361
10362 def p_specify_item_10(p):
10363 '''specify_item : K_Snochange '(' spec_reference_event ',' spec_reference_event ',' delay_value ',' delay_value spec_notifier_opt ')' ';' '''
10364 if(parse_debug):
10365 print('specify_item_10', list(p))
10366
10367 # { delete p[7];
10368 # delete p[9];
10369 # }
10370 ()
10371
10372
10373 def p_specify_item_11(p):
10374 '''specify_item : K_Speriod '(' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
10375 if(parse_debug):
10376 print('specify_item_11', list(p))
10377
10378 # { delete p[5];
10379 # }
10380 ()
10381
10382
10383 def p_specify_item_12(p):
10384 '''specify_item : K_Srecovery '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
10385 if(parse_debug):
10386 print('specify_item_12', list(p))
10387
10388 # { delete p[7];
10389 # }
10390 ()
10391
10392
10393 def p_specify_item_13(p):
10394 '''specify_item : K_Srecrem '(' spec_reference_event ',' spec_reference_event ',' delay_value ',' delay_value spec_notifier_opt ')' ';' '''
10395 if(parse_debug):
10396 print('specify_item_13', list(p))
10397
10398 # { delete p[7];
10399 # delete p[9];
10400 # }
10401 ()
10402
10403
10404 def p_specify_item_14(p):
10405 '''specify_item : K_Sremoval '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
10406 if(parse_debug):
10407 print('specify_item_14', list(p))
10408
10409 # { delete p[7];
10410 # }
10411 ()
10412
10413
10414 def p_specify_item_15(p):
10415 '''specify_item : K_Ssetup '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
10416 if(parse_debug):
10417 print('specify_item_15', list(p))
10418
10419 # { delete p[7];
10420 # }
10421 ()
10422
10423
10424 def p_specify_item_16(p):
10425 '''specify_item : K_Ssetuphold '(' spec_reference_event ',' spec_reference_event ',' delay_value ',' delay_value spec_notifier_opt ')' ';' '''
10426 if(parse_debug):
10427 print('specify_item_16', list(p))
10428
10429 # { delete p[7];
10430 # delete p[9];
10431 # }
10432 ()
10433
10434
10435 def p_specify_item_17(p):
10436 '''specify_item : K_Sskew '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
10437 if(parse_debug):
10438 print('specify_item_17', list(p))
10439
10440 # { delete p[7];
10441 # }
10442 ()
10443
10444
10445 def p_specify_item_18(p):
10446 '''specify_item : K_Stimeskew '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' '''
10447 if(parse_debug):
10448 print('specify_item_18', list(p))
10449
10450 # { delete p[7];
10451 # }
10452 ()
10453
10454
10455 def p_specify_item_19(p):
10456 '''specify_item : K_Swidth '(' spec_reference_event ',' delay_value ',' expression spec_notifier_opt ')' ';' '''
10457 if(parse_debug):
10458 print('specify_item_19', list(p))
10459
10460 # { delete p[5];
10461 # delete p[7];
10462 # }
10463 ()
10464
10465
10466 def p_specify_item_20(p):
10467 '''specify_item : K_Swidth '(' spec_reference_event ',' delay_value ')' ';' '''
10468 if(parse_debug):
10469 print('specify_item_20', list(p))
10470
10471 # { delete p[5];
10472 # }
10473 ()
10474
10475
10476 def p_specify_item_21(p):
10477 '''specify_item : K_pulsestyle_onevent specify_path_identifiers ';' '''
10478 if(parse_debug):
10479 print('specify_item_21', list(p))
10480
10481 # { delete p[2];
10482 # }
10483 ()
10484
10485
10486 def p_specify_item_22(p):
10487 '''specify_item : K_pulsestyle_ondetect specify_path_identifiers ';' '''
10488 if(parse_debug):
10489 print('specify_item_22', list(p))
10490
10491 # { delete p[2];
10492 # }
10493 ()
10494
10495
10496 def p_specify_item_23(p):
10497 '''specify_item : K_showcancelled specify_path_identifiers ';' '''
10498 if(parse_debug):
10499 print('specify_item_23', list(p))
10500
10501 # { delete p[2];
10502 # }
10503 ()
10504
10505
10506 def p_specify_item_24(p):
10507 '''specify_item : K_noshowcancelled specify_path_identifiers ';' '''
10508 if(parse_debug):
10509 print('specify_item_24', list(p))
10510
10511 # { delete p[2];
10512 # }
10513 ()
10514
10515
10516 def p_specify_item_list_1(p):
10517 '''specify_item_list : specify_item '''
10518 if(parse_debug):
10519 print('specify_item_list_1', list(p))
10520
10521
10522 ()
10523
10524
10525 def p_specify_item_list_2(p):
10526 '''specify_item_list : specify_item_list specify_item '''
10527 if(parse_debug):
10528 print('specify_item_list_2', list(p))
10529
10530
10531 ()
10532
10533
10534 def p_specify_item_list_opt_1(p):
10535 '''specify_item_list_opt : '''
10536 if(parse_debug):
10537 print('specify_item_list_opt_1', list(p))
10538
10539 # { }
10540 ()
10541
10542
10543 def p_specify_item_list_opt_2(p):
10544 '''specify_item_list_opt : specify_item_list '''
10545 if(parse_debug):
10546 print('specify_item_list_opt_2', list(p))
10547
10548 # { }
10549 ()
10550
10551
10552 def p_specify_edge_path_decl_1(p):
10553 '''specify_edge_path_decl : specify_edge_path '=' '(' delay_value_list ')' '''
10554 if(parse_debug):
10555 print('specify_edge_path_decl_1', list(p))
10556
10557 # { p[0] = pform_assign_path_delay(p[1], p[4]); }
10558 ()
10559
10560
10561 def p_specify_edge_path_decl_2(p):
10562 '''specify_edge_path_decl : specify_edge_path '=' delay_value_simple '''
10563 if(parse_debug):
10564 print('specify_edge_path_decl_2', list(p))
10565
10566 # { list<PExpr*>*tmp = new list<PExpr*>;
10567 # tmp->push_back(p[3]);
10568 # p[0] = pform_assign_path_delay(p[1], tmp);
10569 # }
10570 ()
10571
10572
10573 def p_edge_operator_1(p):
10574 '''edge_operator : K_posedge '''
10575 if(parse_debug):
10576 print('edge_operator_1', list(p))
10577 p[0] = True
10578
10579
10580 ()
10581
10582
10583 def p_edge_operator_2(p):
10584 '''edge_operator : K_negedge '''
10585 if(parse_debug):
10586 print('edge_operator_2', list(p))
10587 p[0] = False
10588
10589
10590 ()
10591
10592
10593 def p_specify_edge_path_1(p):
10594 '''specify_edge_path : '(' specify_path_identifiers spec_polarity K_EG '(' specify_path_identifiers polarity_operator expression ')' ')' '''
10595 if(parse_debug):
10596 print('specify_edge_path_1', list(p))
10597
10598 # { int edge_flag = 0;
10599 # p[0] = pform_make_specify_edge_path(@1, edge_flag, p[2], p[3], false, p[6], p[8]); }
10600 ()
10601
10602
10603 def p_specify_edge_path_2(p):
10604 '''specify_edge_path : '(' edge_operator specify_path_identifiers spec_polarity K_EG '(' specify_path_identifiers polarity_operator expression ')' ')' '''
10605 if(parse_debug):
10606 print('specify_edge_path_2', list(p))
10607
10608 # { int edge_flag = p[2]? 1 : -1;
10609 # p[0] = pform_make_specify_edge_path(@1, edge_flag, p[3], p[4], false, p[7], p[9]);}
10610 ()
10611
10612
10613 def p_specify_edge_path_3(p):
10614 '''specify_edge_path : '(' specify_path_identifiers spec_polarity K_SG '(' specify_path_identifiers polarity_operator expression ')' ')' '''
10615 if(parse_debug):
10616 print('specify_edge_path_3', list(p))
10617
10618 # { int edge_flag = 0;
10619 # p[0] = pform_make_specify_edge_path(@1, edge_flag, p[2], p[3], true, p[6], p[8]); }
10620 ()
10621
10622
10623 def p_specify_edge_path_4(p):
10624 '''specify_edge_path : '(' edge_operator specify_path_identifiers spec_polarity K_SG '(' specify_path_identifiers polarity_operator expression ')' ')' '''
10625 if(parse_debug):
10626 print('specify_edge_path_4', list(p))
10627
10628 # { int edge_flag = p[2]? 1 : -1;
10629 # p[0] = pform_make_specify_edge_path(@1, edge_flag, p[3], p[4], true, p[7], p[9]); }
10630 ()
10631
10632
10633 def p_polarity_operator_1(p):
10634 '''polarity_operator : K_PO_POS '''
10635 if(parse_debug):
10636 print('polarity_operator_1', list(p))
10637
10638
10639 ()
10640
10641
10642 def p_polarity_operator_2(p):
10643 '''polarity_operator : K_PO_NEG '''
10644 if(parse_debug):
10645 print('polarity_operator_2', list(p))
10646
10647
10648 ()
10649
10650
10651 def p_polarity_operator_3(p):
10652 '''polarity_operator : ':' '''
10653 if(parse_debug):
10654 print('polarity_operator_3', list(p))
10655
10656
10657 ()
10658
10659
10660 def p_specify_simple_path_decl_1(p):
10661 '''specify_simple_path_decl : specify_simple_path '=' '(' delay_value_list ')' '''
10662 if(parse_debug):
10663 print('specify_simple_path_decl_1', list(p))
10664
10665 # { p[0] = pform_assign_path_delay(p[1], p[4]); }
10666 ()
10667
10668
10669 def p_specify_simple_path_decl_2(p):
10670 '''specify_simple_path_decl : specify_simple_path '=' delay_value_simple '''
10671 if(parse_debug):
10672 print('specify_simple_path_decl_2', list(p))
10673
10674 # { list<PExpr*>*tmp = new list<PExpr*>;
10675 # tmp->push_back(p[3]);
10676 # p[0] = pform_assign_path_delay(p[1], tmp);
10677 # }
10678 ()
10679
10680
10681 def p_specify_simple_path_decl_3(p):
10682 '''specify_simple_path_decl : specify_simple_path '=' '(' error ')' '''
10683 if(parse_debug):
10684 print('specify_simple_path_decl_3', list(p))
10685
10686 # { yyerror(@3, "Syntax error in delay value list.");
10687 # yyerrok;
10688 # p[0] = None
10689 # }
10690 ()
10691
10692
10693 def p_specify_simple_path_1(p):
10694 '''specify_simple_path : '(' specify_path_identifiers spec_polarity K_EG specify_path_identifiers ')' '''
10695 if(parse_debug):
10696 print('specify_simple_path_1', list(p))
10697
10698 # { p[0] = pform_make_specify_path(@1, p[2], p[3], false, p[5]); }
10699 ()
10700
10701
10702 def p_specify_simple_path_2(p):
10703 '''specify_simple_path : '(' specify_path_identifiers spec_polarity K_SG specify_path_identifiers ')' '''
10704 if(parse_debug):
10705 print('specify_simple_path_2', list(p))
10706
10707 # { p[0] = pform_make_specify_path(@1, p[2], p[3], true, p[5]); }
10708 ()
10709
10710
10711 def p_specify_simple_path_3(p):
10712 '''specify_simple_path : '(' error ')' '''
10713 if(parse_debug):
10714 print('specify_simple_path_3', list(p))
10715
10716 # { yyerror(@1, "Invalid simple path");
10717 # yyerrok;
10718 # }
10719 ()
10720
10721
10722 def p_specify_path_identifiers_1(p):
10723 '''specify_path_identifiers : IDENTIFIER '''
10724 if(parse_debug):
10725 print('specify_path_identifiers_1', list(p))
10726
10727 # { list<perm_string>*tmp = new list<perm_string>;
10728 # tmp->push_back(lex_strings.make(p[1]));
10729 # p[0] = tmp;
10730 # delete[]p[1];
10731 # }
10732 ()
10733
10734
10735 def p_specify_path_identifiers_2(p):
10736 '''specify_path_identifiers : IDENTIFIER '[' expr_primary ']' '''
10737 if(parse_debug):
10738 print('specify_path_identifiers_2', list(p))
10739
10740 # { if (gn_specify_blocks_flag) {
10741 # yywarn(@4, "Bit selects are not currently supported "
10742 # "in path declarations. The declaration "
10743 # "will be applied to the whole vector.");
10744 # }
10745 # list<perm_string>*tmp = new list<perm_string>;
10746 # tmp->push_back(lex_strings.make(p[1]));
10747 # p[0] = tmp;
10748 # delete[]p[1];
10749 # }
10750 ()
10751
10752
10753 def p_specify_path_identifiers_3(p):
10754 '''specify_path_identifiers : IDENTIFIER '[' expr_primary polarity_operator expr_primary ']' '''
10755 if(parse_debug):
10756 print('specify_path_identifiers_3', list(p))
10757
10758 # { if (gn_specify_blocks_flag) {
10759 # yywarn(@4, "Part selects are not currently supported "
10760 # "in path declarations. The declaration "
10761 # "will be applied to the whole vector.");
10762 # }
10763 # list<perm_string>*tmp = new list<perm_string>;
10764 # tmp->push_back(lex_strings.make(p[1]));
10765 # p[0] = tmp;
10766 # delete[]p[1];
10767 # }
10768 ()
10769
10770
10771 def p_specify_path_identifiers_4(p):
10772 '''specify_path_identifiers : specify_path_identifiers ',' IDENTIFIER '''
10773 if(parse_debug):
10774 print('specify_path_identifiers_4', list(p))
10775
10776 # { list<perm_string>*tmp = p[1];
10777 # tmp->push_back(lex_strings.make(p[3]));
10778 # p[0] = tmp;
10779 # delete[]p[3];
10780 # }
10781 ()
10782
10783
10784 def p_specify_path_identifiers_5(p):
10785 '''specify_path_identifiers : specify_path_identifiers ',' IDENTIFIER '[' expr_primary ']' '''
10786 if(parse_debug):
10787 print('specify_path_identifiers_5', list(p))
10788
10789 # { if (gn_specify_blocks_flag) {
10790 # yywarn(@4, "Bit selects are not currently supported "
10791 # "in path declarations. The declaration "
10792 # "will be applied to the whole vector.");
10793 # }
10794 # list<perm_string>*tmp = p[1];
10795 # tmp->push_back(lex_strings.make(p[3]));
10796 # p[0] = tmp;
10797 # delete[]p[3];
10798 # }
10799 ()
10800
10801
10802 def p_specify_path_identifiers_6(p):
10803 '''specify_path_identifiers : specify_path_identifiers ',' IDENTIFIER '[' expr_primary polarity_operator expr_primary ']' '''
10804 if(parse_debug):
10805 print('specify_path_identifiers_6', list(p))
10806
10807 # { if (gn_specify_blocks_flag) {
10808 # yywarn(@4, "Part selects are not currently supported "
10809 # "in path declarations. The declaration "
10810 # "will be applied to the whole vector.");
10811 # }
10812 # list<perm_string>*tmp = p[1];
10813 # tmp->push_back(lex_strings.make(p[3]));
10814 # p[0] = tmp;
10815 # delete[]p[3];
10816 # }
10817 ()
10818
10819
10820 def p_specparam_1(p):
10821 '''specparam : IDENTIFIER '=' expression '''
10822 if(parse_debug):
10823 print('specparam_1', list(p))
10824
10825 # { PExpr*tmp = p[3];
10826 # pform_set_specparam(@1, lex_strings.make(p[1]),
10827 # param_active_range, tmp);
10828 # delete[]p[1];
10829 # }
10830 ()
10831
10832
10833 def p_specparam_2(p):
10834 '''specparam : IDENTIFIER '=' expression ':' expression ':' expression '''
10835 if(parse_debug):
10836 print('specparam_2', list(p))
10837
10838 # { PExpr*tmp = 0;
10839 # switch (min_typ_max_flag) {
10840 # case MIN:
10841 # tmp = p[3];
10842 # delete p[5];
10843 # delete p[7];
10844 # break;
10845 # case TYP:
10846 # delete p[3];
10847 # tmp = p[5];
10848 # delete p[7];
10849 # break;
10850 # case MAX:
10851 # delete p[3];
10852 # delete p[5];
10853 # tmp = p[7];
10854 # break;
10855 # }
10856 # if (min_typ_max_warn > 0) {
10857 # cerr << tmp->get_fileline() << ": warning: choosing ";
10858 # switch (min_typ_max_flag) {
10859 # case MIN:
10860 # cerr << "min";
10861 # break;
10862 # case TYP:
10863 # cerr << "typ";
10864 # break;
10865 # case MAX:
10866 # cerr << "max";
10867 # break;
10868 # }
10869 # cerr << " expression." << endl;
10870 # min_typ_max_warn -= 1;
10871 # }
10872 # pform_set_specparam(@1, lex_strings.make(p[1]),
10873 # param_active_range, tmp);
10874 # delete[]p[1];
10875 # }
10876 ()
10877
10878
10879 def p_specparam_3(p):
10880 '''specparam : PATHPULSE_IDENTIFIER '=' expression '''
10881 if(parse_debug):
10882 print('specparam_3', list(p))
10883
10884 # { delete[]p[1];
10885 # delete p[3];
10886 # }
10887 ()
10888
10889
10890 def p_specparam_4(p):
10891 '''specparam : PATHPULSE_IDENTIFIER '=' '(' expression ',' expression ')' '''
10892 if(parse_debug):
10893 print('specparam_4', list(p))
10894
10895 # { delete[]p[1];
10896 # delete p[4];
10897 # delete p[6];
10898 # }
10899 ()
10900
10901
10902 def p_specparam_list_1(p):
10903 '''specparam_list : specparam '''
10904 if(parse_debug):
10905 print('specparam_list_1', list(p))
10906
10907
10908 ()
10909
10910
10911 def p_specparam_list_2(p):
10912 '''specparam_list : specparam_list ',' specparam '''
10913 if(parse_debug):
10914 print('specparam_list_2', list(p))
10915
10916
10917 ()
10918
10919
10920 def p_specparam_decl_1(p):
10921 '''specparam_decl : specparam_list '''
10922 if(parse_debug):
10923 print('specparam_decl_1', list(p))
10924
10925
10926 ()
10927
10928
10929 def p_specparam_decl_2(p):
10930 '''specparam_decl : dimensions _embed0_specparam_decl specparam_list '''
10931 if(parse_debug):
10932 print('specparam_decl_2', list(p))
10933
10934 # { param_active_range = 0; }
10935 ()
10936
10937
10938 def p__embed0_specparam_decl(p):
10939 '''_embed0_specparam_decl : '''
10940
10941 # { param_active_range = p[1]; }
10942 ()
10943
10944
10945 def p_spec_polarity_1(p):
10946 '''spec_polarity : '+' '''
10947 if(parse_debug):
10948 print('spec_polarity_1', list(p))
10949
10950 # { p[0] = '+'; }
10951 ()
10952
10953
10954 def p_spec_polarity_2(p):
10955 '''spec_polarity : '-' '''
10956 if(parse_debug):
10957 print('spec_polarity_2', list(p))
10958
10959 # { p[0] = '-'; }
10960 ()
10961
10962
10963 def p_spec_polarity_3(p):
10964 '''spec_polarity : '''
10965 if(parse_debug):
10966 print('spec_polarity_3', list(p))
10967
10968 # { p[0] = None }
10969 ()
10970
10971
10972 def p_spec_reference_event_1(p):
10973 '''spec_reference_event : K_posedge expression '''
10974 if(parse_debug):
10975 print('spec_reference_event_1', list(p))
10976
10977 # { delete p[2]; }
10978 ()
10979
10980
10981 def p_spec_reference_event_2(p):
10982 '''spec_reference_event : K_negedge expression '''
10983 if(parse_debug):
10984 print('spec_reference_event_2', list(p))
10985
10986 # { delete p[2]; }
10987 ()
10988
10989
10990 def p_spec_reference_event_3(p):
10991 '''spec_reference_event : K_posedge expr_primary K_TAND expression '''
10992 if(parse_debug):
10993 print('spec_reference_event_3', list(p))
10994
10995 # { delete p[2];
10996 # delete p[4];
10997 # }
10998 ()
10999
11000
11001 def p_spec_reference_event_4(p):
11002 '''spec_reference_event : K_negedge expr_primary K_TAND expression '''
11003 if(parse_debug):
11004 print('spec_reference_event_4', list(p))
11005
11006 # { delete p[2];
11007 # delete p[4];
11008 # }
11009 ()
11010
11011
11012 def p_spec_reference_event_5(p):
11013 '''spec_reference_event : K_edge '[' edge_descriptor_list ']' expr_primary '''
11014 if(parse_debug):
11015 print('spec_reference_event_5', list(p))
11016
11017 # { delete p[5]; }
11018 ()
11019
11020
11021 def p_spec_reference_event_6(p):
11022 '''spec_reference_event : K_edge '[' edge_descriptor_list ']' expr_primary K_TAND expression '''
11023 if(parse_debug):
11024 print('spec_reference_event_6', list(p))
11025
11026 # { delete p[5];
11027 # delete p[7];
11028 # }
11029 ()
11030
11031
11032 def p_spec_reference_event_7(p):
11033 '''spec_reference_event : expr_primary K_TAND expression '''
11034 if(parse_debug):
11035 print('spec_reference_event_7', list(p))
11036
11037 # { delete p[1];
11038 # delete p[3];
11039 # }
11040 ()
11041
11042
11043 def p_spec_reference_event_8(p):
11044 '''spec_reference_event : expr_primary '''
11045 if(parse_debug):
11046 print('spec_reference_event_8', list(p))
11047
11048 # { delete p[1]; }
11049 ()
11050
11051
11052 def p_edge_descriptor_list_1(p):
11053 '''edge_descriptor_list : edge_descriptor_list ',' K_edge_descriptor '''
11054 if(parse_debug):
11055 print('edge_descriptor_list_1', list(p))
11056
11057
11058 ()
11059
11060
11061 def p_edge_descriptor_list_2(p):
11062 '''edge_descriptor_list : K_edge_descriptor '''
11063 if(parse_debug):
11064 print('edge_descriptor_list_2', list(p))
11065
11066
11067 ()
11068
11069
11070 def p_spec_notifier_opt_1(p):
11071 '''spec_notifier_opt : '''
11072 if(parse_debug):
11073 print('spec_notifier_opt_1', list(p))
11074
11075 # { }
11076 ()
11077
11078
11079 def p_spec_notifier_opt_2(p):
11080 '''spec_notifier_opt : spec_notifier '''
11081 if(parse_debug):
11082 print('spec_notifier_opt_2', list(p))
11083
11084 # { }
11085 ()
11086
11087
11088 def p_spec_notifier_1(p):
11089 '''spec_notifier : ',' '''
11090 if(parse_debug):
11091 print('spec_notifier_1', list(p))
11092
11093 # { args_after_notifier = 0; }
11094 ()
11095
11096
11097 def p_spec_notifier_2(p):
11098 '''spec_notifier : ',' hierarchy_identifier '''
11099 if(parse_debug):
11100 print('spec_notifier_2', list(p))
11101
11102 # { args_after_notifier = 0; delete p[2]; }
11103 ()
11104
11105
11106 def p_spec_notifier_3(p):
11107 '''spec_notifier : spec_notifier ',' '''
11108 if(parse_debug):
11109 print('spec_notifier_3', list(p))
11110
11111 # { args_after_notifier += 1; }
11112 ()
11113
11114
11115 def p_spec_notifier_4(p):
11116 '''spec_notifier : spec_notifier ',' hierarchy_identifier '''
11117 if(parse_debug):
11118 print('spec_notifier_4', list(p))
11119
11120 # { args_after_notifier += 1;
11121 # if (args_after_notifier >= 3) {
11122 # cerr << @3 << ": warning: timing checks are not supported "
11123 # "and delayed signal \"" << *p[3]
11124 # << "\" will not be driven." << endl;
11125 # }
11126 # delete p[3]; }
11127 ()
11128
11129
11130 def p_spec_notifier_5(p):
11131 '''spec_notifier : IDENTIFIER '''
11132 if(parse_debug):
11133 print('spec_notifier_5', list(p))
11134
11135 # { args_after_notifier = 0; delete[]p[1]; }
11136 ()
11137
11138
11139 def p_statement_item_1(p):
11140 '''statement_item : K_assign lpvalue '=' expression ';' '''
11141 if(parse_debug):
11142 print('statement_item_1', list(p))
11143
11144 # { PCAssign*tmp = new PCAssign(p[2], p[4]);
11145 # FILE_NAME(tmp, @1);
11146 # p[0] = tmp;
11147 # }
11148 ()
11149
11150
11151 def p_statement_item_2(p):
11152 '''statement_item : K_deassign lpvalue ';' '''
11153 if(parse_debug):
11154 print('statement_item_2', list(p))
11155
11156 # { PDeassign*tmp = new PDeassign(p[2]);
11157 # FILE_NAME(tmp, @1);
11158 # p[0] = tmp;
11159 # }
11160 ()
11161
11162
11163 def p_statement_item_3(p):
11164 '''statement_item : K_force lpvalue '=' expression ';' '''
11165 if(parse_debug):
11166 print('statement_item_3', list(p))
11167
11168 # { PForce*tmp = new PForce(p[2], p[4]);
11169 # FILE_NAME(tmp, @1);
11170 # p[0] = tmp;
11171 # }
11172 ()
11173
11174
11175 def p_statement_item_4(p):
11176 '''statement_item : K_release lpvalue ';' '''
11177 if(parse_debug):
11178 print('statement_item_4', list(p))
11179
11180 # { PRelease*tmp = new PRelease(p[2]);
11181 # FILE_NAME(tmp, @1);
11182 # p[0] = tmp;
11183 # }
11184 ()
11185
11186
11187 def p_statement_item_5(p):
11188 '''statement_item : K_begin K_end '''
11189 if(parse_debug):
11190 print('statement_item_5', list(p))
11191
11192 # { PBlock*tmp = new PBlock(PBlock::BL_SEQ);
11193 # FILE_NAME(tmp, @1);
11194 # p[0] = tmp;
11195 # }
11196 ()
11197
11198
11199 def p_statement_item_6(p):
11200 '''statement_item : K_begin _embed0_statement_item block_item_decls_opt _embed1_statement_item statement_or_null_list K_end '''
11201 if(parse_debug):
11202 print('statement_item_6', list(p))
11203
11204 # { PBlock*tmp;
11205 # if (p[3]) {
11206 # pform_pop_scope();
11207 # assert(! current_block_stack.empty());
11208 # tmp = current_block_stack.top();
11209 # current_block_stack.pop();
11210 # } else {
11211 # tmp = new PBlock(PBlock::BL_SEQ);
11212 # FILE_NAME(tmp, @1);
11213 # }
11214 # if (p[5]) tmp->set_statement(*p[5]);
11215 # delete p[5];
11216 # p[0] = tmp;
11217 # }
11218 ()
11219
11220
11221 def p_statement_item_7(p):
11222 '''statement_item : K_begin ':' IDENTIFIER _embed2_statement_item block_item_decls_opt statement_or_null_list_opt K_end endlabel_opt '''
11223 if(parse_debug):
11224 print('statement_item_7', list(p))
11225
11226 # { pform_pop_scope();
11227 # assert(! current_block_stack.empty());
11228 # PBlock*tmp = current_block_stack.top();
11229 # current_block_stack.pop();
11230 # if (p[6]) tmp->set_statement(*p[6]);
11231 # delete p[6];
11232 # if (p[8]) {
11233 # if (strcmp(p[3],p[8]) != 0) {
11234 # yyerror(@8, "error: End label doesn't match begin name");
11235 # }
11236 # if (! gn_system_verilog()) {
11237 # yyerror(@8, "error: Begin end labels require "
11238 # "SystemVerilog.");
11239 # }
11240 # delete[]p[8];
11241 # }
11242 # delete[]p[3];
11243 # p[0] = tmp;
11244 # }
11245 ()
11246
11247
11248 def p_statement_item_8(p):
11249 '''statement_item : K_fork join_keyword '''
11250 if(parse_debug):
11251 print('statement_item_8', list(p))
11252
11253 # { PBlock*tmp = new PBlock(p[2]);
11254 # FILE_NAME(tmp, @1);
11255 # p[0] = tmp;
11256 # }
11257 ()
11258
11259
11260 def p_statement_item_9(p):
11261 '''statement_item : K_fork _embed3_statement_item block_item_decls_opt _embed4_statement_item statement_or_null_list join_keyword '''
11262 if(parse_debug):
11263 print('statement_item_9', list(p))
11264
11265 # { PBlock*tmp;
11266 # if (p[3]) {
11267 # pform_pop_scope();
11268 # assert(! current_block_stack.empty());
11269 # tmp = current_block_stack.top();
11270 # current_block_stack.pop();
11271 # tmp->set_join_type(p[6]);
11272 # } else {
11273 # tmp = new PBlock(p[6]);
11274 # FILE_NAME(tmp, @1);
11275 # }
11276 # if (p[5]) tmp->set_statement(*p[5]);
11277 # delete p[5];
11278 # p[0] = tmp;
11279 # }
11280 ()
11281
11282
11283 def p_statement_item_10(p):
11284 '''statement_item : K_fork ':' IDENTIFIER _embed5_statement_item block_item_decls_opt statement_or_null_list_opt join_keyword endlabel_opt '''
11285 if(parse_debug):
11286 print('statement_item_10', list(p))
11287
11288 # { pform_pop_scope();
11289 # assert(! current_block_stack.empty());
11290 # PBlock*tmp = current_block_stack.top();
11291 # current_block_stack.pop();
11292 # tmp->set_join_type(p[7]);
11293 # if (p[6]) tmp->set_statement(*p[6]);
11294 # delete p[6];
11295 # if (p[8]) {
11296 # if (strcmp(p[3],p[8]) != 0) {
11297 # yyerror(@8, "error: End label doesn't match fork name");
11298 # }
11299 # if (! gn_system_verilog()) {
11300 # yyerror(@8, "error: Fork end labels require "
11301 # "SystemVerilog.");
11302 # }
11303 # delete[]p[8];
11304 # }
11305 # delete[]p[3];
11306 # p[0] = tmp;
11307 # }
11308 ()
11309
11310
11311 def p_statement_item_11(p):
11312 '''statement_item : K_disable hierarchy_identifier ';' '''
11313 if(parse_debug):
11314 print('statement_item_11', list(p))
11315
11316 # { PDisable*tmp = new PDisable(*p[2]);
11317 # FILE_NAME(tmp, @1);
11318 # delete p[2];
11319 # p[0] = tmp;
11320 # }
11321 ()
11322
11323
11324 def p_statement_item_12(p):
11325 '''statement_item : K_disable K_fork ';' '''
11326 if(parse_debug):
11327 print('statement_item_12', list(p))
11328
11329 # { pform_name_t tmp_name;
11330 # PDisable*tmp = new PDisable(tmp_name);
11331 # FILE_NAME(tmp, @1);
11332 # p[0] = tmp;
11333 # }
11334 ()
11335
11336
11337 def p_statement_item_13(p):
11338 '''statement_item : K_TRIGGER hierarchy_identifier ';' '''
11339 if(parse_debug):
11340 print('statement_item_13', list(p))
11341
11342 # { PTrigger*tmp = new PTrigger(*p[2]);
11343 # FILE_NAME(tmp, @1);
11344 # delete p[2];
11345 # p[0] = tmp;
11346 # }
11347 ()
11348
11349
11350 def p_statement_item_14(p):
11351 '''statement_item : procedural_assertion_statement '''
11352 if(parse_debug):
11353 print('statement_item_14', list(p))
11354 p[0] = p[1]
11355
11356
11357 ()
11358
11359
11360 def p_statement_item_15(p):
11361 '''statement_item : loop_statement '''
11362 if(parse_debug):
11363 print('statement_item_15', list(p))
11364 p[0] = p[1]
11365
11366
11367 ()
11368
11369
11370 def p_statement_item_16(p):
11371 '''statement_item : jump_statement '''
11372 if(parse_debug):
11373 print('statement_item_16', list(p))
11374 p[0] = p[1]
11375
11376
11377 ()
11378
11379
11380 def p_statement_item_17(p):
11381 '''statement_item : K_case '(' expression ')' case_items K_endcase '''
11382 if(parse_debug):
11383 print('statement_item_17', list(p))
11384
11385 # { PCase*tmp = new PCase(NetCase::EQ, p[3], p[5]);
11386 # FILE_NAME(tmp, @1);
11387 # p[0] = tmp;
11388 # }
11389 ()
11390
11391
11392 def p_statement_item_18(p):
11393 '''statement_item : K_casex '(' expression ')' case_items K_endcase '''
11394 if(parse_debug):
11395 print('statement_item_18', list(p))
11396
11397 # { PCase*tmp = new PCase(NetCase::EQX, p[3], p[5]);
11398 # FILE_NAME(tmp, @1);
11399 # p[0] = tmp;
11400 # }
11401 ()
11402
11403
11404 def p_statement_item_19(p):
11405 '''statement_item : K_casez '(' expression ')' case_items K_endcase '''
11406 if(parse_debug):
11407 print('statement_item_19', list(p))
11408
11409 # { PCase*tmp = new PCase(NetCase::EQZ, p[3], p[5]);
11410 # FILE_NAME(tmp, @1);
11411 # p[0] = tmp;
11412 # }
11413 ()
11414
11415
11416 def p_statement_item_20(p):
11417 '''statement_item : K_case '(' expression ')' error K_endcase '''
11418 if(parse_debug):
11419 print('statement_item_20', list(p))
11420
11421 # { yyerrok; }
11422 ()
11423
11424
11425 def p_statement_item_21(p):
11426 '''statement_item : K_casex '(' expression ')' error K_endcase '''
11427 if(parse_debug):
11428 print('statement_item_21', list(p))
11429
11430 # { yyerrok; }
11431 ()
11432
11433
11434 def p_statement_item_22(p):
11435 '''statement_item : K_casez '(' expression ')' error K_endcase '''
11436 if(parse_debug):
11437 print('statement_item_22', list(p))
11438
11439 # { yyerrok; }
11440 ()
11441
11442
11443 def p_statement_item_23(p):
11444 '''statement_item : K_if '(' expression ')' statement_or_null %prec less_than_K_else '''
11445 if(parse_debug):
11446 print('statement_item_23', list(p))
11447
11448 # { PCondit*tmp = new PCondit(p[3], p[5], 0);
11449 # FILE_NAME(tmp, @1);
11450 # p[0] = tmp;
11451 # }
11452 ()
11453
11454
11455 def p_statement_item_24(p):
11456 '''statement_item : K_if '(' expression ')' statement_or_null K_else statement_or_null '''
11457 if(parse_debug):
11458 print('statement_item_24', list(p))
11459
11460 # { PCondit*tmp = new PCondit(p[3], p[5], p[7]);
11461 # FILE_NAME(tmp, @1);
11462 # p[0] = tmp;
11463 # }
11464 ()
11465
11466
11467 def p_statement_item_25(p):
11468 '''statement_item : K_if '(' error ')' statement_or_null %prec less_than_K_else '''
11469 if(parse_debug):
11470 print('statement_item_25', list(p))
11471
11472 # { yyerror(@1, "error: Malformed conditional expression.");
11473 # p[0] = p[5];
11474 # }
11475 ()
11476
11477
11478 def p_statement_item_26(p):
11479 '''statement_item : K_if '(' error ')' statement_or_null K_else statement_or_null '''
11480 if(parse_debug):
11481 print('statement_item_26', list(p))
11482
11483 # { yyerror(@1, "error: Malformed conditional expression.");
11484 # p[0] = p[5];
11485 # }
11486 ()
11487
11488
11489 def p_statement_item_27(p):
11490 '''statement_item : compressed_statement ';' '''
11491 if(parse_debug):
11492 print('statement_item_27', list(p))
11493 p[0] = p[1]
11494
11495
11496 ()
11497
11498
11499 def p_statement_item_28(p):
11500 '''statement_item : inc_or_dec_expression ';' '''
11501 if(parse_debug):
11502 print('statement_item_28', list(p))
11503
11504 # { p[0] = pform_compressed_assign_from_inc_dec(@1, p[1]); }
11505 ()
11506
11507
11508 def p_statement_item_29(p):
11509 '''statement_item : delay1 statement_or_null '''
11510 if(parse_debug):
11511 print('statement_item_29', list(p))
11512
11513 # { PExpr*del = p[1]->front();
11514 # assert(p[1]->size() == 1);
11515 # delete p[1];
11516 # PDelayStatement*tmp = new PDelayStatement(del, p[2]);
11517 # FILE_NAME(tmp, @1);
11518 # p[0] = tmp;
11519 # }
11520 ()
11521
11522
11523 def p_statement_item_30(p):
11524 '''statement_item : event_control statement_or_null '''
11525 if(parse_debug):
11526 print('statement_item_30', list(p))
11527
11528 # { PEventStatement*tmp = p[1];
11529 # if (tmp == 0) {
11530 # yyerror(@1, "error: Invalid event control.");
11531 # p[0] = None
11532 # } else {
11533 # tmp->set_statement(p[2]);
11534 # p[0] = tmp;
11535 # }
11536 # }
11537 ()
11538
11539
11540 def p_statement_item_31(p):
11541 '''statement_item : '@' '*' statement_or_null '''
11542 if(parse_debug):
11543 print('statement_item_31', list(p))
11544
11545 # { PEventStatement*tmp = new PEventStatement;
11546 # FILE_NAME(tmp, @1);
11547 # tmp->set_statement(p[3]);
11548 # p[0] = tmp;
11549 # }
11550 ()
11551
11552
11553 def p_statement_item_32(p):
11554 '''statement_item : '@' '(' '*' ')' statement_or_null '''
11555 if(parse_debug):
11556 print('statement_item_32', list(p))
11557
11558 # { PEventStatement*tmp = new PEventStatement;
11559 # FILE_NAME(tmp, @1);
11560 # tmp->set_statement(p[5]);
11561 # p[0] = tmp;
11562 # }
11563 ()
11564
11565
11566 def p_statement_item_33(p):
11567 '''statement_item : lpvalue '=' expression ';' '''
11568 if(parse_debug):
11569 print('statement_item33', list(p))
11570 if p[3]:
11571 expr = Node(syms.expr_stmt, [p[1], Leaf(token.EQUAL, p[2]), p[3]])
11572 if(parse_debug):
11573 print("expr TODO", repr(expr))
11574 else:
11575 expr = Node(syms.expr_stmt, [p[1], Leaf(token.EQUAL, p[2]), ])
11576 if(parse_debug):
11577 print("expr", repr(expr))
11578 if(parse_debug):
11579 print("expr (python):'%s'" % expr)
11580 p[0] = expr
11581
11582 # { PAssign*tmp = new PAssign(p[1],p[3]);
11583 # FILE_NAME(tmp, @1);
11584 # p[0] = tmp;
11585 # }
11586 ()
11587
11588
11589 def p_statement_item_34(p):
11590 '''statement_item : error '=' expression ';' '''
11591 if(parse_debug):
11592 print('statement_item_34', list(p))
11593
11594 # { yyerror(@2, "Syntax in assignment statement l-value.");
11595 # yyerrok;
11596 # p[0] = new PNoop;
11597 # }
11598 ()
11599
11600
11601 def p_statement_item_35(p):
11602 '''statement_item : lpvalue K_LE expression ';' '''
11603 if(parse_debug):
11604 print('statement_item_35', list(p))
11605
11606 # { PAssignNB*tmp = new PAssignNB(p[1],p[3]);
11607 # FILE_NAME(tmp, @1);
11608 # p[0] = tmp;
11609 # }
11610 ()
11611
11612
11613 def p_statement_item_36(p):
11614 '''statement_item : error K_LE expression ';' '''
11615 if(parse_debug):
11616 print('statement_item_36', list(p))
11617
11618 # { yyerror(@2, "Syntax in assignment statement l-value.");
11619 # yyerrok;
11620 # p[0] = new PNoop;
11621 # }
11622 ()
11623
11624
11625 def p_statement_item_37(p):
11626 '''statement_item : lpvalue '=' delay1 expression ';' '''
11627 if(parse_debug):
11628 print('statement_item_37', list(p))
11629
11630 # { PExpr*del = p[3]->front(); p[3]->pop_front();
11631 # assert(p[3]->empty());
11632 # PAssign*tmp = new PAssign(p[1],del,p[4]);
11633 # FILE_NAME(tmp, @1);
11634 # p[0] = tmp;
11635 # }
11636 ()
11637
11638
11639 def p_statement_item_38(p):
11640 '''statement_item : lpvalue K_LE delay1 expression ';' '''
11641 if(parse_debug):
11642 print('statement_item_38', list(p))
11643
11644 # { PExpr*del = p[3]->front(); p[3]->pop_front();
11645 # assert(p[3]->empty());
11646 # PAssignNB*tmp = new PAssignNB(p[1],del,p[4]);
11647 # FILE_NAME(tmp, @1);
11648 # p[0] = tmp;
11649 # }
11650 ()
11651
11652
11653 def p_statement_item_39(p):
11654 '''statement_item : lpvalue '=' event_control expression ';' '''
11655 if(parse_debug):
11656 print('statement_item_39', list(p))
11657
11658 # { PAssign*tmp = new PAssign(p[1],0,p[3],p[4]);
11659 # FILE_NAME(tmp, @1);
11660 # p[0] = tmp;
11661 # }
11662 ()
11663
11664
11665 def p_statement_item_40(p):
11666 '''statement_item : lpvalue '=' K_repeat '(' expression ')' event_control expression ';' '''
11667 if(parse_debug):
11668 print('statement_item_40', list(p))
11669
11670 # { PAssign*tmp = new PAssign(p[1],p[5],p[7],p[8]);
11671 # FILE_NAME(tmp,@1);
11672 # tmp->set_lineno(@1.first_line);
11673 # p[0] = tmp;
11674 # }
11675 ()
11676
11677
11678 def p_statement_item_41(p):
11679 '''statement_item : lpvalue K_LE event_control expression ';' '''
11680 if(parse_debug):
11681 print('statement_item_41', list(p))
11682
11683 # { PAssignNB*tmp = new PAssignNB(p[1],0,p[3],p[4]);
11684 # FILE_NAME(tmp, @1);
11685 # p[0] = tmp;
11686 # }
11687 ()
11688
11689
11690 def p_statement_item_42(p):
11691 '''statement_item : lpvalue K_LE K_repeat '(' expression ')' event_control expression ';' '''
11692 if(parse_debug):
11693 print('statement_item_42', list(p))
11694
11695 # { PAssignNB*tmp = new PAssignNB(p[1],p[5],p[7],p[8]);
11696 # FILE_NAME(tmp, @1);
11697 # p[0] = tmp;
11698 # }
11699 ()
11700
11701
11702 def p_statement_item_43(p):
11703 '''statement_item : lpvalue '=' dynamic_array_new ';' '''
11704 if(parse_debug):
11705 print('statement_item_43', list(p))
11706
11707 # { PAssign*tmp = new PAssign(p[1],p[3]);
11708 # FILE_NAME(tmp, @1);
11709 # p[0] = tmp;
11710 # }
11711 ()
11712
11713
11714 def p_statement_item_44(p):
11715 '''statement_item : lpvalue '=' class_new ';' '''
11716 if(parse_debug):
11717 print('statement_item_44', list(p))
11718
11719 # { PAssign*tmp = new PAssign(p[1],p[3]);
11720 # FILE_NAME(tmp, @1);
11721 # p[0] = tmp;
11722 # }
11723 ()
11724
11725
11726 def p_statement_item_45(p):
11727 '''statement_item : K_wait '(' expression ')' statement_or_null '''
11728 if(parse_debug):
11729 print('statement_item_45', list(p))
11730
11731 # { PEventStatement*tmp;
11732 # PEEvent*etmp = new PEEvent(PEEvent::POSITIVE, p[3]);
11733 # tmp = new PEventStatement(etmp);
11734 # FILE_NAME(tmp,@1);
11735 # tmp->set_statement(p[5]);
11736 # p[0] = tmp;
11737 # }
11738 ()
11739
11740
11741 def p_statement_item_46(p):
11742 '''statement_item : K_wait K_fork ';' '''
11743 if(parse_debug):
11744 print('statement_item_46', list(p))
11745
11746 # { PEventStatement*tmp = new PEventStatement((PEEvent*)0);
11747 # FILE_NAME(tmp,@1);
11748 # p[0] = tmp;
11749 # }
11750 ()
11751
11752
11753 def p_statement_item_47(p):
11754 '''statement_item : SYSTEM_IDENTIFIER '(' expression_list_with_nuls ')' ';' '''
11755 if(parse_debug):
11756 print('statement_item_47', list(p))
11757
11758 # { PCallTask*tmp = new PCallTask(lex_strings.make(p[1]), *p[3]);
11759 # FILE_NAME(tmp,@1);
11760 # delete[]p[1];
11761 # delete p[3];
11762 # p[0] = tmp;
11763 # }
11764 ()
11765
11766
11767 def p_statement_item_48(p):
11768 '''statement_item : SYSTEM_IDENTIFIER ';' '''
11769 if(parse_debug):
11770 print('statement_item_48', list(p))
11771
11772 # { list<PExpr*>pt;
11773 # PCallTask*tmp = new PCallTask(lex_strings.make(p[1]), pt);
11774 # FILE_NAME(tmp,@1);
11775 # delete[]p[1];
11776 # p[0] = tmp;
11777 # }
11778 ()
11779
11780
11781 def p_statement_item_49(p):
11782 '''statement_item : hierarchy_identifier '(' expression_list_with_nuls ')' ';' '''
11783 if(parse_debug):
11784 print('statement_item_49', list(p))
11785
11786 # { PCallTask*tmp = pform_make_call_task(@1, *p[1], *p[3]);
11787 # delete p[1];
11788 # delete p[3];
11789 # p[0] = tmp;
11790 # }
11791 ()
11792
11793
11794 def p_statement_item_50(p):
11795 '''statement_item : hierarchy_identifier K_with '{' constraint_block_item_list_opt '}' ';' '''
11796 if(parse_debug):
11797 print('statement_item_50', list(p))
11798
11799 # { /* ....randomize with { <constraints> } */
11800 # if (p[1] && peek_tail_name(*p[1]) == "randomize") {
11801 # if (!gn_system_verilog())
11802 # yyerror(@2, "error: Randomize with constraint requires SystemVerilog.");
11803 # else
11804 # yyerror(@2, "sorry: Randomize with constraint not supported.");
11805 # } else {
11806 # yyerror(@2, "error: Constraint block can only be applied to randomize method.");
11807 # }
11808 # list<PExpr*>pt;
11809 # PCallTask*tmp = new PCallTask(*p[1], pt);
11810 # FILE_NAME(tmp, @1);
11811 # delete p[1];
11812 # p[0] = tmp;
11813 # }
11814 ()
11815
11816
11817 def p_statement_item_51(p):
11818 '''statement_item : implicit_class_handle '.' hierarchy_identifier '(' expression_list_with_nuls ')' ';' '''
11819 if(parse_debug):
11820 print('statement_item_51', list(p))
11821
11822 # { pform_name_t*t_name = p[1];
11823 # while (! p[3]->empty()) {
11824 # t_name->push_back(p[3]->front());
11825 # p[3]->pop_front();
11826 # }
11827 # PCallTask*tmp = new PCallTask(*t_name, *p[5]);
11828 # FILE_NAME(tmp, @1);
11829 # delete p[1];
11830 # delete p[3];
11831 # delete p[5];
11832 # p[0] = tmp;
11833 # }
11834 ()
11835
11836
11837 def p_statement_item_52(p):
11838 '''statement_item : hierarchy_identifier ';' '''
11839 if(parse_debug):
11840 print('statement_item_52', list(p))
11841
11842 # { list<PExpr*>pt;
11843 # PCallTask*tmp = pform_make_call_task(@1, *p[1], pt);
11844 # delete p[1];
11845 # p[0] = tmp;
11846 # }
11847 ()
11848
11849
11850 def p_statement_item_53(p):
11851 '''statement_item : implicit_class_handle '.' K_new '(' expression_list_with_nuls ')' ';' '''
11852 if(parse_debug):
11853 print('statement_item_53', list(p))
11854
11855 # { PChainConstructor*tmp = new PChainConstructor(*p[5]);
11856 # FILE_NAME(tmp, @3);
11857 # delete p[1];
11858 # p[0] = tmp;
11859 # }
11860 ()
11861
11862
11863 def p_statement_item_54(p):
11864 '''statement_item : hierarchy_identifier '(' error ')' ';' '''
11865 if(parse_debug):
11866 print('statement_item_54', list(p))
11867
11868 # { yyerror(@3, "error: Syntax error in task arguments.");
11869 # list<PExpr*>pt;
11870 # PCallTask*tmp = pform_make_call_task(@1, *p[1], pt);
11871 # delete p[1];
11872 # p[0] = tmp;
11873 # }
11874 ()
11875
11876
11877 def p_statement_item_55(p):
11878 '''statement_item : error ';' '''
11879 if(parse_debug):
11880 print('statement_item_55', list(p))
11881
11882 # { yyerror(@2, "error: malformed statement");
11883 # yyerrok;
11884 # p[0] = new PNoop;
11885 # }
11886 ()
11887
11888
11889 def p__embed0_statement_item(p):
11890 '''_embed0_statement_item : '''
11891
11892 # { PBlock*tmp = pform_push_block_scope(0, PBlock::BL_SEQ);
11893 # FILE_NAME(tmp, @1);
11894 # current_block_stack.push(tmp);
11895 # }
11896 ()
11897
11898
11899 def p__embed1_statement_item(p):
11900 '''_embed1_statement_item : '''
11901
11902 # { if (p[3]) {
11903 # if (! gn_system_verilog()) {
11904 # yyerror("error: Variable declaration in unnamed block "
11905 # "requires SystemVerilog.");
11906 # }
11907 # } else {
11908 # /* If there are no declarations in the scope then just delete it. */
11909 # pform_pop_scope();
11910 # assert(! current_block_stack.empty());
11911 # PBlock*tmp = current_block_stack.top();
11912 # current_block_stack.pop();
11913 # delete tmp;
11914 # }
11915 # }
11916 ()
11917
11918
11919 def p__embed2_statement_item(p):
11920 '''_embed2_statement_item : '''
11921
11922 # { PBlock*tmp = pform_push_block_scope(p[3], PBlock::BL_SEQ);
11923 # FILE_NAME(tmp, @1);
11924 # current_block_stack.push(tmp);
11925 # }
11926 ()
11927
11928
11929 def p__embed3_statement_item(p):
11930 '''_embed3_statement_item : '''
11931
11932 # { PBlock*tmp = pform_push_block_scope(0, PBlock::BL_PAR);
11933 # FILE_NAME(tmp, @1);
11934 # current_block_stack.push(tmp);
11935 # }
11936 ()
11937
11938
11939 def p__embed4_statement_item(p):
11940 '''_embed4_statement_item : '''
11941
11942 # { if (p[3]) {
11943 # if (! gn_system_verilog()) {
11944 # yyerror("error: Variable declaration in unnamed block "
11945 # "requires SystemVerilog.");
11946 # }
11947 # } else {
11948 # /* If there are no declarations in the scope then just delete it. */
11949 # pform_pop_scope();
11950 # assert(! current_block_stack.empty());
11951 # PBlock*tmp = current_block_stack.top();
11952 # current_block_stack.pop();
11953 # delete tmp;
11954 # }
11955 # }
11956 ()
11957
11958
11959 def p__embed5_statement_item(p):
11960 '''_embed5_statement_item : '''
11961
11962 # { PBlock*tmp = pform_push_block_scope(p[3], PBlock::BL_PAR);
11963 # FILE_NAME(tmp, @1);
11964 # current_block_stack.push(tmp);
11965 # }
11966 ()
11967
11968
11969 def p_compressed_statement_1(p):
11970 '''compressed_statement : lpvalue K_PLUS_EQ expression '''
11971 if(parse_debug):
11972 print('compressed_statement_1', list(p))
11973
11974 # { PAssign*tmp = new PAssign(p[1], '+', p[3]);
11975 # FILE_NAME(tmp, @1);
11976 # p[0] = tmp;
11977 # }
11978 ()
11979
11980
11981 def p_compressed_statement_2(p):
11982 '''compressed_statement : lpvalue K_MINUS_EQ expression '''
11983 if(parse_debug):
11984 print('compressed_statement_2', list(p))
11985
11986 # { PAssign*tmp = new PAssign(p[1], '-', p[3]);
11987 # FILE_NAME(tmp, @1);
11988 # p[0] = tmp;
11989 # }
11990 ()
11991
11992
11993 def p_compressed_statement_3(p):
11994 '''compressed_statement : lpvalue K_MUL_EQ expression '''
11995 if(parse_debug):
11996 print('compressed_statement_3', list(p))
11997
11998 # { PAssign*tmp = new PAssign(p[1], '*', p[3]);
11999 # FILE_NAME(tmp, @1);
12000 # p[0] = tmp;
12001 # }
12002 ()
12003
12004
12005 def p_compressed_statement_4(p):
12006 '''compressed_statement : lpvalue K_DIV_EQ expression '''
12007 if(parse_debug):
12008 print('compressed_statement_4', list(p))
12009
12010 # { PAssign*tmp = new PAssign(p[1], '/', p[3]);
12011 # FILE_NAME(tmp, @1);
12012 # p[0] = tmp;
12013 # }
12014 ()
12015
12016
12017 def p_compressed_statement_5(p):
12018 '''compressed_statement : lpvalue K_MOD_EQ expression '''
12019 if(parse_debug):
12020 print('compressed_statement_5', list(p))
12021
12022 # { PAssign*tmp = new PAssign(p[1], '%', p[3]);
12023 # FILE_NAME(tmp, @1);
12024 # p[0] = tmp;
12025 # }
12026 ()
12027
12028
12029 def p_compressed_statement_6(p):
12030 '''compressed_statement : lpvalue K_AND_EQ expression '''
12031 if(parse_debug):
12032 print('compressed_statement_6', list(p))
12033
12034 # { PAssign*tmp = new PAssign(p[1], '&', p[3]);
12035 # FILE_NAME(tmp, @1);
12036 # p[0] = tmp;
12037 # }
12038 ()
12039
12040
12041 def p_compressed_statement_7(p):
12042 '''compressed_statement : lpvalue K_OR_EQ expression '''
12043 if(parse_debug):
12044 print('compressed_statement_7', list(p))
12045
12046 # { PAssign*tmp = new PAssign(p[1], '|', p[3]);
12047 # FILE_NAME(tmp, @1);
12048 # p[0] = tmp;
12049 # }
12050 ()
12051
12052
12053 def p_compressed_statement_8(p):
12054 '''compressed_statement : lpvalue K_XOR_EQ expression '''
12055 if(parse_debug):
12056 print('compressed_statement_8', list(p))
12057
12058 # { PAssign*tmp = new PAssign(p[1], '^', p[3]);
12059 # FILE_NAME(tmp, @1);
12060 # p[0] = tmp;
12061 # }
12062 ()
12063
12064
12065 def p_compressed_statement_9(p):
12066 '''compressed_statement : lpvalue K_LS_EQ expression '''
12067 if(parse_debug):
12068 print('compressed_statement_9', list(p))
12069
12070 # { PAssign *tmp = new PAssign(p[1], 'l', p[3]);
12071 # FILE_NAME(tmp, @1);
12072 # p[0] = tmp;
12073 # }
12074 ()
12075
12076
12077 def p_compressed_statement_10(p):
12078 '''compressed_statement : lpvalue K_RS_EQ expression '''
12079 if(parse_debug):
12080 print('compressed_statement_10', list(p))
12081
12082 # { PAssign*tmp = new PAssign(p[1], 'r', p[3]);
12083 # FILE_NAME(tmp, @1);
12084 # p[0] = tmp;
12085 # }
12086 ()
12087
12088
12089 def p_compressed_statement_11(p):
12090 '''compressed_statement : lpvalue K_RSS_EQ expression '''
12091 if(parse_debug):
12092 print('compressed_statement_11', list(p))
12093
12094 # { PAssign *tmp = new PAssign(p[1], 'R', p[3]);
12095 # FILE_NAME(tmp, @1);
12096 # p[0] = tmp;
12097 # }
12098 ()
12099
12100
12101 def p_statement_or_null_list_opt_1(p):
12102 '''statement_or_null_list_opt : statement_or_null_list '''
12103 if(parse_debug):
12104 print('statement_or_null_list_opt_1', list(p))
12105 p[0] = p[1]
12106
12107
12108 ()
12109
12110
12111 def p_statement_or_null_list_opt_2(p):
12112 '''statement_or_null_list_opt : '''
12113 if(parse_debug):
12114 print('statement_or_null_list_opt_2', list(p))
12115
12116 # { p[0] = None }
12117 ()
12118
12119
12120 def p_statement_or_null_list_1(p):
12121 '''statement_or_null_list : statement_or_null_list statement_or_null '''
12122 if(parse_debug):
12123 print('statement_or_null_list_1', list(p))
12124
12125 # { vector<Statement*>*tmp = p[1];
12126 # if (p[2]) tmp->push_back(p[2]);
12127 # p[0] = tmp;
12128 # }
12129 ()
12130
12131
12132 def p_statement_or_null_list_2(p):
12133 '''statement_or_null_list : statement_or_null '''
12134 if(parse_debug):
12135 print('statement_or_null_list_2', list(p))
12136
12137 # { vector<Statement*>*tmp = new vector<Statement*>(0);
12138 # if (p[1]) tmp->push_back(p[1]);
12139 # p[0] = tmp;
12140 # }
12141 ()
12142
12143
12144 def p_analog_statement_1(p):
12145 '''analog_statement : branch_probe_expression K_CONTRIBUTE expression ';' '''
12146 if(parse_debug):
12147 print('analog_statement_1', list(p))
12148
12149 # { p[0] = pform_contribution_statement(@2, p[1], p[3]); }
12150 ()
12151
12152
12153 def p_task_item_1(p):
12154 '''task_item : block_item_decl '''
12155 if(parse_debug):
12156 print('task_item_1', list(p))
12157
12158 # { p[0] = new vector<pform_tf_port_t>(0); }
12159 ()
12160
12161
12162 def p_task_item_2(p):
12163 '''task_item : tf_port_declaration '''
12164 if(parse_debug):
12165 print('task_item_2', list(p))
12166 p[0] = p[1]
12167
12168
12169 ()
12170
12171
12172 def p_task_item_list_1(p):
12173 '''task_item_list : task_item_list task_item '''
12174 if(parse_debug):
12175 print('task_item_list_1', list(p))
12176
12177 # { vector<pform_tf_port_t>*tmp = p[1];
12178 # size_t s1 = tmp->size();
12179 # tmp->resize(s1 + p[2]->size());
12180 # for (size_t idx = 0 ; idx < p[2]->size() ; idx += 1)
12181 # tmp->at(s1 + idx) = p[2]->at(idx);
12182 # delete p[2];
12183 # p[0] = tmp;
12184 # }
12185 ()
12186
12187
12188 def p_task_item_list_2(p):
12189 '''task_item_list : task_item '''
12190 if(parse_debug):
12191 print('task_item_list_2', list(p))
12192 p[0] = p[1]
12193
12194
12195 ()
12196
12197
12198 def p_task_item_list_opt_1(p):
12199 '''task_item_list_opt : task_item_list '''
12200 if(parse_debug):
12201 print('task_item_list_opt_1', list(p))
12202 p[0] = p[1]
12203
12204
12205 ()
12206
12207
12208 def p_task_item_list_opt_2(p):
12209 '''task_item_list_opt : '''
12210 if(parse_debug):
12211 print('task_item_list_opt_2', list(p))
12212
12213 # { p[0] = None }
12214 ()
12215
12216
12217 def p_tf_port_list_opt_1(p):
12218 '''tf_port_list_opt : tf_port_list '''
12219 if(parse_debug):
12220 print('tf_port_list_opt_1', list(p))
12221 p[0] = p[1]
12222
12223
12224 ()
12225
12226
12227 def p_tf_port_list_opt_2(p):
12228 '''tf_port_list_opt : '''
12229 if(parse_debug):
12230 print('tf_port_list_opt_2', list(p))
12231
12232 # { p[0] = None }
12233 ()
12234
12235
12236 def p_udp_body_1(p):
12237 '''udp_body : K_table udp_entry_list K_endtable '''
12238 if(parse_debug):
12239 print('udp_body_1', list(p))
12240
12241 # { lex_end_table();
12242 # p[0] = p[2];
12243 # }
12244 ()
12245
12246
12247 def p_udp_body_2(p):
12248 '''udp_body : K_table K_endtable '''
12249 if(parse_debug):
12250 print('udp_body_2', list(p))
12251
12252 # { lex_end_table();
12253 # yyerror(@1, "error: Empty UDP table.");
12254 # p[0] = None
12255 # }
12256 ()
12257
12258
12259 def p_udp_body_3(p):
12260 '''udp_body : K_table error K_endtable '''
12261 if(parse_debug):
12262 print('udp_body_3', list(p))
12263
12264 # { lex_end_table();
12265 # yyerror(@2, "Errors in UDP table");
12266 # yyerrok;
12267 # p[0] = None
12268 # }
12269 ()
12270
12271
12272 def p_udp_entry_list_1(p):
12273 '''udp_entry_list : udp_comb_entry_list '''
12274 if(parse_debug):
12275 print('udp_entry_list_1', list(p))
12276
12277
12278 ()
12279
12280
12281 def p_udp_entry_list_2(p):
12282 '''udp_entry_list : udp_sequ_entry_list '''
12283 if(parse_debug):
12284 print('udp_entry_list_2', list(p))
12285
12286
12287 ()
12288
12289
12290 def p_udp_comb_entry_1(p):
12291 '''udp_comb_entry : udp_input_list ':' udp_output_sym ';' '''
12292 if(parse_debug):
12293 print('udp_comb_entry_1', list(p))
12294
12295 # { char*tmp = new char[strlen(p[1])+3];
12296 # strcpy(tmp, p[1]);
12297 # char*tp = tmp+strlen(tmp);
12298 # *tp++ = ':';
12299 # *tp++ = p[3];
12300 # *tp++ = 0;
12301 # delete[]p[1];
12302 # p[0] = tmp;
12303 # }
12304 ()
12305
12306
12307 def p_udp_comb_entry_list_1(p):
12308 '''udp_comb_entry_list : udp_comb_entry '''
12309 if(parse_debug):
12310 print('udp_comb_entry_list_1', list(p))
12311
12312 # { list<string>*tmp = new list<string>;
12313 # tmp->push_back(p[1]);
12314 # delete[]p[1];
12315 # p[0] = tmp;
12316 # }
12317 ()
12318
12319
12320 def p_udp_comb_entry_list_2(p):
12321 '''udp_comb_entry_list : udp_comb_entry_list udp_comb_entry '''
12322 if(parse_debug):
12323 print('udp_comb_entry_list_2', list(p))
12324
12325 # { list<string>*tmp = p[1];
12326 # tmp->push_back(p[2]);
12327 # delete[]p[2];
12328 # p[0] = tmp;
12329 # }
12330 ()
12331
12332
12333 def p_udp_sequ_entry_list_1(p):
12334 '''udp_sequ_entry_list : udp_sequ_entry '''
12335 if(parse_debug):
12336 print('udp_sequ_entry_list_1', list(p))
12337
12338 # { list<string>*tmp = new list<string>;
12339 # tmp->push_back(p[1]);
12340 # delete[]p[1];
12341 # p[0] = tmp;
12342 # }
12343 ()
12344
12345
12346 def p_udp_sequ_entry_list_2(p):
12347 '''udp_sequ_entry_list : udp_sequ_entry_list udp_sequ_entry '''
12348 if(parse_debug):
12349 print('udp_sequ_entry_list_2', list(p))
12350
12351 # { list<string>*tmp = p[1];
12352 # tmp->push_back(p[2]);
12353 # delete[]p[2];
12354 # p[0] = tmp;
12355 # }
12356 ()
12357
12358
12359 def p_udp_sequ_entry_1(p):
12360 '''udp_sequ_entry : udp_input_list ':' udp_input_sym ':' udp_output_sym ';' '''
12361 if(parse_debug):
12362 print('udp_sequ_entry_1', list(p))
12363
12364 # { char*tmp = new char[strlen(p[1])+5];
12365 # strcpy(tmp, p[1]);
12366 # char*tp = tmp+strlen(tmp);
12367 # *tp++ = ':';
12368 # *tp++ = p[3];
12369 # *tp++ = ':';
12370 # *tp++ = p[5];
12371 # *tp++ = 0;
12372 # p[0] = tmp;
12373 # }
12374 ()
12375
12376
12377 def p_udp_initial_1(p):
12378 '''udp_initial : K_initial IDENTIFIER '=' number ';' '''
12379 if(parse_debug):
12380 print('udp_initial_1', list(p))
12381
12382 # { PExpr*etmp = new PENumber(p[4]);
12383 # PEIdent*itmp = new PEIdent(lex_strings.make(p[2]));
12384 # PAssign*atmp = new PAssign(itmp, etmp);
12385 # FILE_NAME(atmp, @2);
12386 # delete[]p[2];
12387 # p[0] = atmp;
12388 # }
12389 ()
12390
12391
12392 def p_udp_init_opt_1(p):
12393 '''udp_init_opt : udp_initial '''
12394 if(parse_debug):
12395 print('udp_init_opt_1', list(p))
12396 p[0] = p[1]
12397
12398
12399 ()
12400
12401
12402 def p_udp_init_opt_2(p):
12403 '''udp_init_opt : '''
12404 if(parse_debug):
12405 print('udp_init_opt_2', list(p))
12406
12407 # { p[0] = None }
12408 ()
12409
12410
12411 def p_udp_input_list_1(p):
12412 '''udp_input_list : udp_input_sym '''
12413 if(parse_debug):
12414 print('udp_input_list_1', list(p))
12415
12416 # { char*tmp = new char[2];
12417 # tmp[0] = p[1];
12418 # tmp[1] = 0;
12419 # p[0] = tmp;
12420 # }
12421 ()
12422
12423
12424 def p_udp_input_list_2(p):
12425 '''udp_input_list : udp_input_list udp_input_sym '''
12426 if(parse_debug):
12427 print('udp_input_list_2', list(p))
12428
12429 # { char*tmp = new char[strlen(p[1])+2];
12430 # strcpy(tmp, p[1]);
12431 # char*tp = tmp+strlen(tmp);
12432 # *tp++ = p[2];
12433 # *tp++ = 0;
12434 # delete[]p[1];
12435 # p[0] = tmp;
12436 # }
12437 ()
12438
12439
12440 def p_udp_input_sym_1(p):
12441 '''udp_input_sym : '0' '''
12442 if(parse_debug):
12443 print('udp_input_sym_1', list(p))
12444
12445 # { p[0] = '0'; }
12446 ()
12447
12448
12449 def p_udp_input_sym_2(p):
12450 '''udp_input_sym : '1' '''
12451 if(parse_debug):
12452 print('udp_input_sym_2', list(p))
12453
12454 # { p[0] = '1'; }
12455 ()
12456
12457
12458 def p_udp_input_sym_3(p):
12459 '''udp_input_sym : 'x' '''
12460 if(parse_debug):
12461 print('udp_input_sym_3', list(p))
12462
12463 # { p[0] = 'x'; }
12464 ()
12465
12466
12467 def p_udp_input_sym_4(p):
12468 '''udp_input_sym : '?' '''
12469 if(parse_debug):
12470 print('udp_input_sym_4', list(p))
12471
12472 # { p[0] = '?'; }
12473 ()
12474
12475
12476 def p_udp_input_sym_5(p):
12477 '''udp_input_sym : 'b' '''
12478 if(parse_debug):
12479 print('udp_input_sym_5', list(p))
12480
12481 # { p[0] = 'b'; }
12482 ()
12483
12484
12485 def p_udp_input_sym_6(p):
12486 '''udp_input_sym : '*' '''
12487 if(parse_debug):
12488 print('udp_input_sym_6', list(p))
12489
12490 # { p[0] = '*'; }
12491 ()
12492
12493
12494 def p_udp_input_sym_7(p):
12495 '''udp_input_sym : '%' '''
12496 if(parse_debug):
12497 print('udp_input_sym_7', list(p))
12498
12499 # { p[0] = '%'; }
12500 ()
12501
12502
12503 def p_udp_input_sym_8(p):
12504 '''udp_input_sym : 'f' '''
12505 if(parse_debug):
12506 print('udp_input_sym_8', list(p))
12507
12508 # { p[0] = 'f'; }
12509 ()
12510
12511
12512 def p_udp_input_sym_9(p):
12513 '''udp_input_sym : 'F' '''
12514 if(parse_debug):
12515 print('udp_input_sym_9', list(p))
12516
12517 # { p[0] = 'F'; }
12518 ()
12519
12520
12521 def p_udp_input_sym_10(p):
12522 '''udp_input_sym : 'l' '''
12523 if(parse_debug):
12524 print('udp_input_sym_10', list(p))
12525
12526 # { p[0] = 'l'; }
12527 ()
12528
12529
12530 def p_udp_input_sym_11(p):
12531 '''udp_input_sym : 'h' '''
12532 if(parse_debug):
12533 print('udp_input_sym_11', list(p))
12534
12535 # { p[0] = 'h'; }
12536 ()
12537
12538
12539 def p_udp_input_sym_12(p):
12540 '''udp_input_sym : 'B' '''
12541 if(parse_debug):
12542 print('udp_input_sym_12', list(p))
12543
12544 # { p[0] = 'B'; }
12545 ()
12546
12547
12548 def p_udp_input_sym_13(p):
12549 '''udp_input_sym : 'r' '''
12550 if(parse_debug):
12551 print('udp_input_sym_13', list(p))
12552
12553 # { p[0] = 'r'; }
12554 ()
12555
12556
12557 def p_udp_input_sym_14(p):
12558 '''udp_input_sym : 'R' '''
12559 if(parse_debug):
12560 print('udp_input_sym_14', list(p))
12561
12562 # { p[0] = 'R'; }
12563 ()
12564
12565
12566 def p_udp_input_sym_15(p):
12567 '''udp_input_sym : 'M' '''
12568 if(parse_debug):
12569 print('udp_input_sym_15', list(p))
12570
12571 # { p[0] = 'M'; }
12572 ()
12573
12574
12575 def p_udp_input_sym_16(p):
12576 '''udp_input_sym : 'n' '''
12577 if(parse_debug):
12578 print('udp_input_sym_16', list(p))
12579
12580 # { p[0] = 'n'; }
12581 ()
12582
12583
12584 def p_udp_input_sym_17(p):
12585 '''udp_input_sym : 'N' '''
12586 if(parse_debug):
12587 print('udp_input_sym_17', list(p))
12588
12589 # { p[0] = 'N'; }
12590 ()
12591
12592
12593 def p_udp_input_sym_18(p):
12594 '''udp_input_sym : 'p' '''
12595 if(parse_debug):
12596 print('udp_input_sym_18', list(p))
12597
12598 # { p[0] = 'p'; }
12599 ()
12600
12601
12602 def p_udp_input_sym_19(p):
12603 '''udp_input_sym : 'P' '''
12604 if(parse_debug):
12605 print('udp_input_sym_19', list(p))
12606
12607 # { p[0] = 'P'; }
12608 ()
12609
12610
12611 def p_udp_input_sym_20(p):
12612 '''udp_input_sym : 'Q' '''
12613 if(parse_debug):
12614 print('udp_input_sym_20', list(p))
12615
12616 # { p[0] = 'Q'; }
12617 ()
12618
12619
12620 def p_udp_input_sym_21(p):
12621 '''udp_input_sym : 'q' '''
12622 if(parse_debug):
12623 print('udp_input_sym_21', list(p))
12624
12625 # { p[0] = 'q'; }
12626 ()
12627
12628
12629 def p_udp_input_sym_22(p):
12630 '''udp_input_sym : '_' '''
12631 if(parse_debug):
12632 print('udp_input_sym_22', list(p))
12633
12634 # { p[0] = '_'; }
12635 ()
12636
12637
12638 def p_udp_input_sym_23(p):
12639 '''udp_input_sym : '+' '''
12640 if(parse_debug):
12641 print('udp_input_sym_23', list(p))
12642
12643 # { p[0] = '+'; }
12644 ()
12645
12646
12647 def p_udp_input_sym_24(p):
12648 '''udp_input_sym : DEC_NUMBER '''
12649 if(parse_debug):
12650 print('udp_input_sym_24', list(p))
12651
12652 # { yyerror(@1, "internal error: Input digits parse as decimal number!"); p[0] = '0'; }
12653 ()
12654
12655
12656 def p_udp_output_sym_1(p):
12657 '''udp_output_sym : '0' '''
12658 if(parse_debug):
12659 print('udp_output_sym_1', list(p))
12660
12661 # { p[0] = '0'; }
12662 ()
12663
12664
12665 def p_udp_output_sym_2(p):
12666 '''udp_output_sym : '1' '''
12667 if(parse_debug):
12668 print('udp_output_sym_2', list(p))
12669
12670 # { p[0] = '1'; }
12671 ()
12672
12673
12674 def p_udp_output_sym_3(p):
12675 '''udp_output_sym : 'x' '''
12676 if(parse_debug):
12677 print('udp_output_sym_3', list(p))
12678
12679 # { p[0] = 'x'; }
12680 ()
12681
12682
12683 def p_udp_output_sym_4(p):
12684 '''udp_output_sym : '-' '''
12685 if(parse_debug):
12686 print('udp_output_sym_4', list(p))
12687
12688 # { p[0] = '-'; }
12689 ()
12690
12691
12692 def p_udp_output_sym_5(p):
12693 '''udp_output_sym : DEC_NUMBER '''
12694 if(parse_debug):
12695 print('udp_output_sym_5', list(p))
12696
12697 # { yyerror(@1, "internal error: Output digits parse as decimal number!"); p[0] = '0'; }
12698 ()
12699
12700
12701 def p_udp_port_decl_1(p):
12702 '''udp_port_decl : K_input list_of_identifiers ';' '''
12703 if(parse_debug):
12704 print('udp_port_decl_1', list(p))
12705
12706 # { p[0] = pform_make_udp_input_ports(p[2]); }
12707 ()
12708
12709
12710 def p_udp_port_decl_2(p):
12711 '''udp_port_decl : K_output IDENTIFIER ';' '''
12712 if(parse_debug):
12713 print('udp_port_decl_2', list(p))
12714
12715 # { perm_string pname = lex_strings.make(p[2]);
12716 # PWire*pp = new PWire(pname, NetNet::IMPLICIT, NetNet::POUTPUT, IVL_VT_LOGIC);
12717 # vector<PWire*>*tmp = new vector<PWire*>(1);
12718 # (*tmp)[0] = pp;
12719 # p[0] = tmp;
12720 # delete[]p[2];
12721 # }
12722 ()
12723
12724
12725 def p_udp_port_decl_3(p):
12726 '''udp_port_decl : K_reg IDENTIFIER ';' '''
12727 if(parse_debug):
12728 print('udp_port_decl_3', list(p))
12729
12730 # { perm_string pname = lex_strings.make(p[2]);
12731 # PWire*pp = new PWire(pname, NetNet::REG, NetNet::PIMPLICIT, IVL_VT_LOGIC);
12732 # vector<PWire*>*tmp = new vector<PWire*>(1);
12733 # (*tmp)[0] = pp;
12734 # p[0] = tmp;
12735 # delete[]p[2];
12736 # }
12737 ()
12738
12739
12740 def p_udp_port_decl_4(p):
12741 '''udp_port_decl : K_reg K_output IDENTIFIER ';' '''
12742 if(parse_debug):
12743 print('udp_port_decl_4', list(p))
12744
12745 # { perm_string pname = lex_strings.make(p[3]);
12746 # PWire*pp = new PWire(pname, NetNet::REG, NetNet::POUTPUT, IVL_VT_LOGIC);
12747 # vector<PWire*>*tmp = new vector<PWire*>(1);
12748 # (*tmp)[0] = pp;
12749 # p[0] = tmp;
12750 # delete[]p[3];
12751 # }
12752 ()
12753
12754
12755 def p_udp_port_decls_1(p):
12756 '''udp_port_decls : udp_port_decl '''
12757 if(parse_debug):
12758 print('udp_port_decls_1', list(p))
12759 p[0] = p[1]
12760
12761
12762 ()
12763
12764
12765 def p_udp_port_decls_2(p):
12766 '''udp_port_decls : udp_port_decls udp_port_decl '''
12767 if(parse_debug):
12768 print('udp_port_decls_2', list(p))
12769
12770 # { vector<PWire*>*tmp = p[1];
12771 # size_t s1 = p[1]->size();
12772 # tmp->resize(s1+p[2]->size());
12773 # for (size_t idx = 0 ; idx < p[2]->size() ; idx += 1)
12774 # tmp->at(s1+idx) = p[2]->at(idx);
12775 # p[0] = tmp;
12776 # delete p[2];
12777 # }
12778 ()
12779
12780
12781 def p_udp_port_list_1(p):
12782 '''udp_port_list : IDENTIFIER '''
12783 if(parse_debug):
12784 print('udp_port_list_1', list(p))
12785
12786 # { list<perm_string>*tmp = new list<perm_string>;
12787 # tmp->push_back(lex_strings.make(p[1]));
12788 # delete[]p[1];
12789 # p[0] = tmp;
12790 # }
12791 ()
12792
12793
12794 def p_udp_port_list_2(p):
12795 '''udp_port_list : udp_port_list ',' IDENTIFIER '''
12796 if(parse_debug):
12797 print('udp_port_list_2', list(p))
12798
12799 # { list<perm_string>*tmp = p[1];
12800 # tmp->push_back(lex_strings.make(p[3]));
12801 # delete[]p[3];
12802 # p[0] = tmp;
12803 # }
12804 ()
12805
12806
12807 def p_udp_reg_opt_1(p):
12808 '''udp_reg_opt : K_reg '''
12809 if(parse_debug):
12810 print('udp_reg_opt_1', list(p))
12811 p[0] = True
12812
12813
12814 ()
12815
12816
12817 def p_udp_reg_opt_2(p):
12818 '''udp_reg_opt : '''
12819 if(parse_debug):
12820 print('udp_reg_opt_2', list(p))
12821 p[0] = False
12822
12823
12824 ()
12825
12826
12827 def p_udp_initial_expr_opt_1(p):
12828 '''udp_initial_expr_opt : '=' expression '''
12829 if(parse_debug):
12830 print('udp_initial_expr_opt_1', list(p))
12831 p[0] = p[2]
12832
12833
12834 ()
12835
12836
12837 def p_udp_initial_expr_opt_2(p):
12838 '''udp_initial_expr_opt : '''
12839 if(parse_debug):
12840 print('udp_initial_expr_opt_2', list(p))
12841
12842 # { p[0] = None }
12843 ()
12844
12845
12846 def p_udp_input_declaration_list_1(p):
12847 '''udp_input_declaration_list : K_input IDENTIFIER '''
12848 if(parse_debug):
12849 print('udp_input_declaration_list_1', list(p))
12850
12851 # { list<perm_string>*tmp = new list<perm_string>;
12852 # tmp->push_back(lex_strings.make(p[2]));
12853 # p[0] = tmp;
12854 # delete[]p[2];
12855 # }
12856 ()
12857
12858
12859 def p_udp_input_declaration_list_2(p):
12860 '''udp_input_declaration_list : udp_input_declaration_list ',' K_input IDENTIFIER '''
12861 if(parse_debug):
12862 print('udp_input_declaration_list_2', list(p))
12863
12864 # { list<perm_string>*tmp = p[1];
12865 # tmp->push_back(lex_strings.make(p[4]));
12866 # p[0] = tmp;
12867 # delete[]p[4];
12868 # }
12869 ()
12870
12871
12872 def p_udp_primitive_1(p):
12873 '''udp_primitive : K_primitive IDENTIFIER '(' udp_port_list ')' ';' udp_port_decls udp_init_opt udp_body K_endprimitive endlabel_opt '''
12874 if(parse_debug):
12875 print('udp_primitive_1', list(p))
12876
12877 # { perm_string tmp2 = lex_strings.make(p[2]);
12878 # pform_make_udp(tmp2, p[4], p[7], p[9], p[8],
12879 # @2.text, @2.first_line);
12880 # if (p[11]) {
12881 # if (strcmp(p[2],p[11]) != 0) {
12882 # yyerror(@11, "error: End label doesn't match "
12883 # "primitive name");
12884 # }
12885 # if (! gn_system_verilog()) {
12886 # yyerror(@11, "error: Primitive end labels "
12887 # "require SystemVerilog.");
12888 # }
12889 # delete[]p[11];
12890 # }
12891 # delete[]p[2];
12892 # }
12893 ()
12894
12895
12896 def p_udp_primitive_2(p):
12897 '''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 '''
12898 if(parse_debug):
12899 print('udp_primitive_2', list(p))
12900
12901 # { perm_string tmp2 = lex_strings.make(p[2]);
12902 # perm_string tmp6 = lex_strings.make(p[6]);
12903 # pform_make_udp(tmp2, p[5], tmp6, p[7], p[9], p[12],
12904 # @2.text, @2.first_line);
12905 # if (p[14]) {
12906 # if (strcmp(p[2],p[14]) != 0) {
12907 # yyerror(@14, "error: End label doesn't match "
12908 # "primitive name");
12909 # }
12910 # if (! gn_system_verilog()) {
12911 # yyerror(@14, "error: Primitive end labels "
12912 # "require SystemVerilog.");
12913 # }
12914 # delete[]p[14];
12915 # }
12916 # delete[]p[2];
12917 # delete[]p[6];
12918 # }
12919 ()
12920
12921
12922 def p_K_packed_opt_1(p):
12923 '''K_packed_opt : K_packed '''
12924 if(parse_debug):
12925 print('K_packed_opt', list(p))
12926 p[0] = True
12927
12928
12929 ()
12930
12931
12932 def p_K_packed_opt_2(p):
12933 '''K_packed_opt : '''
12934 if(parse_debug):
12935 print('K_packed_opt', list(p))
12936 p[0] = False
12937
12938
12939 ()
12940
12941
12942 def p_K_reg_opt_1(p):
12943 '''K_reg_opt : K_reg '''
12944 if(parse_debug):
12945 print('K_reg_opt', list(p))
12946 p[0] = True
12947
12948
12949 ()
12950
12951
12952 def p_K_reg_opt_2(p):
12953 '''K_reg_opt : '''
12954 if(parse_debug):
12955 print('K_reg_opt', list(p))
12956 p[0] = False
12957
12958
12959 ()
12960
12961
12962 def p_K_static_opt_1(p):
12963 '''K_static_opt : K_static '''
12964 if(parse_debug):
12965 print('K_static_opt', list(p))
12966 p[0] = True
12967
12968
12969 ()
12970
12971
12972 def p_K_static_opt_2(p):
12973 '''K_static_opt : '''
12974 if(parse_debug):
12975 print('K_static_opt', list(p))
12976 p[0] = False
12977
12978
12979 ()
12980
12981
12982 def p_K_virtual_opt_1(p):
12983 '''K_virtual_opt : K_virtual '''
12984 if(parse_debug):
12985 print(p)
12986 p[0] = True
12987
12988
12989 ()
12990
12991
12992 def p_K_virtual_opt_2(p):
12993 '''K_virtual_opt : '''
12994 if(parse_debug):
12995 print(p)
12996 p[0] = False
12997
12998
12999 ()
13000
13001
13002 def p_error(p):
13003 if(parse_debug):
13004 print("error", p)
13005 exit(0)
13006
13007
13008 yacc.yacc(debug=0)