diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index f3e8950f8..38800e6f9 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -425,7 +425,7 @@ private: void preserveTopIfaces(AstNetlist* rootp) { for (AstNodeModule* modp = rootp->modulesp(); modp && modp->level() <= 2; - modp = VN_AS(modp->nextp(), NodeModule)) { + modp = VN_AS(modp->nextp(), NodeModule)) { for (AstNode* subnodep = modp->stmtsp(); subnodep; subnodep = subnodep->nextp()) { if (AstVar* const varp = VN_CAST(subnodep, Var)) { if (varp->isIfaceRef()) { @@ -433,23 +433,24 @@ private: const AstIfaceRefDType* ifacerefp = nullptr; if (VN_IS(subtypep, IfaceRefDType)) { ifacerefp = VN_AS(varp->subDTypep(), IfaceRefDType); - } - else if (VN_IS(subtypep, BracketArrayDType)) { - const AstBracketArrayDType* const arrp = VN_AS(subtypep, BracketArrayDType); + } else if (VN_IS(subtypep, BracketArrayDType)) { + const AstBracketArrayDType* const arrp + = VN_AS(subtypep, BracketArrayDType); const AstNodeDType* const arrsubtypep = arrp->subDTypep(); if (VN_IS(arrsubtypep, IfaceRefDType)) { ifacerefp = VN_AS(arrsubtypep, IfaceRefDType); } - } - else if (VN_IS(subtypep, UnpackArrayDType)) { - const AstUnpackArrayDType* const arrp = VN_AS(subtypep, UnpackArrayDType); + } else if (VN_IS(subtypep, UnpackArrayDType)) { + const AstUnpackArrayDType* const arrp + = VN_AS(subtypep, UnpackArrayDType); const AstNodeDType* const arrsubtypep = arrp->subDTypep(); if (VN_IS(arrsubtypep, IfaceRefDType)) { ifacerefp = VN_AS(arrsubtypep, IfaceRefDType); } } - if (ifacerefp && !ifacerefp->cellp() && (ifacerefp->ifacep()->user1() == 0)) { + if (ifacerefp && !ifacerefp->cellp() + && (ifacerefp->ifacep()->user1() == 0)) { ifacerefp->ifacep()->user1(1); } } @@ -491,7 +492,9 @@ public: void V3Dead::deadifyModules(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DeadVisitor{nodep, false, false, false, false, !v3Global.opt.topIfacesSupported()}; } // Destruct before checking + { + DeadVisitor{nodep, false, false, false, false, !v3Global.opt.topIfacesSupported()}; + } // Destruct before checking V3Global::dumpCheckGlobalTree("deadModules", 0, dumpTree() >= 6); } diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index f5d93991a..0611e6297 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -310,8 +310,8 @@ public: } VSymEnt* insertTopIface(AstCell* nodep, const string& scopename) { VSymEnt* const symp = new VSymEnt{&m_syms, nodep}; - UINFO(9, - " INSERTtopiface se" << cvtToHex(symp) << " " << scopename << " " << nodep << endl); + UINFO(9, " INSERTtopiface se" << cvtToHex(symp) << " " << scopename << " " << nodep + << endl); symp->parentp(rootEntp()); // Needed so backward search can find name of top module symp->fallbackp(dunitEntp()); // Needed so can find $unit stuff nodep->user1p(symp); @@ -786,16 +786,16 @@ class LinkDotFindVisitor final : public VNVisitor { const AstIfaceRefDType* ifacerefp = nullptr; if (VN_IS(subtypep, IfaceRefDType)) { ifacerefp = VN_AS(varp->subDTypep(), IfaceRefDType); - } - else if (VN_IS(subtypep, BracketArrayDType)) { - const AstBracketArrayDType* const arrp = VN_AS(subtypep, BracketArrayDType); + } else if (VN_IS(subtypep, BracketArrayDType)) { + const AstBracketArrayDType* const arrp + = VN_AS(subtypep, BracketArrayDType); const AstNodeDType* const arrsubtypep = arrp->subDTypep(); if (VN_IS(arrsubtypep, IfaceRefDType)) { ifacerefp = VN_AS(arrsubtypep, IfaceRefDType); } - } - else if (VN_IS(subtypep, UnpackArrayDType)) { - const AstUnpackArrayDType* const arrp = VN_AS(subtypep, UnpackArrayDType); + } else if (VN_IS(subtypep, UnpackArrayDType)) { + const AstUnpackArrayDType* const arrp + = VN_AS(subtypep, UnpackArrayDType); const AstNodeDType* const arrsubtypep = arrp->subDTypep(); if (VN_IS(arrsubtypep, IfaceRefDType)) { ifacerefp = VN_AS(arrsubtypep, IfaceRefDType); @@ -803,10 +803,19 @@ class LinkDotFindVisitor final : public VNVisitor { } if (ifacerefp && !ifacerefp->cellp()) { - // A dummy cell to keep the top level interface alive and correctly optimized for default parameter values - AstCell* ifacecellp = new AstCell{nodep->fileline(), nodep->fileline(), modp->name() + "__02E" + varp->name(), ifacerefp->ifaceName(), nullptr, nullptr, nullptr}; + // A dummy cell to keep the top level interface alive and correctly + // optimized for default parameter values + AstCell* ifacecellp + = new AstCell{nodep->fileline(), + nodep->fileline(), + modp->name() + "__02E" + varp->name(), + ifacerefp->ifaceName(), + nullptr, + nullptr, + nullptr}; ifacecellp->modp(ifacerefp->ifacep()); - m_curSymp = m_modSymp = m_statep->insertTopIface(ifacecellp, m_scope); + m_curSymp = m_modSymp + = m_statep->insertTopIface(ifacecellp, m_scope); { iterate(ifacecellp); } } } diff --git a/src/V3LinkLevel.cpp b/src/V3LinkLevel.cpp index fbc4d86bd..417cd08dc 100644 --- a/src/V3LinkLevel.cpp +++ b/src/V3LinkLevel.cpp @@ -199,8 +199,7 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { } else { ioNames.insert(oldvarp->name()); } - } - else if (v3Global.opt.topIfacesSupported() && oldvarp->isIfaceRef()) { + } else if (v3Global.opt.topIfacesSupported() && oldvarp->isIfaceRef()) { const AstNodeDType* const subtypep = oldvarp->subDTypep(); if (VN_IS(subtypep, IfaceRefDType)) { const AstIfaceRefDType* const ifacerefp = VN_AS(subtypep, IfaceRefDType); @@ -217,10 +216,12 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { const AstUnpackArrayDType* const arrp = VN_AS(subtypep, UnpackArrayDType); const AstNodeDType* const arrsubtypep = arrp->subDTypep(); if (VN_IS(arrsubtypep, IfaceRefDType)) { - const AstIfaceRefDType* const ifacerefp = VN_AS(arrsubtypep, IfaceRefDType); + const AstIfaceRefDType* const ifacerefp + = VN_AS(arrsubtypep, IfaceRefDType); if (!ifacerefp->cellp()) { if (ioNames.find(oldvarp->name()) != ioNames.end()) { - // UINFO(8, "Multitop dup interface array found: " << oldvarp << endl); + // UINFO(8, "Multitop dup interface array found: " << oldvarp + // << endl); dupNames.insert(oldvarp->name()); } else { ioNames.insert(oldvarp->name()); @@ -285,9 +286,9 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { // Skip length and width comp; we know it's a direct assignment pinp->modVarp(oldvarp); cellp->addPinsp(pinp); - } - else if (v3Global.opt.topIfacesSupported() && oldvarp->isIfaceRef()) { - // for each interface port on oldmodp instantiate a corresponding interface cell in $root + } else if (v3Global.opt.topIfacesSupported() && oldvarp->isIfaceRef()) { + // for each interface port on oldmodp instantiate a corresponding interface + // cell in $root const AstNodeDType* const subtypep = oldvarp->subDTypep(); if (VN_IS(subtypep, IfaceRefDType)) { const AstIfaceRefDType* const ifacerefp = VN_AS(subtypep, IfaceRefDType); @@ -298,34 +299,44 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { name = oldmodp->name() + "__02E" + name; } - AstCell* ifacecellp = new AstCell{newmodp->fileline(), newmodp->fileline(), name, ifacerefp->ifaceName(), nullptr, nullptr, nullptr}; + AstCell* ifacecellp = new AstCell{newmodp->fileline(), + newmodp->fileline(), + name, + ifacerefp->ifaceName(), + nullptr, + nullptr, + nullptr}; ifacecellp->modp(ifacerefp->ifacep()); newmodp->addStmtsp(ifacecellp); - AstIfaceRefDType* const idtypep = new AstIfaceRefDType{newmodp->fileline(), name, ifacerefp->ifaceName()}; + AstIfaceRefDType* const idtypep = new AstIfaceRefDType{ + newmodp->fileline(), name, ifacerefp->ifaceName()}; idtypep->ifacep(nullptr); idtypep->dtypep(idtypep); idtypep->cellp(ifacecellp); rootp->typeTablep()->addTypesp(idtypep); - AstVar* varp = new AstVar{newmodp->fileline(), VVarType::IFACEREF, name + "__Viftop", idtypep}; + AstVar* varp = new AstVar{newmodp->fileline(), VVarType::IFACEREF, + name + "__Viftop", idtypep}; varp->isIfaceParent(true); ifacecellp->addNextHere(varp); ifacecellp->hasIfaceVar(true); - AstPin* const pinp = new AstPin{ - oldvarp->fileline(), 0, varp->name(), - new AstVarRef{varp->fileline(), varp, - oldvarp->isWritable() ? VAccess::WRITE : VAccess::READ}}; + AstPin* const pinp + = new AstPin{oldvarp->fileline(), 0, varp->name(), + new AstVarRef{varp->fileline(), varp, + oldvarp->isWritable() ? VAccess::WRITE + : VAccess::READ}}; pinp->modVarp(oldvarp); cellp->addPinsp(pinp); } - } - else if (VN_IS(subtypep, UnpackArrayDType)) { - const AstUnpackArrayDType* const oldarrp = VN_AS(subtypep, UnpackArrayDType); + } else if (VN_IS(subtypep, UnpackArrayDType)) { + const AstUnpackArrayDType* const oldarrp + = VN_AS(subtypep, UnpackArrayDType); const AstNodeDType* const arrsubtypep = oldarrp->subDTypep(); if (VN_IS(arrsubtypep, IfaceRefDType)) { - const AstIfaceRefDType* const ifacerefp = VN_AS(arrsubtypep, IfaceRefDType); + const AstIfaceRefDType* const ifacerefp + = VN_AS(arrsubtypep, IfaceRefDType); if (!ifacerefp->cellp()) { string name = oldvarp->name(); if (dupNames.find(name) != dupNames.end()) { @@ -333,19 +344,31 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { name = oldmodp->name() + "__02E" + name; } - AstUnpackArrayDType* arraydtypep = VN_AS(oldvarp->dtypep(), UnpackArrayDType); - AstCell* ifacearraycellp = new AstCell{newmodp->fileline(), newmodp->fileline(), name, ifacerefp->ifaceName(), nullptr, nullptr, arraydtypep->rangep()->cloneTree(true)}; + AstUnpackArrayDType* arraydtypep + = VN_AS(oldvarp->dtypep(), UnpackArrayDType); + AstCell* ifacearraycellp + = new AstCell{newmodp->fileline(), + newmodp->fileline(), + name, + ifacerefp->ifaceName(), + nullptr, + nullptr, + arraydtypep->rangep()->cloneTree(true)}; ifacearraycellp->modp(ifacerefp->ifacep()); newmodp->addStmtsp(ifacearraycellp); - AstIfaceRefDType* const idtypep = new AstIfaceRefDType{newmodp->fileline(), name, ifacerefp->ifaceName()}; + AstIfaceRefDType* const idtypep = new AstIfaceRefDType{ + newmodp->fileline(), name, ifacerefp->ifaceName()}; idtypep->ifacep(nullptr); idtypep->dtypep(idtypep); idtypep->cellp(ifacearraycellp); rootp->typeTablep()->addTypesp(idtypep); - AstNodeArrayDType* const arrp = new AstUnpackArrayDType{newmodp->fileline(), idtypep, arraydtypep->rangep()->cloneTree(true)}; - AstVar* varp = new AstVar{newmodp->fileline(), VVarType::IFACEREF, name + "__Viftop", arrp}; + AstNodeArrayDType* const arrp = new AstUnpackArrayDType{ + newmodp->fileline(), idtypep, + arraydtypep->rangep()->cloneTree(true)}; + AstVar* varp = new AstVar{newmodp->fileline(), VVarType::IFACEREF, + name + "__Viftop", arrp}; varp->isIfaceParent(true); ifacearraycellp->addNextHere(varp); ifacearraycellp->hasIfaceVar(true); @@ -354,7 +377,8 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { AstPin* const pinp = new AstPin{ oldvarp->fileline(), 0, varp->name(), new AstVarRef{varp->fileline(), varp, - oldvarp->isWritable() ? VAccess::WRITE : VAccess::READ}}; + oldvarp->isWritable() ? VAccess::WRITE + : VAccess::READ}}; pinp->modVarp(oldvarp); cellp->addPinsp(pinp); }