diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 8bfefe137..378942655 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -158,9 +158,7 @@ private: std::array m_scopeAliasMap; // Map of aliases std::vector m_ifaceVarSyms; // List of AstIfaceRefDType's to be imported IfaceModSyms m_ifaceModSyms; // List of AstIface+Symbols to be processed - bool m_forPrimary; // First link - bool m_forPrearray; // Compress cell__[array] refs - bool m_forScopeCreation; // Remove VarXRefs for V3Scope + const VLinkDotStep m_step; // Operational step public: // METHODS @@ -202,11 +200,9 @@ public: // CONSTRUCTORS LinkDotState(AstNetlist* rootp, VLinkDotStep step) - : m_syms{rootp} { + : m_syms{rootp} + , m_step(step) { UINFO(4, __FUNCTION__ << ": " << endl); - m_forPrimary = (step == LDS_PRIMARY); - m_forPrearray = (step == LDS_PARAMED || step == LDS_PRIMARY); - m_forScopeCreation = (step == LDS_SCOPED); s_errorThisp = this; V3Error::errorExitCb(preErrorDumpHandler); // If get error, dump self } @@ -217,9 +213,10 @@ public: // ACCESSORS VSymGraph* symsp() { return &m_syms; } - bool forPrimary() const { return m_forPrimary; } - bool forPrearray() const { return m_forPrearray; } - bool forScopeCreation() const { return m_forScopeCreation; } + int stepNumber() const { return int(m_step); } + bool forPrimary() const { return m_step == LDS_PRIMARY; } + bool forPrearray() const { return m_step == LDS_PARAMED || m_step == LDS_PRIMARY; } + bool forScopeCreation() const { return m_step == LDS_SCOPED; } // METHODS static string nodeTextType(AstNode* nodep) { @@ -590,7 +587,7 @@ public: baddot = ident; // So user can see where they botched it okSymp = lookupSymp; string altIdent; - if (m_forPrearray) { + if (forPrearray()) { // GENFOR Begin is foo__BRA__##__KET__ after we've genloop unrolled, // but presently should be just "foo". // Likewise cell foo__[array] before we've expanded arrays is just foo @@ -620,7 +617,7 @@ public: else if (ident == "$root") { lookupSymp = rootEntp(); // We've added the '$root' module, now everything else is one lower - if (!m_forPrearray) { + if (!forPrearray()) { lookupSymp = lookupSymp->findIdFlat(ident); UASSERT(lookupSymp, "Cannot find $root module under netlist"); } @@ -1017,9 +1014,12 @@ class LinkDotFindVisitor final : public VNVisitor { for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) { if (VN_IS(stmtp, Var) || VN_IS(stmtp, Foreach)) { std::string name; + const std::string stepStr = m_statep->forPrimary() + ? "" + : std::to_string(m_statep->stepNumber()) + "_"; do { ++m_modBlockNum; - name = "unnamedblk" + cvtToStr(m_modBlockNum); + name = "unnamedblk" + stepStr + cvtToStr(m_modBlockNum); // Increment again if earlier pass of V3LinkDot claimed this name } while (m_curSymp->findIdFlat(name)); nodep->name(name); diff --git a/test_regress/t/t_foreach_blkname.v b/test_regress/t/t_foreach_blkname.v index 768e7697f..3eceb8a3c 100644 --- a/test_regress/t/t_foreach_blkname.v +++ b/test_regress/t/t_foreach_blkname.v @@ -12,5 +12,8 @@ module t; end foreach (a[i]) begin end + begin + int x; + end endfunction endmodule diff --git a/test_regress/t/t_randcase_bad.out b/test_regress/t/t_randcase_bad.out index 4e3daeeac..6d1b58341 100644 --- a/test_regress/t/t_randcase_bad.out +++ b/test_regress/t/t_randcase_bad.out @@ -1,2 +1,2 @@ -[0] %Error: t_randcase_bad.v:12: Assertion failed in top.t.unnamedblk1: All randcase items had 0 weights (IEEE 1800-2017 18.16) +[0] %Error: t_randcase_bad.v:12: Assertion failed in top.t.unnamedblk2_1: All randcase items had 0 weights (IEEE 1800-2017 18.16) *-* All Finished *-*