diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 5a446fb1d..752eb0ea0 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -73,25 +73,31 @@ private: AstNode* newIfAssertOn(AstNode* nodep) { // Add a internal if to check assertions are on. // Don't make this a AND term, as it's unlikely to need to test this. - return new AstIf (nodep->fileline(), - // If assertions are off, have constant propagation rip them out later - // This allows syntax errors and such to be detected normally. - (v3Global.opt.assertOn() - ? (AstNode*)(new AstCMath(nodep->fileline(), "Verilated::assertOn()", 1)) - : (AstNode*)(new AstConst(nodep->fileline(), AstConst::LogicFalse()))), - nodep, NULL); + AstNode* newp + = new AstIf (nodep->fileline(), + // If assertions are off, have constant propagation rip them out later + // This allows syntax errors and such to be detected normally. + (v3Global.opt.assertOn() + ? (AstNode*)(new AstCMath(nodep->fileline(), "Verilated::assertOn()", 1)) + : (AstNode*)(new AstConst(nodep->fileline(), AstConst::LogicFalse()))), + nodep, NULL); + newp->user1(true); // Don't assert/cover this if + return newp; } AstNode* newIfCoverageOn(AstNode* nodep) { // Add a internal if to check coverage is on // Don't make this a AND term, as it's unlikely to need to test this. - return new AstIf (nodep->fileline(), - // If assertions are off, have constant propagation rip them out later - // This allows syntax errors and such to be detected normally. - (v3Global.opt.coverage() - ? (AstNode*)(new AstConst(nodep->fileline(), AstConst::LogicTrue())) - : (AstNode*)(new AstConst(nodep->fileline(), AstConst::LogicFalse()))), - nodep, NULL); + AstNode* newp + = new AstIf (nodep->fileline(), + // If assertions are off, have constant propagation rip them out later + // This allows syntax errors and such to be detected normally. + (v3Global.opt.coverage() + ? (AstNode*)(new AstConst(nodep->fileline(), AstConst::LogicTrue())) + : (AstNode*)(new AstConst(nodep->fileline(), AstConst::LogicFalse()))), + nodep, NULL); + newp->user1(true); // Don't assert/cover this if + return newp; } AstNode* newFireAssert(AstNode* nodep, const string& message) { @@ -176,6 +182,7 @@ private: } virtual void visit(AstIf* nodep, AstNUser*) { + if (nodep->user1SetOnce()) return; if (nodep->uniquePragma() || nodep->unique0Pragma()) { AstNodeIf* ifp = nodep; AstNode* propp = NULL; @@ -184,13 +191,14 @@ private: // If this statement ends with 'else if', then nextIf will point to the // nextIf statement. Otherwise it will be null. AstNodeIf* nextifp = dynamic_cast(ifp->elsesp()); + ifp->condp()->iterateAndNext(*this); // Recurse into the true case. - ifp->ifsp()->iterateChildren(*this); + ifp->ifsp()->iterateAndNext(*this); // If the last else is not an else if, recurse into that too. if (ifp->elsesp() && !nextifp) { - ifp->elsesp()->iterateChildren(*this); + ifp->elsesp()->iterateAndNext(*this); } // Build a bitmask of the true predicates @@ -225,8 +233,7 @@ private: nodep->replaceWith(checkifp); pushDeletep(nodep); } else { - nodep->ifsp()->iterateChildren(*this); - nodep->elsesp()->iterateChildren(*this); + nodep->iterateChildren(*this); } } diff --git a/src/V3Branch.cpp b/src/V3Branch.cpp index 37521c8c4..699f9b8e2 100644 --- a/src/V3Branch.cpp +++ b/src/V3Branch.cpp @@ -94,9 +94,9 @@ private: public: // CONSTUCTORS - BranchVisitor(AstNetlist* rootp) { + BranchVisitor(AstNetlist* nodep) { reset(); - rootp->iterateChildren(*this); + nodep->iterateChildren(*this); } virtual ~BranchVisitor() {} }; diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index b2c012af9..d1af2895c 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -245,23 +245,23 @@ class EmitVBaseVisitor : public EmitCBaseVisitor { virtual void visit(AstFOpen* nodep, AstNUser*) { putfs(nodep,nodep->verilogKwd()); putbs(" ("); - if (nodep->filep()) nodep->filep()->iterateChildren(*this); + if (nodep->filep()) nodep->filep()->iterateAndNext(*this); putbs(","); - if (nodep->filenamep()) nodep->filenamep()->iterateChildren(*this); + if (nodep->filenamep()) nodep->filenamep()->iterateAndNext(*this); putbs(","); - if (nodep->modep()) nodep->modep()->iterateChildren(*this); + if (nodep->modep()) nodep->modep()->iterateAndNext(*this); puts(");\n"); } virtual void visit(AstFClose* nodep, AstNUser*) { putfs(nodep,nodep->verilogKwd()); putbs(" ("); - if (nodep->filep()) nodep->filep()->iterateChildren(*this); + if (nodep->filep()) nodep->filep()->iterateAndNext(*this); puts(");\n"); } virtual void visit(AstFFlush* nodep, AstNUser*) { putfs(nodep,nodep->verilogKwd()); putbs(" ("); - if (nodep->filep()) nodep->filep()->iterateChildren(*this); + if (nodep->filep()) nodep->filep()->iterateAndNext(*this); puts(");\n"); } virtual void visit(AstJumpGo* nodep, AstNUser*) { @@ -269,23 +269,23 @@ class EmitVBaseVisitor : public EmitCBaseVisitor { } virtual void visit(AstJumpLabel* nodep, AstNUser*) { putbs("begin : "+cvtToStr((void*)(nodep))+"\n"); - if (nodep->stmtsp()) nodep->stmtsp()->iterateChildren(*this); + if (nodep->stmtsp()) nodep->stmtsp()->iterateAndNext(*this); puts("end\n"); } virtual void visit(AstReadMem* nodep, AstNUser*) { putfs(nodep,nodep->verilogKwd()); putbs(" ("); - if (nodep->filenamep()) nodep->filenamep()->iterateChildren(*this); + if (nodep->filenamep()) nodep->filenamep()->iterateAndNext(*this); putbs(","); - if (nodep->memp()) nodep->memp()->iterateChildren(*this); - if (nodep->lsbp()) { putbs(","); nodep->lsbp()->iterateChildren(*this); } - if (nodep->msbp()) { putbs(","); nodep->msbp()->iterateChildren(*this); } + if (nodep->memp()) nodep->memp()->iterateAndNext(*this); + if (nodep->lsbp()) { putbs(","); nodep->lsbp()->iterateAndNext(*this); } + if (nodep->msbp()) { putbs(","); nodep->msbp()->iterateAndNext(*this); } puts(");\n"); } virtual void visit(AstSysIgnore* nodep, AstNUser*) { putfs(nodep,nodep->verilogKwd()); putbs(" ("); - nodep->exprsp()->iterateChildren(*this); + nodep->exprsp()->iterateAndNext(*this); puts(");\n"); } virtual void visit(AstNodeFor* nodep, AstNUser*) { diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index 2aa5b133e..3fe5a480e 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -115,7 +115,7 @@ private: } virtual void visit(AstActive* nodep, AstNUser*) { m_activep = nodep; - nodep->sensesp()->iterateChildren(*this); + nodep->sensesp()->iterateChildren(*this); // iterateAndNext? m_activep = NULL; nodep->iterateChildren(*this); } @@ -201,7 +201,7 @@ private: virtual void visit(AstActive* nodep, AstNUser*) { UINFO(8,"ACTIVE "<sensesp()->iterateChildren(*this); + nodep->sensesp()->iterateChildren(*this); // iterateAndNext? m_activep = NULL; nodep->iterateChildren(*this); } diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 530d367ee..5514ce2a1 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1711,7 +1711,7 @@ private: virtual void visit(AstPslCover* nodep, AstNUser*) { // TOP LEVEL NODE nodep->propp()->iterateAndNext(*this,WidthVP(1,1,BOTH).p()); - nodep->stmtsp()->iterateChildren(*this,WidthVP(ANYSIZE,0,BOTH).p()); + nodep->stmtsp()->iterateAndNext(*this); widthCheckReduce(nodep,"Property",nodep->propp()); // it's like an if() condition. } virtual void visit(AstPslAssert* nodep, AstNUser*) { diff --git a/test_regress/t/t_assert_basic.v b/test_regress/t/t_assert_basic.v index 4af4a3d72..02322c752 100644 --- a/test_regress/t/t_assert_basic.v +++ b/test_regress/t/t_assert_basic.v @@ -27,6 +27,7 @@ module t (/*AUTOARG*/ if (cyc!=0) begin cyc <= cyc + 1; toggle <= !cyc[0]; + if (cyc==7) assert (cyc[0] == cyc[1]); // bug743 if (cyc==9) begin `ifdef FAILING_ASSERTIONS assert (0) else $info;