From a54ac52a35e4781723f0b0be73cd1f13af022397 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 29 Nov 2020 08:23:36 -0500 Subject: [PATCH] Internals: Use 'Bit' where mean 2-state type. No functional change. --- src/V3Assert.cpp | 6 +-- src/V3AssertPre.cpp | 8 ++-- src/V3Ast.h | 4 +- src/V3AstNodes.h | 98 +++++++++++++++++++++++-------------------- src/V3Case.cpp | 11 +++-- src/V3Delayed.cpp | 4 +- src/V3LinkDot.cpp | 2 +- src/V3LinkResolve.cpp | 8 ++-- src/V3MergeCond.cpp | 9 ++-- src/V3Trace.cpp | 4 +- src/V3Unknown.cpp | 4 +- src/V3Width.cpp | 60 +++++++++++++------------- src/verilog.y | 12 +++--- 13 files changed, 117 insertions(+), 113 deletions(-) diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index dea371906..de633e7ef 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -73,7 +73,7 @@ private: // This allows syntax errors and such to be detected normally. (v3Global.opt.assertOn() ? static_cast(new AstCMath(fl, "Verilated::assertOn()", 1)) - : static_cast(new AstConst(fl, AstConst::LogicFalse()))), + : static_cast(new AstConst(fl, AstConst::BitFalse()))), nodep, nullptr); newp->user1(true); // Don't assert/cover this if return newp; @@ -207,7 +207,7 @@ private: bool allow_none = nodep->unique0Pragma(); // Empty case means no property - if (!propp) propp = new AstConst(nodep->fileline(), AstConst::LogicFalse()); + if (!propp) propp = new AstConst(nodep->fileline(), AstConst::BitFalse()); // Note: if this ends with an 'else', then we don't need to validate that one of the // predicates evaluates to true. @@ -276,7 +276,7 @@ private: } } // Empty case means no property - if (!propp) propp = new AstConst(nodep->fileline(), AstConst::LogicFalse()); + if (!propp) propp = new AstConst(nodep->fileline(), AstConst::BitFalse()); bool allow_none = has_default || nodep->unique0Pragma(); AstNode* ohot diff --git a/src/V3AssertPre.cpp b/src/V3AssertPre.cpp index 59a89461a..727e0aafe 100644 --- a/src/V3AssertPre.cpp +++ b/src/V3AssertPre.cpp @@ -103,7 +103,7 @@ private: AstNode* past = new AstPast(fl, exprp, nullptr); past->dtypeFrom(exprp); exprp = new AstAnd(fl, past, new AstNot(fl, exprp->cloneTree(false))); - exprp->dtypeSetLogicBool(); + exprp->dtypeSetBit(); nodep->replaceWith(exprp); nodep->sentreep(newSenTree(nodep)); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -122,7 +122,7 @@ private: AstNode* past = new AstPast(fl, exprp, nullptr); past->dtypeFrom(exprp); exprp = new AstAnd(fl, new AstNot(fl, past), exprp->cloneTree(false)); - exprp->dtypeSetLogicBool(); + exprp->dtypeSetBit(); nodep->replaceWith(exprp); nodep->sentreep(newSenTree(nodep)); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -135,7 +135,7 @@ private: AstNode* past = new AstPast(fl, exprp, nullptr); past->dtypeFrom(exprp); exprp = new AstEq(fl, past, exprp->cloneTree(false)); - exprp->dtypeSetLogicBool(); + exprp->dtypeSetBit(); nodep->replaceWith(exprp); nodep->sentreep(newSenTree(nodep)); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -153,7 +153,7 @@ private: AstNode* past = new AstPast(fl, lhsp, nullptr); past->dtypeFrom(lhsp); AstNode* exprp = new AstOr(fl, new AstNot(fl, past), rhsp); - exprp->dtypeSetLogicBool(); + exprp->dtypeSetBit(); nodep->replaceWith(exprp); nodep->sentreep(newSenTree(nodep)); VL_DO_DANGLING(pushDeletep(nodep), nodep); diff --git a/src/V3Ast.h b/src/V3Ast.h index a6649441d..969ea9da2 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1721,7 +1721,7 @@ public: void dtypeSetLogicSized(int width, VSigning numeric) { dtypep(findLogicDType(width, width, numeric)); // Since sized, widthMin is width } - void dtypeSetLogicBool() { dtypep(findLogicBoolDType()); } + void dtypeSetBit() { dtypep(findBitDType()); } void dtypeSetDouble() { dtypep(findDoubleDType()); } void dtypeSetString() { dtypep(findStringDType()); } void dtypeSetSigned32() { dtypep(findSigned32DType()); } @@ -1730,7 +1730,7 @@ public: void dtypeSetVoid() { dtypep(findVoidDType()); } // Data type locators - AstNodeDType* findLogicBoolDType() { return findBasicDType(AstBasicDTypeKwd::LOGIC); } + AstNodeDType* findBitDType() { return findBasicDType(AstBasicDTypeKwd::LOGIC); } AstNodeDType* findDoubleDType() { return findBasicDType(AstBasicDTypeKwd::DOUBLE); } AstNodeDType* findStringDType() { return findBasicDType(AstBasicDTypeKwd::STRING); } AstNodeDType* findSigned32DType() { return findBasicDType(AstBasicDTypeKwd::INTEGER); } diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 63f91c1a5..f93d968d7 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -140,17 +140,23 @@ public: , m_num(V3Number::String(), this, num) { dtypeSetString(); } - class LogicFalse {}; - AstConst(FileLine* fl, LogicFalse) // Shorthand const 0, dtype should be a logic of size 1 + class BitFalse {}; + AstConst(FileLine* fl, BitFalse) // Shorthand const 0, dtype should be a logic of size 1 : ASTGEN_SUPER(fl) , m_num(this, 1, 0) { - dtypeSetLogicBool(); + dtypeSetBit(); } - class LogicTrue {}; - AstConst(FileLine* fl, LogicTrue) // Shorthand const 1, dtype should be a logic of size 1 + class BitTrue {}; + AstConst(FileLine* fl, BitTrue) // Shorthand const 1, dtype should be a logic of size 1 : ASTGEN_SUPER(fl) , m_num(this, 1, 1) { - dtypeSetLogicBool(); + dtypeSetBit(); + } + class BitTrueFalse {}; + AstConst(FileLine* fl, BitTrueFalse, bool on) + : ASTGEN_SUPER(fl) + , m_num(this, 1, on ? 1 : 0) { + dtypeSetBit(); } ASTNODE_NODE_FUNCS(Const) virtual string name() const override { return num().ascii(); } // * = Value @@ -4822,7 +4828,7 @@ public: : ASTGEN_SUPER(fl) { addOp1p(exprp); addOp2p(itemsp); - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(Inside) AstNode* exprp() const { return op1p(); } // op1 = LHS expression to compare with @@ -5545,7 +5551,7 @@ class AstRedAnd final : public AstNodeUniop { public: AstRedAnd(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER(fl, lhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(RedAnd) virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRedAnd(lhs); } @@ -5559,7 +5565,7 @@ class AstRedOr final : public AstNodeUniop { public: AstRedOr(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER(fl, lhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(RedOr) virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRedOr(lhs); } @@ -5573,7 +5579,7 @@ class AstRedXor final : public AstNodeUniop { public: AstRedXor(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER(fl, lhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(RedXor) virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRedXor(lhs); } @@ -5592,7 +5598,7 @@ class AstRedXnor final : public AstNodeUniop { public: AstRedXnor(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER(fl, lhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(RedXnor) virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRedXnor(lhs); } @@ -5626,7 +5632,7 @@ class AstLogNot final : public AstNodeUniop { public: AstLogNot(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER(fl, lhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(LogNot) virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opLogNot(lhs); } @@ -5899,7 +5905,7 @@ class AstIsUnknown final : public AstNodeUniop { public: AstIsUnknown(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER(fl, lhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(IsUnknown) virtual void numberOperate(V3Number& out, const V3Number& lhs) override { @@ -5916,7 +5922,7 @@ class AstIsUnbounded final : public AstNodeUniop { public: AstIsUnbounded(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER(fl, lhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(IsUnbounded) virtual void numberOperate(V3Number& out, const V3Number&) override { @@ -5934,7 +5940,7 @@ class AstOneHot final : public AstNodeUniop { public: AstOneHot(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER(fl, lhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(OneHot) virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opOneHot(lhs); } @@ -5950,7 +5956,7 @@ class AstOneHot0 final : public AstNodeUniop { public: AstOneHot0(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER(fl, lhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(OneHot0) virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opOneHot0(lhs); } @@ -6523,7 +6529,7 @@ class AstLogOr final : public AstNodeBiop { public: AstLogOr(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(LogOr) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6546,7 +6552,7 @@ class AstLogAnd final : public AstNodeBiop { public: AstLogAnd(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(LogAnd) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6569,7 +6575,7 @@ class AstLogEq final : public AstNodeBiCom { public: AstLogEq(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(LogEq) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6592,7 +6598,7 @@ class AstLogIf final : public AstNodeBiop { public: AstLogIf(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(LogIf) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6703,7 +6709,7 @@ class AstEq final : public AstNodeBiCom { public: AstEq(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(Eq) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6727,7 +6733,7 @@ class AstEqD final : public AstNodeBiCom { public: AstEqD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(EqD) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6751,7 +6757,7 @@ class AstEqN final : public AstNodeBiCom { public: AstEqN(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(EqN) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6775,7 +6781,7 @@ class AstNeq final : public AstNodeBiCom { public: AstNeq(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(Neq) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6797,7 +6803,7 @@ class AstNeqD final : public AstNodeBiCom { public: AstNeqD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(NeqD) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6821,7 +6827,7 @@ class AstNeqN final : public AstNodeBiCom { public: AstNeqN(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(NeqN) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6845,7 +6851,7 @@ class AstLt final : public AstNodeBiop { public: AstLt(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(Lt) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6867,7 +6873,7 @@ class AstLtD final : public AstNodeBiop { public: AstLtD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(LtD) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6891,7 +6897,7 @@ class AstLtS final : public AstNodeBiop { public: AstLtS(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(LtS) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6914,7 +6920,7 @@ class AstLtN final : public AstNodeBiop { public: AstLtN(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(LtN) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6938,7 +6944,7 @@ class AstGt final : public AstNodeBiop { public: AstGt(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(Gt) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6960,7 +6966,7 @@ class AstGtD final : public AstNodeBiop { public: AstGtD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(GtD) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -6984,7 +6990,7 @@ class AstGtS final : public AstNodeBiop { public: AstGtS(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(GtS) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7007,7 +7013,7 @@ class AstGtN final : public AstNodeBiop { public: AstGtN(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(GtN) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7031,7 +7037,7 @@ class AstGte final : public AstNodeBiop { public: AstGte(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(Gte) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7055,7 +7061,7 @@ class AstGteD final : public AstNodeBiop { public: AstGteD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(GteD) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7079,7 +7085,7 @@ class AstGteS final : public AstNodeBiop { public: AstGteS(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(GteS) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7102,7 +7108,7 @@ class AstGteN final : public AstNodeBiop { public: AstGteN(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(GteN) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7126,7 +7132,7 @@ class AstLte final : public AstNodeBiop { public: AstLte(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(Lte) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7150,7 +7156,7 @@ class AstLteD final : public AstNodeBiop { public: AstLteD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(LteD) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7174,7 +7180,7 @@ class AstLteS final : public AstNodeBiop { public: AstLteS(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(LteS) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7197,7 +7203,7 @@ class AstLteN final : public AstNodeBiop { public: AstLteN(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(LteN) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7794,7 +7800,7 @@ class AstEqCase final : public AstNodeBiCom { public: AstEqCase(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(EqCase) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7816,7 +7822,7 @@ class AstNeqCase final : public AstNodeBiCom { public: AstNeqCase(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(NeqCase) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7839,7 +7845,7 @@ class AstEqWild final : public AstNodeBiop { public: AstEqWild(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(EqWild) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { @@ -7863,7 +7869,7 @@ class AstNeqWild final : public AstNodeBiop { public: AstNeqWild(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER(fl, lhsp, rhsp) { - dtypeSetLogicBool(); + dtypeSetBit(); } ASTNODE_NODE_FUNCS(NeqWild) virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { diff --git a/src/V3Case.cpp b/src/V3Case.cpp index 3b36aa6ba..06ece071c 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -318,7 +318,7 @@ private: itemp = VN_CAST(itemp->nextp(), CaseItem)) { if (!itemp->condsp()) { // Default clause. Just make true, we'll optimize it away later - itemp->condsp(new AstConst(itemp->fileline(), AstConst::LogicTrue())); + itemp->condsp(new AstConst(itemp->fileline(), AstConst::BitTrue())); hadDefault = true; } else { // Expressioned clause @@ -336,7 +336,7 @@ private: VL_DANGLING(iconstp); // For simplicity, make expression that is not equal, and let later // optimizations remove it - condp = new AstConst(itemp->fileline(), AstConst::LogicFalse()); + condp = new AstConst(itemp->fileline(), AstConst::BitFalse()); } else if (AstInsideRange* irangep = VN_CAST(icondp, InsideRange)) { // Similar logic in V3Width::visit(AstInside) condp = irangep->newAndFromInside(cexprp, irangep->lhsp()->unlinkFrBack(), @@ -375,9 +375,8 @@ private: if (!hadDefault) { // If there was no default, add a empty one, this greatly simplifies below code // and constant propagation will just eliminate it for us later. - nodep->addItemsp( - new AstCaseItem(nodep->fileline(), - new AstConst(nodep->fileline(), AstConst::LogicTrue()), nullptr)); + nodep->addItemsp(new AstCaseItem( + nodep->fileline(), new AstConst(nodep->fileline(), AstConst::BitTrue()), nullptr)); } if (debug() >= 9) nodep->dumpTree(cout, " _comp_COND: "); // Now build the IF statement tree @@ -419,7 +418,7 @@ private: VL_DANGLING(ifexprp); if (depth == CASE_ENCODER_GROUP_DEPTH) { // End of group - can skip the condition VL_DO_DANGLING(itemexprp->deleteTree(), itemexprp); - itemexprp = new AstConst(itemp->fileline(), AstConst::LogicTrue()); + itemexprp = new AstConst(itemp->fileline(), AstConst::BitTrue()); } AstIf* newp = new AstIf(itemp->fileline(), itemexprp, istmtsp, nullptr); if (itemnextp) { diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 096dbe912..60888600e 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -289,7 +289,7 @@ private: new AstConst(nodep->fileline(), 0)); AstAssign* setassignp = new AstAssign( nodep->fileline(), new AstVarRef(nodep->fileline(), setvscp, VAccess::WRITE), - new AstConst(nodep->fileline(), AstConst::LogicTrue())); + new AstConst(nodep->fileline(), AstConst::BitTrue())); nodep->addNextHere(setassignp); } if (m_nextDlyp) { // Tell next assigndly it can share the variable @@ -436,7 +436,7 @@ private: prep = new AstAssignPre( nodep->fileline(), new AstVarRef(nodep->fileline(), dlyvscp, VAccess::WRITE), - new AstConst(nodep->fileline(), AstConst::LogicFalse())); + new AstConst(nodep->fileline(), AstConst::BitFalse())); } else { prep = new AstAssignPre( nodep->fileline(), diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 23f600284..c82b3dba5 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -2099,7 +2099,7 @@ private: if (start) { AstNode* newp; if (m_ds.m_dotErr) { - newp = new AstConst(nodep->fileline(), AstConst::LogicFalse()); + newp = new AstConst(nodep->fileline(), AstConst::BitFalse()); } else { // RHS is what we're left with newp = nodep->rhsp()->unlinkFrBack(); diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 8734e2532..9d8ba6828 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -472,10 +472,10 @@ private: } varoutp = varp; // Tie off - m_modp->addStmtp(new AstAssignW( - varp->fileline(), - new AstVarRef(varp->fileline(), varp, VAccess::WRITE), - new AstConst(varp->fileline(), AstConst::LogicFalse()))); + m_modp->addStmtp( + new AstAssignW(varp->fileline(), + new AstVarRef(varp->fileline(), varp, VAccess::WRITE), + new AstConst(varp->fileline(), AstConst::BitFalse()))); } else { varp->v3error("Only inputs and outputs are allowed in udp modules"); } diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 73742a3be..d0d23b7bc 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -161,7 +161,7 @@ private: // rarely required (only when trying to merge a "cond & value" with an // earlier ternary), we will just always mask it for safety. AstNode* maskLsb(AstNode* nodep) { - AstNode* const maskp = new AstConst(nodep->fileline(), AstConst::LogicTrue()); + AstNode* const maskp = new AstConst(nodep->fileline(), AstConst::BitTrue()); return new AstAnd(nodep->fileline(), nodep, maskp); } @@ -170,8 +170,7 @@ private: // of the RHS is expected to be deleted by the caller. AstNode* foldAndUnlink(AstNode* rhsp, bool condTrue) { if (rhsp->sameTree(m_mgCondp)) { - return condTrue ? new AstConst(rhsp->fileline(), AstConst::LogicTrue()) - : new AstConst(rhsp->fileline(), AstConst::LogicFalse()); + return new AstConst(rhsp->fileline(), AstConst::BitTrueFalse(), condTrue); } else if (AstNodeCond* const condp = extractCond(rhsp)) { AstNode* const resp = condTrue ? condp->expr1p()->unlinkFrBack() : condp->expr2p()->unlinkFrBack(); @@ -183,12 +182,12 @@ private: } else if (AstAnd* const andp = VN_CAST(rhsp, And)) { if (andp->lhsp()->sameTree(m_mgCondp)) { return condTrue ? maskLsb(andp->rhsp()->unlinkFrBack()) - : new AstConst(rhsp->fileline(), AstConst::LogicFalse()); + : new AstConst(rhsp->fileline(), AstConst::BitFalse()); } else { UASSERT_OBJ(andp->rhsp()->sameTree(m_mgCondp), rhsp, "AstAnd doesn't hold condition expression"); return condTrue ? maskLsb(andp->lhsp()->unlinkFrBack()) - : new AstConst(rhsp->fileline(), AstConst::LogicFalse()); + : new AstConst(rhsp->fileline(), AstConst::BitFalse()); } } rhsp->v3fatalSrc("Don't know how to fold expression"); diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 9a704175b..fcd5e7e03 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -426,7 +426,7 @@ private: void addActivitySetter(AstNode* insertp, uint32_t code) { FileLine* const fl = insertp->fileline(); AstAssign* const setterp = new AstAssign(fl, selectActivity(fl, code, VAccess::WRITE), - new AstConst(fl, AstConst::LogicTrue())); + new AstConst(fl, AstConst::BitTrue())); if (AstCCall* const callp = VN_CAST(insertp, CCall)) { callp->addNextHere(setterp); } else if (AstCFunc* const funcp = VN_CAST(insertp, CFunc)) { @@ -687,7 +687,7 @@ private: // Clear fine grained activity flags for (uint32_t i = 0; i < m_activityNumber; ++i) { AstNode* const clrp = new AstAssign(fl, selectActivity(fl, i, VAccess::WRITE), - new AstConst(fl, AstConst::LogicFalse())); + new AstConst(fl, AstConst::BitFalse())); cleanupFuncp->addStmtsp(clrp); } } diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 6c760998e..0c2dcc553 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -254,7 +254,7 @@ private: iterateChildren(nodep); // Ahh, we're two state, so this is easy UINFO(4, " ISUNKNOWN->0 " << nodep << endl); - AstConst* newp = new AstConst(nodep->fileline(), AstConst::LogicFalse()); + AstConst* newp = new AstConst(nodep->fileline(), AstConst::BitFalse()); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } @@ -275,7 +275,7 @@ private: nonXp = nodep->fhsp(); else { // Was all X-s UINFO(4, " COUNTBITS('x)->0 " << nodep << endl); - AstConst* newp = new AstConst(nodep->fileline(), AstConst::LogicFalse()); + AstConst* newp = new AstConst(nodep->fileline(), AstConst::BitFalse()); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); return; diff --git a/src/V3Width.cpp b/src/V3Width.cpp index edba6166d..a781e4c87 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -794,7 +794,7 @@ private: AstConst* widthConstp = VN_CAST(nodep->widthp(), Const); if (!widthConstp) { nodep->v3error("Width of bit extract isn't a constant"); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); return; } int width = nodep->widthConst(); @@ -1085,7 +1085,7 @@ private: virtual void visit(AstFell* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->exprp(), SELF, BOTH); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } virtual void visit(AstPast* nodep) override { @@ -1115,7 +1115,7 @@ private: virtual void visit(AstRose* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->exprp(), SELF, BOTH); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } @@ -1129,7 +1129,7 @@ private: virtual void visit(AstStable* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->exprp(), SELF, BOTH); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } @@ -1137,7 +1137,7 @@ private: if (m_vup->prelim()) { iterateCheckBool(nodep, "LHS", nodep->lhsp(), BOTH); iterateCheckBool(nodep, "RHS", nodep->rhsp(), BOTH); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } @@ -1182,7 +1182,7 @@ private: virtual void visit(AstIsUnbounded* nodep) override { if (m_vup->prelim()) { userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } virtual void visit(AstUCFunc* nodep) override { @@ -1567,7 +1567,7 @@ private: virtual void visit(AstRefDType* nodep) override { if (nodep->doingWidth()) { // Early exit if have circular parameter definition nodep->v3error("Typedef's type is circular: " << nodep->prettyName()); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); nodep->doingWidth(false); return; } @@ -1729,7 +1729,7 @@ private: if (!underDtp) underDtp = underp->dtypep()->basicp(); if (!underDtp) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: Size-changing cast on non-basic data type"); - underDtp = VN_CAST(nodep->findLogicBoolDType(), BasicDType); + underDtp = VN_CAST(nodep->findBitDType(), BasicDType); } UASSERT_OBJ(underp == nodep->op1p(), nodep, "Assuming op1 is cast value"); // A cast propagates its size to the lower expression and is included in the maximum @@ -1770,7 +1770,7 @@ private: UASSERT_OBJ(nodep->valuep(), nodep, "circular, but without value"); nodep->v3error("Variable's initial value is circular: " << nodep->prettyNameQ()); pushDeletep(nodep->valuep()->unlinkFrBack()); - nodep->valuep(new AstConst(nodep->fileline(), AstConst::LogicTrue())); + nodep->valuep(new AstConst(nodep->fileline(), AstConst::BitTrue())); nodep->dtypeFrom(nodep->valuep()); nodep->didWidth(true); return; @@ -2116,7 +2116,7 @@ private: for (AstNode* itemp = nodep->itemsp(); itemp; itemp = itemp->nextp()) { iterateCheck(nodep, "Inside Item", itemp, CONTEXT, FINAL, subDTypep, EXTEND_EXP); } - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); if (debug() >= 9) nodep->dumpTree(cout, "-inside-in: "); // Now rip out the inside and replace with simple math AstNode* newp = nullptr; @@ -2140,7 +2140,7 @@ private: newp = inewp; } } - if (!newp) newp = new AstConst(nodep->fileline(), AstConst::LogicFalse()); + if (!newp) newp = new AstConst(nodep->fileline(), AstConst::BitFalse()); if (debug() >= 9) newp->dumpTree(cout, "-inside-out: "); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -2270,7 +2270,7 @@ private: << nodep->fromp()->dtypep()->prettyTypeName() << "'"); } // Error handling - nodep->replaceWith(new AstConst(nodep->fileline(), AstConst::LogicFalse())); + nodep->replaceWith(new AstConst(nodep->fileline(), AstConst::BitFalse())); VL_DO_DANGLING(pushDeletep(nodep), nodep); } AstNode* memberSelClass(AstMemberSel* nodep, AstClassRefDType* adtypep) { @@ -2590,7 +2590,7 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find" || nodep->name() == "find_first" || nodep->name() == "find_last") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findLogicBoolDType(), + AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), adtypep->keyDTypep(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); @@ -2600,7 +2600,7 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find_index" || nodep->name() == "find_first_index" || nodep->name() == "find_last_index") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findLogicBoolDType(), + AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), adtypep->keyDTypep(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); @@ -2695,7 +2695,7 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find" || nodep->name() == "find_first" || nodep->name() == "find_last" || nodep->name() == "find_index") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findLogicBoolDType(), + AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); @@ -2705,7 +2705,7 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find_index" || nodep->name() == "find_first_index" || nodep->name() == "find_last_index") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findLogicBoolDType(), + AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); @@ -2827,7 +2827,7 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find" || nodep->name() == "find_first" || nodep->name() == "find_last") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findLogicBoolDType(), + AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); @@ -2837,7 +2837,7 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find_index" || nodep->name() == "find_first_index" || nodep->name() == "find_last_index") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findLogicBoolDType(), + AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); @@ -3453,7 +3453,7 @@ private: } if (patp) { // Determine initial values - vdtypep = nodep->findLogicBoolDType(); + vdtypep = nodep->findBitDType(); patp->dtypep(vdtypep); AstNode* valuep = patternMemberValueIterate(patp); { // Packed. Convert to concat for now. @@ -3537,7 +3537,7 @@ private: iterateCheckBool(nodep, "Disable", nodep->disablep(), BOTH); // it's like an if() condition. } - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } @@ -4184,7 +4184,7 @@ private: if (nodep->didWidth()) return; if (nodep->doingWidth()) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: Recursive function or task call"); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); nodep->didWidth(true); return; } @@ -4539,7 +4539,7 @@ private: UASSERT_OBJ(!nodep->op2p(), nodep, "For unary ops only!"); if (m_vup->prelim()) { iterateCheckBool(nodep, "LHS", nodep->op1p(), BOTH); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } void visit_log_and_or(AstNodeBiop* nodep) { @@ -4551,7 +4551,7 @@ private: if (m_vup->prelim()) { iterateCheckBool(nodep, "LHS", nodep->lhsp(), BOTH); iterateCheckBool(nodep, "RHS", nodep->rhsp(), BOTH); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } void visit_red_and_or(AstNodeUniop* nodep) { @@ -4563,7 +4563,7 @@ private: // Sign: unsigned out (11.8.1) if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } void visit_red_unknown(AstNodeUniop* nodep) { @@ -4575,7 +4575,7 @@ private: // Sign: unsigned out (11.8.1) if (m_vup->prelim()) { userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } @@ -4638,7 +4638,7 @@ private: iterateCheck(nodep, "RHS", nodep->rhsp(), CONTEXT, FINAL, subDTypep, (signedFl ? EXTEND_LHS : EXTEND_ZERO), warnOn); } - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } void visit_cmp_real(AstNodeBiop* nodep) { @@ -4653,7 +4653,7 @@ private: // See similar handling in visit_cmp_eq_gt where created iterateCheckReal(nodep, "LHS", nodep->lhsp(), BOTH); iterateCheckReal(nodep, "RHS", nodep->rhsp(), BOTH); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } void visit_cmp_string(AstNodeBiop* nodep) { @@ -4666,7 +4666,7 @@ private: // See similar handling in visit_cmp_eq_gt where created iterateCheckString(nodep, "LHS", nodep->lhsp(), BOTH); iterateCheckString(nodep, "RHS", nodep->rhsp(), BOTH); - nodep->dtypeSetLogicBool(); + nodep->dtypeSetBit(); } } @@ -5181,10 +5181,10 @@ private: nodep->v3error("Logical operator " << nodep->prettyTypeName() << " expects a non-complex data type on the " << side << "."); - underp->replaceWith(new AstConst(nodep->fileline(), AstConst::LogicFalse())); + underp->replaceWith(new AstConst(nodep->fileline(), AstConst::BitFalse())); VL_DO_DANGLING(pushDeletep(underp), underp); } else { - bool bad = widthBad(underp, nodep->findLogicBoolDType()); + bool bad = widthBad(underp, nodep->findBitDType()); if (bad) { { // if (warnOn), but not needed here if (debug() > 4) nodep->backp()->dumpTree(cout, " back: "); diff --git a/src/verilog.y b/src/verilog.y index 7026be4bd..31bd79457 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -3114,14 +3114,14 @@ statement_item: // IEEE: statement_item | yP_MINUSGT idDotted/*hierarchical_identifier-event*/ ';' { // AssignDly because we don't have stratified queue, and need to // read events, clear next event, THEN apply this set - $$ = new AstAssignDly($1, $2, new AstConst($1, AstConst::LogicTrue())); } + $$ = new AstAssignDly($1, $2, new AstConst($1, AstConst::BitTrue())); } //UNSUP yP_MINUSGTGT delay_or_event_controlE hierarchical_identifier/*event*/ ';' { UNSUP } // // IEEE remove below | yP_MINUSGTGT delayE idDotted/*hierarchical_identifier-event*/ ';' - { $$ = new AstAssignDly($1, $3, new AstConst($1, AstConst::LogicTrue())); } + { $$ = new AstAssignDly($1, $3, new AstConst($1, AstConst::BitTrue())); } // // // IEEE: loop_statement - | yFOREVER stmtBlock { $$ = new AstWhile($1,new AstConst($1,AstConst::LogicTrue()),$2); } + | yFOREVER stmtBlock { $$ = new AstWhile($1,new AstConst($1, AstConst::BitTrue()), $2); } | yREPEAT '(' expr ')' stmtBlock { $$ = new AstRepeat($1,$3,$5);} | yWHILE '(' expr ')' stmtBlock { $$ = new AstWhile($1,$3,$5);} // // for's first ';' is in for_initialization @@ -3179,7 +3179,7 @@ statementFor: // IEEE: part of statement $$->addStmtsp(new AstWhile($1, $4,$8,$6)); } | yFOR '(' for_initialization ';' for_stepE ')' stmtBlock { $$ = new AstBegin($1, "", $3, false, true); - $$->addStmtsp(new AstWhile($1, new AstConst($1,AstConst::LogicTrue()),$7,$5)); } + $$->addStmtsp(new AstWhile($1, new AstConst($1,AstConst::BitTrue()), $7, $5)); } ; statementVerilatorPragmas: @@ -4191,7 +4191,7 @@ expr: // IEEE: part of expression/constant_expression/primary // // IEEE: "... hierarchical_identifier select" see below // // // IEEE: empty_queue (IEEE 1800-2017 empty_unpacked_array_concatenation) - | '{' '}' { $$ = new AstConst($1, AstConst::LogicFalse()); + | '{' '}' { $$ = new AstConst($1, AstConst::BitFalse()); BBUNSUP($1, "Unsupported: empty queues (\"{ }\")"); } // // // IEEE: concatenation/constant_concatenation @@ -4250,7 +4250,7 @@ expr: // IEEE: part of expression/constant_expression/primary // // // IEEE: cond_predicate - here to avoid reduce problems // // Note expr includes cond_pattern - | ~l~expr yP_ANDANDAND ~r~expr { $$ = new AstConst($2, AstConst::LogicFalse()); + | ~l~expr yP_ANDANDAND ~r~expr { $$ = new AstConst($2, AstConst::BitFalse()); BBUNSUP($2, "Unsupported: &&& expression"); } // // // IEEE: cond_pattern - here to avoid reduce problems