3 # * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com)
4 # * Copyright CERN 2012-2013 / Stephen Williams (steve@icarus.com)
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.
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.
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.
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
33 #from parse_tokens import tokens
34 tokens
= lexor
.tokens
# list(set(lexor.tokens).union(set(tokens)))
35 literals
= lexor
.literals
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'),
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'),
51 ('left', '*', '/', '%'),
53 ('left', 'UNARY_PREC'),
54 ('nonassoc', 'less_than_K_else'),
55 ('nonassoc', 'K_else'),
57 ('nonassoc', 'K_exclude'),
58 ('nonassoc', 'no_timeunits_declaration'),
59 ('nonassoc', 'one_timeunits_declaration'),
60 ('nonassoc', 'K_timeunit', 'K_timeprecision')
64 IVL_VT_NO_TYPE
= 'VT_NO_TYPE'
65 IVL_VT_BOOL
= 'VT_BOOL'
66 IVL_VT_LOGIC
= 'VT_LOGIC'
68 IVL_VT_VOID = 0, /* Not used */
69 IVL_VT_NO_TYPE = 1, /* Place holder for missing/unknown type. */
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 */
81 NN_IMPLICIT
= 'IMPLICIT'
82 NN_IMPLICIT_REG
= 'IMPLICIT_REG'
83 NN_INTEGER
= 'INTEGER'
87 NN_SUPPLY0
= 'SUPPLY0'
88 NN_SUPPLY1
= 'SUPPLY1'
95 NN_UNRESOLVED_WIRE
= 'UNRESOLVED_WIRE'
97 NP_NOT_A_PORT
= 'NOT_A_PORT'
98 NP_PIMPLICIT
= 'PIMPLICIT'
100 NP_POUTPUT
= 'POUTPUT'
106 def __init__(self
, typ
, signed
):
115 def add_statement(self
, s
):
116 self
.statements
+= [s
]
119 # -------------- RULES ----------------
123 def p_source_text_1(p
):
124 '''source_text : timeunits_declaration_opt _embed0_source_text description_list '''
126 print('source_text', list(p
))
132 def p_source_text_2(p
):
135 print('source_text', list(p
))
141 def p__embed0_source_text(p
):
142 '''_embed0_source_text : '''
145 # { pform_set_scope_timescale(yyloc); }
149 def p_assertion_item_1(p
):
150 '''assertion_item : concurrent_assertion_item '''
152 print('assertion_item_1', list(p
))
158 def p_assignment_pattern_1(p
):
159 '''assignment_pattern : K_LP expression_list_proper '}' '''
161 print('assignment_pattern_1', list(p
))
164 # { PEAssignPattern*tmp = new PEAssignPattern(*p[2]);
165 # FILE_NAME(tmp, @1);
172 def p_assignment_pattern_2(p
):
173 '''assignment_pattern : K_LP '}' '''
175 print('assignment_pattern_2', list(p
))
178 # { PEAssignPattern*tmp = new PEAssignPattern;
179 # FILE_NAME(tmp, @1);
185 def p_block_identifier_opt_1(p
):
186 '''block_identifier_opt : IDENTIFIER ':' '''
188 print('block_identifier_opt_1', list(p
))
194 def p_block_identifier_opt_2(p
):
195 '''block_identifier_opt : '''
197 print('block_identifier_opt_2', list(p
))
203 def p_class_declaration_1(p
):
204 '''class_declaration : K_virtual_opt K_class lifetime_opt class_identifier class_declaration_extends_opt ';' _embed0_class_declaration class_items_opt K_endclass _embed1_class_declaration class_declaration_endlabel_opt '''
206 print('class_declaration_1', list(p
))
209 # { // Wrap up the class.
210 # if (p[11] && p[4] && p[4]->name != p[11]) {
211 # yyerror(@11, "error: Class end label doesn't match class name.");
218 def p__embed0_class_declaration(p
):
219 '''_embed0_class_declaration : '''
222 # { pform_start_class_declaration(@2, p[4], p[5].type, p[5].exprs, p[3]); }
226 def p__embed1_class_declaration(p
):
227 '''_embed1_class_declaration : '''
230 # { // Process a class.
231 # pform_end_class_declaration(@9);
236 def p_class_constraint_1(p
):
237 '''class_constraint : constraint_prototype '''
239 print('class_constraint_1', list(p
))
245 def p_class_constraint_2(p
):
246 '''class_constraint : constraint_declaration '''
248 print('class_constraint_2', list(p
))
254 def p_class_identifier_1(p
):
255 '''class_identifier : IDENTIFIER '''
257 print('class_identifier_1', list(p
))
260 # { // Create a synthetic typedef for the class name so that the
261 # // lexor detects the name as a type.
262 # perm_string name = lex_strings.make(p[1]);
263 # class_type_t*tmp = new class_type_t(name);
264 # FILE_NAME(tmp, @1);
265 # pform_set_typedef(name, tmp, NULL);
272 def p_class_identifier_2(p
):
273 '''class_identifier : TYPE_IDENTIFIER '''
275 print('class_identifier_2', list(p
))
278 # { class_type_t*tmp = dynamic_cast<class_type_t*>(p[1].type);
280 # yyerror(@1, "Type name \"%s\"is not a predeclared class name.", p[1].text);
288 def p_class_declaration_endlabel_opt_1(p
):
289 '''class_declaration_endlabel_opt : ':' TYPE_IDENTIFIER '''
291 print('class_declaration_endlabel_opt_1', list(p
))
294 # { class_type_t*tmp = dynamic_cast<class_type_t*> (p[2].type);
296 # yyerror(@2, "error: class declaration endlabel \"%s\" is not a class name\n", p[2].text);
299 # p[0] = strdupnew(tmp->name.str());
306 def p_class_declaration_endlabel_opt_2(p
):
307 '''class_declaration_endlabel_opt : ':' IDENTIFIER '''
309 print('class_declaration_endlabel_opt_2', list(p
))
316 def p_class_declaration_endlabel_opt_3(p
):
317 '''class_declaration_endlabel_opt : '''
319 print('class_declaration_endlabel_opt_3', list(p
))
326 def p_class_declaration_extends_opt_1(p
):
327 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '''
329 print('class_declaration_extends_opt_1', list(p
))
332 # { p[0].type = p[2].type;
339 def p_class_declaration_extends_opt_2(p
):
340 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '(' expression_list_with_nuls ')' '''
342 print('class_declaration_extends_opt_2', list(p
))
345 # { p[0].type = p[2].type;
352 def p_class_declaration_extends_opt_3(p
):
353 '''class_declaration_extends_opt : '''
355 print('class_declaration_extends_opt_3', list(p
))
358 # { p[0].type = 0; p[0].exprs = 0; }
362 def p_class_items_opt_1(p
):
363 '''class_items_opt : class_items '''
365 print('class_items_opt_1', list(p
))
371 def p_class_items_opt_2(p
):
372 '''class_items_opt : '''
374 print('class_items_opt_2', list(p
))
380 def p_class_items_1(p
):
381 '''class_items : class_items class_item '''
383 print('class_items_1', list(p
))
389 def p_class_items_2(p
):
390 '''class_items : class_item '''
392 print('class_items_2', list(p
))
398 def p_class_item_1(p
):
399 '''class_item : method_qualifier_opt K_function K_new _embed0_class_item '(' tf_port_list_opt ')' ';' function_item_list_opt statement_or_null_list_opt K_endfunction endnew_opt '''
401 print('class_item_1', list(p
))
404 # { current_function->set_ports(p[6]);
405 # pform_set_constructor_return(current_function);
406 # pform_set_this_class(@3, current_function);
407 # current_function_set_statement(@3, p[10]);
409 # current_function = 0;
414 def p_class_item_2(p
):
415 '''class_item : property_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
417 print('class_item_2', list(p
))
420 # { pform_class_property(@2, p[1], p[2], p[3]); }
424 def p_class_item_3(p
):
425 '''class_item : K_const class_item_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
427 print('class_item_3', list(p
))
430 # { pform_class_property(@1, p[2] | property_qualifier_t::make_const(), p[3], p[4]); }
434 def p_class_item_4(p
):
435 '''class_item : method_qualifier_opt task_declaration '''
437 print('class_item_4', list(p
))
440 # { /* The task_declaration rule puts this into the class */ }
444 def p_class_item_5(p
):
445 '''class_item : method_qualifier_opt function_declaration '''
447 print('class_item_5', list(p
))
450 # { /* The function_declaration rule puts this into the class */ }
454 def p_class_item_6(p
):
455 '''class_item : K_extern method_qualifier_opt K_function K_new ';' '''
457 print('class_item_6', list(p
))
460 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
464 def p_class_item_7(p
):
465 '''class_item : K_extern method_qualifier_opt K_function K_new '(' tf_port_list_opt ')' ';' '''
467 print('class_item_7', list(p
))
470 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
474 def p_class_item_8(p
):
475 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER ';' '''
477 print('class_item_8', list(p
))
480 # { yyerror(@1, "sorry: External methods are not yet supported.");
486 def p_class_item_9(p
):
487 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' ';' '''
489 print('class_item_9', list(p
))
492 # { yyerror(@1, "sorry: External methods are not yet supported.");
498 def p_class_item_10(p
):
499 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER ';' '''
501 print('class_item_10', list(p
))
504 # { yyerror(@1, "sorry: External methods are not yet supported.");
510 def p_class_item_11(p
):
511 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER '(' tf_port_list_opt ')' ';' '''
513 print('class_item_11', list(p
))
516 # { yyerror(@1, "sorry: External methods are not yet supported.");
522 def p_class_item_12(p
):
523 '''class_item : class_constraint '''
525 print('class_item_12', list(p
))
531 def p_class_item_13(p
):
532 '''class_item : property_qualifier_opt data_type error ';' '''
534 print('class_item_13', list(p
))
537 # { yyerror(@3, "error: Errors in variable names after data type.");
543 def p_class_item_14(p
):
544 '''class_item : property_qualifier_opt IDENTIFIER error ';' '''
546 print('class_item_14', list(p
))
549 # { yyerror(@3, "error: %s doesn't name a type.", p[2]);
555 def p_class_item_15(p
):
556 '''class_item : method_qualifier_opt K_function K_new error K_endfunction endnew_opt '''
558 print('class_item_15', list(p
))
561 # { yyerror(@1, "error: I give up on this class constructor declaration.");
567 def p_class_item_16(p
):
568 '''class_item : error ';' '''
570 print('class_item_16', list(p
))
573 # { yyerror(@2, "error: invalid class item.");
579 def p__embed0_class_item(p
):
580 '''_embed0_class_item : '''
583 # { assert(current_function==0);
584 # current_function = pform_push_constructor_scope(@3);
589 def p_class_item_qualifier_1(p
):
590 '''class_item_qualifier : K_static '''
592 print('class_item_qualifier_1', list(p
))
595 # { p[0] = property_qualifier_t::make_static(); }
599 def p_class_item_qualifier_2(p
):
600 '''class_item_qualifier : K_protected '''
602 print('class_item_qualifier_2', list(p
))
605 # { p[0] = property_qualifier_t::make_protected(); }
609 def p_class_item_qualifier_3(p
):
610 '''class_item_qualifier : K_local '''
612 print('class_item_qualifier_3', list(p
))
615 # { p[0] = property_qualifier_t::make_local(); }
619 def p_class_item_qualifier_list_1(p
):
620 '''class_item_qualifier_list : class_item_qualifier_list class_item_qualifier '''
622 print('class_item_qualifier_list_1', list(p
))
625 # { p[0] = p[1] | p[2]; }
629 def p_class_item_qualifier_list_2(p
):
630 '''class_item_qualifier_list : class_item_qualifier '''
632 print('class_item_qualifier_list_2', list(p
))
639 def p_class_item_qualifier_opt_1(p
):
640 '''class_item_qualifier_opt : class_item_qualifier_list '''
642 print('class_item_qualifier_opt_1', list(p
))
649 def p_class_item_qualifier_opt_2(p
):
650 '''class_item_qualifier_opt : '''
652 print('class_item_qualifier_opt_2', list(p
))
655 # { p[0] = property_qualifier_t::make_none(); }
659 def p_class_new_1(p
):
660 '''class_new : K_new '(' expression_list_with_nuls ')' '''
662 print('class_new_1', list(p
))
665 # { list<PExpr*>*expr_list = p[3];
666 # strip_tail_items(expr_list);
667 # PENewClass*tmp = new PENewClass(*expr_list);
668 # FILE_NAME(tmp, @1);
675 def p_class_new_2(p
):
676 '''class_new : K_new hierarchy_identifier '''
678 print('class_new_2', list(p
))
681 # { PEIdent*tmpi = new PEIdent(*p[2]);
682 # FILE_NAME(tmpi, @2);
683 # PENewCopy*tmp = new PENewCopy(tmpi);
684 # FILE_NAME(tmp, @1);
691 def p_class_new_3(p
):
692 '''class_new : K_new '''
694 print('class_new_3', list(p
))
697 # { PENewClass*tmp = new PENewClass;
698 # FILE_NAME(tmp, @1);
704 def p_concurrent_assertion_item_1(p
):
705 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' property_spec ')' statement_or_null '''
707 print('concurrent_assertion_item_1', list(p
))
711 # if (gn_assertions_flag) {
712 # yyerror(@2, "sorry: concurrent_assertion_item not supported."
713 # " Try -gno-assertion to turn this message off.");
719 def p_concurrent_assertion_item_2(p
):
720 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' error ')' statement_or_null '''
722 print('concurrent_assertion_item_2', list(p
))
726 # yyerror(@2, "error: Error in property_spec of concurrent assertion item.");
731 def p_constraint_block_item_1(p
):
732 '''constraint_block_item : constraint_expression '''
734 print('constraint_block_item_1', list(p
))
740 def p_constraint_block_item_list_1(p
):
741 '''constraint_block_item_list : constraint_block_item_list constraint_block_item '''
743 print('constraint_block_item_list_1', list(p
))
749 def p_constraint_block_item_list_2(p
):
750 '''constraint_block_item_list : constraint_block_item '''
752 print('constraint_block_item_list_2', list(p
))
758 def p_constraint_block_item_list_opt_1(p
):
759 '''constraint_block_item_list_opt : '''
761 print('constraint_block_item_list_opt_1', list(p
))
767 def p_constraint_block_item_list_opt_2(p
):
768 '''constraint_block_item_list_opt : constraint_block_item_list '''
770 print('constraint_block_item_list_opt_2', list(p
))
776 def p_constraint_declaration_1(p
):
777 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' constraint_block_item_list_opt '}' '''
779 print('constraint_declaration_1', list(p
))
782 # { yyerror(@2, "sorry: Constraint declarations not supported."); }
786 def p_constraint_declaration_2(p
):
787 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' error '}' '''
789 print('constraint_declaration_2', list(p
))
792 # { yyerror(@4, "error: Errors in the constraint block item list."); }
796 def p_constraint_expression_1(p
):
797 '''constraint_expression : expression ';' '''
799 print('constraint_expression_1', list(p
))
805 def p_constraint_expression_2(p
):
806 '''constraint_expression : expression K_dist '{' '}' ';' '''
808 print('constraint_expression_2', list(p
))
814 def p_constraint_expression_3(p
):
815 '''constraint_expression : expression K_TRIGGER constraint_set '''
817 print('constraint_expression_3', list(p
))
823 def p_constraint_expression_4(p
):
824 '''constraint_expression : K_if '(' expression ')' constraint_set %prec less_than_K_else '''
826 print('constraint_expression_4', list(p
))
832 def p_constraint_expression_5(p
):
833 '''constraint_expression : K_if '(' expression ')' constraint_set K_else constraint_set '''
835 print('constraint_expression_5', list(p
))
841 def p_constraint_expression_6(p
):
842 '''constraint_expression : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' constraint_set '''
844 print('constraint_expression_6', list(p
))
850 def p_constraint_expression_list_1(p
):
851 '''constraint_expression_list : constraint_expression_list constraint_expression '''
853 print('constraint_expression_list_1', list(p
))
859 def p_constraint_expression_list_2(p
):
860 '''constraint_expression_list : constraint_expression '''
862 print('constraint_expression_list_2', list(p
))
868 def p_constraint_prototype_1(p
):
869 '''constraint_prototype : K_static_opt K_constraint IDENTIFIER ';' '''
871 print('constraint_prototype_1', list(p
))
874 # { yyerror(@2, "sorry: Constraint prototypes not supported."); }
878 def p_constraint_set_1(p
):
879 '''constraint_set : constraint_expression '''
881 print('constraint_set_1', list(p
))
887 def p_constraint_set_2(p
):
888 '''constraint_set : '{' constraint_expression_list '}' '''
890 print('constraint_set_2', list(p
))
896 def p_data_declaration_1(p
):
897 '''data_declaration : attribute_list_opt data_type_or_implicit list_of_variable_decl_assignments ';' '''
899 print('data_declaration_1', list(p
))
902 # { data_type_t*data_type = p[2];
903 # if (data_type == 0) {
904 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
905 # FILE_NAME(data_type, @2);
907 # pform_makewire(@2, 0, str_strength, p[3], NetNet::IMPLICIT_REG, data_type);
912 def p_data_type_1(p
):
913 '''data_type : integer_vector_type unsigned_signed_opt dimensions_opt '''
915 print('data_type_1', list(p
))
918 if (use_vtype
== IVL_VT_NO_TYPE
):
919 use_vtype
= IVL_VT_LOGIC
921 dt
= DataType(use_vtype
, signed
=p
[2])
923 dt
.reg_flag
= reg_flag
927 # { ivl_variable_type_t use_vtype = p[1];
928 # bool reg_flag = false;
929 # if (use_vtype == IVL_VT_NO_TYPE) {
930 # use_vtype = IVL_VT_LOGIC;
933 # vector_type_t*tmp = new vector_type_t(use_vtype, p[2], p[3]);
934 # tmp->reg_flag = reg_flag;
935 # FILE_NAME(tmp, @1);
941 def p_data_type_2(p
):
942 '''data_type : non_integer_type '''
944 print('data_type_2', list(p
))
948 # { real_type_t*tmp = new real_type_t(p[1]);
949 # FILE_NAME(tmp, @1);
955 def p_data_type_3(p
):
956 '''data_type : struct_data_type '''
958 print('data_type_3', list(p
))
962 # { if (!p[1]->packed_flag) {
963 # yyerror(@1, "sorry: Unpacked structs not supported.");
970 def p_data_type_4(p
):
971 '''data_type : enum_data_type '''
973 print('data_type_4', list(p
))
980 def p_data_type_5(p
):
981 '''data_type : atom2_type signed_unsigned_opt '''
983 print('data_type_5', list(p
))
986 # { atom2_type_t*tmp = new atom2_type_t(p[1], p[2]);
987 # FILE_NAME(tmp, @1);
993 def p_data_type_6(p
):
994 '''data_type : K_integer signed_unsigned_opt '''
996 print('data_type_6', list(p
))
999 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
1000 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[2], pd);
1001 # tmp->reg_flag = true;
1002 # tmp->integer_flag = true;
1008 def p_data_type_7(p
):
1009 '''data_type : K_time '''
1011 print('data_type_7', list(p
))
1014 # { list<pform_range_t>*pd = make_range_from_width(64);
1015 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
1016 # tmp->reg_flag = !gn_system_verilog();
1022 def p_data_type_8(p
):
1023 '''data_type : TYPE_IDENTIFIER dimensions_opt '''
1025 print('data_type_8', list(p
))
1029 # parray_type_t*tmp = new parray_type_t(p[1].type, p[2]);
1030 # FILE_NAME(tmp, @1);
1032 # } else p[0] = p[1].type;
1033 # delete[]p[1].text;
1038 def p_data_type_9(p
):
1039 '''data_type : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_data_type TYPE_IDENTIFIER '''
1041 print('data_type_9', list(p
))
1044 # { lex_in_package_scope(0);
1046 # delete[]p[4].text;
1051 def p_data_type_10(p
):
1052 '''data_type : K_string '''
1054 print('data_type_10', list(p
))
1057 # { string_type_t*tmp = new string_type_t;
1058 # FILE_NAME(tmp, @1);
1064 def p__embed0_data_type(p
):
1065 '''_embed0_data_type : '''
1068 # { lex_in_package_scope(p[1]); }
1072 def p_data_type_or_implicit_1(p
):
1073 '''data_type_or_implicit : data_type '''
1075 print('data_type_or_implicit_1', list(p
))
1082 def p_data_type_or_implicit_2(p
):
1083 '''data_type_or_implicit : signing dimensions_opt '''
1085 print('data_type_or_implicit_2', list(p
))
1088 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[1], p[2]);
1089 # tmp->implicit_flag = true;
1090 # FILE_NAME(tmp, @1);
1096 def p_data_type_or_implicit_3(p
):
1097 '''data_type_or_implicit : dimensions '''
1099 print('data_type_or_implicit_3', list(p
))
1103 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, p[1]);
1104 # tmp->implicit_flag = true;
1105 # FILE_NAME(tmp, @1);
1111 def p_data_type_or_implicit_4(p
):
1112 '''data_type_or_implicit : '''
1113 if(parse_debug
> 2):
1114 print('data_type_or_implicit_4', list(p
))
1121 def p_data_type_or_implicit_or_void_1(p
):
1122 '''data_type_or_implicit_or_void : data_type_or_implicit '''
1124 print('data_type_or_implicit_or_void_1', list(p
))
1131 def p_data_type_or_implicit_or_void_2(p
):
1132 '''data_type_or_implicit_or_void : K_void '''
1134 print('data_type_or_implicit_or_void_2', list(p
))
1137 # { void_type_t*tmp = new void_type_t;
1138 # FILE_NAME(tmp, @1);
1144 def p_description_1(p
):
1145 '''description : module '''
1146 if(parse_debug
> 2):
1147 print('description_1', list(p
))
1153 def p_description_2(p
):
1154 '''description : udp_primitive '''
1156 print('description_2', list(p
))
1162 def p_description_3(p
):
1163 '''description : config_declaration '''
1165 print('description_3', list(p
))
1171 def p_description_4(p
):
1172 '''description : nature_declaration '''
1174 print('description_4', list(p
))
1180 def p_description_5(p
):
1181 '''description : package_declaration '''
1183 print('description_5', list(p
))
1189 def p_description_6(p
):
1190 '''description : discipline_declaration '''
1192 print('description_6', list(p
))
1198 def p_description_7(p
):
1199 '''description : package_item '''
1201 print('description_7', list(p
))
1207 def p_description_8(p
):
1208 '''description : KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' '''
1210 print('description_8', list(p
))
1213 # { perm_string tmp3 = lex_strings.make(p[3]);
1214 # pform_set_type_attrib(tmp3, p[5], p[7]);
1221 def p_description_list_1(p
):
1222 '''description_list : description '''
1223 if(parse_debug
> 2):
1224 print('description_list_1', list(p
))
1230 def p_description_list_2(p
):
1231 '''description_list : description_list description '''
1233 print('description_list_2', list(p
))
1239 def p_endnew_opt_1(p
):
1240 '''endnew_opt : ':' K_new '''
1242 print('endnew_opt_1', list(p
))
1248 def p_endnew_opt_2(p
):
1251 print('endnew_opt_2', list(p
))
1257 def p_dynamic_array_new_1(p
):
1258 '''dynamic_array_new : K_new '[' expression ']' '''
1260 print('dynamic_array_new_1', list(p
))
1263 # { p[0] = new PENewArray(p[3], 0);
1264 # FILE_NAME(p[0], @1);
1269 def p_dynamic_array_new_2(p
):
1270 '''dynamic_array_new : K_new '[' expression ']' '(' expression ')' '''
1272 print('dynamic_array_new_2', list(p
))
1275 # { p[0] = new PENewArray(p[3], p[6]);
1276 # FILE_NAME(p[0], @1);
1281 def p_for_step_1(p
):
1282 '''for_step : lpvalue '=' expression '''
1284 print('for_step_1', list(p
))
1287 # { PAssign*tmp = new PAssign(p[1],p[3]);
1288 # FILE_NAME(tmp, @1);
1294 def p_for_step_2(p
):
1295 '''for_step : inc_or_dec_expression '''
1297 print('for_step_2', list(p
))
1300 # { p[0] = pform_compressed_assign_from_inc_dec(@1, p[1]); }
1304 def p_for_step_3(p
):
1305 '''for_step : compressed_statement '''
1307 print('for_step_3', list(p
))
1314 def p_function_declaration_1(p
):
1315 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER ';' _embed0_function_declaration function_item_list statement_or_null_list_opt K_endfunction _embed1_function_declaration endlabel_opt '''
1317 print('function_declaration_1', list(p
))
1320 # { // Last step: check any closing name.
1322 # if (strcmp(p[4],p[11]) != 0) {
1323 # yyerror(@11, "error: End label doesn't match "
1326 # if (! gn_system_verilog()) {
1327 # yyerror(@11, "error: Function end labels require "
1328 # "SystemVerilog.");
1337 def p_function_declaration_2(p
):
1338 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER _embed2_function_declaration '(' tf_port_list_opt ')' ';' block_item_decls_opt statement_or_null_list_opt K_endfunction _embed3_function_declaration endlabel_opt '''
1340 print('function_declaration_2', list(p
))
1343 # { // Last step: check any closing name.
1345 # if (strcmp(p[4],p[14]) != 0) {
1346 # yyerror(@14, "error: End label doesn't match "
1349 # if (! gn_system_verilog()) {
1350 # yyerror(@14, "error: Function end labels require "
1351 # "SystemVerilog.");
1360 def p_function_declaration_3(p
):
1361 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER error K_endfunction _embed4_function_declaration endlabel_opt '''
1363 print('function_declaration_3', list(p
))
1366 # { // Last step: check any closing name.
1368 # if (strcmp(p[4],p[8]) != 0) {
1369 # yyerror(@8, "error: End label doesn't match function name");
1371 # if (! gn_system_verilog()) {
1372 # yyerror(@8, "error: Function end labels require "
1373 # "SystemVerilog.");
1382 def p__embed0_function_declaration(p
):
1383 '''_embed0_function_declaration : '''
1386 # { assert(current_function == 0);
1387 # current_function = pform_push_function_scope(@1, p[4], p[2]);
1392 def p__embed1_function_declaration(p
):
1393 '''_embed1_function_declaration : '''
1396 # { current_function->set_ports(p[7]);
1397 # current_function->set_return(p[3]);
1398 # current_function_set_statement(p[8]? @8 : @4, p[8]);
1399 # pform_set_this_class(@4, current_function);
1400 # pform_pop_scope();
1401 # current_function = 0;
1406 def p__embed2_function_declaration(p
):
1407 '''_embed2_function_declaration : '''
1410 # { assert(current_function == 0);
1411 # current_function = pform_push_function_scope(@1, p[4], p[2]);
1416 def p__embed3_function_declaration(p
):
1417 '''_embed3_function_declaration : '''
1420 # { current_function->set_ports(p[7]);
1421 # current_function->set_return(p[3]);
1422 # current_function_set_statement(p[11]? @11 : @4, p[11]);
1423 # pform_set_this_class(@4, current_function);
1424 # pform_pop_scope();
1425 # current_function = 0;
1426 # if (p[7]==0 && !gn_system_verilog()) {
1427 # yyerror(@4, "error: Empty parenthesis syntax requires SystemVerilog.");
1433 def p__embed4_function_declaration(p
):
1434 '''_embed4_function_declaration : '''
1438 # if (current_function) {
1439 # pform_pop_scope();
1440 # current_function = 0;
1442 # assert(current_function == 0);
1443 # yyerror(@1, "error: Syntax error defining function.");
1449 def p_import_export_1(p
):
1450 '''import_export : K_import '''
1452 print('import_export_1', list(p
))
1459 def p_import_export_2(p
):
1460 '''import_export : K_export '''
1462 print('import_export_2', list(p
))
1469 def p_implicit_class_handle_1(p
):
1470 '''implicit_class_handle : K_this '''
1472 print('implicit_class_handle_1', list(p
))
1475 # { p[0] = pform_create_this(); }
1479 def p_implicit_class_handle_2(p
):
1480 '''implicit_class_handle : K_super '''
1482 print('implicit_class_handle_2', list(p
))
1485 # { p[0] = pform_create_super(); }
1489 def p_inc_or_dec_expression_1(p
):
1490 '''inc_or_dec_expression : K_INCR lpvalue %prec UNARY_PREC '''
1492 print('inc_or_dec_expression_1', list(p
))
1495 # { PEUnary*tmp = new PEUnary('I', p[2]);
1496 # FILE_NAME(tmp, @2);
1502 def p_inc_or_dec_expression_2(p
):
1503 '''inc_or_dec_expression : lpvalue K_INCR %prec UNARY_PREC '''
1505 print('inc_or_dec_expression_2', list(p
))
1508 # { PEUnary*tmp = new PEUnary('i', p[1]);
1509 # FILE_NAME(tmp, @1);
1515 def p_inc_or_dec_expression_3(p
):
1516 '''inc_or_dec_expression : K_DECR lpvalue %prec UNARY_PREC '''
1518 print('inc_or_dec_expression_3', list(p
))
1521 # { PEUnary*tmp = new PEUnary('D', p[2]);
1522 # FILE_NAME(tmp, @2);
1528 def p_inc_or_dec_expression_4(p
):
1529 '''inc_or_dec_expression : lpvalue K_DECR %prec UNARY_PREC '''
1531 print('inc_or_dec_expression_4', list(p
))
1534 # { PEUnary*tmp = new PEUnary('d', p[1]);
1535 # FILE_NAME(tmp, @1);
1541 def p_inside_expression_1(p
):
1542 '''inside_expression : expression K_inside '{' open_range_list '}' '''
1544 print('inside_expression_1', list(p
))
1547 # { yyerror(@2, "sorry: \"inside\" expressions not supported yet.");
1553 def p_integer_vector_type_1(p
):
1554 '''integer_vector_type : K_reg '''
1556 print('integer_vector_type_1', list(p
))
1557 p
[0] = IVL_VT_NO_TYPE
1563 def p_integer_vector_type_2(p
):
1564 '''integer_vector_type : K_bit '''
1566 print('integer_vector_type_2', list(p
))
1573 def p_integer_vector_type_3(p
):
1574 '''integer_vector_type : K_logic '''
1576 print('integer_vector_type_3', list(p
))
1583 def p_integer_vector_type_4(p
):
1584 '''integer_vector_type : K_bool '''
1586 print('integer_vector_type_4', list(p
))
1589 # { p[0] = IVL_VT_BOOL; }
1593 def p_join_keyword_1(p
):
1594 '''join_keyword : K_join '''
1596 print('join_keyword_1', list(p
))
1599 # { p[0] = PBlock::BL_PAR; }
1603 def p_join_keyword_2(p
):
1604 '''join_keyword : K_join_none '''
1606 print('join_keyword_2', list(p
))
1609 # { p[0] = PBlock::BL_JOIN_NONE; }
1613 def p_join_keyword_3(p
):
1614 '''join_keyword : K_join_any '''
1616 print('join_keyword_3', list(p
))
1619 # { p[0] = PBlock::BL_JOIN_ANY; }
1623 def p_jump_statement_1(p
):
1624 '''jump_statement : K_break ';' '''
1626 print('jump_statement_1', list(p
))
1629 # { yyerror(@1, "sorry: break statements not supported.");
1635 def p_jump_statement_2(p
):
1636 '''jump_statement : K_return ';' '''
1638 print('jump_statement_2', list(p
))
1641 # { PReturn*tmp = new PReturn(0);
1642 # FILE_NAME(tmp, @1);
1648 def p_jump_statement_3(p
):
1649 '''jump_statement : K_return expression ';' '''
1651 print('jump_statement_3', list(p
))
1654 # { PReturn*tmp = new PReturn(p[2]);
1655 # FILE_NAME(tmp, @1);
1661 def p_lifetime_1(p
):
1662 '''lifetime : K_automatic '''
1664 print('lifetime_1', list(p
))
1667 # { p[0] = LexicalScope::AUTOMATIC; }
1671 def p_lifetime_2(p
):
1672 '''lifetime : K_static '''
1674 print('lifetime_2', list(p
))
1677 # { p[0] = LexicalScope::STATIC; }
1681 def p_lifetime_opt_1(p
):
1682 '''lifetime_opt : lifetime '''
1684 print('lifetime_opt_1', list(p
))
1691 def p_lifetime_opt_2(p
):
1692 '''lifetime_opt : '''
1693 if(parse_debug
> 2):
1694 print('lifetime_opt_2', list(p
))
1697 # { p[0] = LexicalScope::INHERITED; }
1701 def p_loop_statement_1(p
):
1702 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' for_step ')' statement_or_null '''
1704 print('loop_statement_1', list(p
))
1707 # { PForStatement*tmp = new PForStatement(p[3], p[5], p[7], p[9], p[11]);
1708 # FILE_NAME(tmp, @1);
1714 def p_loop_statement_2(p
):
1715 '''loop_statement : K_for '(' data_type IDENTIFIER '=' expression ';' expression ';' for_step ')' _embed0_loop_statement statement_or_null '''
1717 print('loop_statement_2', list(p
))
1720 # { pform_name_t tmp_hident;
1721 # tmp_hident.push_back(name_component_t(lex_strings.make(p[4])));
1723 # PEIdent*tmp_ident = pform_new_ident(tmp_hident);
1724 # FILE_NAME(tmp_ident, @4);
1726 # PForStatement*tmp_for = new PForStatement(tmp_ident, p[6], p[8], p[10], p[13]);
1727 # FILE_NAME(tmp_for, @1);
1729 # pform_pop_scope();
1730 # vector<Statement*>tmp_for_list (1);
1731 # tmp_for_list[0] = tmp_for;
1732 # PBlock*tmp_blk = current_block_stack.top();
1733 # current_block_stack.pop();
1734 # tmp_blk->set_statement(tmp_for_list);
1741 def p_loop_statement_3(p
):
1742 '''loop_statement : K_forever statement_or_null '''
1744 print('loop_statement_3', list(p
))
1747 # { PForever*tmp = new PForever(p[2]);
1748 # FILE_NAME(tmp, @1);
1754 def p_loop_statement_4(p
):
1755 '''loop_statement : K_repeat '(' expression ')' statement_or_null '''
1757 print('loop_statement_4', list(p
))
1760 # { PRepeat*tmp = new PRepeat(p[3], p[5]);
1761 # FILE_NAME(tmp, @1);
1767 def p_loop_statement_5(p
):
1768 '''loop_statement : K_while '(' expression ')' statement_or_null '''
1770 print('loop_statement_5', list(p
))
1773 # { PWhile*tmp = new PWhile(p[3], p[5]);
1774 # FILE_NAME(tmp, @1);
1780 def p_loop_statement_6(p
):
1781 '''loop_statement : K_do statement_or_null K_while '(' expression ')' ';' '''
1783 print('loop_statement_6', list(p
))
1786 # { PDoWhile*tmp = new PDoWhile(p[5], p[2]);
1787 # FILE_NAME(tmp, @1);
1793 def p_loop_statement_7(p
):
1794 '''loop_statement : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' _embed1_loop_statement statement_or_null '''
1796 print('loop_statement_7', list(p
))
1799 # { PForeach*tmp_for = pform_make_foreach(@1, p[3], p[5], p[9]);
1801 # pform_pop_scope();
1802 # vector<Statement*>tmp_for_list(1);
1803 # tmp_for_list[0] = tmp_for;
1804 # PBlock*tmp_blk = current_block_stack.top();
1805 # current_block_stack.pop();
1806 # tmp_blk->set_statement(tmp_for_list);
1812 def p_loop_statement_8(p
):
1813 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' error ')' statement_or_null '''
1815 print('loop_statement_8', list(p
))
1819 # yyerror(@1, "error: Error in for loop step assignment.");
1824 def p_loop_statement_9(p
):
1825 '''loop_statement : K_for '(' lpvalue '=' expression ';' error ';' for_step ')' statement_or_null '''
1827 print('loop_statement_9', list(p
))
1831 # yyerror(@1, "error: Error in for loop condition expression.");
1836 def p_loop_statement_10(p
):
1837 '''loop_statement : K_for '(' error ')' statement_or_null '''
1839 print('loop_statement_10', list(p
))
1843 # yyerror(@1, "error: Incomprehensible for loop.");
1848 def p_loop_statement_11(p
):
1849 '''loop_statement : K_while '(' error ')' statement_or_null '''
1851 print('loop_statement_11', list(p
))
1855 # yyerror(@1, "error: Error in while loop condition.");
1860 def p_loop_statement_12(p
):
1861 '''loop_statement : K_do statement_or_null K_while '(' error ')' ';' '''
1863 print('loop_statement_12', list(p
))
1867 # yyerror(@1, "error: Error in do/while loop condition.");
1872 def p_loop_statement_13(p
):
1873 '''loop_statement : K_foreach '(' IDENTIFIER '[' error ']' ')' statement_or_null '''
1875 print('loop_statement_13', list(p
))
1879 # yyerror(@4, "error: Errors in foreach loop variables list.");
1884 def p__embed0_loop_statement(p
):
1885 '''_embed0_loop_statement : '''
1888 # { static unsigned for_counter = 0;
1889 # char for_block_name [64];
1890 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_for_loop%u", for_counter);
1892 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1893 # FILE_NAME(tmp, @1);
1894 # current_block_stack.push(tmp);
1896 # list<decl_assignment_t*>assign_list;
1897 # decl_assignment_t*tmp_assign = new decl_assignment_t;
1898 # tmp_assign->name = lex_strings.make(p[4]);
1899 # assign_list.push_back(tmp_assign);
1900 # pform_makewire(@4, 0, str_strength, &assign_list, NetNet::REG, p[3]);
1905 def p__embed1_loop_statement(p
):
1906 '''_embed1_loop_statement : '''
1909 # { static unsigned foreach_counter = 0;
1910 # char for_block_name[64];
1911 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_foreach%u", foreach_counter);
1912 # foreach_counter += 1;
1914 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1915 # FILE_NAME(tmp, @1);
1916 # current_block_stack.push(tmp);
1918 # pform_make_foreach_declarations(@1, p[5]);
1923 def p_list_of_variable_decl_assignments_1(p
):
1924 '''list_of_variable_decl_assignments : variable_decl_assignment '''
1926 print('list_of_variable_decl_assignments_1', list(p
))
1929 # { list<decl_assignment_t*>*tmp = new list<decl_assignment_t*>;
1930 # tmp->push_back(p[1]);
1936 def p_list_of_variable_decl_assignments_2(p
):
1937 '''list_of_variable_decl_assignments : list_of_variable_decl_assignments ',' variable_decl_assignment '''
1939 print('list_of_variable_decl_assignments_2', list(p
))
1942 # { list<decl_assignment_t*>*tmp = p[1];
1943 # tmp->push_back(p[3]);
1949 def p_variable_decl_assignment_1(p
):
1950 '''variable_decl_assignment : IDENTIFIER dimensions_opt '''
1952 print('variable_decl_assignment_1', list(p
))
1955 # { decl_assignment_t*tmp = new decl_assignment_t;
1956 # tmp->name = lex_strings.make(p[1]);
1958 # tmp->index = *p[2];
1967 def p_variable_decl_assignment_2(p
):
1968 '''variable_decl_assignment : IDENTIFIER '=' expression '''
1970 print('variable_decl_assignment_2', list(p
))
1973 # { decl_assignment_t*tmp = new decl_assignment_t;
1974 # tmp->name = lex_strings.make(p[1]);
1975 # tmp->expr .reset(p[3]);
1982 def p_variable_decl_assignment_3(p
):
1983 '''variable_decl_assignment : IDENTIFIER '=' K_new '(' ')' '''
1985 print('variable_decl_assignment_3', list(p
))
1988 # { decl_assignment_t*tmp = new decl_assignment_t;
1989 # tmp->name = lex_strings.make(p[1]);
1990 # PENewClass*expr = new PENewClass;
1991 # FILE_NAME(expr, @3);
1992 # tmp->expr .reset(expr);
1999 def p_loop_variables_1(p
):
2000 '''loop_variables : loop_variables ',' IDENTIFIER '''
2002 print('loop_variables_1', list(p
))
2005 # { list<perm_string>*tmp = p[1];
2006 # tmp->push_back(lex_strings.make(p[3]));
2013 def p_loop_variables_2(p
):
2014 '''loop_variables : IDENTIFIER '''
2016 print('loop_variables_2', list(p
))
2019 # { list<perm_string>*tmp = new list<perm_string>;
2020 # tmp->push_back(lex_strings.make(p[1]));
2027 def p_method_qualifier_1(p
):
2028 '''method_qualifier : K_virtual '''
2030 print('method_qualifier_1', list(p
))
2036 def p_method_qualifier_2(p
):
2037 '''method_qualifier : class_item_qualifier '''
2039 print('method_qualifier_2', list(p
))
2045 def p_method_qualifier_opt_1(p
):
2046 '''method_qualifier_opt : method_qualifier '''
2048 print('method_qualifier_opt_1', list(p
))
2054 def p_method_qualifier_opt_2(p
):
2055 '''method_qualifier_opt : '''
2057 print('method_qualifier_opt_2', list(p
))
2063 def p_modport_declaration_1(p
):
2064 '''modport_declaration : K_modport _embed0_modport_declaration modport_item_list ';' '''
2066 print('modport_declaration_1', list(p
))
2072 def p__embed0_modport_declaration(p
):
2073 '''_embed0_modport_declaration : '''
2076 # { if (!pform_in_interface())
2077 # yyerror(@1, "error: modport declarations are only allowed "
2078 # "in interfaces.");
2083 def p_modport_item_list_1(p
):
2084 '''modport_item_list : modport_item '''
2086 print('modport_item_list_1', list(p
))
2092 def p_modport_item_list_2(p
):
2093 '''modport_item_list : modport_item_list ',' modport_item '''
2095 print('modport_item_list_2', list(p
))
2101 def p_modport_item_1(p
):
2102 '''modport_item : IDENTIFIER _embed0_modport_item '(' modport_ports_list ')' '''
2104 print('modport_item_1', list(p
))
2107 # { pform_end_modport_item(@1); }
2111 def p__embed0_modport_item(p
):
2112 '''_embed0_modport_item : '''
2115 # { pform_start_modport_item(@1, p[1]); }
2119 def p_modport_ports_list_1(p
):
2120 '''modport_ports_list : modport_ports_declaration '''
2122 print('modport_ports_list_1', list(p
))
2128 def p_modport_ports_list_2(p
):
2129 '''modport_ports_list : modport_ports_list ',' modport_ports_declaration '''
2131 print('modport_ports_list_2', list(p
))
2137 def p_modport_ports_list_3(p
):
2138 '''modport_ports_list : modport_ports_list ',' modport_simple_port '''
2140 print('modport_ports_list_3', list(p
))
2143 # { if (last_modport_port.type == MP_SIMPLE) {
2144 # pform_add_modport_port(@3, last_modport_port.direction,
2145 # p[3]->name, p[3]->parm);
2147 # yyerror(@3, "error: modport expression not allowed here.");
2154 def p_modport_ports_list_4(p
):
2155 '''modport_ports_list : modport_ports_list ',' modport_tf_port '''
2157 print('modport_ports_list_4', list(p
))
2160 # { if (last_modport_port.type != MP_TF)
2161 # yyerror(@3, "error: task/function declaration not allowed here.");
2166 def p_modport_ports_list_5(p
):
2167 '''modport_ports_list : modport_ports_list ',' IDENTIFIER '''
2169 print('modport_ports_list_5', list(p
))
2172 # { if (last_modport_port.type == MP_SIMPLE) {
2173 # pform_add_modport_port(@3, last_modport_port.direction,
2174 # lex_strings.make(p[3]), 0);
2175 # } else if (last_modport_port.type != MP_TF) {
2176 # yyerror(@3, "error: list of identifiers not allowed here.");
2183 def p_modport_ports_list_6(p
):
2184 '''modport_ports_list : modport_ports_list ',' '''
2186 print('modport_ports_list_6', list(p
))
2189 # { yyerror(@2, "error: NULL port declarations are not allowed"); }
2193 def p_modport_ports_declaration_1(p
):
2194 '''modport_ports_declaration : attribute_list_opt port_direction IDENTIFIER '''
2196 print('modport_ports_declaration_1', list(p
))
2199 # { last_modport_port.type = MP_SIMPLE;
2200 # last_modport_port.direction = p[2];
2201 # pform_add_modport_port(@3, p[2], lex_strings.make(p[3]), 0);
2208 def p_modport_ports_declaration_2(p
):
2209 '''modport_ports_declaration : attribute_list_opt port_direction modport_simple_port '''
2211 print('modport_ports_declaration_2', list(p
))
2214 # { last_modport_port.type = MP_SIMPLE;
2215 # last_modport_port.direction = p[2];
2216 # pform_add_modport_port(@3, p[2], p[3]->name, p[3]->parm);
2223 def p_modport_ports_declaration_3(p
):
2224 '''modport_ports_declaration : attribute_list_opt import_export IDENTIFIER '''
2226 print('modport_ports_declaration_3', list(p
))
2229 # { last_modport_port.type = MP_TF;
2230 # last_modport_port.is_import = p[2];
2231 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
2238 def p_modport_ports_declaration_4(p
):
2239 '''modport_ports_declaration : attribute_list_opt import_export modport_tf_port '''
2241 print('modport_ports_declaration_4', list(p
))
2244 # { last_modport_port.type = MP_TF;
2245 # last_modport_port.is_import = p[2];
2246 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
2252 def p_modport_ports_declaration_5(p
):
2253 '''modport_ports_declaration : attribute_list_opt K_clocking IDENTIFIER '''
2255 print('modport_ports_declaration_5', list(p
))
2258 # { last_modport_port.type = MP_CLOCKING;
2259 # last_modport_port.direction = NetNet::NOT_A_PORT;
2260 # yyerror(@3, "sorry: modport clocking declaration is not yet supported.");
2267 def p_modport_simple_port_1(p
):
2268 '''modport_simple_port : '.' IDENTIFIER '(' expression ')' '''
2270 print('modport_simple_port_1', list(p
))
2273 # { named_pexpr_t*tmp = new named_pexpr_t;
2274 # tmp->name = lex_strings.make(p[2]);
2282 def p_modport_tf_port_1(p
):
2283 '''modport_tf_port : K_task IDENTIFIER '''
2285 print('modport_tf_port_1', list(p
))
2291 def p_modport_tf_port_2(p
):
2292 '''modport_tf_port : K_task IDENTIFIER '(' tf_port_list_opt ')' '''
2294 print('modport_tf_port_2', list(p
))
2300 def p_modport_tf_port_3(p
):
2301 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '''
2303 print('modport_tf_port_3', list(p
))
2309 def p_modport_tf_port_4(p
):
2310 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' '''
2312 print('modport_tf_port_4', list(p
))
2318 def p_non_integer_type_1(p
):
2319 '''non_integer_type : K_real '''
2321 print('non_integer_type_1', list(p
))
2324 # { p[0] = real_type_t::REAL; }
2328 def p_non_integer_type_2(p
):
2329 '''non_integer_type : K_realtime '''
2331 print('non_integer_type_2', list(p
))
2334 # { p[0] = real_type_t::REAL; }
2338 def p_non_integer_type_3(p
):
2339 '''non_integer_type : K_shortreal '''
2341 print('non_integer_type_3', list(p
))
2344 # { p[0] = real_type_t::SHORTREAL; }
2349 '''number : BASED_NUMBER '''
2351 print('number_1', list(p
))
2353 p
[1] = p
[1].replace("'b", "0b")
2354 p
[1] = p
[1].replace("'x", "0x")
2355 num
= Leaf(token
.NUMBER
, "%s" % (p
[1]))
2359 # { p[0] = p[1]; based_size = 0;}
2364 '''number : DEC_NUMBER '''
2366 print('number_2', list(p
))
2367 p
[1] = p
[1].replace("'b", "0b")
2368 p
[1] = p
[1].replace("'x", "0x")
2369 num
= Leaf(token
.NUMBER
, "%s" % (p
[1]))
2373 # { p[0] = p[1]; based_size = 0;}
2378 '''number : DEC_NUMBER BASED_NUMBER '''
2380 print('number_3', list(p
))
2382 p
[2] = p
[2].replace("'b", "0b")
2383 p
[2] = p
[2].replace("'x", "0x")
2385 num
= Leaf(token
.NUMBER
, "%s" % (p
[2]))
2389 # { p[0] = pform_verinum_with_size(p[1],p[2], @2.text, @2.first_line);
2395 '''number : UNBASED_NUMBER '''
2397 print('number_4', list(p
))
2400 # { p[0] = p[1]; based_size = 0;}
2405 '''number : DEC_NUMBER UNBASED_NUMBER '''
2407 print('number_5', list(p
))
2410 # { yyerror(@1, "error: Unbased SystemVerilog literal cannot have "
2412 # p[0] = p[1]; based_size = 0;}
2416 def p_open_range_list_1(p
):
2417 '''open_range_list : open_range_list ',' value_range '''
2419 print('open_range_list_1', list(p
))
2425 def p_open_range_list_2(p
):
2426 '''open_range_list : value_range '''
2428 print('open_range_list_2', list(p
))
2434 def p_package_declaration_1(p
):
2435 '''package_declaration : K_package lifetime_opt IDENTIFIER ';' _embed0_package_declaration timeunits_declaration_opt _embed1_package_declaration package_item_list_opt K_endpackage endlabel_opt '''
2437 print('package_declaration_1', list(p
))
2440 # { pform_end_package_declaration(@1);
2441 # // If an end label is present make sure it match the package name.
2443 # if (strcmp(p[3],p[10]) != 0) {
2444 # yyerror(@10, "error: End label doesn't match package name");
2453 def p__embed0_package_declaration(p
):
2454 '''_embed0_package_declaration : '''
2457 # { pform_start_package_declaration(@1, p[3], p[2]); }
2461 def p__embed1_package_declaration(p
):
2462 '''_embed1_package_declaration : '''
2465 # { pform_set_scope_timescale(@1); }
2469 def p_module_package_import_list_opt_1(p
):
2470 '''module_package_import_list_opt : '''
2471 if(parse_debug
> 1):
2472 print('module_package_import_list_opt_1', list(p
))
2478 def p_module_package_import_list_opt_2(p
):
2479 '''module_package_import_list_opt : package_import_list '''
2481 print('module_package_import_list_opt_2', list(p
))
2487 def p_package_import_list_1(p
):
2488 '''package_import_list : package_import_declaration '''
2490 print('package_import_list_1', list(p
))
2496 def p_package_import_list_2(p
):
2497 '''package_import_list : package_import_list package_import_declaration '''
2499 print('package_import_list_2', list(p
))
2505 def p_package_import_declaration_1(p
):
2506 '''package_import_declaration : K_import package_import_item_list ';' '''
2508 print('package_import_declaration_1', list(p
))
2515 def p_package_import_item_1(p
):
2516 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '''
2518 print('package_import_item_1', list(p
))
2521 # { pform_package_import(@2, p[1], p[3]);
2527 def p_package_import_item_2(p
):
2528 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES '*' '''
2530 print('package_import_item_2', list(p
))
2533 # { pform_package_import(@2, p[1], 0);
2538 def p_package_import_item_list_1(p
):
2539 '''package_import_item_list : package_import_item_list ',' package_import_item '''
2541 print('package_import_item_list_1', list(p
))
2547 def p_package_import_item_list_2(p
):
2548 '''package_import_item_list : package_import_item '''
2550 print('package_import_item_list_2', list(p
))
2556 def p_package_item_1(p
):
2557 '''package_item : timeunits_declaration '''
2559 print('package_item_1', list(p
))
2565 def p_package_item_2(p
):
2566 '''package_item : K_parameter param_type parameter_assign_list ';' '''
2568 print('package_item_2', list(p
))
2574 def p_package_item_3(p
):
2575 '''package_item : K_localparam param_type localparam_assign_list ';' '''
2577 print('package_item_3', list(p
))
2583 def p_package_item_4(p
):
2584 '''package_item : type_declaration '''
2586 print('package_item_4', list(p
))
2592 def p_package_item_5(p
):
2593 '''package_item : function_declaration '''
2595 print('package_item_5', list(p
))
2601 def p_package_item_6(p
):
2602 '''package_item : task_declaration '''
2604 print('package_item_6', list(p
))
2610 def p_package_item_7(p
):
2611 '''package_item : data_declaration '''
2613 print('package_item_7', list(p
))
2619 def p_package_item_8(p
):
2620 '''package_item : class_declaration '''
2622 print('package_item_8', list(p
))
2628 def p_package_item_list_1(p
):
2629 '''package_item_list : package_item_list package_item '''
2631 print('package_item_list_1', list(p
))
2637 def p_package_item_list_2(p
):
2638 '''package_item_list : package_item '''
2640 print('package_item_list_2', list(p
))
2646 def p_package_item_list_opt_1(p
):
2647 '''package_item_list_opt : package_item_list '''
2649 print('package_item_list_opt_1', list(p
))
2655 def p_package_item_list_opt_2(p
):
2656 '''package_item_list_opt : '''
2658 print('package_item_list_opt_2', list(p
))
2664 def p_port_direction_1(p
):
2665 '''port_direction : K_input '''
2667 print('port_direction_1', list(p
))
2670 # { p[0] = NetNet::PINPUT; }
2674 def p_port_direction_2(p
):
2675 '''port_direction : K_output '''
2677 print('port_direction_2', list(p
))
2680 # { p[0] = NetNet::POUTPUT; }
2684 def p_port_direction_3(p
):
2685 '''port_direction : K_inout '''
2687 print('port_direction_3', list(p
))
2690 # { p[0] = NetNet::PINOUT; }
2694 def p_port_direction_4(p
):
2695 '''port_direction : K_ref '''
2697 print('port_direction_4', list(p
))
2700 # { p[0] = NetNet::PREF;
2701 # if (!gn_system_verilog()) {
2702 # yyerror(@1, "error: Reference ports (ref) require SystemVerilog.");
2703 # p[0] = NetNet::PINPUT;
2709 def p_port_direction_opt_1(p
):
2710 '''port_direction_opt : port_direction '''
2712 print('port_direction_opt_1', list(p
))
2719 def p_port_direction_opt_2(p
):
2720 '''port_direction_opt : '''
2722 print('port_direction_opt_2', list(p
))
2725 # { p[0] = NetNet::PIMPLICIT; }
2729 def p_property_expr_1(p
):
2730 '''property_expr : expression '''
2732 print('property_expr_1', list(p
))
2738 def p_procedural_assertion_statement_1(p
):
2739 '''procedural_assertion_statement : K_assert '(' expression ')' statement %prec less_than_K_else '''
2741 print('procedural_assertion_statement_1', list(p
))
2744 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2750 def p_procedural_assertion_statement_2(p
):
2751 '''procedural_assertion_statement : K_assert '(' expression ')' K_else statement '''
2753 print('procedural_assertion_statement_2', list(p
))
2756 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2762 def p_procedural_assertion_statement_3(p
):
2763 '''procedural_assertion_statement : K_assert '(' expression ')' statement K_else statement '''
2765 print('procedural_assertion_statement_3', list(p
))
2768 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2774 def p_property_qualifier_1(p
):
2775 '''property_qualifier : class_item_qualifier '''
2777 print('property_qualifier_1', list(p
))
2783 def p_property_qualifier_2(p
):
2784 '''property_qualifier : random_qualifier '''
2786 print('property_qualifier_2', list(p
))
2792 def p_property_qualifier_opt_1(p
):
2793 '''property_qualifier_opt : property_qualifier_list '''
2795 print('property_qualifier_opt_1', list(p
))
2802 def p_property_qualifier_opt_2(p
):
2803 '''property_qualifier_opt : '''
2805 print('property_qualifier_opt_2', list(p
))
2808 # { p[0] = property_qualifier_t::make_none(); }
2812 def p_property_qualifier_list_1(p
):
2813 '''property_qualifier_list : property_qualifier_list property_qualifier '''
2815 print('property_qualifier_list_1', list(p
))
2818 # { p[0] = p[1] | p[2]; }
2822 def p_property_qualifier_list_2(p
):
2823 '''property_qualifier_list : property_qualifier '''
2825 print('property_qualifier_list_2', list(p
))
2832 def p_property_spec_1(p
):
2833 '''property_spec : clocking_event_opt property_spec_disable_iff_opt property_expr '''
2835 print('property_spec_1', list(p
))
2841 def p_property_spec_disable_iff_opt_1(p
):
2842 '''property_spec_disable_iff_opt : K_disable K_iff '(' expression ')' '''
2844 print('property_spec_disable_iff_opt_1', list(p
))
2850 def p_property_spec_disable_iff_opt_2(p
):
2851 '''property_spec_disable_iff_opt : '''
2853 print('property_spec_disable_iff_opt_2', list(p
))
2859 def p_random_qualifier_1(p
):
2860 '''random_qualifier : K_rand '''
2862 print('random_qualifier_1', list(p
))
2865 # { p[0] = property_qualifier_t::make_rand(); }
2869 def p_random_qualifier_2(p
):
2870 '''random_qualifier : K_randc '''
2872 print('random_qualifier_2', list(p
))
2875 # { p[0] = property_qualifier_t::make_randc(); }
2879 def p_real_or_realtime_1(p
):
2880 '''real_or_realtime : K_real '''
2882 print('real_or_realtime_1', list(p
))
2888 def p_real_or_realtime_2(p
):
2889 '''real_or_realtime : K_realtime '''
2891 print('real_or_realtime_2', list(p
))
2898 '''signing : K_signed '''
2900 print('signing_1', list(p
))
2908 '''signing : K_unsigned '''
2910 print('signing_2', list(p
))
2917 def p_simple_type_or_string_1(p
):
2918 '''simple_type_or_string : integer_vector_type '''
2920 print('simple_type_or_string_1', list(p
))
2923 # { ivl_variable_type_t use_vtype = p[1];
2924 # bool reg_flag = false;
2925 # if (use_vtype == IVL_VT_NO_TYPE) {
2926 # use_vtype = IVL_VT_LOGIC;
2929 # vector_type_t*tmp = new vector_type_t(use_vtype, false, 0);
2930 # tmp->reg_flag = reg_flag;
2931 # FILE_NAME(tmp, @1);
2937 def p_simple_type_or_string_2(p
):
2938 '''simple_type_or_string : non_integer_type '''
2940 print('simple_type_or_string_2', list(p
))
2943 # { real_type_t*tmp = new real_type_t(p[1]);
2944 # FILE_NAME(tmp, @1);
2950 def p_simple_type_or_string_3(p
):
2951 '''simple_type_or_string : atom2_type '''
2953 print('simple_type_or_string_3', list(p
))
2956 # { atom2_type_t*tmp = new atom2_type_t(p[1], true);
2957 # FILE_NAME(tmp, @1);
2963 def p_simple_type_or_string_4(p
):
2964 '''simple_type_or_string : K_integer '''
2966 print('simple_type_or_string_4', list(p
))
2969 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
2970 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, true, pd);
2971 # tmp->reg_flag = true;
2972 # tmp->integer_flag = true;
2978 def p_simple_type_or_string_5(p
):
2979 '''simple_type_or_string : K_time '''
2981 print('simple_type_or_string_5', list(p
))
2984 # { list<pform_range_t>*pd = make_range_from_width(64);
2985 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
2986 # tmp->reg_flag = !gn_system_verilog();
2992 def p_simple_type_or_string_6(p
):
2993 '''simple_type_or_string : TYPE_IDENTIFIER '''
2995 print('simple_type_or_string_6', list(p
))
2998 # { p[0] = p[1].type;
2999 # delete[]p[1].text;
3004 def p_simple_type_or_string_7(p
):
3005 '''simple_type_or_string : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_simple_type_or_string TYPE_IDENTIFIER '''
3007 print('simple_type_or_string_7', list(p
))
3010 # { lex_in_package_scope(0);
3012 # delete[]p[4].text;
3017 def p_simple_type_or_string_8(p
):
3018 '''simple_type_or_string : K_string '''
3020 print('simple_type_or_string_8', list(p
))
3023 # { string_type_t*tmp = new string_type_t;
3024 # FILE_NAME(tmp, @1);
3030 def p__embed0_simple_type_or_string(p
):
3031 '''_embed0_simple_type_or_string : '''
3034 # { lex_in_package_scope(p[1]); }
3038 def p_statement_1(p
):
3039 '''statement : attribute_list_opt statement_item '''
3041 print('statement_1', list(p
))
3043 # { pform_bind_attributes(p[2]->attributes, p[1]);
3050 def p_statement_or_null_1(p
):
3051 '''statement_or_null : statement '''
3053 print('statement_or_null_1', list(p
))
3060 def p_statement_or_null_2(p
):
3061 '''statement_or_null : attribute_list_opt ';' '''
3063 print('statement_or_null_2', list(p
))
3065 raise(Exception("p_statement_or_null_2"))
3072 def p_stream_expression_1(p
):
3073 '''stream_expression : expression '''
3075 print('stream_expression_1', list(p
))
3081 def p_stream_expression_list_1(p
):
3082 '''stream_expression_list : stream_expression_list ',' stream_expression '''
3084 print('stream_expression_list_1', list(p
))
3090 def p_stream_expression_list_2(p
):
3091 '''stream_expression_list : stream_expression '''
3093 print('stream_expression_list_2', list(p
))
3099 def p_stream_operator_1(p
):
3100 '''stream_operator : K_LS '''
3102 print('stream_operator_1', list(p
))
3108 def p_stream_operator_2(p
):
3109 '''stream_operator : K_RS '''
3111 print('stream_operator_2', list(p
))
3117 def p_streaming_concatenation_1(p
):
3118 '''streaming_concatenation : '{' stream_operator '{' stream_expression_list '}' '}' '''
3120 print('streaming_concatenation_1', list(p
))
3123 # { /* streaming concatenation is a SystemVerilog thing. */
3124 # if (gn_system_verilog()) {
3125 # yyerror(@2, "sorry: Streaming concatenation not supported.");
3128 # yyerror(@2, "error: Streaming concatenation requires SystemVerilog");
3135 def p_task_declaration_1(p
):
3136 '''task_declaration : K_task lifetime_opt IDENTIFIER ';' _embed0_task_declaration task_item_list_opt statement_or_null_list_opt K_endtask _embed1_task_declaration endlabel_opt '''
3138 print('task_declaration_1', list(p
))
3141 # { // Last step: check any closing name. This is done late so
3142 # // that the parser can look ahead to detect the present
3143 # // endlabel_opt but still have the pform_endmodule() called
3144 # // early enough that the lexor can know we are outside the
3147 # if (strcmp(p[3],p[10]) != 0) {
3148 # yyerror(@10, "error: End label doesn't match task name");
3150 # if (! gn_system_verilog()) {
3151 # yyerror(@10, "error: Task end labels require "
3152 # "SystemVerilog.");
3161 def p_task_declaration_2(p
):
3162 '''task_declaration : K_task lifetime_opt IDENTIFIER '(' _embed2_task_declaration tf_port_list ')' ';' block_item_decls_opt statement_or_null_list_opt K_endtask _embed3_task_declaration endlabel_opt '''
3164 print('task_declaration_2', list(p
))
3167 # { // Last step: check any closing name. This is done late so
3168 # // that the parser can look ahead to detect the present
3169 # // endlabel_opt but still have the pform_endmodule() called
3170 # // early enough that the lexor can know we are outside the
3173 # if (strcmp(p[3],p[13]) != 0) {
3174 # yyerror(@13, "error: End label doesn't match task name");
3176 # if (! gn_system_verilog()) {
3177 # yyerror(@13, "error: Task end labels require "
3178 # "SystemVerilog.");
3187 def p_task_declaration_3(p
):
3188 '''task_declaration : K_task lifetime_opt IDENTIFIER '(' ')' ';' _embed4_task_declaration block_item_decls_opt statement_or_null_list K_endtask _embed5_task_declaration endlabel_opt '''
3190 print('task_declaration_3', list(p
))
3193 # { // Last step: check any closing name. This is done late so
3194 # // that the parser can look ahead to detect the present
3195 # // endlabel_opt but still have the pform_endmodule() called
3196 # // early enough that the lexor can know we are outside the
3199 # if (strcmp(p[3],p[12]) != 0) {
3200 # yyerror(@12, "error: End label doesn't match task name");
3202 # if (! gn_system_verilog()) {
3203 # yyerror(@12, "error: Task end labels require "
3204 # "SystemVerilog.");
3213 def p_task_declaration_4(p
):
3214 '''task_declaration : K_task lifetime_opt IDENTIFIER error K_endtask _embed6_task_declaration endlabel_opt '''
3216 print('task_declaration_4', list(p
))
3219 # { // Last step: check any closing name. This is done late so
3220 # // that the parser can look ahead to detect the present
3221 # // endlabel_opt but still have the pform_endmodule() called
3222 # // early enough that the lexor can know we are outside the
3225 # if (strcmp(p[3],p[7]) != 0) {
3226 # yyerror(@7, "error: End label doesn't match task name");
3228 # if (! gn_system_verilog()) {
3229 # yyerror(@7, "error: Task end labels require "
3230 # "SystemVerilog.");
3239 def p__embed0_task_declaration(p
):
3240 '''_embed0_task_declaration : '''
3243 # { assert(current_task == 0);
3244 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3249 def p__embed1_task_declaration(p
):
3250 '''_embed1_task_declaration : '''
3253 # { current_task->set_ports(p[6]);
3254 # current_task_set_statement(@3, p[7]);
3255 # pform_set_this_class(@3, current_task);
3256 # pform_pop_scope();
3258 # if (p[7] && p[7]->size() > 1 && !gn_system_verilog()) {
3259 # yyerror(@7, "error: Task body with multiple statements requires SystemVerilog.");
3266 def p__embed2_task_declaration(p
):
3267 '''_embed2_task_declaration : '''
3270 # { assert(current_task == 0);
3271 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3276 def p__embed3_task_declaration(p
):
3277 '''_embed3_task_declaration : '''
3280 # { current_task->set_ports(p[6]);
3281 # current_task_set_statement(@3, p[10]);
3282 # pform_set_this_class(@3, current_task);
3283 # pform_pop_scope();
3285 # if (p[10]) delete p[10];
3290 def p__embed4_task_declaration(p
):
3291 '''_embed4_task_declaration : '''
3294 # { assert(current_task == 0);
3295 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3300 def p__embed5_task_declaration(p
):
3301 '''_embed5_task_declaration : '''
3304 # { current_task->set_ports(0);
3305 # current_task_set_statement(@3, p[9]);
3306 # pform_set_this_class(@3, current_task);
3307 # if (! current_task->method_of()) {
3308 # cerr << @3 << ": warning: task definition for \"" << p[3]
3309 # << "\" has an empty port declaration list!" << endl;
3311 # pform_pop_scope();
3313 # if (p[9]->size() > 1 && !gn_system_verilog()) {
3314 # yyerror(@9, "error: Task body with multiple statements requires SystemVerilog.");
3321 def p__embed6_task_declaration(p
):
3322 '''_embed6_task_declaration : '''
3326 # if (current_task) {
3327 # pform_pop_scope();
3334 def p_tf_port_declaration_1(p
):
3335 '''tf_port_declaration : port_direction K_reg_opt unsigned_signed_opt dimensions_opt list_of_identifiers ';' '''
3337 print('tf_port_declaration_1', list(p
))
3340 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1],
3341 # p[2] ? IVL_VT_LOGIC :
3343 # p[3], p[4], p[5]);
3349 def p_tf_port_declaration_2(p
):
3350 '''tf_port_declaration : port_direction K_integer list_of_identifiers ';' '''
3352 print('tf_port_declaration_2', list(p
))
3355 # { list<pform_range_t>*range_stub = make_range_from_width(integer_width);
3356 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, true,
3357 # range_stub, p[3], true);
3363 def p_tf_port_declaration_3(p
):
3364 '''tf_port_declaration : port_direction K_time list_of_identifiers ';' '''
3366 print('tf_port_declaration_3', list(p
))
3369 # { list<pform_range_t>*range_stub = make_range_from_width(64);
3370 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, false,
3371 # range_stub, p[3]);
3377 def p_tf_port_declaration_4(p
):
3378 '''tf_port_declaration : port_direction real_or_realtime list_of_identifiers ';' '''
3380 print('tf_port_declaration_4', list(p
))
3383 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_REAL, true,
3390 def p_tf_port_declaration_5(p
):
3391 '''tf_port_declaration : port_direction K_string list_of_identifiers ';' '''
3393 print('tf_port_declaration_5', list(p
))
3396 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_STRING, true,
3403 def p_tf_port_item_1(p
):
3404 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER dimensions_opt tf_port_item_expr_opt '''
3406 print('tf_port_item_1', list(p
))
3409 # { vector<pform_tf_port_t>*tmp;
3410 # NetNet::PortType use_port_type = p[1];
3411 # if ((use_port_type == NetNet::PIMPLICIT) && (gn_system_verilog() || (p[2] == 0)))
3412 # use_port_type = port_declaration_context.port_type;
3413 # perm_string name = lex_strings.make(p[3]);
3414 # list<perm_string>* ilist = list_from_identifier(p[3]);
3416 # if (use_port_type == NetNet::PIMPLICIT) {
3417 # yyerror(@1, "error: missing task/function port direction.");
3418 # use_port_type = NetNet::PINPUT; // for error recovery
3420 # if ((p[2] == 0) && (p[1]==NetNet::PIMPLICIT)) {
3421 # // Detect special case this is an undecorated
3422 # // identifier and we need to get the declaration from
3425 # yyerror(@4, "internal error: How can there be an unpacked range here?\n");
3427 # tmp = pform_make_task_ports(@3, use_port_type,
3428 # port_declaration_context.data_type,
3432 # // Otherwise, the decorations for this identifier
3433 # // indicate the type. Save the type for any right
3434 # // context that may come later.
3435 # port_declaration_context.port_type = use_port_type;
3437 # p[2] = new vector_type_t(IVL_VT_LOGIC, false, 0);
3438 # FILE_NAME(p[2], @3);
3440 # port_declaration_context.data_type = p[2];
3441 # tmp = pform_make_task_ports(@3, use_port_type, p[2], ilist);
3444 # pform_set_reg_idx(name, p[4]);
3449 # assert(tmp->size()==1);
3450 # tmp->front().defe = p[5];
3456 def p_tf_port_item_2(p
):
3457 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER error '''
3459 print('tf_port_item_2', list(p
))
3462 # { yyerror(@3, "error: Error in task/function port item after port name %s.", p[3]);
3469 def p_tf_port_item_expr_opt_1(p
):
3470 '''tf_port_item_expr_opt : '=' expression '''
3472 print('tf_port_item_expr_opt_1', list(p
))
3475 # { if (! gn_system_verilog()) {
3476 # yyerror(@1, "error: Task/function default arguments require "
3477 # "SystemVerilog.");
3484 def p_tf_port_item_expr_opt_2(p
):
3485 '''tf_port_item_expr_opt : '''
3487 print('tf_port_item_expr_opt_2', list(p
))
3494 def p_tf_port_list_1(p
):
3495 '''tf_port_list : _embed0_tf_port_list tf_port_item_list '''
3497 print('tf_port_list_1', list(p
))
3504 def p__embed0_tf_port_list(p
):
3505 '''_embed0_tf_port_list : '''
3508 # { port_declaration_context.port_type = gn_system_verilog() ? NetNet::PINPUT : NetNet::PIMPLICIT;
3509 # port_declaration_context.data_type = 0;
3514 def p_tf_port_item_list_1(p
):
3515 '''tf_port_item_list : tf_port_item_list ',' tf_port_item '''
3517 print('tf_port_item_list_1', list(p
))
3520 # { vector<pform_tf_port_t>*tmp;
3521 # if (p[1] && p[3]) {
3522 # size_t s1 = p[1]->size();
3524 # tmp->resize(tmp->size()+p[3]->size());
3525 # for (size_t idx = 0 ; idx < p[3]->size() ; idx += 1)
3526 # tmp->at(s1+idx) = p[3]->at(idx);
3528 # } else if (p[1]) {
3538 def p_tf_port_item_list_2(p
):
3539 '''tf_port_item_list : tf_port_item '''
3541 print('tf_port_item_list_2', list(p
))
3548 def p_tf_port_item_list_3(p
):
3549 '''tf_port_item_list : error ',' tf_port_item '''
3551 print('tf_port_item_list_3', list(p
))
3554 # { yyerror(@2, "error: Syntax error in task/function port declaration.");
3560 def p_tf_port_item_list_4(p
):
3561 '''tf_port_item_list : tf_port_item_list ',' '''
3563 print('tf_port_item_list_4', list(p
))
3566 # { yyerror(@2, "error: NULL port declarations are not allowed.");
3572 def p_tf_port_item_list_5(p
):
3573 '''tf_port_item_list : tf_port_item_list ';' '''
3575 print('tf_port_item_list_5', list(p
))
3578 # { yyerror(@2, "error: ';' is an invalid port declaration separator.");
3584 def p_timeunits_declaration_1(p
):
3585 '''timeunits_declaration : K_timeunit TIME_LITERAL ';' '''
3587 print('timeunits_declaration_1', list(p
))
3590 # { pform_set_timeunit(p[2], allow_timeunit_decl); }
3594 def p_timeunits_declaration_2(p
):
3595 '''timeunits_declaration : K_timeunit TIME_LITERAL '/' TIME_LITERAL ';' '''
3597 print('timeunits_declaration_2', list(p
))
3600 # { bool initial_decl = allow_timeunit_decl && allow_timeprec_decl;
3601 # pform_set_timeunit(p[2], initial_decl);
3602 # pform_set_timeprec(p[4], initial_decl);
3607 def p_timeunits_declaration_3(p
):
3608 '''timeunits_declaration : K_timeprecision TIME_LITERAL ';' '''
3610 print('timeunits_declaration_3', list(p
))
3613 # { pform_set_timeprec(p[2], allow_timeprec_decl); }
3617 def p_timeunits_declaration_opt_1(p
):
3618 '''timeunits_declaration_opt : %prec no_timeunits_declaration '''
3619 if(parse_debug
> 2):
3620 print('timeunits_declaration_opt_1', list(p
))
3626 def p_timeunits_declaration_opt_2(p
):
3627 '''timeunits_declaration_opt : timeunits_declaration %prec one_timeunits_declaration '''
3629 print('timeunits_declaration_opt_2', list(p
))
3635 def p_timeunits_declaration_opt_3(p
):
3636 '''timeunits_declaration_opt : timeunits_declaration timeunits_declaration '''
3638 print('timeunits_declaration_opt_3', list(p
))
3644 def p_value_range_1(p
):
3645 '''value_range : expression '''
3647 print('value_range_1', list(p
))
3654 def p_value_range_2(p
):
3655 '''value_range : '[' expression ':' expression ']' '''
3657 print('value_range_2', list(p
))
3664 def p_variable_dimension_1(p
):
3665 '''variable_dimension : '[' expression ':' expression ']' '''
3667 print('variable_dimension_1', list(p
))
3668 # { list<pform_range_t> *tmp = new list<pform_range_t>;
3669 # pform_range_t index (p[2],p[4]);
3670 # tmp->push_back(index);
3673 # XXX TODO: subscriptlist
3676 if end
.endswith("-1"):
3679 end
= str(int(end
)+1)
3682 p
[0] = '[%s:%s]' % (start
, end
) # python slice is LO:HI+1
3688 def p_variable_dimension_2(p
):
3689 '''variable_dimension : '[' expression ']' '''
3691 print('variable_dimension_2', list(p
))
3694 # { // SystemVerilog canonical range
3695 # if (!gn_system_verilog()) {
3697 # cerr << @2 << ": warning: Use of SystemVerilog [size] dimension. "
3698 # << "Use at least -g2005-sv to remove this warning." << endl;
3700 # list<pform_range_t> *tmp = new list<pform_range_t>;
3701 # pform_range_t index;
3702 # index.first = new PENumber(new verinum((uint64_t)0, integer_width));
3703 # index.second = new PEBinary('-', p[2], new PENumber(new verinum((uint64_t)1, integer_width)));
3704 # tmp->push_back(index);
3710 def p_variable_dimension_3(p
):
3711 '''variable_dimension : '[' ']' '''
3713 print('variable_dimension_3', list(p
))
3716 # { list<pform_range_t> *tmp = new list<pform_range_t>;
3717 # pform_range_t index (0,0);
3718 # tmp->push_back(index);
3724 def p_variable_dimension_4(p
):
3725 '''variable_dimension : '[' '$' ']' '''
3727 print('variable_dimension_4', list(p
))
3730 # { // SystemVerilog queue
3731 # list<pform_range_t> *tmp = new list<pform_range_t>;
3732 # pform_range_t index (new PENull,0);
3733 # if (!gn_system_verilog()) {
3734 # yyerror("error: Queue declarations require SystemVerilog.");
3736 # tmp->push_back(index);
3742 def p_variable_lifetime_1(p
):
3743 '''variable_lifetime : lifetime '''
3745 print('variable_lifetime_1', list(p
))
3748 # { if (!gn_system_verilog()) {
3749 # yyerror(@1, "error: overriding the default variable lifetime "
3750 # "requires SystemVerilog.");
3751 # } else if (p[1] != pform_peek_scope()->default_lifetime) {
3752 # yyerror(@1, "sorry: overriding the default variable lifetime "
3753 # "is not yet supported.");
3755 # var_lifetime = p[1];
3760 def p_attribute_list_opt_1(p
):
3761 '''attribute_list_opt : attribute_instance_list '''
3763 print('attribute_list_opt_1', list(p
))
3770 def p_attribute_list_opt_2(p
):
3771 '''attribute_list_opt : '''
3772 if(parse_debug
> 2):
3773 print('attribute_list_opt_2', list(p
))
3780 def p_attribute_instance_list_1(p
):
3781 '''attribute_instance_list : K_PSTAR K_STARP '''
3783 print('attribute_instance_list_1', list(p
))
3790 def p_attribute_instance_list_2(p
):
3791 '''attribute_instance_list : K_PSTAR attribute_list K_STARP '''
3793 print('attribute_instance_list_2', list(p
))
3800 def p_attribute_instance_list_3(p
):
3801 '''attribute_instance_list : attribute_instance_list K_PSTAR K_STARP '''
3803 print('attribute_instance_list_3', list(p
))
3810 def p_attribute_instance_list_4(p
):
3811 '''attribute_instance_list : attribute_instance_list K_PSTAR attribute_list K_STARP '''
3813 print('attribute_instance_list_4', list(p
))
3816 # { list<named_pexpr_t>*tmp = p[1];
3818 # tmp->splice(tmp->end(), *p[3]);
3821 # } else p[0] = p[3];
3826 def p_attribute_list_1(p
):
3827 '''attribute_list : attribute_list ',' attribute '''
3829 print('attribute_list_1', list(p
))
3832 # { list<named_pexpr_t>*tmp = p[1];
3833 # tmp->push_back(*p[3]);
3840 def p_attribute_list_2(p
):
3841 '''attribute_list : attribute '''
3843 print('attribute_list_2', list(p
))
3846 # { list<named_pexpr_t>*tmp = new list<named_pexpr_t>;
3847 # tmp->push_back(*p[1]);
3854 def p_attribute_1(p
):
3855 '''attribute : IDENTIFIER '''
3857 print('attribute_1', list(p
))
3860 # { named_pexpr_t*tmp = new named_pexpr_t;
3861 # tmp->name = lex_strings.make(p[1]);
3869 def p_attribute_2(p
):
3870 '''attribute : IDENTIFIER '=' expression '''
3872 print('attribute_2', list(p
))
3875 # { PExpr*tmp = p[3];
3876 # named_pexpr_t*tmp2 = new named_pexpr_t;
3877 # tmp2->name = lex_strings.make(p[1]);
3885 def p_block_item_decl_1(p
):
3886 '''block_item_decl : data_type register_variable_list ';' '''
3888 print('block_item_decl_1', list(p
))
3891 # { if (p[1]) pform_set_data_type(@1, p[1], p[2], NetNet::REG, attributes_in_context);
3896 def p_block_item_decl_2(p
):
3897 '''block_item_decl : variable_lifetime data_type register_variable_list ';' '''
3899 print('block_item_decl_2', list(p
))
3902 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
3903 # var_lifetime = LexicalScope::INHERITED;
3908 def p_block_item_decl_3(p
):
3909 '''block_item_decl : K_reg data_type register_variable_list ';' '''
3911 print('block_item_decl_3', list(p
))
3914 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
3919 def p_block_item_decl_4(p
):
3920 '''block_item_decl : variable_lifetime K_reg data_type register_variable_list ';' '''
3922 print('block_item_decl_4', list(p
))
3925 # { if (p[3]) pform_set_data_type(@3, p[3], p[4], NetNet::REG, attributes_in_context);
3926 # var_lifetime = LexicalScope::INHERITED;
3931 def p_block_item_decl_5(p
):
3932 '''block_item_decl : K_event event_variable_list ';' '''
3934 print('block_item_decl_5', list(p
))
3937 # { if (p[2]) pform_make_events(p[2], @1.text, @1.first_line);
3942 def p_block_item_decl_6(p
):
3943 '''block_item_decl : K_parameter param_type parameter_assign_list ';' '''
3945 print('block_item_decl_6', list(p
))
3951 def p_block_item_decl_7(p
):
3952 '''block_item_decl : K_localparam param_type localparam_assign_list ';' '''
3954 print('block_item_decl_7', list(p
))
3960 def p_block_item_decl_8(p
):
3961 '''block_item_decl : type_declaration '''
3963 print('block_item_decl_8', list(p
))
3969 def p_block_item_decl_9(p
):
3970 '''block_item_decl : K_integer error ';' '''
3972 print('block_item_decl_9', list(p
))
3975 # { yyerror(@1, "error: syntax error in integer variable list.");
3981 def p_block_item_decl_10(p
):
3982 '''block_item_decl : K_time error ';' '''
3984 print('block_item_decl_10', list(p
))
3987 # { yyerror(@1, "error: syntax error in time variable list.");
3993 def p_block_item_decl_11(p
):
3994 '''block_item_decl : K_parameter error ';' '''
3996 print('block_item_decl_11', list(p
))
3999 # { yyerror(@1, "error: syntax error in parameter list.");
4005 def p_block_item_decl_12(p
):
4006 '''block_item_decl : K_localparam error ';' '''
4008 print('block_item_decl_12', list(p
))
4011 # { yyerror(@1, "error: syntax error localparam list.");
4017 def p_block_item_decls_1(p
):
4018 '''block_item_decls : block_item_decl '''
4020 print('block_item_decls_1', list(p
))
4026 def p_block_item_decls_2(p
):
4027 '''block_item_decls : block_item_decls block_item_decl '''
4029 print('block_item_decls_2', list(p
))
4035 def p_block_item_decls_opt_1(p
):
4036 '''block_item_decls_opt : block_item_decls '''
4038 print('block_item_decls_opt_1', list(p
))
4045 def p_block_item_decls_opt_2(p
):
4046 '''block_item_decls_opt : '''
4048 print('block_item_decls_opt_2', list(p
))
4055 def p_type_declaration_1(p
):
4056 '''type_declaration : K_typedef data_type IDENTIFIER dimensions_opt ';' '''
4058 print('type_declaration_1', list(p
))
4061 # { perm_string name = lex_strings.make(p[3]);
4062 # pform_set_typedef(name, p[2], p[4]);
4068 def p_type_declaration_2(p
):
4069 '''type_declaration : K_typedef data_type TYPE_IDENTIFIER ';' '''
4071 print('type_declaration_2', list(p
))
4074 # { perm_string name = lex_strings.make(p[3].text);
4075 # if (pform_test_type_identifier_local(name)) {
4076 # yyerror(@3, "error: Typedef identifier \"%s\" is already a type name.", p[3].text);
4079 # pform_set_typedef(name, p[2], NULL);
4081 # delete[]p[3].text;
4086 def p_type_declaration_3(p
):
4087 '''type_declaration : K_typedef K_class IDENTIFIER ';' '''
4089 print('type_declaration_3', list(p
))
4092 # { // Create a synthetic typedef for the class name so that the
4093 # // lexor detects the name as a type.
4094 # perm_string name = lex_strings.make(p[3]);
4095 # class_type_t*tmp = new class_type_t(name);
4096 # FILE_NAME(tmp, @3);
4097 # pform_set_typedef(name, tmp, NULL);
4103 def p_type_declaration_4(p
):
4104 '''type_declaration : K_typedef K_enum IDENTIFIER ';' '''
4106 print('type_declaration_4', list(p
))
4109 # { yyerror(@1, "sorry: Enum forward declarations not supported yet."); }
4113 def p_type_declaration_5(p
):
4114 '''type_declaration : K_typedef K_struct IDENTIFIER ';' '''
4116 print('type_declaration_5', list(p
))
4119 # { yyerror(@1, "sorry: Struct forward declarations not supported yet."); }
4123 def p_type_declaration_6(p
):
4124 '''type_declaration : K_typedef K_union IDENTIFIER ';' '''
4126 print('type_declaration_6', list(p
))
4129 # { yyerror(@1, "sorry: Union forward declarations not supported yet."); }
4133 def p_type_declaration_7(p
):
4134 '''type_declaration : K_typedef IDENTIFIER ';' '''
4136 print('type_declaration_7', list(p
))
4139 # { // Create a synthetic typedef for the class name so that the
4140 # // lexor detects the name as a type.
4141 # perm_string name = lex_strings.make(p[2]);
4142 # class_type_t*tmp = new class_type_t(name);
4143 # FILE_NAME(tmp, @2);
4144 # pform_set_typedef(name, tmp, NULL);
4150 def p_type_declaration_8(p
):
4151 '''type_declaration : K_typedef error ';' '''
4153 print('type_declaration_8', list(p
))
4156 # { yyerror(@2, "error: Syntax error in typedef clause.");
4162 def p_enum_data_type_1(p
):
4163 '''enum_data_type : K_enum '{' enum_name_list '}' '''
4165 print('enum_data_type_1', list(p
))
4168 # { enum_type_t*enum_type = new enum_type_t;
4169 # FILE_NAME(enum_type, @1);
4170 # enum_type->names .reset(p[3]);
4171 # enum_type->base_type = IVL_VT_BOOL;
4172 # enum_type->signed_flag = true;
4173 # enum_type->integer_flag = false;
4174 # enum_type->range.reset(make_range_from_width(32));
4180 def p_enum_data_type_2(p
):
4181 '''enum_data_type : K_enum atom2_type signed_unsigned_opt '{' enum_name_list '}' '''
4183 print('enum_data_type_2', list(p
))
4186 # { enum_type_t*enum_type = new enum_type_t;
4187 # FILE_NAME(enum_type, @1);
4188 # enum_type->names .reset(p[5]);
4189 # enum_type->base_type = IVL_VT_BOOL;
4190 # enum_type->signed_flag = p[3];
4191 # enum_type->integer_flag = false;
4192 # enum_type->range.reset(make_range_from_width(p[2]));
4198 def p_enum_data_type_3(p
):
4199 '''enum_data_type : K_enum K_integer signed_unsigned_opt '{' enum_name_list '}' '''
4201 print('enum_data_type_3', list(p
))
4204 # { enum_type_t*enum_type = new enum_type_t;
4205 # FILE_NAME(enum_type, @1);
4206 # enum_type->names .reset(p[5]);
4207 # enum_type->base_type = IVL_VT_LOGIC;
4208 # enum_type->signed_flag = p[3];
4209 # enum_type->integer_flag = true;
4210 # enum_type->range.reset(make_range_from_width(integer_width));
4216 def p_enum_data_type_4(p
):
4217 '''enum_data_type : K_enum K_logic unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
4219 print('enum_data_type_4', list(p
))
4222 # { enum_type_t*enum_type = new enum_type_t;
4223 # FILE_NAME(enum_type, @1);
4224 # enum_type->names .reset(p[6]);
4225 # enum_type->base_type = IVL_VT_LOGIC;
4226 # enum_type->signed_flag = p[3];
4227 # enum_type->integer_flag = false;
4228 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
4234 def p_enum_data_type_5(p
):
4235 '''enum_data_type : K_enum K_reg unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
4237 print('enum_data_type_5', list(p
))
4240 # { enum_type_t*enum_type = new enum_type_t;
4241 # FILE_NAME(enum_type, @1);
4242 # enum_type->names .reset(p[6]);
4243 # enum_type->base_type = IVL_VT_LOGIC;
4244 # enum_type->signed_flag = p[3];
4245 # enum_type->integer_flag = false;
4246 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
4252 def p_enum_data_type_6(p
):
4253 '''enum_data_type : K_enum K_bit unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
4255 print('enum_data_type_6', list(p
))
4258 # { enum_type_t*enum_type = new enum_type_t;
4259 # FILE_NAME(enum_type, @1);
4260 # enum_type->names .reset(p[6]);
4261 # enum_type->base_type = IVL_VT_BOOL;
4262 # enum_type->signed_flag = p[3];
4263 # enum_type->integer_flag = false;
4264 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
4270 def p_enum_name_list_1(p
):
4271 '''enum_name_list : enum_name '''
4273 print('enum_name_list_1', list(p
))
4281 def p_enum_name_list_2(p
):
4282 '''enum_name_list : enum_name_list ',' enum_name '''
4284 print('enum_name_list_2', list(p
))
4287 # { list<named_pexpr_t>*lst = p[1];
4288 # lst->splice(lst->end(), *p[3]);
4295 def p_pos_neg_number_1(p
):
4296 '''pos_neg_number : number '''
4298 print('pos_neg_number_1', list(p
))
4306 def p_pos_neg_number_2(p
):
4307 '''pos_neg_number : '-' number '''
4309 print('pos_neg_number_2', list(p
))
4312 # { verinum tmp = -(*(p[2]));
4319 def p_enum_name_1(p
):
4320 '''enum_name : IDENTIFIER '''
4322 print('enum_name_1', list(p
))
4325 # { perm_string name = lex_strings.make(p[1]);
4327 # p[0] = make_named_number(name);
4332 def p_enum_name_2(p
):
4333 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '''
4335 print('enum_name_2', list(p
))
4338 # { perm_string name = lex_strings.make(p[1]);
4339 # long count = check_enum_seq_value(@1, p[3], false);
4341 # p[0] = make_named_numbers(name, 0, count-1);
4347 def p_enum_name_3(p
):
4348 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '''
4350 print('enum_name_3', list(p
))
4353 # { perm_string name = lex_strings.make(p[1]);
4354 # p[0] = make_named_numbers(name, check_enum_seq_value(@1, p[3], true),
4355 # check_enum_seq_value(@1, p[5], true));
4363 def p_enum_name_4(p
):
4364 '''enum_name : IDENTIFIER '=' expression '''
4366 print('enum_name_4', list(p
))
4369 # { perm_string name = lex_strings.make(p[1]);
4371 # p[0] = make_named_number(name, p[3]);
4376 def p_enum_name_5(p
):
4377 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '=' expression '''
4379 print('enum_name_5', list(p
))
4382 # { perm_string name = lex_strings.make(p[1]);
4383 # long count = check_enum_seq_value(@1, p[3], false);
4384 # p[0] = make_named_numbers(name, 0, count-1, p[6]);
4391 def p_enum_name_6(p
):
4392 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '=' expression '''
4394 print('enum_name_6', list(p
))
4397 # { perm_string name = lex_strings.make(p[1]);
4398 # p[0] = make_named_numbers(name, check_enum_seq_value(@1, p[3], true),
4399 # check_enum_seq_value(@1, p[5], true), p[8]);
4407 def p_struct_data_type_1(p
):
4408 '''struct_data_type : K_struct K_packed_opt '{' struct_union_member_list '}' '''