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(par