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