From 2bc42fc6e2c9ab5e6e59e86dcabdf22401bc0690 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Tue, 26 Jul 2016 21:40:27 +0100 Subject: [PATCH] Fix for GitHub issue #104 - assigning hierarchical signal from top level task. When emitting a design, all scopes must be emitted before emitting any top level task/function/method definitions, otherwise hierarchical references can't always be resolved. --- emit.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/emit.cc b/emit.cc index 6a08431f8..eaa183454 100644 --- a/emit.cc +++ b/emit.cc @@ -513,7 +513,6 @@ int Design::emit(struct target_t*tgt) const for (map::const_iterator scope = root_tasks_.begin() ; scope != root_tasks_.end() ; ++ scope) { scope->first->emit_scope(tgt); - scope->first->emit_defs(tgt); } // enumerate package scopes @@ -527,7 +526,6 @@ int Design::emit(struct target_t*tgt) const const NetScope*use_scope = cur->second->class_scope(); cur->second->emit_scope(tgt); tgt->class_type(use_scope, cur->second); - cur->second->emit_defs(tgt); } // enumerate root scopes @@ -554,6 +552,12 @@ int Design::emit(struct target_t*tgt) const // emit task and function definitions bool tasks_rc = true; + for (map::const_iterator scope = root_tasks_.begin() + ; scope != root_tasks_.end() ; ++ scope) + tasks_rc &= scope->first->emit_defs(tgt); + for (map::const_iterator cur = classes_.begin() + ; cur != classes_.end() ; ++cur) + tasks_rc &= cur->second->emit_defs(tgt); for (map::const_iterator scope = packages_.begin() ; scope != packages_.end() ; ++ scope ) tasks_rc &= scope->second->emit_defs(tgt);