From cda95c15543aa73ee379f6d5bb383905fd619340 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Tue, 26 Jul 2016 21:59:54 +0100 Subject: [PATCH] Fix vlog95 target to handle hierarchical references in root-level tasks. (cherry picked from commit 8461e1d9c415f8152c98c58728656c82f88cd84a) --- tgt-vlog95/misc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tgt-vlog95/misc.c b/tgt-vlog95/misc.c index 5076bd4c6..7c8d32987 100644 --- a/tgt-vlog95/misc.c +++ b/tgt-vlog95/misc.c @@ -747,7 +747,9 @@ void emit_name_of_nexus(ivl_scope_t scope, ivl_nexus_t nex, unsigned allow_UD) * This function traverses the scope tree looking for the enclosing module * scope. When it is found the module scope is returned. As far as this * translation is concerned a package is a special form of a module - * definition and a class is also a top level scope. + * definition and a class is also a top level scope. In SystemVerilog, + * tasks and functions can also be top level scopes - we create a wrapper + * module for these later. */ ivl_scope_t get_module_scope(ivl_scope_t scope) { @@ -756,6 +758,12 @@ ivl_scope_t get_module_scope(ivl_scope_t scope) (ivl_scope_type(scope) != IVL_SCT_PACKAGE) && (ivl_scope_type(scope) != IVL_SCT_CLASS)) { ivl_scope_t pscope = ivl_scope_parent(scope); + if (pscope == 0) { + if (ivl_scope_type(scope) == IVL_SCT_TASK) + break; + if (ivl_scope_type(scope) == IVL_SCT_FUNCTION) + break; + } assert(pscope); scope = pscope; }