Apply 'make format'

This commit is contained in:
github action 2022-10-01 14:53:40 +00:00
parent 159cf0429c
commit f1ba6cb517
3 changed files with 80 additions and 44 deletions

View File

@ -425,7 +425,7 @@ private:
void preserveTopIfaces(AstNetlist* rootp) { void preserveTopIfaces(AstNetlist* rootp) {
for (AstNodeModule* modp = rootp->modulesp(); modp && modp->level() <= 2; 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()) { for (AstNode* subnodep = modp->stmtsp(); subnodep; subnodep = subnodep->nextp()) {
if (AstVar* const varp = VN_CAST(subnodep, Var)) { if (AstVar* const varp = VN_CAST(subnodep, Var)) {
if (varp->isIfaceRef()) { if (varp->isIfaceRef()) {
@ -433,23 +433,24 @@ private:
const AstIfaceRefDType* ifacerefp = nullptr; const AstIfaceRefDType* ifacerefp = nullptr;
if (VN_IS(subtypep, IfaceRefDType)) { if (VN_IS(subtypep, IfaceRefDType)) {
ifacerefp = VN_AS(varp->subDTypep(), IfaceRefDType); ifacerefp = VN_AS(varp->subDTypep(), IfaceRefDType);
} } else if (VN_IS(subtypep, BracketArrayDType)) {
else if (VN_IS(subtypep, BracketArrayDType)) { const AstBracketArrayDType* const arrp
const AstBracketArrayDType* const arrp = VN_AS(subtypep, BracketArrayDType); = VN_AS(subtypep, BracketArrayDType);
const AstNodeDType* const arrsubtypep = arrp->subDTypep(); const AstNodeDType* const arrsubtypep = arrp->subDTypep();
if (VN_IS(arrsubtypep, IfaceRefDType)) { if (VN_IS(arrsubtypep, IfaceRefDType)) {
ifacerefp = VN_AS(arrsubtypep, IfaceRefDType); ifacerefp = VN_AS(arrsubtypep, IfaceRefDType);
} }
} } else if (VN_IS(subtypep, UnpackArrayDType)) {
else if (VN_IS(subtypep, UnpackArrayDType)) { const AstUnpackArrayDType* const arrp
const AstUnpackArrayDType* const arrp = VN_AS(subtypep, UnpackArrayDType); = VN_AS(subtypep, UnpackArrayDType);
const AstNodeDType* const arrsubtypep = arrp->subDTypep(); const AstNodeDType* const arrsubtypep = arrp->subDTypep();
if (VN_IS(arrsubtypep, IfaceRefDType)) { if (VN_IS(arrsubtypep, IfaceRefDType)) {
ifacerefp = VN_AS(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); ifacerefp->ifacep()->user1(1);
} }
} }
@ -491,7 +492,9 @@ public:
void V3Dead::deadifyModules(AstNetlist* nodep) { void V3Dead::deadifyModules(AstNetlist* nodep) {
UINFO(2, __FUNCTION__ << ": " << endl); 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); V3Global::dumpCheckGlobalTree("deadModules", 0, dumpTree() >= 6);
} }

View File

@ -310,8 +310,8 @@ public:
} }
VSymEnt* insertTopIface(AstCell* nodep, const string& scopename) { VSymEnt* insertTopIface(AstCell* nodep, const string& scopename) {
VSymEnt* const symp = new VSymEnt{&m_syms, nodep}; VSymEnt* const symp = new VSymEnt{&m_syms, nodep};
UINFO(9, UINFO(9, " INSERTtopiface se" << cvtToHex(symp) << " " << scopename << " " << nodep
" INSERTtopiface se" << cvtToHex(symp) << " " << scopename << " " << nodep << endl); << endl);
symp->parentp(rootEntp()); // Needed so backward search can find name of top module symp->parentp(rootEntp()); // Needed so backward search can find name of top module
symp->fallbackp(dunitEntp()); // Needed so can find $unit stuff symp->fallbackp(dunitEntp()); // Needed so can find $unit stuff
nodep->user1p(symp); nodep->user1p(symp);
@ -786,16 +786,16 @@ class LinkDotFindVisitor final : public VNVisitor {
const AstIfaceRefDType* ifacerefp = nullptr; const AstIfaceRefDType* ifacerefp = nullptr;
if (VN_IS(subtypep, IfaceRefDType)) { if (VN_IS(subtypep, IfaceRefDType)) {
ifacerefp = VN_AS(varp->subDTypep(), IfaceRefDType); ifacerefp = VN_AS(varp->subDTypep(), IfaceRefDType);
} } else if (VN_IS(subtypep, BracketArrayDType)) {
else if (VN_IS(subtypep, BracketArrayDType)) { const AstBracketArrayDType* const arrp
const AstBracketArrayDType* const arrp = VN_AS(subtypep, BracketArrayDType); = VN_AS(subtypep, BracketArrayDType);
const AstNodeDType* const arrsubtypep = arrp->subDTypep(); const AstNodeDType* const arrsubtypep = arrp->subDTypep();
if (VN_IS(arrsubtypep, IfaceRefDType)) { if (VN_IS(arrsubtypep, IfaceRefDType)) {
ifacerefp = VN_AS(arrsubtypep, IfaceRefDType); ifacerefp = VN_AS(arrsubtypep, IfaceRefDType);
} }
} } else if (VN_IS(subtypep, UnpackArrayDType)) {
else if (VN_IS(subtypep, UnpackArrayDType)) { const AstUnpackArrayDType* const arrp
const AstUnpackArrayDType* const arrp = VN_AS(subtypep, UnpackArrayDType); = VN_AS(subtypep, UnpackArrayDType);
const AstNodeDType* const arrsubtypep = arrp->subDTypep(); const AstNodeDType* const arrsubtypep = arrp->subDTypep();
if (VN_IS(arrsubtypep, IfaceRefDType)) { if (VN_IS(arrsubtypep, IfaceRefDType)) {
ifacerefp = VN_AS(arrsubtypep, IfaceRefDType); ifacerefp = VN_AS(arrsubtypep, IfaceRefDType);
@ -803,10 +803,19 @@ class LinkDotFindVisitor final : public VNVisitor {
} }
if (ifacerefp && !ifacerefp->cellp()) { if (ifacerefp && !ifacerefp->cellp()) {
// A dummy cell to keep the top level interface alive and correctly optimized for default parameter values // A dummy cell to keep the top level interface alive and correctly
AstCell* ifacecellp = new AstCell{nodep->fileline(), nodep->fileline(), modp->name() + "__02E" + varp->name(), ifacerefp->ifaceName(), nullptr, nullptr, nullptr}; // 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()); 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); } { iterate(ifacecellp); }
} }
} }

View File

@ -199,8 +199,7 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) {
} else { } else {
ioNames.insert(oldvarp->name()); ioNames.insert(oldvarp->name());
} }
} } else if (v3Global.opt.topIfacesSupported() && oldvarp->isIfaceRef()) {
else if (v3Global.opt.topIfacesSupported() && oldvarp->isIfaceRef()) {
const AstNodeDType* const subtypep = oldvarp->subDTypep(); const AstNodeDType* const subtypep = oldvarp->subDTypep();
if (VN_IS(subtypep, IfaceRefDType)) { if (VN_IS(subtypep, IfaceRefDType)) {
const AstIfaceRefDType* const ifacerefp = VN_AS(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 AstUnpackArrayDType* const arrp = VN_AS(subtypep, UnpackArrayDType);
const AstNodeDType* const arrsubtypep = arrp->subDTypep(); const AstNodeDType* const arrsubtypep = arrp->subDTypep();
if (VN_IS(arrsubtypep, IfaceRefDType)) { 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 (!ifacerefp->cellp()) {
if (ioNames.find(oldvarp->name()) != ioNames.end()) { 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()); dupNames.insert(oldvarp->name());
} else { } else {
ioNames.insert(oldvarp->name()); 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 // Skip length and width comp; we know it's a direct assignment
pinp->modVarp(oldvarp); pinp->modVarp(oldvarp);
cellp->addPinsp(pinp); cellp->addPinsp(pinp);
} } else if (v3Global.opt.topIfacesSupported() && oldvarp->isIfaceRef()) {
else if (v3Global.opt.topIfacesSupported() && oldvarp->isIfaceRef()) { // for each interface port on oldmodp instantiate a corresponding interface
// for each interface port on oldmodp instantiate a corresponding interface cell in $root // cell in $root
const AstNodeDType* const subtypep = oldvarp->subDTypep(); const AstNodeDType* const subtypep = oldvarp->subDTypep();
if (VN_IS(subtypep, IfaceRefDType)) { if (VN_IS(subtypep, IfaceRefDType)) {
const AstIfaceRefDType* const ifacerefp = VN_AS(subtypep, IfaceRefDType); const AstIfaceRefDType* const ifacerefp = VN_AS(subtypep, IfaceRefDType);
@ -298,34 +299,44 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) {
name = oldmodp->name() + "__02E" + name; 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()); ifacecellp->modp(ifacerefp->ifacep());
newmodp->addStmtsp(ifacecellp); 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->ifacep(nullptr);
idtypep->dtypep(idtypep); idtypep->dtypep(idtypep);
idtypep->cellp(ifacecellp); idtypep->cellp(ifacecellp);
rootp->typeTablep()->addTypesp(idtypep); 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); varp->isIfaceParent(true);
ifacecellp->addNextHere(varp); ifacecellp->addNextHere(varp);
ifacecellp->hasIfaceVar(true); ifacecellp->hasIfaceVar(true);
AstPin* const pinp = new AstPin{ AstPin* const pinp
oldvarp->fileline(), 0, varp->name(), = new AstPin{oldvarp->fileline(), 0, varp->name(),
new AstVarRef{varp->fileline(), varp, new AstVarRef{varp->fileline(), varp,
oldvarp->isWritable() ? VAccess::WRITE : VAccess::READ}}; oldvarp->isWritable() ? VAccess::WRITE
: VAccess::READ}};
pinp->modVarp(oldvarp); pinp->modVarp(oldvarp);
cellp->addPinsp(pinp); cellp->addPinsp(pinp);
} }
} } else if (VN_IS(subtypep, UnpackArrayDType)) {
else if (VN_IS(subtypep, UnpackArrayDType)) { const AstUnpackArrayDType* const oldarrp
const AstUnpackArrayDType* const oldarrp = VN_AS(subtypep, UnpackArrayDType); = VN_AS(subtypep, UnpackArrayDType);
const AstNodeDType* const arrsubtypep = oldarrp->subDTypep(); const AstNodeDType* const arrsubtypep = oldarrp->subDTypep();
if (VN_IS(arrsubtypep, IfaceRefDType)) { 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 (!ifacerefp->cellp()) {
string name = oldvarp->name(); string name = oldvarp->name();
if (dupNames.find(name) != dupNames.end()) { if (dupNames.find(name) != dupNames.end()) {
@ -333,19 +344,31 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) {
name = oldmodp->name() + "__02E" + name; name = oldmodp->name() + "__02E" + name;
} }
AstUnpackArrayDType* arraydtypep = VN_AS(oldvarp->dtypep(), UnpackArrayDType); AstUnpackArrayDType* arraydtypep
AstCell* ifacearraycellp = new AstCell{newmodp->fileline(), newmodp->fileline(), name, ifacerefp->ifaceName(), nullptr, nullptr, arraydtypep->rangep()->cloneTree(true)}; = 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()); ifacearraycellp->modp(ifacerefp->ifacep());
newmodp->addStmtsp(ifacearraycellp); 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->ifacep(nullptr);
idtypep->dtypep(idtypep); idtypep->dtypep(idtypep);
idtypep->cellp(ifacearraycellp); idtypep->cellp(ifacearraycellp);
rootp->typeTablep()->addTypesp(idtypep); rootp->typeTablep()->addTypesp(idtypep);
AstNodeArrayDType* const arrp = new AstUnpackArrayDType{newmodp->fileline(), idtypep, arraydtypep->rangep()->cloneTree(true)}; AstNodeArrayDType* const arrp = new AstUnpackArrayDType{
AstVar* varp = new AstVar{newmodp->fileline(), VVarType::IFACEREF, name + "__Viftop", arrp}; newmodp->fileline(), idtypep,
arraydtypep->rangep()->cloneTree(true)};
AstVar* varp = new AstVar{newmodp->fileline(), VVarType::IFACEREF,
name + "__Viftop", arrp};
varp->isIfaceParent(true); varp->isIfaceParent(true);
ifacearraycellp->addNextHere(varp); ifacearraycellp->addNextHere(varp);
ifacearraycellp->hasIfaceVar(true); ifacearraycellp->hasIfaceVar(true);
@ -354,7 +377,8 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) {
AstPin* const pinp = new AstPin{ AstPin* const pinp = new AstPin{
oldvarp->fileline(), 0, varp->name(), oldvarp->fileline(), 0, varp->name(),
new AstVarRef{varp->fileline(), varp, new AstVarRef{varp->fileline(), varp,
oldvarp->isWritable() ? VAccess::WRITE : VAccess::READ}}; oldvarp->isWritable() ? VAccess::WRITE
: VAccess::READ}};
pinp->modVarp(oldvarp); pinp->modVarp(oldvarp);
cellp->addPinsp(pinp); cellp->addPinsp(pinp);
} }