From 167005f84934bb215300ddc0ac02bb19ffb76dd6 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 5 Mar 2022 13:44:51 +0100 Subject: [PATCH] tgt-vlog95: Generate initializers for package variables While a package can not have logic defined in it. It can have variables with initializers. These initializers currently get ignored when converting the package to a module in the vlog95 backend. Make sure packages are treated the same as modules here and that the initializers are turned into initial blocks in the generate vlog95 code. Signed-off-by: Lars-Peter Clausen --- tgt-vlog95/scope.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tgt-vlog95/scope.c b/tgt-vlog95/scope.c index 393b53c63..1b8916c19 100644 --- a/tgt-vlog95/scope.c +++ b/tgt-vlog95/scope.c @@ -696,7 +696,8 @@ static int find_tfb_process(ivl_process_t proc, ivl_scope_t scope) * processes that are used to set local variables. */ assert(ivl_process_type(proc) == IVL_PR_INITIAL); /* Find the module scope for this task/function. */ - while (ivl_scope_type(mod_scope) != IVL_SCT_MODULE) { + while (ivl_scope_type(mod_scope) != IVL_SCT_MODULE && + ivl_scope_type(mod_scope) != IVL_SCT_PACKAGE) { mod_scope = ivl_scope_parent(mod_scope); assert(mod_scope); } @@ -1154,7 +1155,9 @@ int emit_scope(ivl_scope_t scope, ivl_scope_t parent) for (idx = 0; idx < count; idx += 1) { emit_tran(scope, ivl_scope_switch(scope, idx)); } + } + if (sc_type == IVL_SCT_MODULE || sc_type == IVL_SCT_PACKAGE) { /* Output any initial blocks for tasks or functions or named * blocks defined in this module. Used to initialize local * variables. */