wire assignments
[sv2nmigen.git] / parse_sv.py
1 # %{
2 # /*
3 # * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com)
4 # * Copyright CERN 2012-2013 / Stephen Williams (steve@icarus.com)
5 # *
6 # * This source code is free software; you can redistribute it
7 # * and/or modify it in source code form under the terms of the GNU
8 # * General Public License as published by the Free Software
9 # * Foundation; either version 2 of the License, or (at your option)
10 # * any later version.
11 # *
12 # * This program is distributed in the hope that it will be useful,
13 # * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # * GNU General Public License for more details.
16 # *
17 # * You should have received a copy of the GNU General Public License
18 # * along with this program; if not, write to the Free Software
19 # * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # */
21
22 import lexor
23 from ply import yacc, lex
24 from lib2to3.pytree import Node, Leaf
25 from lib2to3.pgen2 import token
26 from lib2to3.pygram import python_symbols as syms
27
28 yacc1_debug = 0
29 yacc2_debug = 0
30 parse_debug = 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 # -------------- RULES ----------------
112 ()
113
114
115 def p_source_text_1(p):
116 '''source_text : timeunits_declaration_opt _embed0_source_text description_list '''
117 if(parse_debug > 2):
118 print('source_text', list(p))
119
120
121 ()
122
123
124 def p_source_text_2(p):
125 '''source_text : '''
126 if(parse_debug):
127 print('source_text', list(p))
128
129
130 ()
131
132
133 def p__embed0_source_text(p):
134 '''_embed0_source_text : '''
135
136 # { pform_set_scope_timescale(yyloc); }
137 ()
138
139
140 def p_assertion_item_1(p):
141 '''assertion_item : concurrent_assertion_item '''
142 if(parse_debug):
143 print('assertion_item_1', list(p))
144
145
146 ()
147
148
149 def p_assignment_pattern_1(p):
150 '''assignment_pattern : K_LP expression_list_proper '}' '''
151 if(parse_debug):
152 print('assignment_pattern_1', list(p))
153
154 # { PEAssignPattern*tmp = new PEAssignPattern(*p[2]);
155 # FILE_NAME(tmp, @1);
156 # delete p[2];
157 # p[0] = tmp;
158 # }
159 ()
160
161
162 def p_assignment_pattern_2(p):
163 '''assignment_pattern : K_LP '}' '''
164 if(parse_debug):
165 print('assignment_pattern_2', list(p))
166
167 # { PEAssignPattern*tmp = new PEAssignPattern;
168 # FILE_NAME(tmp, @1);
169 # p[0] = tmp;
170 # }
171 ()
172
173
174 def p_block_identifier_opt_1(p):
175 '''block_identifier_opt : IDENTIFIER ':' '''
176 if(parse_debug):
177 print('block_identifier_opt_1', list(p))
178
179
180 ()
181
182
183 def p_block_identifier_opt_2(p):
184 '''block_identifier_opt : '''
185 if(parse_debug):
186 print('block_identifier_opt_2', list(p))
187
188
189 ()
190
191
192 def p_class_declaration_1(p):
193 '''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 '''
194 if(parse_debug):
195 print('class_declaration_1', list(p))
196
197 # { // Wrap up the class.
198 # if (p[11] && p[4] && p[4]->name != p[11]) {
199 # yyerror(@11, "error: Class end label doesn't match class name.");
200 # delete[]p[11];
201 # }
202 # }
203 ()
204
205
206 def p__embed0_class_declaration(p):
207 '''_embed0_class_declaration : '''
208
209 # { pform_start_class_declaration(@2, p[4], p[5].type, p[5].exprs, p[3]); }
210 ()
211
212
213 def p__embed1_class_declaration(p):
214 '''_embed1_class_declaration : '''
215
216 # { // Process a class.
217 # pform_end_class_declaration(@9);
218 # }
219 ()
220
221
222 def p_class_constraint_1(p):
223 '''class_constraint : constraint_prototype '''
224 if(parse_debug):
225 print('class_constraint_1', list(p))
226
227
228 ()
229
230
231 def p_class_constraint_2(p):
232 '''class_constraint : constraint_declaration '''
233 if(parse_debug):
234 print('class_constraint_2', list(p))
235
236
237 ()
238
239
240 def p_class_identifier_1(p):
241 '''class_identifier : IDENTIFIER '''
242 if(parse_debug):
243 print('class_identifier_1', list(p))
244
245 # { // Create a synthetic typedef for the class name so that the
246 # // lexor detects the name as a type.
247 # perm_string name = lex_strings.make(p[1]);
248 # class_type_t*tmp = new class_type_t(name);
249 # FILE_NAME(tmp, @1);
250 # pform_set_typedef(name, tmp, NULL);
251 # delete[]p[1];
252 # p[0] = tmp;
253 # }
254 ()
255
256
257 def p_class_identifier_2(p):
258 '''class_identifier : TYPE_IDENTIFIER '''
259 if(parse_debug):
260 print('class_identifier_2', list(p))
261
262 # { class_type_t*tmp = dynamic_cast<class_type_t*>(p[1].type);
263 # if (tmp == 0) {
264 # yyerror(@1, "Type name \"%s\"is not a predeclared class name.", p[1].text);
265 # }
266 # delete[]p[1].text;
267 # p[0] = tmp;
268 # }
269 ()
270
271
272 def p_class_declaration_endlabel_opt_1(p):
273 '''class_declaration_endlabel_opt : ':' TYPE_IDENTIFIER '''
274 if(parse_debug):
275 print('class_declaration_endlabel_opt_1', list(p))
276
277 # { class_type_t*tmp = dynamic_cast<class_type_t*> (p[2].type);
278 # if (tmp == 0) {
279 # yyerror(@2, "error: class declaration endlabel \"%s\" is not a class name\n", p[2].text);
280 # p[0] = None
281 # } else {
282 # p[0] = strdupnew(tmp->name.str());
283 # }
284 # delete[]p[2].text;
285 # }
286 ()
287
288
289 def p_class_declaration_endlabel_opt_2(p):
290 '''class_declaration_endlabel_opt : ':' IDENTIFIER '''
291 if(parse_debug):
292 print('class_declaration_endlabel_opt_2', list(p))
293 p[0] = p[2]
294
295
296 ()
297
298
299 def p_class_declaration_endlabel_opt_3(p):
300 '''class_declaration_endlabel_opt : '''
301 if(parse_debug):
302 print('class_declaration_endlabel_opt_3', list(p))
303
304 # { p[0] = None }
305 ()
306
307
308 def p_class_declaration_extends_opt_1(p):
309 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '''
310 if(parse_debug):
311 print('class_declaration_extends_opt_1', list(p))
312
313 # { p[0].type = p[2].type;
314 # p[0].exprs= 0;
315 # delete[]p[2].text;
316 # }
317 ()
318
319
320 def p_class_declaration_extends_opt_2(p):
321 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '(' expression_list_with_nuls ')' '''
322 if(parse_debug):
323 print('class_declaration_extends_opt_2', list(p))
324
325 # { p[0].type = p[2].type;
326 # p[0].exprs = p[4];
327 # delete[]p[2].text;
328 # }
329 ()
330
331
332 def p_class_declaration_extends_opt_3(p):
333 '''class_declaration_extends_opt : '''
334 if(parse_debug):
335 print('class_declaration_extends_opt_3', list(p))
336
337 # { p[0].type = 0; p[0].exprs = 0; }
338 ()
339
340
341 def p_class_items_opt_1(p):
342 '''class_items_opt : class_items '''
343 if(parse_debug):
344 print('class_items_opt_1', list(p))
345
346
347 ()
348
349
350 def p_class_items_opt_2(p):
351 '''class_items_opt : '''
352 if(parse_debug):
353 print('class_items_opt_2', list(p))
354
355
356 ()
357
358
359 def p_class_items_1(p):
360 '''class_items : class_items class_item '''
361 if(parse_debug):
362 print('class_items_1', list(p))
363
364
365 ()
366
367
368 def p_class_items_2(p):
369 '''class_items : class_item '''
370 if(parse_debug):
371 print('class_items_2', list(p))
372
373
374 ()
375
376
377 def p_class_item_1(p):
378 '''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 '''
379 if(parse_debug):
380 print('class_item_1', list(p))
381
382 # { current_function->set_ports(p[6]);
383 # pform_set_constructor_return(current_function);
384 # pform_set_this_class(@3, current_function);
385 # current_function_set_statement(@3, p[10]);
386 # pform_pop_scope();
387 # current_function = 0;
388 # }
389 ()
390
391
392 def p_class_item_2(p):
393 '''class_item : property_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
394 if(parse_debug):
395 print('class_item_2', list(p))
396
397 # { pform_class_property(@2, p[1], p[2], p[3]); }
398 ()
399
400
401 def p_class_item_3(p):
402 '''class_item : K_const class_item_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
403 if(parse_debug):
404 print('class_item_3', list(p))
405
406 # { pform_class_property(@1, p[2] | property_qualifier_t::make_const(), p[3], p[4]); }
407 ()
408
409
410 def p_class_item_4(p):
411 '''class_item : method_qualifier_opt task_declaration '''
412 if(parse_debug):
413 print('class_item_4', list(p))
414
415 # { /* The task_declaration rule puts this into the class */ }
416 ()
417
418
419 def p_class_item_5(p):
420 '''class_item : method_qualifier_opt function_declaration '''
421 if(parse_debug):
422 print('class_item_5', list(p))
423
424 # { /* The function_declaration rule puts this into the class */ }
425 ()
426
427
428 def p_class_item_6(p):
429 '''class_item : K_extern method_qualifier_opt K_function K_new ';' '''
430 if(parse_debug):
431 print('class_item_6', list(p))
432
433 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
434 ()
435
436
437 def p_class_item_7(p):
438 '''class_item : K_extern method_qualifier_opt K_function K_new '(' tf_port_list_opt ')' ';' '''
439 if(parse_debug):
440 print('class_item_7', list(p))
441
442 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
443 ()
444
445
446 def p_class_item_8(p):
447 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER ';' '''
448 if(parse_debug):
449 print('class_item_8', list(p))
450
451 # { yyerror(@1, "sorry: External methods are not yet supported.");
452 # delete[] p[5];
453 # }
454 ()
455
456
457 def p_class_item_9(p):
458 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' ';' '''
459 if(parse_debug):
460 print('class_item_9', list(p))
461
462 # { yyerror(@1, "sorry: External methods are not yet supported.");
463 # delete[] p[5];
464 # }
465 ()
466
467
468 def p_class_item_10(p):
469 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER ';' '''
470 if(parse_debug):
471 print('class_item_10', list(p))
472
473 # { yyerror(@1, "sorry: External methods are not yet supported.");
474 # delete[] p[4];
475 # }
476 ()
477
478
479 def p_class_item_11(p):
480 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER '(' tf_port_list_opt ')' ';' '''
481 if(parse_debug):
482 print('class_item_11', list(p))
483
484 # { yyerror(@1, "sorry: External methods are not yet supported.");
485 # delete[] p[4];
486 # }
487 ()
488
489
490 def p_class_item_12(p):
491 '''class_item : class_constraint '''
492 if(parse_debug):
493 print('class_item_12', list(p))
494
495
496 ()
497
498
499 def p_class_item_13(p):
500 '''class_item : property_qualifier_opt data_type error ';' '''
501 if(parse_debug):
502 print('class_item_13', list(p))
503
504 # { yyerror(@3, "error: Errors in variable names after data type.");
505 # yyerrok;
506 # }
507 ()
508
509
510 def p_class_item_14(p):
511 '''class_item : property_qualifier_opt IDENTIFIER error ';' '''
512 if(parse_debug):
513 print('class_item_14', list(p))
514
515 # { yyerror(@3, "error: %s doesn't name a type.", p[2]);
516 # yyerrok;
517 # }
518 ()
519
520
521 def p_class_item_15(p):
522 '''class_item : method_qualifier_opt K_function K_new error K_endfunction endnew_opt '''
523 if(parse_debug):
524 print('class_item_15', list(p))
525
526 # { yyerror(@1, "error: I give up on this class constructor declaration.");
527 # yyerrok;
528 # }
529 ()
530
531
532 def p_class_item_16(p):
533 '''class_item : error ';' '''
534 if(parse_debug):
535 print('class_item_16', list(p))
536
537 # { yyerror(@2, "error: invalid class item.");
538 # yyerrok;
539 # }
540 ()
541
542
543 def p__embed0_class_item(p):
544 '''_embed0_class_item : '''
545
546 # { assert(current_function==0);
547 # current_function = pform_push_constructor_scope(@3);
548 # }
549 ()
550
551
552 def p_class_item_qualifier_1(p):
553 '''class_item_qualifier : K_static '''
554 if(parse_debug):
555 print('class_item_qualifier_1', list(p))
556
557 # { p[0] = property_qualifier_t::make_static(); }
558 ()
559
560
561 def p_class_item_qualifier_2(p):
562 '''class_item_qualifier : K_protected '''
563 if(parse_debug):
564 print('class_item_qualifier_2', list(p))
565
566 # { p[0] = property_qualifier_t::make_protected(); }
567 ()
568
569
570 def p_class_item_qualifier_3(p):
571 '''class_item_qualifier : K_local '''
572 if(parse_debug):
573 print('class_item_qualifier_3', list(p))
574
575 # { p[0] = property_qualifier_t::make_local(); }
576 ()
577
578
579 def p_class_item_qualifier_list_1(p):
580 '''class_item_qualifier_list : class_item_qualifier_list class_item_qualifier '''
581 if(parse_debug):
582 print('class_item_qualifier_list_1', list(p))
583
584 # { p[0] = p[1] | p[2]; }
585 ()
586
587
588 def p_class_item_qualifier_list_2(p):
589 '''class_item_qualifier_list : class_item_qualifier '''
590 if(parse_debug):
591 print('class_item_qualifier_list_2', list(p))
592 p[0] = p[1]
593
594
595 ()
596
597
598 def p_class_item_qualifier_opt_1(p):
599 '''class_item_qualifier_opt : class_item_qualifier_list '''
600 if(parse_debug):
601 print('class_item_qualifier_opt_1', list(p))
602 p[0] = p[1]
603
604
605 ()
606
607
608 def p_class_item_qualifier_opt_2(p):
609 '''class_item_qualifier_opt : '''
610 if(parse_debug):
611 print('class_item_qualifier_opt_2', list(p))
612
613 # { p[0] = property_qualifier_t::make_none(); }
614 ()
615
616
617 def p_class_new_1(p):
618 '''class_new : K_new '(' expression_list_with_nuls ')' '''
619 if(parse_debug):
620 print('class_new_1', list(p))
621
622 # { list<PExpr*>*expr_list = p[3];
623 # strip_tail_items(expr_list);
624 # PENewClass*tmp = new PENewClass(*expr_list);
625 # FILE_NAME(tmp, @1);
626 # delete p[3];
627 # p[0] = tmp;
628 # }
629 ()
630
631
632 def p_class_new_2(p):
633 '''class_new : K_new hierarchy_identifier '''
634 if(parse_debug):
635 print('class_new_2', list(p))
636
637 # { PEIdent*tmpi = new PEIdent(*p[2]);
638 # FILE_NAME(tmpi, @2);
639 # PENewCopy*tmp = new PENewCopy(tmpi);
640 # FILE_NAME(tmp, @1);
641 # delete p[2];
642 # p[0] = tmp;
643 # }
644 ()
645
646
647 def p_class_new_3(p):
648 '''class_new : K_new '''
649 if(parse_debug):
650 print('class_new_3', list(p))
651
652 # { PENewClass*tmp = new PENewClass;
653 # FILE_NAME(tmp, @1);
654 # p[0] = tmp;
655 # }
656 ()
657
658
659 def p_concurrent_assertion_item_1(p):
660 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' property_spec ')' statement_or_null '''
661 if(parse_debug):
662 print('concurrent_assertion_item_1', list(p))
663
664 # { /* */
665 # if (gn_assertions_flag) {
666 # yyerror(@2, "sorry: concurrent_assertion_item not supported."
667 # " Try -gno-assertion to turn this message off.");
668 # }
669 # }
670 ()
671
672
673 def p_concurrent_assertion_item_2(p):
674 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' error ')' statement_or_null '''
675 if(parse_debug):
676 print('concurrent_assertion_item_2', list(p))
677
678 # { yyerrok;
679 # yyerror(@2, "error: Error in property_spec of concurrent assertion item.");
680 # }
681 ()
682
683
684 def p_constraint_block_item_1(p):
685 '''constraint_block_item : constraint_expression '''
686 if(parse_debug):
687 print('constraint_block_item_1', list(p))
688
689
690 ()
691
692
693 def p_constraint_block_item_list_1(p):
694 '''constraint_block_item_list : constraint_block_item_list constraint_block_item '''
695 if(parse_debug):
696 print('constraint_block_item_list_1', list(p))
697
698
699 ()
700
701
702 def p_constraint_block_item_list_2(p):
703 '''constraint_block_item_list : constraint_block_item '''
704 if(parse_debug):
705 print('constraint_block_item_list_2', list(p))
706
707
708 ()
709
710
711 def p_constraint_block_item_list_opt_1(p):
712 '''constraint_block_item_list_opt : '''
713 if(parse_debug):
714 print('constraint_block_item_list_opt_1', list(p))
715
716
717 ()
718
719
720 def p_constraint_block_item_list_opt_2(p):
721 '''constraint_block_item_list_opt : constraint_block_item_list '''
722 if(parse_debug):
723 print('constraint_block_item_list_opt_2', list(p))
724
725
726 ()
727
728
729 def p_constraint_declaration_1(p):
730 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' constraint_block_item_list_opt '}' '''
731 if(parse_debug):
732 print('constraint_declaration_1', list(p))
733
734 # { yyerror(@2, "sorry: Constraint declarations not supported."); }
735 ()
736
737
738 def p_constraint_declaration_2(p):
739 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' error '}' '''
740 if(parse_debug):
741 print('constraint_declaration_2', list(p))
742
743 # { yyerror(@4, "error: Errors in the constraint block item list."); }
744 ()
745
746
747 def p_constraint_expression_1(p):
748 '''constraint_expression : expression ';' '''
749 if(parse_debug):
750 print('constraint_expression_1', list(p))
751
752
753 ()
754
755
756 def p_constraint_expression_2(p):
757 '''constraint_expression : expression K_dist '{' '}' ';' '''
758 if(parse_debug):
759 print('constraint_expression_2', list(p))
760
761
762 ()
763
764
765 def p_constraint_expression_3(p):
766 '''constraint_expression : expression K_TRIGGER constraint_set '''
767 if(parse_debug):
768 print('constraint_expression_3', list(p))
769
770
771 ()
772
773
774 def p_constraint_expression_4(p):
775 '''constraint_expression : K_if '(' expression ')' constraint_set %prec less_than_K_else '''
776 if(parse_debug):
777 print('constraint_expression_4', list(p))
778
779
780 ()
781
782
783 def p_constraint_expression_5(p):
784 '''constraint_expression : K_if '(' expression ')' constraint_set K_else constraint_set '''
785 if(parse_debug):
786 print('constraint_expression_5', list(p))
787
788
789 ()
790
791
792 def p_constraint_expression_6(p):
793 '''constraint_expression : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' constraint_set '''
794 if(parse_debug):
795 print('constraint_expression_6', list(p))
796
797
798 ()
799
800
801 def p_constraint_expression_list_1(p):
802 '''constraint_expression_list : constraint_expression_list constraint_expression '''
803 if(parse_debug):
804 print('constraint_expression_list_1', list(p))
805
806
807 ()
808
809
810 def p_constraint_expression_list_2(p):
811 '''constraint_expression_list : constraint_expression '''
812 if(parse_debug):
813 print('constraint_expression_list_2', list(p))
814
815
816 ()
817
818
819 def p_constraint_prototype_1(p):
820 '''constraint_prototype : K_static_opt K_constraint IDENTIFIER ';' '''
821 if(parse_debug):
822 print('constraint_prototype_1', list(p))
823
824 # { yyerror(@2, "sorry: Constraint prototypes not supported."); }
825 ()
826
827
828 def p_constraint_set_1(p):
829 '''constraint_set : constraint_expression '''
830 if(parse_debug):
831 print('constraint_set_1', list(p))
832
833
834 ()
835
836
837 def p_constraint_set_2(p):
838 '''constraint_set : '{' constraint_expression_list '}' '''
839 if(parse_debug):
840 print('constraint_set_2', list(p))
841
842
843 ()
844
845
846 def p_data_declaration_1(p):
847 '''data_declaration : attribute_list_opt data_type_or_implicit list_of_variable_decl_assignments ';' '''
848 if(parse_debug):
849 print('data_declaration_1', list(p))
850
851 # { data_type_t*data_type = p[2];
852 # if (data_type == 0) {
853 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
854 # FILE_NAME(data_type, @2);
855 # }
856 # pform_makewire(@2, 0, str_strength, p[3], NetNet::IMPLICIT_REG, data_type);
857 # }
858 ()
859
860
861 def p_data_type_1(p):
862 '''data_type : integer_vector_type unsigned_signed_opt dimensions_opt '''
863 if(parse_debug):
864 print('data_type_1', list(p))
865 use_vtype = p[1]
866 reg_flag = False
867 if (use_vtype == IVL_VT_NO_TYPE):
868 use_vtype = IVL_VT_LOGIC
869 reg_flag = True
870 dt = DataType(use_vtype, signed=p[2])
871 dt.dims = p[3]
872 dt.reg_flag = reg_flag
873 p[0] = dt
874
875 # { ivl_variable_type_t use_vtype = p[1];
876 # bool reg_flag = false;
877 # if (use_vtype == IVL_VT_NO_TYPE) {
878 # use_vtype = IVL_VT_LOGIC;
879 # reg_flag = true;
880 # }
881 # vector_type_t*tmp = new vector_type_t(use_vtype, p[2], p[3]);
882 # tmp->reg_flag = reg_flag;
883 # FILE_NAME(tmp, @1);
884 # p[0] = tmp;
885 # }
886 ()
887
888
889 def p_data_type_2(p):
890 '''data_type : non_integer_type '''
891 if(parse_debug):
892 print('data_type_2', list(p))
893 p[0] = p[1]
894
895 # { real_type_t*tmp = new real_type_t(p[1]);
896 # FILE_NAME(tmp, @1);
897 # p[0] = tmp;
898 # }
899 ()
900
901
902 def p_data_type_3(p):
903 '''data_type : struct_data_type '''
904 if(parse_debug):
905 print('data_type_3', list(p))
906 p[0] = p[1]
907
908 # { if (!p[1]->packed_flag) {
909 # yyerror(@1, "sorry: Unpacked structs not supported.");
910 # }
911 # p[0] = p[1];
912 # }
913 ()
914
915
916 def p_data_type_4(p):
917 '''data_type : enum_data_type '''
918 if(parse_debug):
919 print('data_type_4', list(p))
920 p[0] = p[1]
921
922
923 ()
924
925
926 def p_data_type_5(p):
927 '''data_type : atom2_type signed_unsigned_opt '''
928 if(parse_debug):
929 print('data_type_5', list(p))
930
931 # { atom2_type_t*tmp = new atom2_type_t(p[1], p[2]);
932 # FILE_NAME(tmp, @1);
933 # p[0] = tmp;
934 # }
935 ()
936
937
938 def p_data_type_6(p):
939 '''data_type : K_integer signed_unsigned_opt '''
940 if(parse_debug):
941 print('data_type_6', list(p))
942
943 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
944 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[2], pd);
945 # tmp->reg_flag = true;
946 # tmp->integer_flag = true;
947 # p[0] = tmp;
948 # }
949 ()
950
951
952 def p_data_type_7(p):
953 '''data_type : K_time '''
954 if(parse_debug):
955 print('data_type_7', list(p))
956
957 # { list<pform_range_t>*pd = make_range_from_width(64);
958 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
959 # tmp->reg_flag = !gn_system_verilog();
960 # p[0] = tmp;
961 # }
962 ()
963
964
965 def p_data_type_8(p):
966 '''data_type : TYPE_IDENTIFIER dimensions_opt '''
967 if(parse_debug):
968 print('data_type_8', list(p))
969
970 # { if (p[2]) {
971 # parray_type_t*tmp = new parray_type_t(p[1].type, p[2]);
972 # FILE_NAME(tmp, @1);
973 # p[0] = tmp;
974 # } else p[0] = p[1].type;
975 # delete[]p[1].text;
976 # }
977 ()
978
979
980 def p_data_type_9(p):
981 '''data_type : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_data_type TYPE_IDENTIFIER '''
982 if(parse_debug):
983 print('data_type_9', list(p))
984
985 # { lex_in_package_scope(0);
986 # p[0] = p[4].type;
987 # delete[]p[4].text;
988 # }
989 ()
990
991
992 def p_data_type_10(p):
993 '''data_type : K_string '''
994 if(parse_debug):
995 print('data_type_10', list(p))
996
997 # { string_type_t*tmp = new string_type_t;
998 # FILE_NAME(tmp, @1);
999 # p[0] = tmp;
1000 # }
1001 ()
1002
1003
1004 def p__embed0_data_type(p):
1005 '''_embed0_data_type : '''
1006
1007 # { lex_in_package_scope(p[1]); }
1008 ()
1009
1010
1011 def p_data_type_or_implicit_1(p):
1012 '''data_type_or_implicit : data_type '''
1013 if(parse_debug):
1014 print('data_type_or_implicit_1', list(p))
1015 p[0] = p[1]
1016
1017
1018 ()
1019
1020
1021 def p_data_type_or_implicit_2(p):
1022 '''data_type_or_implicit : signing dimensions_opt '''
1023 if(parse_debug):
1024 print('data_type_or_implicit_2', list(p))
1025
1026 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[1], p[2]);
1027 # tmp->implicit_flag = true;
1028 # FILE_NAME(tmp, @1);
1029 # p[0] = tmp;
1030 # }
1031 ()
1032
1033
1034 def p_data_type_or_implicit_3(p):
1035 '''data_type_or_implicit : dimensions '''
1036 if(parse_debug):
1037 print('data_type_or_implicit_3', list(p))
1038 p[0] = list(p)
1039
1040 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, p[1]);
1041 # tmp->implicit_flag = true;
1042 # FILE_NAME(tmp, @1);
1043 # p[0] = tmp;
1044 # }
1045 ()
1046
1047
1048 def p_data_type_or_implicit_4(p):
1049 '''data_type_or_implicit : '''
1050 if(parse_debug > 2):
1051 print('data_type_or_implicit_4', list(p))
1052
1053 # { p[0] = None }
1054 ()
1055
1056
1057 def p_data_type_or_implicit_or_void_1(p):
1058 '''data_type_or_implicit_or_void : data_type_or_implicit '''
1059 if(parse_debug):
1060 print('data_type_or_implicit_or_void_1', list(p))
1061 p[0] = p[1]
1062
1063
1064 ()
1065
1066
1067 def p_data_type_or_implicit_or_void_2(p):
1068 '''data_type_or_implicit_or_void : K_void '''
1069 if(parse_debug):
1070 print('data_type_or_implicit_or_void_2', list(p))
1071
1072 # { void_type_t*tmp = new void_type_t;
1073 # FILE_NAME(tmp, @1);
1074 # p[0] = tmp;
1075 # }
1076 ()
1077
1078
1079 def p_description_1(p):
1080 '''description : module '''
1081 if(parse_debug > 2):
1082 print('description_1', list(p))
1083
1084
1085 ()
1086
1087
1088 def p_description_2(p):
1089 '''description : udp_primitive '''
1090 if(parse_debug):
1091 print('description_2', list(p))
1092
1093
1094 ()
1095
1096
1097 def p_description_3(p):
1098 '''description : config_declaration '''
1099 if(parse_debug):
1100 print('description_3', list(p))
1101
1102
1103 ()
1104
1105
1106 def p_description_4(p):
1107 '''description : nature_declaration '''
1108 if(parse_debug):
1109 print('description_4', list(p))
1110
1111
1112 ()
1113
1114
1115 def p_description_5(p):
1116 '''description : package_declaration '''
1117 if(parse_debug):
1118 print('description_5', list(p))
1119
1120
1121 ()
1122
1123
1124 def p_description_6(p):
1125 '''description : discipline_declaration '''
1126 if(parse_debug):
1127 print('description_6', list(p))
1128
1129
1130 ()
1131
1132
1133 def p_description_7(p):
1134 '''description : package_item '''
1135 if(parse_debug):
1136 print('description_7', list(p))
1137
1138
1139 ()
1140
1141
1142 def p_description_8(p):
1143 '''description : KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' '''
1144 if(parse_debug):
1145 print('description_8', list(p))
1146
1147 # { perm_string tmp3 = lex_strings.make(p[3]);
1148 # pform_set_type_attrib(tmp3, p[5], p[7]);
1149 # delete[] p[3];
1150 # delete[] p[5];
1151 # }
1152 ()
1153
1154
1155 def p_description_list_1(p):
1156 '''description_list : description '''
1157 if(parse_debug > 2):
1158 print('description_list_1', list(p))
1159
1160
1161 ()
1162
1163
1164 def p_description_list_2(p):
1165 '''description_list : description_list description '''
1166 if(parse_debug):
1167 print('description_list_2', list(p))
1168
1169
1170 ()
1171
1172
1173 def p_endnew_opt_1(p):
1174 '''endnew_opt : ':' K_new '''
1175 if(parse_debug):
1176 print('endnew_opt_1', list(p))
1177
1178
1179 ()
1180
1181
1182 def p_endnew_opt_2(p):
1183 '''endnew_opt : '''
1184 if(parse_debug):
1185 print('endnew_opt_2', list(p))
1186
1187
1188 ()
1189
1190
1191 def p_dynamic_array_new_1(p):
1192 '''dynamic_array_new : K_new '[' expression ']' '''
1193 if(parse_debug):
1194 print('dynamic_array_new_1', list(p))
1195
1196 # { p[0] = new PENewArray(p[3], 0);
1197 # FILE_NAME(p[0], @1);
1198 # }
1199 ()
1200
1201
1202 def p_dynamic_array_new_2(p):
1203 '''dynamic_array_new : K_new '[' expression ']' '(' expression ')' '''
1204 if(parse_debug):
1205 print('dynamic_array_new_2', list(p))
1206
1207 # { p[0] = new PENewArray(p[3], p[6]);
1208 # FILE_NAME(p[0], @1);
1209 # }
1210 ()
1211
1212
1213 def p_for_step_1(p):
1214 '''for_step : lpvalue '=' expression '''
1215 if(parse_debug):
1216 print('for_step_1', list(p))
1217
1218 # { PAssign*tmp = new PAssign(p[1],p[3]);
1219 # FILE_NAME(tmp, @1);
1220 # p[0] = tmp;
1221 # }
1222 ()
1223
1224
1225 def p_for_step_2(p):
1226 '''for_step : inc_or_dec_expression '''
1227 if(parse_debug):
1228 print('for_step_2', list(p))
1229
1230 # { p[0] = pform_compressed_assign_from_inc_dec(@1, p[1]); }
1231 ()
1232
1233
1234 def p_for_step_3(p):
1235 '''for_step : compressed_statement '''
1236 if(parse_debug):
1237 print('for_step_3', list(p))
1238 p[0] = p[1]
1239
1240
1241 ()
1242
1243
1244 def p_function_declaration_1(p):
1245 '''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 '''
1246 if(parse_debug):
1247 print('function_declaration_1', list(p))
1248
1249 # { // Last step: check any closing name.
1250 # if (p[11]) {
1251 # if (strcmp(p[4],p[11]) != 0) {
1252 # yyerror(@11, "error: End label doesn't match "
1253 # "function name");
1254 # }
1255 # if (! gn_system_verilog()) {
1256 # yyerror(@11, "error: Function end labels require "
1257 # "SystemVerilog.");
1258 # }
1259 # delete[]p[11];
1260 # }
1261 # delete[]p[4];
1262 # }
1263 ()
1264
1265
1266 def p_function_declaration_2(p):
1267 '''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 '''
1268 if(parse_debug):
1269 print('function_declaration_2', list(p))
1270
1271 # { // Last step: check any closing name.
1272 # if (p[14]) {
1273 # if (strcmp(p[4],p[14]) != 0) {
1274 # yyerror(@14, "error: End label doesn't match "
1275 # "function name");
1276 # }
1277 # if (! gn_system_verilog()) {
1278 # yyerror(@14, "error: Function end labels require "
1279 # "SystemVerilog.");
1280 # }
1281 # delete[]p[14];
1282 # }
1283 # delete[]p[4];
1284 # }
1285 ()
1286
1287
1288 def p_function_declaration_3(p):
1289 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER error K_endfunction _embed4_function_declaration endlabel_opt '''
1290 if(parse_debug):
1291 print('function_declaration_3', list(p))
1292
1293 # { // Last step: check any closing name.
1294 # if (p[8]) {
1295 # if (strcmp(p[4],p[8]) != 0) {
1296 # yyerror(@8, "error: End label doesn't match function name");
1297 # }
1298 # if (! gn_system_verilog()) {
1299 # yyerror(@8, "error: Function end labels require "
1300 # "SystemVerilog.");
1301 # }
1302 # delete[]p[8];
1303 # }
1304 # delete[]p[4];
1305 # }
1306 ()
1307
1308
1309 def p__embed0_function_declaration(p):
1310 '''_embed0_function_declaration : '''
1311
1312 # { assert(current_function == 0);
1313 # current_function = pform_push_function_scope(@1, p[4], p[2]);
1314 # }
1315 ()
1316
1317
1318 def p__embed1_function_declaration(p):
1319 '''_embed1_function_declaration : '''
1320
1321 # { current_function->set_ports(p[7]);
1322 # current_function->set_return(p[3]);
1323 # current_function_set_statement(p[8]? @8 : @4, p[8]);
1324 # pform_set_this_class(@4, current_function);
1325 # pform_pop_scope();
1326 # current_function = 0;
1327 # }
1328 ()
1329
1330
1331 def p__embed2_function_declaration(p):
1332 '''_embed2_function_declaration : '''
1333
1334 # { assert(current_function == 0);
1335 # current_function = pform_push_function_scope(@1, p[4], p[2]);
1336 # }
1337 ()
1338
1339
1340 def p__embed3_function_declaration(p):
1341 '''_embed3_function_declaration : '''
1342
1343 # { current_function->set_ports(p[7]);
1344 # current_function->set_return(p[3]);
1345 # current_function_set_statement(p[11]? @11 : @4, p[11]);
1346 # pform_set_this_class(@4, current_function);
1347 # pform_pop_scope();
1348 # current_function = 0;
1349 # if (p[7]==0 && !gn_system_verilog()) {
1350 # yyerror(@4, "error: Empty parenthesis syntax requires SystemVerilog.");
1351 # }
1352 # }
1353 ()
1354
1355
1356 def p__embed4_function_declaration(p):
1357 '''_embed4_function_declaration : '''
1358
1359 # { /* */
1360 # if (current_function) {
1361 # pform_pop_scope();
1362 # current_function = 0;
1363 # }
1364 # assert(current_function == 0);
1365 # yyerror(@1, "error: Syntax error defining function.");
1366 # yyerrok;
1367 # }
1368 ()
1369
1370
1371 def p_import_export_1(p):
1372 '''import_export : K_import '''
1373 if(parse_debug):
1374 print('import_export_1', list(p))
1375 p[0] = True
1376
1377
1378 ()
1379
1380
1381 def p_import_export_2(p):
1382 '''import_export : K_export '''
1383 if(parse_debug):
1384 print('import_export_2', list(p))
1385 p[0] = False
1386
1387
1388 ()
1389
1390
1391 def p_implicit_class_handle_1(p):
1392 '''implicit_class_handle : K_this '''
1393 if(parse_debug):
1394 print('implicit_class_handle_1', list(p))
1395
1396 # { p[0] = pform_create_this(); }
1397 ()
1398
1399
1400 def p_implicit_class_handle_2(p):
1401 '''implicit_class_handle : K_super '''
1402 if(parse_debug):
1403 print('implicit_class_handle_2', list(p))
1404
1405 # { p[0] = pform_create_super(); }
1406 ()
1407
1408
1409 def p_inc_or_dec_expression_1(p):
1410 '''inc_or_dec_expression : K_INCR lpvalue %prec UNARY_PREC '''
1411 if(parse_debug):
1412 print('inc_or_dec_expression_1', list(p))
1413
1414 # { PEUnary*tmp = new PEUnary('I', p[2]);
1415 # FILE_NAME(tmp, @2);
1416 # p[0] = tmp;
1417 # }
1418 ()
1419
1420
1421 def p_inc_or_dec_expression_2(p):
1422 '''inc_or_dec_expression : lpvalue K_INCR %prec UNARY_PREC '''
1423 if(parse_debug):
1424 print('inc_or_dec_expression_2', list(p))
1425
1426 # { PEUnary*tmp = new PEUnary('i', p[1]);
1427 # FILE_NAME(tmp, @1);
1428 # p[0] = tmp;
1429 # }
1430 ()
1431
1432
1433 def p_inc_or_dec_expression_3(p):
1434 '''inc_or_dec_expression : K_DECR lpvalue %prec UNARY_PREC '''
1435 if(parse_debug):
1436 print('inc_or_dec_expression_3', list(p))
1437
1438 # { PEUnary*tmp = new PEUnary('D', p[2]);
1439 # FILE_NAME(tmp, @2);
1440 # p[0] = tmp;
1441 # }
1442 ()
1443
1444
1445 def p_inc_or_dec_expression_4(p):
1446 '''inc_or_dec_expression : lpvalue K_DECR %prec UNARY_PREC '''
1447 if(parse_debug):
1448 print('inc_or_dec_expression_4', list(p))
1449
1450 # { PEUnary*tmp = new PEUnary('d', p[1]);
1451 # FILE_NAME(tmp, @1);
1452 # p[0] = tmp;
1453 # }
1454 ()
1455
1456
1457 def p_inside_expression_1(p):
1458 '''inside_expression : expression K_inside '{' open_range_list '}' '''
1459 if(parse_debug):
1460 print('inside_expression_1', list(p))
1461
1462 # { yyerror(@2, "sorry: \"inside\" expressions not supported yet.");
1463 # p[0] = None
1464 # }
1465 ()
1466
1467
1468 def p_integer_vector_type_1(p):
1469 '''integer_vector_type : K_reg '''
1470 if(parse_debug):
1471 print('integer_vector_type_1', list(p))
1472 p[0] = IVL_VT_NO_TYPE
1473
1474
1475 ()
1476
1477
1478 def p_integer_vector_type_2(p):
1479 '''integer_vector_type : K_bit '''
1480 if(parse_debug):
1481 print('integer_vector_type_2', list(p))
1482 p[0] = IVL_VT_BOOL
1483
1484
1485 ()
1486
1487
1488 def p_integer_vector_type_3(p):
1489 '''integer_vector_type : K_logic '''
1490 if(parse_debug):
1491 print('integer_vector_type_3', list(p))
1492 p[0] = IVL_VT_LOGIC
1493
1494
1495 ()
1496
1497
1498 def p_integer_vector_type_4(p):
1499 '''integer_vector_type : K_bool '''
1500 if(parse_debug):
1501 print('integer_vector_type_4', list(p))
1502
1503 # { p[0] = IVL_VT_BOOL; }
1504 ()
1505
1506
1507 def p_join_keyword_1(p):
1508 '''join_keyword : K_join '''
1509 if(parse_debug):
1510 print('join_keyword_1', list(p))
1511
1512 # { p[0] = PBlock::BL_PAR; }
1513 ()
1514
1515
1516 def p_join_keyword_2(p):
1517 '''join_keyword : K_join_none '''
1518 if(parse_debug):
1519 print('join_keyword_2', list(p))
1520
1521 # { p[0] = PBlock::BL_JOIN_NONE; }
1522 ()
1523
1524
1525 def p_join_keyword_3(p):
1526 '''join_keyword : K_join_any '''
1527 if(parse_debug):
1528 print('join_keyword_3', list(p))
1529
1530 # { p[0] = PBlock::BL_JOIN_ANY; }
1531 ()
1532
1533
1534 def p_jump_statement_1(p):
1535 '''jump_statement : K_break ';' '''
1536 if(parse_debug):
1537 print('jump_statement_1', list(p))
1538
1539 # { yyerror(@1, "sorry: break statements not supported.");
1540 # p[0] = None
1541 # }
1542 ()
1543
1544
1545 def p_jump_statement_2(p):
1546 '''jump_statement : K_return ';' '''
1547 if(parse_debug):
1548 print('jump_statement_2', list(p))
1549
1550 # { PReturn*tmp = new PReturn(0);
1551 # FILE_NAME(tmp, @1);
1552 # p[0] = tmp;
1553 # }
1554 ()
1555
1556
1557 def p_jump_statement_3(p):
1558 '''jump_statement : K_return expression ';' '''
1559 if(parse_debug):
1560 print('jump_statement_3', list(p))
1561
1562 # { PReturn*tmp = new PReturn(p[2]);
1563 # FILE_NAME(tmp, @1);
1564 # p[0] = tmp;
1565 # }
1566 ()
1567
1568
1569 def p_lifetime_1(p):
1570 '''lifetime : K_automatic '''
1571 if(parse_debug):
1572 print('lifetime_1', list(p))
1573
1574 # { p[0] = LexicalScope::AUTOMATIC; }
1575 ()
1576
1577
1578 def p_lifetime_2(p):
1579 '''lifetime : K_static '''
1580 if(parse_debug):
1581 print('lifetime_2', list(p))
1582
1583 # { p[0] = LexicalScope::STATIC; }
1584 ()
1585
1586
1587 def p_lifetime_opt_1(p):
1588 '''lifetime_opt : lifetime '''
1589 if(parse_debug):
1590 print('lifetime_opt_1', list(p))
1591 p[0] = p[1]
1592
1593
1594 ()
1595
1596
1597 def p_lifetime_opt_2(p):
1598 '''lifetime_opt : '''
1599 if(parse_debug > 2):
1600 print('lifetime_opt_2', list(p))
1601
1602 # { p[0] = LexicalScope::INHERITED; }
1603 ()
1604
1605
1606 def p_loop_statement_1(p):
1607 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' for_step ')' statement_or_null '''
1608 if(parse_debug):
1609 print('loop_statement_1', list(p))
1610
1611 # { PForStatement*tmp = new PForStatement(p[3], p[5], p[7], p[9], p[11]);
1612 # FILE_NAME(tmp, @1);
1613 # p[0] = tmp;
1614 # }
1615 ()
1616
1617
1618 def p_loop_statement_2(p):
1619 '''loop_statement : K_for '(' data_type IDENTIFIER '=' expression ';' expression ';' for_step ')' _embed0_loop_statement statement_or_null '''
1620 if(parse_debug):
1621 print('loop_statement_2', list(p))
1622
1623 # { pform_name_t tmp_hident;
1624 # tmp_hident.push_back(name_component_t(lex_strings.make(p[4])));
1625 #
1626 # PEIdent*tmp_ident = pform_new_ident(tmp_hident);
1627 # FILE_NAME(tmp_ident, @4);
1628 #
1629 # PForStatement*tmp_for = new PForStatement(tmp_ident, p[6], p[8], p[10], p[13]);
1630 # FILE_NAME(tmp_for, @1);
1631 #
1632 # pform_pop_scope();
1633 # vector<Statement*>tmp_for_list (1);
1634 # tmp_for_list[0] = tmp_for;
1635 # PBlock*tmp_blk = current_block_stack.top();
1636 # current_block_stack.pop();
1637 # tmp_blk->set_statement(tmp_for_list);
1638 # p[0] = tmp_blk;
1639 # delete[]p[4];
1640 # }
1641 ()
1642
1643
1644 def p_loop_statement_3(p):
1645 '''loop_statement : K_forever statement_or_null '''
1646 if(parse_debug):
1647 print('loop_statement_3', list(p))
1648
1649 # { PForever*tmp = new PForever(p[2]);
1650 # FILE_NAME(tmp, @1);
1651 # p[0] = tmp;
1652 # }
1653 ()
1654
1655
1656 def p_loop_statement_4(p):
1657 '''loop_statement : K_repeat '(' expression ')' statement_or_null '''
1658 if(parse_debug):
1659 print('loop_statement_4', list(p))
1660
1661 # { PRepeat*tmp = new PRepeat(p[3], p[5]);
1662 # FILE_NAME(tmp, @1);
1663 # p[0] = tmp;
1664 # }
1665 ()
1666
1667
1668 def p_loop_statement_5(p):
1669 '''loop_statement : K_while '(' expression ')' statement_or_null '''
1670 if(parse_debug):
1671 print('loop_statement_5', list(p))
1672
1673 # { PWhile*tmp = new PWhile(p[3], p[5]);
1674 # FILE_NAME(tmp, @1);
1675 # p[0] = tmp;
1676 # }
1677 ()
1678
1679
1680 def p_loop_statement_6(p):
1681 '''loop_statement : K_do statement_or_null K_while '(' expression ')' ';' '''
1682 if(parse_debug):
1683 print('loop_statement_6', list(p))
1684
1685 # { PDoWhile*tmp = new PDoWhile(p[5], p[2]);
1686 # FILE_NAME(tmp, @1);
1687 # p[0] = tmp;
1688 # }
1689 ()
1690
1691
1692 def p_loop_statement_7(p):
1693 '''loop_statement : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' _embed1_loop_statement statement_or_null '''
1694 if(parse_debug):
1695 print('loop_statement_7', list(p))
1696
1697 # { PForeach*tmp_for = pform_make_foreach(@1, p[3], p[5], p[9]);
1698 #
1699 # pform_pop_scope();
1700 # vector<Statement*>tmp_for_list(1);
1701 # tmp_for_list[0] = tmp_for;
1702 # PBlock*tmp_blk = current_block_stack.top();
1703 # current_block_stack.pop();
1704 # tmp_blk->set_statement(tmp_for_list);
1705 # p[0] = tmp_blk;
1706 # }
1707 ()
1708
1709
1710 def p_loop_statement_8(p):
1711 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' error ')' statement_or_null '''
1712 if(parse_debug):
1713 print('loop_statement_8', list(p))
1714
1715 # { p[0] = None
1716 # yyerror(@1, "error: Error in for loop step assignment.");
1717 # }
1718 ()
1719
1720
1721 def p_loop_statement_9(p):
1722 '''loop_statement : K_for '(' lpvalue '=' expression ';' error ';' for_step ')' statement_or_null '''
1723 if(parse_debug):
1724 print('loop_statement_9', list(p))
1725
1726 # { p[0] = None
1727 # yyerror(@1, "error: Error in for loop condition expression.");
1728 # }
1729 ()
1730
1731
1732 def p_loop_statement_10(p):
1733 '''loop_statement : K_for '(' error ')' statement_or_null '''
1734 if(parse_debug):
1735 print('loop_statement_10', list(p))
1736
1737 # { p[0] = None
1738 # yyerror(@1, "error: Incomprehensible for loop.");
1739 # }
1740 ()
1741
1742
1743 def p_loop_statement_11(p):
1744 '''loop_statement : K_while '(' error ')' statement_or_null '''
1745 if(parse_debug):
1746 print('loop_statement_11', list(p))
1747
1748 # { p[0] = None
1749 # yyerror(@1, "error: Error in while loop condition.");
1750 # }
1751 ()
1752
1753
1754 def p_loop_statement_12(p):
1755 '''loop_statement : K_do statement_or_null K_while '(' error ')' ';' '''
1756 if(parse_debug):
1757 print('loop_statement_12', list(p))
1758
1759 # { p[0] = None
1760 # yyerror(@1, "error: Error in do/while loop condition.");
1761 # }
1762 ()
1763
1764
1765 def p_loop_statement_13(p):
1766 '''loop_statement : K_foreach '(' IDENTIFIER '[' error ']' ')' statement_or_null '''
1767 if(parse_debug):
1768 print('loop_statement_13', list(p))
1769
1770 # { p[0] = None
1771 # yyerror(@4, "error: Errors in foreach loop variables list.");
1772 # }
1773 ()
1774
1775
1776 def p__embed0_loop_statement(p):
1777 '''_embed0_loop_statement : '''
1778
1779 # { static unsigned for_counter = 0;
1780 # char for_block_name [64];
1781 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_for_loop%u", for_counter);
1782 # for_counter += 1;
1783 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1784 # FILE_NAME(tmp, @1);
1785 # current_block_stack.push(tmp);
1786 #
1787 # list<decl_assignment_t*>assign_list;
1788 # decl_assignment_t*tmp_assign = new decl_assignment_t;
1789 # tmp_assign->name = lex_strings.make(p[4]);
1790 # assign_list.push_back(tmp_assign);
1791 # pform_makewire(@4, 0, str_strength, &assign_list, NetNet::REG, p[3]);
1792 # }
1793 ()
1794
1795
1796 def p__embed1_loop_statement(p):
1797 '''_embed1_loop_statement : '''
1798
1799 # { static unsigned foreach_counter = 0;
1800 # char for_block_name[64];
1801 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_foreach%u", foreach_counter);
1802 # foreach_counter += 1;
1803 #
1804 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1805 # FILE_NAME(tmp, @1);
1806 # current_block_stack.push(tmp);
1807 #
1808 # pform_make_foreach_declarations(@1, p[5]);
1809 # }
1810 ()
1811
1812
1813 def p_list_of_variable_decl_assignments_1(p):
1814 '''list_of_variable_decl_assignments : variable_decl_assignment '''
1815 if(parse_debug):
1816 print('list_of_variable_decl_assignments_1', list(p))
1817
1818 # { list<decl_assignment_t*>*tmp = new list<decl_assignment_t*>;
1819 # tmp->push_back(p[1]);
1820 # p[0] = tmp;
1821 # }
1822 ()
1823
1824
1825 def p_list_of_variable_decl_assignments_2(p):
1826 '''list_of_variable_decl_assignments : list_of_variable_decl_assignments ',' variable_decl_assignment '''
1827 if(parse_debug):
1828 print('list_of_variable_decl_assignments_2', list(p))
1829
1830 # { list<decl_assignment_t*>*tmp = p[1];
1831 # tmp->push_back(p[3]);
1832 # p[0] = tmp;
1833 # }
1834 ()
1835
1836
1837 def p_variable_decl_assignment_1(p):
1838 '''variable_decl_assignment : IDENTIFIER dimensions_opt '''
1839 if(parse_debug):
1840 print('variable_decl_assignment_1', list(p))
1841
1842 # { decl_assignment_t*tmp = new decl_assignment_t;
1843 # tmp->name = lex_strings.make(p[1]);
1844 # if (p[2]) {
1845 # tmp->index = *p[2];
1846 # delete p[2];
1847 # }
1848 # delete[]p[1];
1849 # p[0] = tmp;
1850 # }
1851 ()
1852
1853
1854 def p_variable_decl_assignment_2(p):
1855 '''variable_decl_assignment : IDENTIFIER '=' expression '''
1856 if(parse_debug):
1857 print('variable_decl_assignment_2', list(p))
1858
1859 # { decl_assignment_t*tmp = new decl_assignment_t;
1860 # tmp->name = lex_strings.make(p[1]);
1861 # tmp->expr .reset(p[3]);
1862 # delete[]p[1];
1863 # p[0] = tmp;
1864 # }
1865 ()
1866
1867
1868 def p_variable_decl_assignment_3(p):
1869 '''variable_decl_assignment : IDENTIFIER '=' K_new '(' ')' '''
1870 if(parse_debug):
1871 print('variable_decl_assignment_3', list(p))
1872
1873 # { decl_assignment_t*tmp = new decl_assignment_t;
1874 # tmp->name = lex_strings.make(p[1]);
1875 # PENewClass*expr = new PENewClass;
1876 # FILE_NAME(expr, @3);
1877 # tmp->expr .reset(expr);
1878 # delete[]p[1];
1879 # p[0] = tmp;
1880 # }
1881 ()
1882
1883
1884 def p_loop_variables_1(p):
1885 '''loop_variables : loop_variables ',' IDENTIFIER '''
1886 if(parse_debug):
1887 print('loop_variables_1', list(p))
1888
1889 # { list<perm_string>*tmp = p[1];
1890 # tmp->push_back(lex_strings.make(p[3]));
1891 # delete[]p[3];
1892 # p[0] = tmp;
1893 # }
1894 ()
1895
1896
1897 def p_loop_variables_2(p):
1898 '''loop_variables : IDENTIFIER '''
1899 if(parse_debug):
1900 print('loop_variables_2', list(p))
1901
1902 # { list<perm_string>*tmp = new list<perm_string>;
1903 # tmp->push_back(lex_strings.make(p[1]));
1904 # delete[]p[1];
1905 # p[0] = tmp;
1906 # }
1907 ()
1908
1909
1910 def p_method_qualifier_1(p):
1911 '''method_qualifier : K_virtual '''
1912 if(parse_debug):
1913 print('method_qualifier_1', list(p))
1914
1915
1916 ()
1917
1918
1919 def p_method_qualifier_2(p):
1920 '''method_qualifier : class_item_qualifier '''
1921 if(parse_debug):
1922 print('method_qualifier_2', list(p))
1923
1924
1925 ()
1926
1927
1928 def p_method_qualifier_opt_1(p):
1929 '''method_qualifier_opt : method_qualifier '''
1930 if(parse_debug):
1931 print('method_qualifier_opt_1', list(p))
1932
1933
1934 ()
1935
1936
1937 def p_method_qualifier_opt_2(p):
1938 '''method_qualifier_opt : '''
1939 if(parse_debug):
1940 print('method_qualifier_opt_2', list(p))
1941
1942
1943 ()
1944
1945
1946 def p_modport_declaration_1(p):
1947 '''modport_declaration : K_modport _embed0_modport_declaration modport_item_list ';' '''
1948 if(parse_debug):
1949 print('modport_declaration_1', list(p))
1950
1951
1952 ()
1953
1954
1955 def p__embed0_modport_declaration(p):
1956 '''_embed0_modport_declaration : '''
1957
1958 # { if (!pform_in_interface())
1959 # yyerror(@1, "error: modport declarations are only allowed "
1960 # "in interfaces.");
1961 # }
1962 ()
1963
1964
1965 def p_modport_item_list_1(p):
1966 '''modport_item_list : modport_item '''
1967 if(parse_debug):
1968 print('modport_item_list_1', list(p))
1969
1970
1971 ()
1972
1973
1974 def p_modport_item_list_2(p):
1975 '''modport_item_list : modport_item_list ',' modport_item '''
1976 if(parse_debug):
1977 print('modport_item_list_2', list(p))
1978
1979
1980 ()
1981
1982
1983 def p_modport_item_1(p):
1984 '''modport_item : IDENTIFIER _embed0_modport_item '(' modport_ports_list ')' '''
1985 if(parse_debug):
1986 print('modport_item_1', list(p))
1987
1988 # { pform_end_modport_item(@1); }
1989 ()
1990
1991
1992 def p__embed0_modport_item(p):
1993 '''_embed0_modport_item : '''
1994
1995 # { pform_start_modport_item(@1, p[1]); }
1996 ()
1997
1998
1999 def p_modport_ports_list_1(p):
2000 '''modport_ports_list : modport_ports_declaration '''
2001 if(parse_debug):
2002 print('modport_ports_list_1', list(p))
2003
2004
2005 ()
2006
2007
2008 def p_modport_ports_list_2(p):
2009 '''modport_ports_list : modport_ports_list ',' modport_ports_declaration '''
2010 if(parse_debug):
2011 print('modport_ports_list_2', list(p))
2012
2013
2014 ()
2015
2016
2017 def p_modport_ports_list_3(p):
2018 '''modport_ports_list : modport_ports_list ',' modport_simple_port '''
2019 if(parse_debug):
2020 print('modport_ports_list_3', list(p))
2021
2022 # { if (last_modport_port.type == MP_SIMPLE) {
2023 # pform_add_modport_port(@3, last_modport_port.direction,
2024 # p[3]->name, p[3]->parm);
2025 # } else {
2026 # yyerror(@3, "error: modport expression not allowed here.");
2027 # }
2028 # delete p[3];
2029 # }
2030 ()
2031
2032
2033 def p_modport_ports_list_4(p):
2034 '''modport_ports_list : modport_ports_list ',' modport_tf_port '''
2035 if(parse_debug):
2036 print('modport_ports_list_4', list(p))
2037
2038 # { if (last_modport_port.type != MP_TF)
2039 # yyerror(@3, "error: task/function declaration not allowed here.");
2040 # }
2041 ()
2042
2043
2044 def p_modport_ports_list_5(p):
2045 '''modport_ports_list : modport_ports_list ',' IDENTIFIER '''
2046 if(parse_debug):
2047 print('modport_ports_list_5', list(p))
2048
2049 # { if (last_modport_port.type == MP_SIMPLE) {
2050 # pform_add_modport_port(@3, last_modport_port.direction,
2051 # lex_strings.make(p[3]), 0);
2052 # } else if (last_modport_port.type != MP_TF) {
2053 # yyerror(@3, "error: list of identifiers not allowed here.");
2054 # }
2055 # delete[] p[3];
2056 # }
2057 ()
2058
2059
2060 def p_modport_ports_list_6(p):
2061 '''modport_ports_list : modport_ports_list ',' '''
2062 if(parse_debug):
2063 print('modport_ports_list_6', list(p))
2064
2065 # { yyerror(@2, "error: NULL port declarations are not allowed"); }
2066 ()
2067
2068
2069 def p_modport_ports_declaration_1(p):
2070 '''modport_ports_declaration : attribute_list_opt port_direction IDENTIFIER '''
2071 if(parse_debug):
2072 print('modport_ports_declaration_1', list(p))
2073
2074 # { last_modport_port.type = MP_SIMPLE;
2075 # last_modport_port.direction = p[2];
2076 # pform_add_modport_port(@3, p[2], lex_strings.make(p[3]), 0);
2077 # delete[] p[3];
2078 # delete p[1];
2079 # }
2080 ()
2081
2082
2083 def p_modport_ports_declaration_2(p):
2084 '''modport_ports_declaration : attribute_list_opt port_direction modport_simple_port '''
2085 if(parse_debug):
2086 print('modport_ports_declaration_2', list(p))
2087
2088 # { last_modport_port.type = MP_SIMPLE;
2089 # last_modport_port.direction = p[2];
2090 # pform_add_modport_port(@3, p[2], p[3]->name, p[3]->parm);
2091 # delete p[3];
2092 # delete p[1];
2093 # }
2094 ()
2095
2096
2097 def p_modport_ports_declaration_3(p):
2098 '''modport_ports_declaration : attribute_list_opt import_export IDENTIFIER '''
2099 if(parse_debug):
2100 print('modport_ports_declaration_3', list(p))
2101
2102 # { last_modport_port.type = MP_TF;
2103 # last_modport_port.is_import = p[2];
2104 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
2105 # delete[] p[3];
2106 # delete p[1];
2107 # }
2108 ()
2109
2110
2111 def p_modport_ports_declaration_4(p):
2112 '''modport_ports_declaration : attribute_list_opt import_export modport_tf_port '''
2113 if(parse_debug):
2114 print('modport_ports_declaration_4', list(p))
2115
2116 # { last_modport_port.type = MP_TF;
2117 # last_modport_port.is_import = p[2];
2118 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
2119 # delete p[1];
2120 # }
2121 ()
2122
2123
2124 def p_modport_ports_declaration_5(p):
2125 '''modport_ports_declaration : attribute_list_opt K_clocking IDENTIFIER '''
2126 if(parse_debug):
2127 print('modport_ports_declaration_5', list(p))
2128
2129 # { last_modport_port.type = MP_CLOCKING;
2130 # last_modport_port.direction = NetNet::NOT_A_PORT;
2131 # yyerror(@3, "sorry: modport clocking declaration is not yet supported.");
2132 # delete[] p[3];
2133 # delete p[1];
2134 # }
2135 ()
2136
2137
2138 def p_modport_simple_port_1(p):
2139 '''modport_simple_port : '.' IDENTIFIER '(' expression ')' '''
2140 if(parse_debug):
2141 print('modport_simple_port_1', list(p))
2142
2143 # { named_pexpr_t*tmp = new named_pexpr_t;
2144 # tmp->name = lex_strings.make(p[2]);
2145 # tmp->parm = p[4];
2146 # delete[]p[2];
2147 # p[0] = tmp;
2148 # }
2149 ()
2150
2151
2152 def p_modport_tf_port_1(p):
2153 '''modport_tf_port : K_task IDENTIFIER '''
2154 if(parse_debug):
2155 print('modport_tf_port_1', list(p))
2156
2157
2158 ()
2159
2160
2161 def p_modport_tf_port_2(p):
2162 '''modport_tf_port : K_task IDENTIFIER '(' tf_port_list_opt ')' '''
2163 if(parse_debug):
2164 print('modport_tf_port_2', list(p))
2165
2166
2167 ()
2168
2169
2170 def p_modport_tf_port_3(p):
2171 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '''
2172 if(parse_debug):
2173 print('modport_tf_port_3', list(p))
2174
2175
2176 ()
2177
2178
2179 def p_modport_tf_port_4(p):
2180 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' '''
2181 if(parse_debug):
2182 print('modport_tf_port_4', list(p))
2183
2184
2185 ()
2186
2187
2188 def p_non_integer_type_1(p):
2189 '''non_integer_type : K_real '''
2190 if(parse_debug):
2191 print('non_integer_type_1', list(p))
2192
2193 # { p[0] = real_type_t::REAL; }
2194 ()
2195
2196
2197 def p_non_integer_type_2(p):
2198 '''non_integer_type : K_realtime '''
2199 if(parse_debug):
2200 print('non_integer_type_2', list(p))
2201
2202 # { p[0] = real_type_t::REAL; }
2203 ()
2204
2205
2206 def p_non_integer_type_3(p):
2207 '''non_integer_type : K_shortreal '''
2208 if(parse_debug):
2209 print('non_integer_type_3', list(p))
2210
2211 # { p[0] = real_type_t::SHORTREAL; }
2212 ()
2213
2214
2215 def p_number_1(p):
2216 '''number : BASED_NUMBER '''
2217 if(parse_debug):
2218 print('number_1', list(p))
2219
2220 # { p[0] = p[1]; based_size = 0;}
2221 ()
2222
2223
2224 def p_number_2(p):
2225 '''number : DEC_NUMBER '''
2226 if(parse_debug):
2227 print('number_2', list(p))
2228 num = Leaf(token.NUMBER, "%s" % (p[1]))
2229 p[0] = num
2230
2231 # { p[0] = p[1]; based_size = 0;}
2232 ()
2233
2234
2235 def p_number_3(p):
2236 '''number : DEC_NUMBER BASED_NUMBER '''
2237 if(parse_debug):
2238 print('number_3', list(p))
2239 num = Leaf(token.NUMBER, "%s:%s" % (p[1], p[2]))
2240 p[0] = num
2241
2242 # { p[0] = pform_verinum_with_size(p[1],p[2], @2.text, @2.first_line);
2243 # based_size = 0; }
2244 ()
2245
2246
2247 def p_number_4(p):
2248 '''number : UNBASED_NUMBER '''
2249 if(parse_debug):
2250 print('number_4', list(p))
2251
2252 # { p[0] = p[1]; based_size = 0;}
2253 ()
2254
2255
2256 def p_number_5(p):
2257 '''number : DEC_NUMBER UNBASED_NUMBER '''
2258 if(parse_debug):
2259 print('number_5', list(p))
2260
2261 # { yyerror(@1, "error: Unbased SystemVerilog literal cannot have "
2262 # "a size.");
2263 # p[0] = p[1]; based_size = 0;}
2264 ()
2265
2266
2267 def p_open_range_list_1(p):
2268 '''open_range_list : open_range_list ',' value_range '''
2269 if(parse_debug):
2270 print('open_range_list_1', list(p))
2271
2272
2273 ()
2274
2275
2276 def p_open_range_list_2(p):
2277 '''open_range_list : value_range '''
2278 if(parse_debug):
2279 print('open_range_list_2', list(p))
2280
2281
2282 ()
2283
2284
2285 def p_package_declaration_1(p):
2286 '''package_declaration : K_package lifetime_opt IDENTIFIER ';' _embed0_package_declaration timeunits_declaration_opt _embed1_package_declaration package_item_list_opt K_endpackage endlabel_opt '''
2287 if(parse_debug):
2288 print('package_declaration_1', list(p))
2289
2290 # { pform_end_package_declaration(@1);
2291 # // If an end label is present make sure it match the package name.
2292 # if (p[10]) {
2293 # if (strcmp(p[3],p[10]) != 0) {
2294 # yyerror(@10, "error: End label doesn't match package name");
2295 # }
2296 # delete[]p[10];
2297 # }
2298 # delete[]p[3];
2299 # }
2300 ()
2301
2302
2303 def p__embed0_package_declaration(p):
2304 '''_embed0_package_declaration : '''
2305
2306 # { pform_start_package_declaration(@1, p[3], p[2]); }
2307 ()
2308
2309
2310 def p__embed1_package_declaration(p):
2311 '''_embed1_package_declaration : '''
2312
2313 # { pform_set_scope_timescale(@1); }
2314 ()
2315
2316
2317 def p_module_package_import_list_opt_1(p):
2318 '''module_package_import_list_opt : '''
2319 if(parse_debug > 1):
2320 print('module_package_import_list_opt_1', list(p))
2321
2322
2323 ()
2324
2325
2326 def p_module_package_import_list_opt_2(p):
2327 '''module_package_import_list_opt : package_import_list '''
2328 if(parse_debug):
2329 print('module_package_import_list_opt_2', list(p))
2330
2331
2332 ()
2333
2334
2335 def p_package_import_list_1(p):
2336 '''package_import_list : package_import_declaration '''
2337 if(parse_debug):
2338 print('package_import_list_1', list(p))
2339
2340
2341 ()
2342
2343
2344 def p_package_import_list_2(p):
2345 '''package_import_list : package_import_list package_import_declaration '''
2346 if(parse_debug):
2347 print('package_import_list_2', list(p))
2348
2349
2350 ()
2351
2352
2353 def p_package_import_declaration_1(p):
2354 '''package_import_declaration : K_import package_import_item_list ';' '''
2355 if(parse_debug):
2356 print('package_import_declaration_1', list(p))
2357
2358 # { }
2359 ()
2360
2361
2362 def p_package_import_item_1(p):
2363 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '''
2364 if(parse_debug):
2365 print('package_import_item_1', list(p))
2366
2367 # { pform_package_import(@2, p[1], p[3]);
2368 # delete[]p[3];
2369 # }
2370 ()
2371
2372
2373 def p_package_import_item_2(p):
2374 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES '*' '''
2375 if(parse_debug):
2376 print('package_import_item_2', list(p))
2377
2378 # { pform_package_import(@2, p[1], 0);
2379 # }
2380 ()
2381
2382
2383 def p_package_import_item_list_1(p):
2384 '''package_import_item_list : package_import_item_list ',' package_import_item '''
2385 if(parse_debug):
2386 print('package_import_item_list_1', list(p))
2387
2388
2389 ()
2390
2391
2392 def p_package_import_item_list_2(p):
2393 '''package_import_item_list : package_import_item '''
2394 if(parse_debug):
2395 print('package_import_item_list_2', list(p))
2396
2397
2398 ()
2399
2400
2401 def p_package_item_1(p):
2402 '''package_item : timeunits_declaration '''
2403 if(parse_debug):
2404 print('package_item_1', list(p))
2405
2406
2407 ()
2408
2409
2410 def p_package_item_2(p):
2411 '''package_item : K_parameter param_type parameter_assign_list ';' '''
2412 if(parse_debug):
2413 print('package_item_2', list(p))
2414
2415
2416 ()
2417
2418
2419 def p_package_item_3(p):
2420 '''package_item : K_localparam param_type localparam_assign_list ';' '''
2421 if(parse_debug):
2422 print('package_item_3', list(p))
2423
2424
2425 ()
2426
2427
2428 def p_package_item_4(p):
2429 '''package_item : type_declaration '''
2430 if(parse_debug):
2431 print('package_item_4', list(p))
2432
2433
2434 ()
2435
2436
2437 def p_package_item_5(p):
2438 '''package_item : function_declaration '''
2439 if(parse_debug):
2440 print('package_item_5', list(p))
2441
2442
2443 ()
2444
2445
2446 def p_package_item_6(p):
2447 '''package_item : task_declaration '''
2448 if(parse_debug):
2449 print('package_item_6', list(p))
2450
2451
2452 ()
2453
2454
2455 def p_package_item_7(p):
2456 '''package_item : data_declaration '''
2457 if(parse_debug):
2458 print('package_item_7', list(p))
2459
2460
2461 ()
2462
2463
2464 def p_package_item_8(p):
2465 '''package_item : class_declaration '''
2466 if(parse_debug):
2467 print('package_item_8', list(p))
2468
2469
2470 ()
2471
2472
2473 def p_package_item_list_1(p):
2474 '''package_item_list : package_item_list package_item '''
2475 if(parse_debug):
2476 print('package_item_list_1', list(p))
2477
2478
2479 ()
2480
2481
2482 def p_package_item_list_2(p):
2483 '''package_item_list : package_item '''
2484 if(parse_debug):
2485 print('package_item_list_2', list(p))
2486
2487
2488 ()
2489
2490
2491 def p_package_item_list_opt_1(p):
2492 '''package_item_list_opt : package_item_list '''
2493 if(parse_debug):
2494 print('package_item_list_opt_1', list(p))
2495
2496
2497 ()
2498
2499
2500 def p_package_item_list_opt_2(p):
2501 '''package_item_list_opt : '''
2502 if(parse_debug):
2503 print('package_item_list_opt_2', list(p))
2504
2505
2506 ()
2507
2508
2509 def p_port_direction_1(p):
2510 '''port_direction : K_input '''
2511 if(parse_debug):
2512 print('port_direction_1', list(p))
2513
2514 # { p[0] = NetNet::PINPUT; }
2515 ()
2516
2517
2518 def p_port_direction_2(p):
2519 '''port_direction : K_output '''
2520 if(parse_debug):
2521 print('port_direction_2', list(p))
2522
2523 # { p[0] = NetNet::POUTPUT; }
2524 ()
2525
2526
2527 def p_port_direction_3(p):
2528 '''port_direction : K_inout '''
2529 if(parse_debug):
2530 print('port_direction_3', list(p))
2531
2532 # { p[0] = NetNet::PINOUT; }
2533 ()
2534
2535
2536 def p_port_direction_4(p):
2537 '''port_direction : K_ref '''
2538 if(parse_debug):
2539 print('port_direction_4', list(p))
2540
2541 # { p[0] = NetNet::PREF;
2542 # if (!gn_system_verilog()) {
2543 # yyerror(@1, "error: Reference ports (ref) require SystemVerilog.");
2544 # p[0] = NetNet::PINPUT;
2545 # }
2546 # }
2547 ()
2548
2549
2550 def p_port_direction_opt_1(p):
2551 '''port_direction_opt : port_direction '''
2552 if(parse_debug):
2553 print('port_direction_opt_1', list(p))
2554 p[0] = p[1]
2555
2556
2557 ()
2558
2559
2560 def p_port_direction_opt_2(p):
2561 '''port_direction_opt : '''
2562 if(parse_debug):
2563 print('port_direction_opt_2', list(p))
2564
2565 # { p[0] = NetNet::PIMPLICIT; }
2566 ()
2567
2568
2569 def p_property_expr_1(p):
2570 '''property_expr : expression '''
2571 if(parse_debug):
2572 print('property_expr_1', list(p))
2573
2574
2575 ()
2576
2577
2578 def p_procedural_assertion_statement_1(p):
2579 '''procedural_assertion_statement : K_assert '(' expression ')' statement %prec less_than_K_else '''
2580 if(parse_debug):
2581 print('procedural_assertion_statement_1', list(p))
2582
2583 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2584 # p[0] = None
2585 # }
2586 ()
2587
2588
2589 def p_procedural_assertion_statement_2(p):
2590 '''procedural_assertion_statement : K_assert '(' expression ')' K_else statement '''
2591 if(parse_debug):
2592 print('procedural_assertion_statement_2', list(p))
2593
2594 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2595 # p[0] = None
2596 # }
2597 ()
2598
2599
2600 def p_procedural_assertion_statement_3(p):
2601 '''procedural_assertion_statement : K_assert '(' expression ')' statement K_else statement '''
2602 if(parse_debug):
2603 print('procedural_assertion_statement_3', list(p))
2604
2605 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2606 # p[0] = None
2607 # }
2608 ()
2609
2610
2611 def p_property_qualifier_1(p):
2612 '''property_qualifier : class_item_qualifier '''
2613 if(parse_debug):
2614 print('property_qualifier_1', list(p))
2615
2616
2617 ()
2618
2619
2620 def p_property_qualifier_2(p):
2621 '''property_qualifier : random_qualifier '''
2622 if(parse_debug):
2623 print('property_qualifier_2', list(p))
2624
2625
2626 ()
2627
2628
2629 def p_property_qualifier_opt_1(p):
2630 '''property_qualifier_opt : property_qualifier_list '''
2631 if(parse_debug):
2632 print('property_qualifier_opt_1', list(p))
2633 p[0] = p[1]
2634
2635
2636 ()
2637
2638
2639 def p_property_qualifier_opt_2(p):
2640 '''property_qualifier_opt : '''
2641 if(parse_debug):
2642 print('property_qualifier_opt_2', list(p))
2643
2644 # { p[0] = property_qualifier_t::make_none(); }
2645 ()
2646
2647
2648 def p_property_qualifier_list_1(p):
2649 '''property_qualifier_list : property_qualifier_list property_qualifier '''
2650 if(parse_debug):
2651 print('property_qualifier_list_1', list(p))
2652
2653 # { p[0] = p[1] | p[2]; }
2654 ()
2655
2656
2657 def p_property_qualifier_list_2(p):
2658 '''property_qualifier_list : property_qualifier '''
2659 if(parse_debug):
2660 print('property_qualifier_list_2', list(p))
2661 p[0] = p[1]
2662
2663
2664 ()
2665
2666
2667 def p_property_spec_1(p):
2668 '''property_spec : clocking_event_opt property_spec_disable_iff_opt property_expr '''
2669 if(parse_debug):
2670 print('property_spec_1', list(p))
2671
2672
2673 ()
2674
2675
2676 def p_property_spec_disable_iff_opt_1(p):
2677 '''property_spec_disable_iff_opt : K_disable K_iff '(' expression ')' '''
2678 if(parse_debug):
2679 print('property_spec_disable_iff_opt_1', list(p))
2680
2681
2682 ()
2683
2684
2685 def p_property_spec_disable_iff_opt_2(p):
2686 '''property_spec_disable_iff_opt : '''
2687 if(parse_debug):
2688 print('property_spec_disable_iff_opt_2', list(p))
2689
2690
2691 ()
2692
2693
2694 def p_random_qualifier_1(p):
2695 '''random_qualifier : K_rand '''
2696 if(parse_debug):
2697 print('random_qualifier_1', list(p))
2698
2699 # { p[0] = property_qualifier_t::make_rand(); }
2700 ()
2701
2702
2703 def p_random_qualifier_2(p):
2704 '''random_qualifier : K_randc '''
2705 if(parse_debug):
2706 print('random_qualifier_2', list(p))
2707
2708 # { p[0] = property_qualifier_t::make_randc(); }
2709 ()
2710
2711
2712 def p_real_or_realtime_1(p):
2713 '''real_or_realtime : K_real '''
2714 if(parse_debug):
2715 print('real_or_realtime_1', list(p))
2716
2717
2718 ()
2719
2720
2721 def p_real_or_realtime_2(p):
2722 '''real_or_realtime : K_realtime '''
2723 if(parse_debug):
2724 print('real_or_realtime_2', list(p))
2725
2726
2727 ()
2728
2729
2730 def p_signing_1(p):
2731 '''signing : K_signed '''
2732 if(parse_debug):
2733 print('signing_1', list(p))
2734 p[0] = True
2735
2736
2737 ()
2738
2739
2740 def p_signing_2(p):
2741 '''signing : K_unsigned '''
2742 if(parse_debug):
2743 print('signing_2', list(p))
2744 p[0] = False
2745
2746
2747 ()
2748
2749
2750 def p_simple_type_or_string_1(p):
2751 '''simple_type_or_string : integer_vector_type '''
2752 if(parse_debug):
2753 print('simple_type_or_string_1', list(p))
2754
2755 # { ivl_variable_type_t use_vtype = p[1];
2756 # bool reg_flag = false;
2757 # if (use_vtype == IVL_VT_NO_TYPE) {
2758 # use_vtype = IVL_VT_LOGIC;
2759 # reg_flag = true;
2760 # }
2761 # vector_type_t*tmp = new vector_type_t(use_vtype, false, 0);
2762 # tmp->reg_flag = reg_flag;
2763 # FILE_NAME(tmp, @1);
2764 # p[0] = tmp;
2765 # }
2766 ()
2767
2768
2769 def p_simple_type_or_string_2(p):
2770 '''simple_type_or_string : non_integer_type '''
2771 if(parse_debug):
2772 print('simple_type_or_string_2', list(p))
2773
2774 # { real_type_t*tmp = new real_type_t(p[1]);
2775 # FILE_NAME(tmp, @1);
2776 # p[0] = tmp;
2777 # }
2778 ()
2779
2780
2781 def p_simple_type_or_string_3(p):
2782 '''simple_type_or_string : atom2_type '''
2783 if(parse_debug):
2784 print('simple_type_or_string_3', list(p))
2785
2786 # { atom2_type_t*tmp = new atom2_type_t(p[1], true);
2787 # FILE_NAME(tmp, @1);
2788 # p[0] = tmp;
2789 # }
2790 ()
2791
2792
2793 def p_simple_type_or_string_4(p):
2794 '''simple_type_or_string : K_integer '''
2795 if(parse_debug):
2796 print('simple_type_or_string_4', list(p))
2797
2798 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
2799 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, true, pd);
2800 # tmp->reg_flag = true;
2801 # tmp->integer_flag = true;
2802 # p[0] = tmp;
2803 # }
2804 ()
2805
2806
2807 def p_simple_type_or_string_5(p):
2808 '''simple_type_or_string : K_time '''
2809 if(parse_debug):
2810 print('simple_type_or_string_5', list(p))
2811
2812 # { list<pform_range_t>*pd = make_range_from_width(64);
2813 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
2814 # tmp->reg_flag = !gn_system_verilog();
2815 # p[0] = tmp;
2816 # }
2817 ()
2818
2819
2820 def p_simple_type_or_string_6(p):
2821 '''simple_type_or_string : TYPE_IDENTIFIER '''
2822 if(parse_debug):
2823 print('simple_type_or_string_6', list(p))
2824
2825 # { p[0] = p[1].type;
2826 # delete[]p[1].text;
2827 # }
2828 ()
2829
2830
2831 def p_simple_type_or_string_7(p):
2832 '''simple_type_or_string : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_simple_type_or_string TYPE_IDENTIFIER '''
2833 if(parse_debug):
2834 print('simple_type_or_string_7', list(p))
2835
2836 # { lex_in_package_scope(0);
2837 # p[0] = p[4].type;
2838 # delete[]p[4].text;
2839 # }
2840 ()
2841
2842
2843 def p_simple_type_or_string_8(p):
2844 '''simple_type_or_string : K_string '''
2845 if(parse_debug):
2846 print('simple_type_or_string_8', list(p))
2847
2848 # { string_type_t*tmp = new string_type_t;
2849 # FILE_NAME(tmp, @1);
2850 # p[0] = tmp;
2851 # }
2852 ()
2853
2854
2855 def p__embed0_simple_type_or_string(p):
2856 '''_embed0_simple_type_or_string : '''
2857
2858 # { lex_in_package_scope(p[1]); }
2859 ()
2860
2861
2862 def p_statement_1(p):
2863 '''statement : attribute_list_opt statement_item '''
2864 if(parse_debug):
2865 print('statement_1', list(p))
2866
2867 # { pform_bind_attributes(p[2]->attributes, p[1]);
2868 # p[0] = p[2];
2869 # }
2870 ()
2871
2872
2873 def p_statement_or_null_1(p):
2874 '''statement_or_null : statement '''
2875 if(parse_debug):
2876 print('statement_or_null_1', list(p))
2877 p[0] = p[1]
2878
2879
2880 ()
2881
2882
2883 def p_statement_or_null_2(p):
2884 '''statement_or_null : attribute_list_opt ';' '''
2885 if(parse_debug):
2886 print('statement_or_null_2', list(p))
2887
2888 # { p[0] = None }
2889 ()
2890
2891
2892 def p_stream_expression_1(p):
2893 '''stream_expression : expression '''
2894 if(parse_debug):
2895 print('stream_expression_1', list(p))
2896
2897
2898 ()
2899
2900
2901 def p_stream_expression_list_1(p):
2902 '''stream_expression_list : stream_expression_list ',' stream_expression '''
2903 if(parse_debug):
2904 print('stream_expression_list_1', list(p))
2905
2906
2907 ()
2908
2909
2910 def p_stream_expression_list_2(p):
2911 '''stream_expression_list : stream_expression '''
2912 if(parse_debug):
2913 print('stream_expression_list_2', list(p))
2914
2915
2916 ()
2917
2918
2919 def p_stream_operator_1(p):
2920 '''stream_operator : K_LS '''
2921 if(parse_debug):
2922 print('stream_operator_1', list(p))
2923
2924
2925 ()
2926
2927
2928 def p_stream_operator_2(p):
2929 '''stream_operator : K_RS '''
2930 if(parse_debug):
2931 print('stream_operator_2', list(p))
2932
2933
2934 ()
2935
2936
2937 def p_streaming_concatenation_1(p):
2938 '''streaming_concatenation : '{' stream_operator '{' stream_expression_list '}' '}' '''
2939 if(parse_debug):
2940 print('streaming_concatenation_1', list(p))
2941
2942 # { /* streaming concatenation is a SystemVerilog thing. */
2943 # if (gn_system_verilog()) {
2944 # yyerror(@2, "sorry: Streaming concatenation not supported.");
2945 # p[0] = None
2946 # } else {
2947 # yyerror(@2, "error: Streaming concatenation requires SystemVerilog");
2948 # p[0] = None
2949 # }
2950 # }
2951 ()
2952
2953
2954 def p_task_declaration_1(p):
2955 '''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 '''
2956 if(parse_debug):
2957 print('task_declaration_1', list(p))
2958
2959 # { // Last step: check any closing name. This is done late so
2960 # // that the parser can look ahead to detect the present
2961 # // endlabel_opt but still have the pform_endmodule() called
2962 # // early enough that the lexor can know we are outside the
2963 # // module.
2964 # if (p[10]) {
2965 # if (strcmp(p[3],p[10]) != 0) {
2966 # yyerror(@10, "error: End label doesn't match task name");
2967 # }
2968 # if (! gn_system_verilog()) {
2969 # yyerror(@10, "error: Task end labels require "
2970 # "SystemVerilog.");
2971 # }
2972 # delete[]p[10];
2973 # }
2974 # delete[]p[3];
2975 # }
2976 ()
2977
2978
2979 def p_task_declaration_2(p):
2980 '''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 '''
2981 if(parse_debug):
2982 print('task_declaration_2', list(p))
2983
2984 # { // Last step: check any closing name. This is done late so
2985 # // that the parser can look ahead to detect the present
2986 # // endlabel_opt but still have the pform_endmodule() called
2987 # // early enough that the lexor can know we are outside the
2988 # // module.
2989 # if (p[13]) {
2990 # if (strcmp(p[3],p[13]) != 0) {
2991 # yyerror(@13, "error: End label doesn't match task name");
2992 # }
2993 # if (! gn_system_verilog()) {
2994 # yyerror(@13, "error: Task end labels require "
2995 # "SystemVerilog.");
2996 # }
2997 # delete[]p[13];
2998 # }
2999 # delete[]p[3];
3000 # }
3001 ()
3002
3003
3004 def p_task_declaration_3(p):
3005 '''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 '''
3006 if(parse_debug):
3007 print('task_declaration_3', list(p))
3008
3009 # { // Last step: check any closing name. This is done late so
3010 # // that the parser can look ahead to detect the present
3011 # // endlabel_opt but still have the pform_endmodule() called
3012 # // early enough that the lexor can know we are outside the
3013 # // module.
3014 # if (p[12]) {
3015 # if (strcmp(p[3],p[12]) != 0) {
3016 # yyerror(@12, "error: End label doesn't match task name");
3017 # }
3018 # if (! gn_system_verilog()) {
3019 # yyerror(@12, "error: Task end labels require "
3020 # "SystemVerilog.");
3021 # }
3022 # delete[]p[12];
3023 # }
3024 # delete[]p[3];
3025 # }
3026 ()
3027
3028
3029 def p_task_declaration_4(p):
3030 '''task_declaration : K_task lifetime_opt IDENTIFIER error K_endtask _embed6_task_declaration endlabel_opt '''
3031 if(parse_debug):
3032 print('task_declaration_4', list(p))
3033
3034 # { // Last step: check any closing name. This is done late so
3035 # // that the parser can look ahead to detect the present
3036 # // endlabel_opt but still have the pform_endmodule() called
3037 # // early enough that the lexor can know we are outside the
3038 # // module.
3039 # if (p[7]) {
3040 # if (strcmp(p[3],p[7]) != 0) {
3041 # yyerror(@7, "error: End label doesn't match task name");
3042 # }
3043 # if (! gn_system_verilog()) {
3044 # yyerror(@7, "error: Task end labels require "
3045 # "SystemVerilog.");
3046 # }
3047 # delete[]p[7];
3048 # }
3049 # delete[]p[3];
3050 # }
3051 ()
3052
3053
3054 def p__embed0_task_declaration(p):
3055 '''_embed0_task_declaration : '''
3056
3057 # { assert(current_task == 0);
3058 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3059 # }
3060 ()
3061
3062
3063 def p__embed1_task_declaration(p):
3064 '''_embed1_task_declaration : '''
3065
3066 # { current_task->set_ports(p[6]);
3067 # current_task_set_statement(@3, p[7]);
3068 # pform_set_this_class(@3, current_task);
3069 # pform_pop_scope();
3070 # current_task = 0;
3071 # if (p[7] && p[7]->size() > 1 && !gn_system_verilog()) {
3072 # yyerror(@7, "error: Task body with multiple statements requires SystemVerilog.");
3073 # }
3074 # delete p[7];
3075 # }
3076 ()
3077
3078
3079 def p__embed2_task_declaration(p):
3080 '''_embed2_task_declaration : '''
3081
3082 # { assert(current_task == 0);
3083 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3084 # }
3085 ()
3086
3087
3088 def p__embed3_task_declaration(p):
3089 '''_embed3_task_declaration : '''
3090
3091 # { current_task->set_ports(p[6]);
3092 # current_task_set_statement(@3, p[10]);
3093 # pform_set_this_class(@3, current_task);
3094 # pform_pop_scope();
3095 # current_task = 0;
3096 # if (p[10]) delete p[10];
3097 # }
3098 ()
3099
3100
3101 def p__embed4_task_declaration(p):
3102 '''_embed4_task_declaration : '''
3103
3104 # { assert(current_task == 0);
3105 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3106 # }
3107 ()
3108
3109
3110 def p__embed5_task_declaration(p):
3111 '''_embed5_task_declaration : '''
3112
3113 # { current_task->set_ports(0);
3114 # current_task_set_statement(@3, p[9]);
3115 # pform_set_this_class(@3, current_task);
3116 # if (! current_task->method_of()) {
3117 # cerr << @3 << ": warning: task definition for \"" << p[3]
3118 # << "\" has an empty port declaration list!" << endl;
3119 # }
3120 # pform_pop_scope();
3121 # current_task = 0;
3122 # if (p[9]->size() > 1 && !gn_system_verilog()) {
3123 # yyerror(@9, "error: Task body with multiple statements requires SystemVerilog.");
3124 # }
3125 # delete p[9];
3126 # }
3127 ()
3128
3129
3130 def p__embed6_task_declaration(p):
3131 '''_embed6_task_declaration : '''
3132
3133 # {
3134 # if (current_task) {
3135 # pform_pop_scope();
3136 # current_task = 0;
3137 # }
3138 # }
3139 ()
3140
3141
3142 def p_tf_port_declaration_1(p):
3143 '''tf_port_declaration : port_direction K_reg_opt unsigned_signed_opt dimensions_opt list_of_identifiers ';' '''
3144 if(parse_debug):
3145 print('tf_port_declaration_1', list(p))
3146
3147 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1],
3148 # p[2] ? IVL_VT_LOGIC :
3149 # IVL_VT_NO_TYPE,
3150 # p[3], p[4], p[5]);
3151 # p[0] = tmp;
3152 # }
3153 ()
3154
3155
3156 def p_tf_port_declaration_2(p):
3157 '''tf_port_declaration : port_direction K_integer list_of_identifiers ';' '''
3158 if(parse_debug):
3159 print('tf_port_declaration_2', list(p))
3160
3161 # { list<pform_range_t>*range_stub = make_range_from_width(integer_width);
3162 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, true,
3163 # range_stub, p[3], true);
3164 # p[0] = tmp;
3165 # }
3166 ()
3167
3168
3169 def p_tf_port_declaration_3(p):
3170 '''tf_port_declaration : port_direction K_time list_of_identifiers ';' '''
3171 if(parse_debug):
3172 print('tf_port_declaration_3', list(p))
3173
3174 # { list<pform_range_t>*range_stub = make_range_from_width(64);
3175 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, false,
3176 # range_stub, p[3]);
3177 # p[0] = tmp;
3178 # }
3179 ()
3180
3181
3182 def p_tf_port_declaration_4(p):
3183 '''tf_port_declaration : port_direction real_or_realtime list_of_identifiers ';' '''
3184 if(parse_debug):
3185 print('tf_port_declaration_4', list(p))
3186
3187 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_REAL, true,
3188 # 0, p[3]);
3189 # p[0] = tmp;
3190 # }
3191 ()
3192
3193
3194 def p_tf_port_declaration_5(p):
3195 '''tf_port_declaration : port_direction K_string list_of_identifiers ';' '''
3196 if(parse_debug):
3197 print('tf_port_declaration_5', list(p))
3198
3199 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_STRING, true,
3200 # 0, p[3]);
3201 # p[0] = tmp;
3202 # }
3203 ()
3204
3205
3206 def p_tf_port_item_1(p):
3207 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER dimensions_opt tf_port_item_expr_opt '''
3208 if(parse_debug):
3209 print('tf_port_item_1', list(p))
3210
3211 # { vector<pform_tf_port_t>*tmp;
3212 # NetNet::PortType use_port_type = p[1];
3213 # if ((use_port_type == NetNet::PIMPLICIT) && (gn_system_verilog() || (p[2] == 0)))
3214 # use_port_type = port_declaration_context.port_type;
3215 # perm_string name = lex_strings.make(p[3]);
3216 # list<perm_string>* ilist = list_from_identifier(p[3]);
3217 #
3218 # if (use_port_type == NetNet::PIMPLICIT) {
3219 # yyerror(@1, "error: missing task/function port direction.");
3220 # use_port_type = NetNet::PINPUT; // for error recovery
3221 # }
3222 # if ((p[2] == 0) && (p[1]==NetNet::PIMPLICIT)) {
3223 # // Detect special case this is an undecorated
3224 # // identifier and we need to get the declaration from
3225 # // left context.
3226 # if (p[4] != 0) {
3227 # yyerror(@4, "internal error: How can there be an unpacked range here?\n");
3228 # }
3229 # tmp = pform_make_task_ports(@3, use_port_type,
3230 # port_declaration_context.data_type,
3231 # ilist);
3232 #
3233 # } else {
3234 # // Otherwise, the decorations for this identifier
3235 # // indicate the type. Save the type for any right
3236 # // context that may come later.
3237 # port_declaration_context.port_type = use_port_type;
3238 # if (p[2] == 0) {
3239 # p[2] = new vector_type_t(IVL_VT_LOGIC, false, 0);
3240 # FILE_NAME(p[2], @3);
3241 # }
3242 # port_declaration_context.data_type = p[2];
3243 # tmp = pform_make_task_ports(@3, use_port_type, p[2], ilist);
3244 # }
3245 # if (p[4] != 0) {
3246 # pform_set_reg_idx(name, p[4]);
3247 # }
3248 #
3249 # p[0] = tmp;
3250 # if (p[5]) {
3251 # assert(tmp->size()==1);
3252 # tmp->front().defe = p[5];
3253 # }
3254 # }
3255 ()
3256
3257
3258 def p_tf_port_item_2(p):
3259 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER error '''
3260 if(parse_debug):
3261 print('tf_port_item_2', list(p))
3262
3263 # { yyerror(@3, "error: Error in task/function port item after port name %s.", p[3]);
3264 # yyerrok;
3265 # p[0] = None
3266 # }
3267 ()
3268
3269
3270 def p_tf_port_item_expr_opt_1(p):
3271 '''tf_port_item_expr_opt : '=' expression '''
3272 if(parse_debug):
3273 print('tf_port_item_expr_opt_1', list(p))
3274
3275 # { if (! gn_system_verilog()) {
3276 # yyerror(@1, "error: Task/function default arguments require "
3277 # "SystemVerilog.");
3278 # }
3279 # p[0] = p[2];
3280 # }
3281 ()
3282
3283
3284 def p_tf_port_item_expr_opt_2(p):
3285 '''tf_port_item_expr_opt : '''
3286 if(parse_debug):
3287 print('tf_port_item_expr_opt_2', list(p))
3288
3289 # { p[0] = None }
3290 ()
3291
3292
3293 def p_tf_port_list_1(p):
3294 '''tf_port_list : _embed0_tf_port_list tf_port_item_list '''
3295 if(parse_debug):
3296 print('tf_port_list_1', list(p))
3297 p[0] = p[2]
3298
3299
3300 ()
3301
3302
3303 def p__embed0_tf_port_list(p):
3304 '''_embed0_tf_port_list : '''
3305
3306 # { port_declaration_context.port_type = gn_system_verilog() ? NetNet::PINPUT : NetNet::PIMPLICIT;
3307 # port_declaration_context.data_type = 0;
3308 # }
3309 ()
3310
3311
3312 def p_tf_port_item_list_1(p):
3313 '''tf_port_item_list : tf_port_item_list ',' tf_port_item '''
3314 if(parse_debug):
3315 print('tf_port_item_list_1', list(p))
3316
3317 # { vector<pform_tf_port_t>*tmp;
3318 # if (p[1] && p[3]) {
3319 # size_t s1 = p[1]->size();
3320 # tmp = p[1];
3321 # tmp->resize(tmp->size()+p[3]->size());
3322 # for (size_t idx = 0 ; idx < p[3]->size() ; idx += 1)
3323 # tmp->at(s1+idx) = p[3]->at(idx);
3324 # delete p[3];
3325 # } else if (p[1]) {
3326 # tmp = p[1];
3327 # } else {
3328 # tmp = p[3];
3329 # }
3330 # p[0] = tmp;
3331 # }
3332 ()
3333
3334
3335 def p_tf_port_item_list_2(p):
3336 '''tf_port_item_list : tf_port_item '''
3337 if(parse_debug):
3338 print('tf_port_item_list_2', list(p))
3339 p[0] = p[1]
3340
3341
3342 ()
3343
3344
3345 def p_tf_port_item_list_3(p):
3346 '''tf_port_item_list : error ',' tf_port_item '''
3347 if(parse_debug):
3348 print('tf_port_item_list_3', list(p))
3349
3350 # { yyerror(@2, "error: Syntax error in task/function port declaration.");
3351 # p[0] = p[3];
3352 # }
3353 ()
3354
3355
3356 def p_tf_port_item_list_4(p):
3357 '''tf_port_item_list : tf_port_item_list ',' '''
3358 if(parse_debug):
3359 print('tf_port_item_list_4', list(p))
3360
3361 # { yyerror(@2, "error: NULL port declarations are not allowed.");
3362 # p[0] = p[1];
3363 # }
3364 ()
3365
3366
3367 def p_tf_port_item_list_5(p):
3368 '''tf_port_item_list : tf_port_item_list ';' '''
3369 if(parse_debug):
3370 print('tf_port_item_list_5', list(p))
3371
3372 # { yyerror(@2, "error: ';' is an invalid port declaration separator.");
3373 # p[0] = p[1];
3374 # }
3375 ()
3376
3377
3378 def p_timeunits_declaration_1(p):
3379 '''timeunits_declaration : K_timeunit TIME_LITERAL ';' '''
3380 if(parse_debug):
3381 print('timeunits_declaration_1', list(p))
3382
3383 # { pform_set_timeunit(p[2], allow_timeunit_decl); }
3384 ()
3385
3386
3387 def p_timeunits_declaration_2(p):
3388 '''timeunits_declaration : K_timeunit TIME_LITERAL '/' TIME_LITERAL ';' '''
3389 if(parse_debug):
3390 print('timeunits_declaration_2', list(p))
3391
3392 # { bool initial_decl = allow_timeunit_decl && allow_timeprec_decl;
3393 # pform_set_timeunit(p[2], initial_decl);
3394 # pform_set_timeprec(p[4], initial_decl);
3395 # }
3396 ()
3397
3398
3399 def p_timeunits_declaration_3(p):
3400 '''timeunits_declaration : K_timeprecision TIME_LITERAL ';' '''
3401 if(parse_debug):
3402 print('timeunits_declaration_3', list(p))
3403
3404 # { pform_set_timeprec(p[2], allow_timeprec_decl); }
3405 ()
3406
3407
3408 def p_timeunits_declaration_opt_1(p):
3409 '''timeunits_declaration_opt : %prec no_timeunits_declaration '''
3410 if(parse_debug > 2):
3411 print('timeunits_declaration_opt_1', list(p))
3412
3413
3414 ()
3415
3416
3417 def p_timeunits_declaration_opt_2(p):
3418 '''timeunits_declaration_opt : timeunits_declaration %prec one_timeunits_declaration '''
3419 if(parse_debug):
3420 print('timeunits_declaration_opt_2', list(p))
3421
3422
3423 ()
3424
3425
3426 def p_timeunits_declaration_opt_3(p):
3427 '''timeunits_declaration_opt : timeunits_declaration timeunits_declaration '''
3428 if(parse_debug):
3429 print('timeunits_declaration_opt_3', list(p))
3430
3431
3432 ()
3433
3434
3435 def p_value_range_1(p):
3436 '''value_range : expression '''
3437 if(parse_debug):
3438 print('value_range_1', list(p))
3439
3440 # { }
3441 ()
3442
3443
3444 def p_value_range_2(p):
3445 '''value_range : '[' expression ':' expression ']' '''
3446 if(parse_debug):
3447 print('value_range_2', list(p))
3448
3449 # { }
3450 ()
3451
3452
3453 def p_variable_dimension_1(p):
3454 '''variable_dimension : '[' expression ':' expression ']' '''
3455 if(parse_debug):
3456 print('variable_dimension_1', list(p))
3457 # { list<pform_range_t> *tmp = new list<pform_range_t>;
3458 # pform_range_t index (p[2],p[4]);
3459 # tmp->push_back(index);
3460 # p[0] = tmp;
3461 # }
3462 # XXX TODO: subscriptlist
3463 start = str(p[4])
3464 end = str(p[2])
3465 if end.endswith("-1"):
3466 end = end[:-2]
3467 elif end.isdigit():
3468 end = str(int(end)+1)
3469 else:
3470 end = "1+%s" % end
3471 p[0] = '[%s:%s]' % (start, end) # python slice is LO:HI+1
3472
3473
3474 ()
3475
3476
3477 def p_variable_dimension_2(p):
3478 '''variable_dimension : '[' expression ']' '''
3479 if(parse_debug):
3480 print('variable_dimension_2', list(p))
3481
3482 # { // SystemVerilog canonical range
3483 # if (!gn_system_verilog()) {
3484 # warn_count += 1;
3485 # cerr << @2 << ": warning: Use of SystemVerilog [size] dimension. "
3486 # << "Use at least -g2005-sv to remove this warning." << endl;
3487 # }
3488 # list<pform_range_t> *tmp = new list<pform_range_t>;
3489 # pform_range_t index;
3490 # index.first = new PENumber(new verinum((uint64_t)0, integer_width));
3491 # index.second = new PEBinary('-', p[2], new PENumber(new verinum((uint64_t)1, integer_width)));
3492 # tmp->push_back(index);
3493 # p[0] = tmp;
3494 # }
3495 ()
3496
3497
3498 def p_variable_dimension_3(p):
3499 '''variable_dimension : '[' ']' '''
3500 if(parse_debug):
3501 print('variable_dimension_3', list(p))
3502
3503 # { list<pform_range_t> *tmp = new list<pform_range_t>;
3504 # pform_range_t index (0,0);
3505 # tmp->push_back(index);
3506 # p[0] = tmp;
3507 # }
3508 ()
3509
3510
3511 def p_variable_dimension_4(p):
3512 '''variable_dimension : '[' '$' ']' '''
3513 if(parse_debug):
3514 print('variable_dimension_4', list(p))
3515
3516 # { // SystemVerilog queue
3517 # list<pform_range_t> *tmp = new list<pform_range_t>;
3518 # pform_range_t index (new PENull,0);
3519 # if (!gn_system_verilog()) {
3520 # yyerror("error: Queue declarations require SystemVerilog.");
3521 # }
3522 # tmp->push_back(index);
3523 # p[0] = tmp;
3524 # }
3525 ()
3526
3527
3528 def p_variable_lifetime_1(p):
3529 '''variable_lifetime : lifetime '''
3530 if(parse_debug):
3531 print('variable_lifetime_1', list(p))
3532
3533 # { if (!gn_system_verilog()) {
3534 # yyerror(@1, "error: overriding the default variable lifetime "
3535 # "requires SystemVerilog.");
3536 # } else if (p[1] != pform_peek_scope()->default_lifetime) {
3537 # yyerror(@1, "sorry: overriding the default variable lifetime "
3538 # "is not yet supported.");
3539 # }
3540 # var_lifetime = p[1];
3541 # }
3542 ()
3543
3544
3545 def p_attribute_list_opt_1(p):
3546 '''attribute_list_opt : attribute_instance_list '''
3547 if(parse_debug):
3548 print('attribute_list_opt_1', list(p))
3549 p[0] = p[1]
3550
3551
3552 ()
3553
3554
3555 def p_attribute_list_opt_2(p):
3556 '''attribute_list_opt : '''
3557 if(parse_debug > 2):
3558 print('attribute_list_opt_2', list(p))
3559
3560 # { p[0] = None }
3561 ()
3562
3563
3564 def p_attribute_instance_list_1(p):
3565 '''attribute_instance_list : K_PSTAR K_STARP '''
3566 if(parse_debug):
3567 print('attribute_instance_list_1', list(p))
3568
3569 # { p[0] = None }
3570 ()
3571
3572
3573 def p_attribute_instance_list_2(p):
3574 '''attribute_instance_list : K_PSTAR attribute_list K_STARP '''
3575 if(parse_debug):
3576 print('attribute_instance_list_2', list(p))
3577 p[0] = p[2]
3578
3579
3580 ()
3581
3582
3583 def p_attribute_instance_list_3(p):
3584 '''attribute_instance_list : attribute_instance_list K_PSTAR K_STARP '''
3585 if(parse_debug):
3586 print('attribute_instance_list_3', list(p))
3587 p[0] = p[1]
3588
3589
3590 ()
3591
3592
3593 def p_attribute_instance_list_4(p):
3594 '''attribute_instance_list : attribute_instance_list K_PSTAR attribute_list K_STARP '''
3595 if(parse_debug):
3596 print('attribute_instance_list_4', list(p))
3597
3598 # { list<named_pexpr_t>*tmp = p[1];
3599 # if (tmp) {
3600 # tmp->splice(tmp->end(), *p[3]);
3601 # delete p[3];
3602 # p[0] = tmp;
3603 # } else p[0] = p[3];
3604 # }
3605 ()
3606
3607
3608 def p_attribute_list_1(p):
3609 '''attribute_list : attribute_list ',' attribute '''
3610 if(parse_debug):
3611 print('attribute_list_1', list(p))
3612
3613 # { list<named_pexpr_t>*tmp = p[1];
3614 # tmp->push_back(*p[3]);
3615 # delete p[3];
3616 # p[0] = tmp;
3617 # }
3618 ()
3619
3620
3621 def p_attribute_list_2(p):
3622 '''attribute_list : attribute '''
3623 if(parse_debug):
3624 print('attribute_list_2', list(p))
3625
3626 # { list<named_pexpr_t>*tmp = new list<named_pexpr_t>;
3627 # tmp->push_back(*p[1]);
3628 # delete p[1];
3629 # p[0] = tmp;
3630 # }
3631 ()
3632
3633
3634 def p_attribute_1(p):
3635 '''attribute : IDENTIFIER '''
3636 if(parse_debug):
3637 print('attribute_1', list(p))
3638
3639 # { named_pexpr_t*tmp = new named_pexpr_t;
3640 # tmp->name = lex_strings.make(p[1]);
3641 # tmp->parm = 0;
3642 # delete[]p[1];
3643 # p[0] = tmp;
3644 # }
3645 ()
3646
3647
3648 def p_attribute_2(p):
3649 '''attribute : IDENTIFIER '=' expression '''
3650 if(parse_debug):
3651 print('attribute_2', list(p))
3652
3653 # { PExpr*tmp = p[3];
3654 # named_pexpr_t*tmp2 = new named_pexpr_t;
3655 # tmp2->name = lex_strings.make(p[1]);
3656 # tmp2->parm = tmp;
3657 # delete[]p[1];
3658 # p[0] = tmp2;
3659 # }
3660 ()
3661
3662
3663 def p_block_item_decl_1(p):
3664 '''block_item_decl : data_type register_variable_list ';' '''
3665 if(parse_debug):
3666 print('block_item_decl_1', list(p))
3667
3668 # { if (p[1]) pform_set_data_type(@1, p[1], p[2], NetNet::REG, attributes_in_context);
3669 # }
3670 ()
3671
3672
3673 def p_block_item_decl_2(p):
3674 '''block_item_decl : variable_lifetime data_type register_variable_list ';' '''
3675 if(parse_debug):
3676 print('block_item_decl_2', list(p))
3677
3678 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
3679 # var_lifetime = LexicalScope::INHERITED;
3680 # }
3681 ()
3682
3683
3684 def p_block_item_decl_3(p):
3685 '''block_item_decl : K_reg data_type register_variable_list ';' '''
3686 if(parse_debug):
3687 print('block_item_decl_3', list(p))
3688
3689 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
3690 # }
3691 ()
3692
3693
3694 def p_block_item_decl_4(p):
3695 '''block_item_decl : variable_lifetime K_reg data_type register_variable_list ';' '''
3696 if(parse_debug):
3697 print('block_item_decl_4', list(p))
3698
3699 # { if (p[3]) pform_set_data_type(@3, p[3], p[4], NetNet::REG, attributes_in_context);
3700 # var_lifetime = LexicalScope::INHERITED;
3701 # }
3702 ()
3703
3704
3705 def p_block_item_decl_5(p):
3706 '''block_item_decl : K_event event_variable_list ';' '''
3707 if(parse_debug):
3708 print('block_item_decl_5', list(p))
3709
3710 # { if (p[2]) pform_make_events(p[2], @1.text, @1.first_line);
3711 # }
3712 ()
3713
3714
3715 def p_block_item_decl_6(p):
3716 '''block_item_decl : K_parameter param_type parameter_assign_list ';' '''
3717 if(parse_debug):
3718 print('block_item_decl_6', list(p))
3719
3720
3721 ()
3722
3723
3724 def p_block_item_decl_7(p):
3725 '''block_item_decl : K_localparam param_type localparam_assign_list ';' '''
3726 if(parse_debug):
3727 print('block_item_decl_7', list(p))
3728
3729
3730 ()
3731
3732
3733 def p_block_item_decl_8(p):
3734 '''block_item_decl : type_declaration '''
3735 if(parse_debug):
3736 print('block_item_decl_8', list(p))
3737
3738
3739 ()
3740
3741
3742 def p_block_item_decl_9(p):
3743 '''block_item_decl : K_integer error ';' '''
3744 if(parse_debug):
3745 print('block_item_decl_9', list(p))
3746
3747 # { yyerror(@1, "error: syntax error in integer variable list.");
3748 # yyerrok;
3749 # }
3750 ()
3751
3752
3753 def p_block_item_decl_10(p):
3754 '''block_item_decl : K_time error ';' '''
3755 if(parse_debug):
3756 print('block_item_decl_10', list(p))
3757
3758 # { yyerror(@1, "error: syntax error in time variable list.");
3759 # yyerrok;
3760 # }
3761 ()
3762
3763
3764 def p_block_item_decl_11(p):
3765 '''block_item_decl : K_parameter error ';' '''
3766 if(parse_debug):
3767 print('block_item_decl_11', list(p))
3768
3769 # { yyerror(@1, "error: syntax error in parameter list.");
3770 # yyerrok;
3771 # }
3772 ()
3773
3774
3775 def p_block_item_decl_12(p):
3776 '''block_item_decl : K_localparam error ';' '''
3777 if(parse_debug):