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