From d554fd666d026a3f829d2d4aaf31b33eeb5fb3fa Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 25 Apr 2019 17:31:16 +0100 Subject: [PATCH] start adding in module parameters --- parse_sv.py | 118 ++++++++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 54 deletions(-) diff --git a/parse_sv.py b/parse_sv.py index 39fe14b..82cb55e 100644 --- a/parse_sv.py +++ b/parse_sv.py @@ -167,7 +167,7 @@ def p_class_declaration_endlabel_opt_1(p): def p_class_declaration_endlabel_opt_2(p): '''class_declaration_endlabel_opt : ':' IDENTIFIER ''' print('class_declaration_endlabel_opt_2', list(p)) - # { $$ = $2; } + p[0] = p[2] () def p_class_declaration_endlabel_opt_3(p): '''class_declaration_endlabel_opt : ''' @@ -341,12 +341,12 @@ def p_class_item_qualifier_list_1(p): def p_class_item_qualifier_list_2(p): '''class_item_qualifier_list : class_item_qualifier ''' print('class_item_qualifier_list_2', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_class_item_qualifier_opt_1(p): '''class_item_qualifier_opt : class_item_qualifier_list ''' print('class_item_qualifier_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_class_item_qualifier_opt_2(p): '''class_item_qualifier_opt : ''' @@ -521,7 +521,7 @@ def p_data_type_3(p): def p_data_type_4(p): '''data_type : enum_data_type ''' print('data_type_4', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_data_type_5(p): '''data_type : atom2_type signed_unsigned_opt ''' @@ -584,7 +584,7 @@ def p__embed0_data_type(p): def p_data_type_or_implicit_1(p): '''data_type_or_implicit : data_type ''' print('data_type_or_implicit_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_data_type_or_implicit_2(p): '''data_type_or_implicit : signing dimensions_opt ''' @@ -612,7 +612,7 @@ def p_data_type_or_implicit_4(p): def p_data_type_or_implicit_or_void_1(p): '''data_type_or_implicit_or_void : data_type_or_implicit ''' print('data_type_or_implicit_or_void_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_data_type_or_implicit_or_void_2(p): '''data_type_or_implicit_or_void : K_void ''' @@ -705,7 +705,7 @@ def p_for_step_2(p): def p_for_step_3(p): '''for_step : compressed_statement ''' print('for_step_3', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_function_declaration_1(p): '''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 ''' @@ -937,7 +937,7 @@ def p_lifetime_2(p): def p_lifetime_opt_1(p): '''lifetime_opt : lifetime ''' print('lifetime_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_lifetime_opt_2(p): '''lifetime_opt : ''' @@ -1348,6 +1348,8 @@ def p_number_1(p): def p_number_2(p): '''number : DEC_NUMBER ''' print('number_2', list(p)) + num = Leaf(token.NUMBER, "%s" % (p[1])) + p[0] = num # { $$ = $1; based_size = 0;} () def p_number_3(p): @@ -1518,7 +1520,7 @@ def p_port_direction_4(p): def p_port_direction_opt_1(p): '''port_direction_opt : port_direction ''' print('port_direction_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_port_direction_opt_2(p): '''port_direction_opt : ''' @@ -1561,7 +1563,7 @@ def p_property_qualifier_2(p): def p_property_qualifier_opt_1(p): '''property_qualifier_opt : property_qualifier_list ''' print('property_qualifier_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_property_qualifier_opt_2(p): '''property_qualifier_opt : ''' @@ -1576,7 +1578,7 @@ def p_property_qualifier_list_1(p): def p_property_qualifier_list_2(p): '''property_qualifier_list : property_qualifier ''' print('property_qualifier_list_2', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_property_spec_1(p): '''property_spec : clocking_event_opt property_spec_disable_iff_opt property_expr ''' @@ -1705,7 +1707,7 @@ def p_statement_1(p): def p_statement_or_null_1(p): '''statement_or_null : statement ''' print('statement_or_null_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_statement_or_null_2(p): '''statement_or_null : attribute_list_opt ';' ''' @@ -2014,7 +2016,7 @@ def p_tf_port_item_expr_opt_2(p): def p_tf_port_list_1(p): '''tf_port_list : _embed0_tf_port_list tf_port_item_list ''' print('tf_port_list_1', list(p)) - # { $$ = $2; } + p[0] = p[2] () def p__embed0_tf_port_list(p): '''_embed0_tf_port_list : ''' @@ -2044,7 +2046,7 @@ def p_tf_port_item_list_1(p): def p_tf_port_item_list_2(p): '''tf_port_item_list : tf_port_item ''' print('tf_port_item_list_2', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_tf_port_item_list_3(p): '''tf_port_item_list : error ',' tf_port_item ''' @@ -2171,7 +2173,7 @@ def p_variable_lifetime_1(p): def p_attribute_list_opt_1(p): '''attribute_list_opt : attribute_instance_list ''' print('attribute_list_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_attribute_list_opt_2(p): '''attribute_list_opt : ''' @@ -2186,12 +2188,12 @@ def p_attribute_instance_list_1(p): def p_attribute_instance_list_2(p): '''attribute_instance_list : K_PSTAR attribute_list K_STARP ''' print('attribute_instance_list_2', list(p)) - # { $$ = $2; } + p[0] = p[2] () def p_attribute_instance_list_3(p): '''attribute_instance_list : attribute_instance_list K_PSTAR K_STARP ''' print('attribute_instance_list_3', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_attribute_instance_list_4(p): '''attribute_instance_list : attribute_instance_list K_PSTAR attribute_list K_STARP ''' @@ -2791,7 +2793,7 @@ def p_delay3_4(p): def p_delay3_opt_1(p): '''delay3_opt : delay3 ''' print('delay3_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_delay3_opt_2(p): '''delay3_opt : ''' @@ -3086,7 +3088,7 @@ def p_drive_strength_6(p): def p_drive_strength_opt_1(p): '''drive_strength_opt : drive_strength ''' print('drive_strength_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_drive_strength_opt_2(p): '''drive_strength_opt : ''' @@ -3171,7 +3173,7 @@ def p_event_control_3(p): def p_event_expression_list_1(p): '''event_expression_list : event_expression ''' print('event_expression_list_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_event_expression_list_2(p): '''event_expression_list : event_expression_list K_or event_expression ''' @@ -3235,17 +3237,17 @@ def p_expression_1(p): '''expression : expr_primary_or_typename ''' print('expression_1', list(p)) p[0] = p[1] - # { $$ = $1; } + p[0] = p[1] () def p_expression_2(p): '''expression : inc_or_dec_expression ''' print('expression_2', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_expression_3(p): '''expression : inside_expression ''' print('expression_3', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_expression_4(p): '''expression : '+' attribute_list_opt expr_primary %prec UNARY_PREC ''' @@ -3591,7 +3593,7 @@ def p_expression_46(p): def p_expr_mintypmax_1(p): '''expr_mintypmax : expression ''' print('expr_mintypmax_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_expr_mintypmax_2(p): '''expr_mintypmax : expression ':' expression ':' expression ''' @@ -4066,7 +4068,7 @@ def p_expr_primary_38(p): def p_expr_primary_39(p): '''expr_primary : '(' expr_mintypmax ')' ''' print('expr_primary_39', list(p)) - # { $$ = $2; } + p[0] = p[2] () def p_expr_primary_40(p): '''expr_primary : '{' expression_list_proper '}' ''' @@ -4146,12 +4148,12 @@ def p_expr_primary_45(p): def p_expr_primary_46(p): '''expr_primary : assignment_pattern ''' print('expr_primary_46', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_expr_primary_47(p): '''expr_primary : streaming_concatenation ''' print('expr_primary_47', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_expr_primary_48(p): '''expr_primary : K_null ''' @@ -4164,7 +4166,7 @@ def p_expr_primary_48(p): def p_function_item_list_opt_1(p): '''function_item_list_opt : function_item_list ''' print('function_item_list_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_function_item_list_opt_2(p): '''function_item_list_opt : ''' @@ -4174,7 +4176,7 @@ def p_function_item_list_opt_2(p): def p_function_item_list_1(p): '''function_item_list : function_item ''' print('function_item_list_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_function_item_list_2(p): '''function_item_list : function_item_list function_item ''' @@ -4198,7 +4200,7 @@ def p_function_item_list_2(p): def p_function_item_1(p): '''function_item : tf_port_declaration ''' print('function_item_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_function_item_2(p): '''function_item : block_item_decl ''' @@ -4820,7 +4822,7 @@ def p_port_declaration_7(p): def p_net_type_opt_1(p): '''net_type_opt : net_type ''' print('net_type_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_net_type_opt_2(p): '''net_type_opt : ''' @@ -4939,7 +4941,7 @@ def p_cont_assign_list_1(p): def p_cont_assign_list_2(p): '''cont_assign_list : cont_assign ''' print('cont_assign_list_2', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_module_1(p): '''module : attribute_list_opt module_start lifetime_opt IDENTIFIER _embed0_module module_package_import_list_opt module_parameter_port_list_opt module_port_list_opt module_attribute_foreign ';' _embed1_module timeunits_declaration_opt _embed2_module module_item_list_opt module_end _embed3_module endlabel_opt ''' @@ -5083,7 +5085,7 @@ def p_module_end_3(p): def p_endlabel_opt_1(p): '''endlabel_opt : ':' IDENTIFIER ''' print('endlabel_opt_1', list(p)) - # { $$ = $2; } + p[0] = p[2] () def p_endlabel_opt_2(p): '''endlabel_opt : ''' @@ -5103,12 +5105,12 @@ def p_module_attribute_foreign_2(p): def p_module_port_list_opt_1(p): '''module_port_list_opt : '(' list_of_ports ')' ''' print('module_port_list_opt_1', list(p)) - # { $$ = $2; } + p[0] = p[2] () def p_module_port_list_opt_2(p): '''module_port_list_opt : '(' list_of_port_declarations ')' ''' print('module_port_list_opt_2', list(p)) - # { $$ = $2; } + p[0] = p[2] () def p_module_port_list_opt_3(p): '''module_port_list_opt : ''' @@ -5130,18 +5132,23 @@ def p_module_parameter_port_list_opt_1(p): def p_module_parameter_port_list_opt_2(p): '''module_parameter_port_list_opt : '#' '(' module_parameter_port_list ')' ''' print('module_parameter_port_list_opt_2', list(p)) + p[0] = p[2] () def p_module_parameter_port_list_1(p): '''module_parameter_port_list : K_parameter param_type parameter_assign ''' print('module_parameter_port_list_1', list(p)) + p[0] = [p[3]] () def p_module_parameter_port_list_2(p): '''module_parameter_port_list : module_parameter_port_list ',' parameter_assign ''' print('module_parameter_port_list_2', list(p)) + p[0] = p[1].append(p[3]) () def p_module_parameter_port_list_3(p): '''module_parameter_port_list : module_parameter_port_list ',' K_parameter param_type parameter_assign ''' print('module_parameter_port_list_3', list(p)) + p[1].append(p[5]) + p[0] = p[1] () def p_module_item_1(p): '''module_item : module ''' @@ -5977,6 +5984,9 @@ def p_localparam_assign_list_2(p): def p_parameter_assign_1(p): '''parameter_assign : IDENTIFIER '=' expression parameter_value_ranges_opt ''' print('parameter_assign_1', list(p)) + tpname = Node(syms.tname, [Leaf(token.NAME, p[1])]) + expr = Node(syms.tfpdef, [tpname, Leaf(token.EQUAL, p[2]), p[3] ]) + p[0] = expr # { PExpr*tmp = $3; # pform_set_parameter(@1, lex_strings.make($1), param_active_type, # param_active_signed, param_active_range, tmp, $4); @@ -5995,7 +6005,7 @@ def p_localparam_assign_1(p): def p_parameter_value_ranges_opt_1(p): '''parameter_value_ranges_opt : parameter_value_ranges ''' print('parameter_value_ranges_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_parameter_value_ranges_opt_2(p): '''parameter_value_ranges_opt : ''' @@ -6040,7 +6050,7 @@ def p_parameter_value_range_5(p): def p_value_range_expression_1(p): '''value_range_expression : expression ''' print('value_range_expression_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_value_range_expression_2(p): '''value_range_expression : K_inf ''' @@ -6168,7 +6178,7 @@ def p_parameter_value_byname_list_2(p): def p_port_1(p): '''port : port_reference ''' print('port_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_port_2(p): '''port : '.' IDENTIFIER '(' port_reference ')' ''' @@ -6199,7 +6209,7 @@ def p_port_4(p): def p_port_opt_1(p): '''port_opt : port ''' print('port_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_port_opt_2(p): '''port_opt : ''' @@ -6350,7 +6360,7 @@ def p_port_reference_4(p): def p_port_reference_list_1(p): '''port_reference_list : port_reference ''' print('port_reference_list_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_port_reference_list_2(p): '''port_reference_list : port_reference_list ',' port_reference ''' @@ -6369,12 +6379,12 @@ def p_dimensions_opt_1(p): def p_dimensions_opt_2(p): '''dimensions_opt : dimensions ''' print('dimensions_opt_2', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_dimensions_1(p): '''dimensions : variable_dimension ''' print('dimensions_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_dimensions_2(p): '''dimensions : dimensions variable_dimension ''' @@ -7194,17 +7204,17 @@ def p_statement_item_13(p): def p_statement_item_14(p): '''statement_item : procedural_assertion_statement ''' print('statement_item_14', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_statement_item_15(p): '''statement_item : loop_statement ''' print('statement_item_15', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_statement_item_16(p): '''statement_item : jump_statement ''' print('statement_item_16', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_statement_item_17(p): '''statement_item : K_case '(' expression ')' case_items K_endcase ''' @@ -7278,7 +7288,7 @@ def p_statement_item_26(p): def p_statement_item_27(p): '''statement_item : compressed_statement ';' ''' print('statement_item_27', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_statement_item_28(p): '''statement_item : inc_or_dec_expression ';' ''' @@ -7708,7 +7718,7 @@ def p_compressed_statement_11(p): def p_statement_or_null_list_opt_1(p): '''statement_or_null_list_opt : statement_or_null_list ''' print('statement_or_null_list_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_statement_or_null_list_opt_2(p): '''statement_or_null_list_opt : ''' @@ -7744,7 +7754,7 @@ def p_task_item_1(p): def p_task_item_2(p): '''task_item : tf_port_declaration ''' print('task_item_2', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_task_item_list_1(p): '''task_item_list : task_item_list task_item ''' @@ -7761,12 +7771,12 @@ def p_task_item_list_1(p): def p_task_item_list_2(p): '''task_item_list : task_item ''' print('task_item_list_2', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_task_item_list_opt_1(p): '''task_item_list_opt : task_item_list ''' print('task_item_list_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_task_item_list_opt_2(p): '''task_item_list_opt : ''' @@ -7776,7 +7786,7 @@ def p_task_item_list_opt_2(p): def p_tf_port_list_opt_1(p): '''tf_port_list_opt : tf_port_list ''' print('tf_port_list_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_tf_port_list_opt_2(p): '''tf_port_list_opt : ''' @@ -7892,7 +7902,7 @@ def p_udp_initial_1(p): def p_udp_init_opt_1(p): '''udp_init_opt : udp_initial ''' print('udp_init_opt_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_udp_init_opt_2(p): '''udp_init_opt : ''' @@ -8106,7 +8116,7 @@ def p_udp_port_decl_4(p): def p_udp_port_decls_1(p): '''udp_port_decls : udp_port_decl ''' print('udp_port_decls_1', list(p)) - # { $$ = $1; } + p[0] = p[1] () def p_udp_port_decls_2(p): '''udp_port_decls : udp_port_decls udp_port_decl ''' @@ -8151,7 +8161,7 @@ def p_udp_reg_opt_2(p): def p_udp_initial_expr_opt_1(p): '''udp_initial_expr_opt : '=' expression ''' print('udp_initial_expr_opt_1', list(p)) - # { $$ = $2; } + p[0] = p[2] () def p_udp_initial_expr_opt_2(p): '''udp_initial_expr_opt : ''' -- 2.30.2