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