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