vvp: Support local flag on real variables

The vvp parser did not accept the local flag on `.var/real`
declarations. This can happen when elaboration creates a compiler-generated
real temporary, for example when a blocking intra-assignment delay is
rewritten from:

    r = #1 1.25;

to assign the right hand side to a temporary before the delay and assign
the temporary to the target after the delay.

Add support for the local flag. Keep a VPI symbol for the variable so
`%load/real` can still resolve the label, but do not attach local real
variables to the current scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2026-06-27 17:36:17 -07:00
parent 77fdcfd800
commit d5306085c5
3 changed files with 9 additions and 7 deletions

View File

@ -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);

View File

@ -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); }

View File

@ -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)