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