diff --git a/vvp/compile.h b/vvp/compile.h index cccc2391a..f2e949d66 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -504,7 +504,7 @@ extern void compile_variable(char*label, char*name, int msb, int lsb, int vpi_type_code, bool signed_flag, bool local_flag); -extern void compile_var_real(char*label, char*name); +extern void compile_var_real(char*label, char*name, bool local_flag); extern void compile_var_string(char*label, char*name); extern void compile_var_darray(char*label, char*name, unsigned size); extern void compile_var_cobject(char*label, char*name); diff --git a/vvp/parse.y b/vvp/parse.y index bd8dba1bf..2fc3dc93c 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -763,8 +763,8 @@ statement | T_LABEL K_VAR_2U local_flag T_STRING ',' signed_t_number signed_t_number ';' { compile_variable($1, $4, $6, $7, vpiIntVar, false, $3); } - | T_LABEL K_VAR_R T_STRING ',' signed_t_number signed_t_number ';' - { compile_var_real($1, $3); } + | T_LABEL K_VAR_R local_flag T_STRING ',' signed_t_number signed_t_number ';' + { compile_var_real($1, $4, $3); } | T_LABEL K_VAR_STR T_STRING ';' { compile_var_string($1, $3); } diff --git a/vvp/words.cc b/vvp/words.cc index 630c430b0..6291a7646 100644 --- a/vvp/words.cc +++ b/vvp/words.cc @@ -35,7 +35,8 @@ using namespace std; static void __compile_var_real(char*label, char*name, - vvp_array_t array, unsigned long array_addr) + vvp_array_t array, unsigned long array_addr, + bool local_flag) { vvp_net_t*net = new vvp_net_t; @@ -55,7 +56,8 @@ static void __compile_var_real(char*label, char*name, if (name) { assert(!array); - vpip_attach_to_current_scope(obj); + if (!local_flag) + vpip_attach_to_current_scope(obj); if (!vpip_peek_current_scope()->is_automatic()) schedule_init_vector(vvp_net_ptr_t(net,0), 0.0); } @@ -67,9 +69,9 @@ static void __compile_var_real(char*label, char*name, delete[] name; } -void compile_var_real(char*label, char*name) +void compile_var_real(char*label, char*name, bool local_flag) { - __compile_var_real(label, name, 0, 0); + __compile_var_real(label, name, 0, 0, local_flag); } void compile_var_string(char*label, char*name)