void warnAlwCombOrder(AstVarRef* nodep) { AstVar* varp = nodep->varp(); if (!varp->isParam() && !varp->isGenVar() && !varp->isUsedLoopIdx() && !varp->fileline()->warnIsOff(V3ErrorCode::ALWCOMBORDER)) { // Warn only once per variable nodep->v3warn(ALWCOMBORDER, "Always_comb variable driven after use: "<<nodep->prettyName()); varp->fileline()->modifyWarnOff(V3ErrorCode::ALWCOMBORDER, true); // Complain just once for any usage } }
void reportViolations() { // Combine bits into overall state AstVar* nodep = m_varp; if (!nodep->isParam() && !nodep->isGenVar()) { bool allU=true; bool allD=true; bool anyU=m_usedWhole; bool anyD=m_drivenWhole; bool anyUnotD=false; bool anyDnotU=false; bool anynotDU=false; for (unsigned bit=0; bit<m_flags.size()/FLAGS_PER_BIT; bit++) { bool used = usedFlag(bit); bool driv = drivenFlag(bit); allU &= used; anyU |= used; allD &= driv; anyD |= driv; anyUnotD |= used && !driv; anyDnotU |= !used && driv; anynotDU |= !used && !driv; } if (allU) m_usedWhole = true; if (allD) m_drivenWhole = true; // Test results if (allU && allD) { // It's fine } else if (!anyD && !anyU) { // UNDRIVEN is considered more serious - as is more likely a bug, // thus undriven+unused bits get UNUSED warnings, as they're not as buggy. if (!unusedMatch(nodep)) { nodep->v3warn(UNUSED, "Signal is not driven, nor used: "<<nodep->prettyName()); nodep->fileline()->modifyWarnOff(V3ErrorCode::UNUSED, true); // Warn only once } } else if (allD && !anyU) { if (!unusedMatch(nodep)) { nodep->v3warn(UNUSED, "Signal is not used: "<<nodep->prettyName()); nodep->fileline()->modifyWarnOff(V3ErrorCode::UNUSED, true); // Warn only once } } else if (!anyD && allU) { nodep->v3warn(UNDRIVEN, "Signal is not driven: "<<nodep->prettyName()); nodep->fileline()->modifyWarnOff(V3ErrorCode::UNDRIVEN, true); // Warn only once } else { // Bits have different dispositions bool setU=false; bool setD=false; if (anynotDU && !unusedMatch(nodep)) { nodep->v3warn(UNUSED, "Bits of signal are not driven, nor used: "<<nodep->prettyName() <<bitNames(BN_BOTH)); setU=true; } if (anyDnotU && !unusedMatch(nodep)) { nodep->v3warn(UNUSED, "Bits of signal are not used: "<<nodep->prettyName() <<bitNames(BN_UNUSED)); setU=true; } if (anyUnotD) { nodep->v3warn(UNDRIVEN, "Bits of signal are not driven: "<<nodep->prettyName() <<bitNames(BN_UNDRIVEN)); setD=true; } if (setU) nodep->fileline()->modifyWarnOff(V3ErrorCode::UNUSED, true); // Warn only once if (setD) nodep->fileline()->modifyWarnOff(V3ErrorCode::UNDRIVEN, true); // Warn only once } } }