From 8bb1d3dabe400f9a9710729a9b81665ccb25ca08 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sat, 6 Sep 2014 17:39:52 -0700 Subject: [PATCH] Emit class definitions after ALL scopes are scanned. --- emit.cc | 16 ++++++++++++++-- netclass.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/emit.cc b/emit.cc index df661b909..c71e05c1e 100644 --- a/emit.cc +++ b/emit.cc @@ -409,14 +409,13 @@ void NetRepeat::emit_recurse(struct target_t*tgt) const void netclass_t::emit_scope(struct target_t*tgt) const { class_scope_->emit_scope(tgt); - class_scope_->emit_defs(tgt); } void NetScope::emit_scope(struct target_t*tgt) const { if (debug_emit) { cerr << "NetScope::emit_scope: " - << "Emit scope basename=" << basename() << endl; + << "Emit scope " << scope_path(this) << endl; } tgt->scope(this); @@ -461,12 +460,20 @@ bool NetScope::emit_defs(struct target_t*tgt) const { bool flag = true; + if (debug_emit) { + cerr << "NetScope::emit_defs: " + << "Emit definitions for " << scope_path(this) << endl; + } + switch (type_) { case PACKAGE: case MODULE: for (map::const_iterator cur = children_.begin() ; cur != children_.end() ; ++ cur ) flag &= cur->second->emit_defs(tgt); + for (map::const_iterator cur = classes_.begin() + ; cur != classes_.end() ; ++ cur) + flag &= cur->second->emit_defs(tgt); break; case FUNC: @@ -485,6 +492,11 @@ bool NetScope::emit_defs(struct target_t*tgt) const return flag; } +bool netclass_t::emit_defs(struct target_t*tgt) const +{ + return class_scope_->emit_defs(tgt); +} + int Design::emit(struct target_t*tgt) const { int rc = 0; diff --git a/netclass.h b/netclass.h index 8305da4ef..4b94293f9 100644 --- a/netclass.h +++ b/netclass.h @@ -105,6 +105,7 @@ class netclass_t : public ivl_type_s { void elaborate(Design*des, PClass*pclass); void emit_scope(struct target_t*tgt) const; + bool emit_defs(struct target_t*tgt) const; void dump_scope(ostream&fd) const;