Suppress WIDTH warnings when adding/subtracting 1'b1.

This commit is contained in:
Wilson Snyder
2010-12-02 14:00:43 -05:00
parent 48047d523a
commit cfd07ccd34
4 changed files with 41 additions and 0 deletions
+6
View File
@@ -1163,6 +1163,12 @@ void WidthVisitor::widthCheck (AstNode* nodep, const char* side,
// Maybe this should be a special warning? Not for now.
ignoreWarn = true;
}
if ((nodep->castAdd() && underp->width()==1 && underp->isOne())
|| (nodep->castSub() && underp->width()==1 && underp->isOne() && 0==strcmp(side,"RHS"))) {
// "foo + 1'b1", or "foo - 1'b1" are very common, people assume they extend correctly
ignoreWarn = true;
}
if (bad && !ignoreWarn) {
if (debug()>4) nodep->backp()->dumpTree(cout," back: ");
nodep->v3warn(WIDTH,"Operator "<<nodep->prettyTypeName()