diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index e649c02cdc..c89ccb227b 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -236,27 +236,20 @@ class UnknownVisitor final : public VNVisitor { AstNodeExpr* const lhsp = nodep->lhsp()->unlinkFrBack(); AstNodeExpr* const rhsp = nodep->rhsp()->unlinkFrBack(); AstNodeExpr* newp; - if (!VN_IS(rhsp, Const)) { - nodep->v3warn(E_UNSUPPORTED, "Unsupported: RHS of ==? or !=? must be " - "constant to be synthesizable"); // Says spec. - // Replace with anything that won't cause more errors - newp = new AstEq{nodep->fileline(), lhsp, rhsp}; + // X or Z's become mask, ala case statements. + V3Number nummask{rhsp, rhsp->width()}; + nummask.opBitsNonX(VN_AS(rhsp, Const)->num()); + V3Number numval{rhsp, rhsp->width()}; + numval.opBitsOne(VN_AS(rhsp, Const)->num()); + AstNodeExpr* const and1p + = new AstAnd{nodep->fileline(), lhsp, new AstConst{nodep->fileline(), nummask}}; + AstNodeExpr* const and2p = new AstConst{nodep->fileline(), numval}; + if (VN_IS(nodep, EqWild)) { + newp = new AstEq{nodep->fileline(), and1p, and2p}; } else { - // X or Z's become mask, ala case statements. - V3Number nummask{rhsp, rhsp->width()}; - nummask.opBitsNonX(VN_AS(rhsp, Const)->num()); - V3Number numval{rhsp, rhsp->width()}; - numval.opBitsOne(VN_AS(rhsp, Const)->num()); - AstNodeExpr* const and1p = new AstAnd{nodep->fileline(), lhsp, - new AstConst{nodep->fileline(), nummask}}; - AstNodeExpr* const and2p = new AstConst{nodep->fileline(), numval}; - if (VN_IS(nodep, EqWild)) { - newp = new AstEq{nodep->fileline(), and1p, and2p}; - } else { - newp = new AstNeq{nodep->fileline(), and1p, and2p}; - } - VL_DO_DANGLING(rhsp->deleteTree(), rhsp); + newp = new AstNeq{nodep->fileline(), and1p, and2p}; } + VL_DO_DANGLING(rhsp->deleteTree(), rhsp); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); // Iterate tree now that we may have gotten rid of the compare