2012-04-13 01:08:20 +00:00
|
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2006-08-26 11:35:28 +00:00
|
|
|
|
//*************************************************************************
|
|
|
|
|
// DESCRIPTION: Verilator: Collect and print statistics
|
|
|
|
|
//
|
2008-04-25 12:14:27 +00:00
|
|
|
|
// Code available from: http://www.veripool.org/verilator
|
2006-08-26 11:35:28 +00:00
|
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2017-01-15 17:09:59 +00:00
|
|
|
|
// Copyright 2005-2017 by Wilson Snyder. This program is free software; you can
|
2006-08-26 11:35:28 +00:00
|
|
|
|
// redistribute it and/or modify it under the terms of either the GNU
|
2009-05-04 21:07:57 +00:00
|
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
|
// Version 2.0.
|
2006-08-26 11:35:28 +00:00
|
|
|
|
//
|
|
|
|
|
// Verilator is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
|
2006-12-18 19:20:45 +00:00
|
|
|
|
#include "config_build.h"
|
|
|
|
|
#include "verilatedos.h"
|
2008-06-30 17:11:25 +00:00
|
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstdarg>
|
2006-08-26 11:35:28 +00:00
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <iomanip>
|
|
|
|
|
|
|
|
|
|
#include "V3Global.h"
|
|
|
|
|
#include "V3Assert.h"
|
|
|
|
|
#include "V3Ast.h"
|
|
|
|
|
#include "V3GraphDfa.h"
|
|
|
|
|
#include "V3Stats.h"
|
|
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
// Assert class functions
|
|
|
|
|
|
|
|
|
|
class AssertVisitor : public AstNVisitor {
|
|
|
|
|
private:
|
|
|
|
|
// NODE STATE/TYPES
|
|
|
|
|
// Cleared on netlist
|
|
|
|
|
// AstNode::user() -> bool. True if processed
|
2008-11-25 14:03:49 +00:00
|
|
|
|
AstUser1InUse m_inuser1;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
|
|
// STATE
|
2009-11-07 11:20:20 +00:00
|
|
|
|
AstNodeModule* m_modp; // Last module
|
2008-08-06 16:52:39 +00:00
|
|
|
|
AstBegin* m_beginp; // Last begin
|
2006-08-26 11:35:28 +00:00
|
|
|
|
V3Double0 m_statAsCover; // Statistic tracking
|
|
|
|
|
V3Double0 m_statAsPsl; // Statistic tracking
|
|
|
|
|
V3Double0 m_statAsFull; // Statistic tracking
|
2007-03-06 21:43:38 +00:00
|
|
|
|
V3Double0 m_statAsSV; // Statistic tracking
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
|
|
// METHODS
|
2007-03-06 21:43:38 +00:00
|
|
|
|
string assertDisplayMessage(AstNode* nodep, const string& prefix, const string& message) {
|
|
|
|
|
return (string("[%0t] "+prefix+": ")+nodep->fileline()->filebasename()
|
|
|
|
|
+":"+cvtToStr(nodep->fileline()->lineno())
|
|
|
|
|
+": Assertion failed in %m"
|
|
|
|
|
+((message != "")?": ":"")+message
|
2014-03-17 00:57:15 +00:00
|
|
|
|
+"\n");
|
2007-03-06 21:43:38 +00:00
|
|
|
|
}
|
|
|
|
|
void replaceDisplay(AstDisplay* nodep, const string& prefix) {
|
2010-02-02 01:15:48 +00:00
|
|
|
|
nodep->displayType(AstDisplayType::DT_WRITE);
|
2010-01-17 20:53:12 +00:00
|
|
|
|
nodep->fmtp()->text(assertDisplayMessage(nodep, prefix, nodep->fmtp()->text()));
|
2013-02-03 18:27:37 +00:00
|
|
|
|
// cppcheck-suppress nullPointer
|
2014-09-05 02:25:19 +00:00
|
|
|
|
AstNode* timenewp = new AstTime(nodep->fileline());
|
|
|
|
|
if (AstNode* timesp = nodep->fmtp()->exprsp()) {
|
|
|
|
|
timesp->unlinkFrBackWithNext();
|
|
|
|
|
timenewp->addNext(timesp);
|
|
|
|
|
}
|
|
|
|
|
nodep->fmtp()->exprsp(timenewp);
|
2010-01-17 20:53:12 +00:00
|
|
|
|
if (!nodep->fmtp()->scopeNamep() && nodep->fmtp()->formatScopeTracking()) {
|
|
|
|
|
nodep->fmtp()->scopeNamep(new AstScopeName(nodep->fileline()));
|
2007-06-14 16:41:32 +00:00
|
|
|
|
}
|
2007-03-06 21:43:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AstNode* newIfAssertOn(AstNode* nodep) {
|
2006-08-26 11:35:28 +00:00
|
|
|
|
// 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.
|
2014-04-17 02:33:25 +00:00
|
|
|
|
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;
|
2007-03-06 21:43:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AstNode* newFireAssert(AstNode* nodep, const string& message) {
|
2010-02-02 01:15:48 +00:00
|
|
|
|
AstDisplay* dispp = new AstDisplay (nodep->fileline(), AstDisplayType::DT_ERROR, message, NULL, NULL);
|
2007-03-06 21:43:38 +00:00
|
|
|
|
AstNode* bodysp = dispp;
|
|
|
|
|
replaceDisplay(dispp, "%%Error"); // Convert to standard DISPLAY format
|
|
|
|
|
bodysp->addNext(new AstStop (nodep->fileline()));
|
|
|
|
|
bodysp = newIfAssertOn(bodysp);
|
2006-08-26 11:35:28 +00:00
|
|
|
|
return bodysp;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-06 16:52:39 +00:00
|
|
|
|
void newPslAssertion(AstNode* nodep, AstNode* propp, AstSenTree* sentreep,
|
|
|
|
|
AstNode* stmtsp, const string& message) {
|
2006-08-26 11:35:28 +00:00
|
|
|
|
propp->unlinkFrBack();
|
|
|
|
|
sentreep->unlinkFrBack();
|
2008-08-06 16:52:39 +00:00
|
|
|
|
if (stmtsp) stmtsp->unlinkFrBack();
|
2006-08-26 11:35:28 +00:00
|
|
|
|
//
|
|
|
|
|
AstNode* bodysp = NULL;
|
2008-06-10 01:25:10 +00:00
|
|
|
|
bool selfDestruct = false;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
if (AstPslCover* snodep = nodep->castPslCover()) {
|
|
|
|
|
if (!v3Global.opt.coverageUser()) {
|
|
|
|
|
selfDestruct = true;
|
|
|
|
|
} else {
|
|
|
|
|
// V3Coverage assigned us a bucket to increment.
|
|
|
|
|
AstCoverInc* covincp = snodep->coverincp()->castCoverInc();
|
2008-11-05 15:23:03 +00:00
|
|
|
|
if (!covincp) snodep->v3fatalSrc("Missing AstCoverInc under assertion");
|
2006-08-26 11:35:28 +00:00
|
|
|
|
covincp->unlinkFrBack();
|
|
|
|
|
if (message!="") covincp->declp()->comment(message);
|
|
|
|
|
bodysp = covincp;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
nodep->v3fatalSrc("Unknown node type");
|
|
|
|
|
}
|
2008-08-06 16:52:39 +00:00
|
|
|
|
if (stmtsp) bodysp = bodysp->addNext(stmtsp);
|
2006-08-26 11:35:28 +00:00
|
|
|
|
AstIf* ifp = new AstIf (nodep->fileline(), propp, bodysp, NULL);
|
|
|
|
|
bodysp = ifp;
|
2014-11-22 15:14:14 +00:00
|
|
|
|
if (nodep->castVAssert()) ifp->branchPred(AstBranchPred::BP_UNLIKELY);
|
2006-08-26 11:35:28 +00:00
|
|
|
|
//
|
|
|
|
|
AstNode* newp = new AstAlways (nodep->fileline(),
|
2013-05-01 02:55:28 +00:00
|
|
|
|
VAlwaysKwd::ALWAYS,
|
2006-08-26 11:35:28 +00:00
|
|
|
|
sentreep,
|
|
|
|
|
bodysp);
|
|
|
|
|
// Install it
|
|
|
|
|
if (selfDestruct) {
|
|
|
|
|
// Delete it after making the tree. This way we can tell the user
|
|
|
|
|
// if it wasn't constructed nicely or has other errors without needing --coverage.
|
|
|
|
|
newp->deleteTree();
|
|
|
|
|
nodep->unlinkFrBack();
|
|
|
|
|
} else {
|
|
|
|
|
nodep->replaceWith(newp);
|
|
|
|
|
}
|
|
|
|
|
// Bye
|
2015-10-04 17:16:35 +00:00
|
|
|
|
pushDeletep(nodep); VL_DANGLING(nodep);
|
2006-08-26 11:35:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-06 21:43:38 +00:00
|
|
|
|
void newVAssertion(AstVAssert* nodep, AstNode* propp) {
|
|
|
|
|
propp->unlinkFrBackWithNext();
|
|
|
|
|
AstNode* passsp = nodep->passsp(); if (passsp) passsp->unlinkFrBackWithNext();
|
|
|
|
|
AstNode* failsp = nodep->failsp(); if (failsp) failsp->unlinkFrBackWithNext();
|
|
|
|
|
//
|
|
|
|
|
if (nodep->castVAssert()) {
|
|
|
|
|
if (passsp) passsp = newIfAssertOn(passsp);
|
|
|
|
|
if (failsp) failsp = newIfAssertOn(failsp);
|
|
|
|
|
} else {
|
|
|
|
|
nodep->v3fatalSrc("Unknown node type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AstIf* ifp = new AstIf (nodep->fileline(), propp, passsp, failsp);
|
|
|
|
|
AstNode* newp = ifp;
|
2010-02-02 01:15:48 +00:00
|
|
|
|
if (nodep->castVAssert()) ifp->branchPred(AstBranchPred::BP_UNLIKELY);
|
2007-03-06 21:43:38 +00:00
|
|
|
|
//
|
|
|
|
|
// Install it
|
|
|
|
|
nodep->replaceWith(newp);
|
|
|
|
|
// Bye
|
2015-10-04 17:16:35 +00:00
|
|
|
|
pushDeletep(nodep); VL_DANGLING(nodep);
|
2007-03-06 21:43:38 +00:00
|
|
|
|
}
|
2014-03-17 01:38:29 +00:00
|
|
|
|
|
2016-11-27 13:11:38 +00:00
|
|
|
|
virtual void visit(AstIf* nodep) {
|
2014-04-17 02:33:25 +00:00
|
|
|
|
if (nodep->user1SetOnce()) return;
|
2014-03-17 01:38:29 +00:00
|
|
|
|
if (nodep->uniquePragma() || nodep->unique0Pragma()) {
|
|
|
|
|
AstNodeIf* ifp = nodep;
|
|
|
|
|
AstNode* propp = NULL;
|
|
|
|
|
bool hasDefaultElse = false;
|
|
|
|
|
do {
|
|
|
|
|
// If this statement ends with 'else if', then nextIf will point to the
|
|
|
|
|
// nextIf statement. Otherwise it will be null.
|
|
|
|
|
AstNodeIf* nextifp = dynamic_cast<AstNodeIf*>(ifp->elsesp());
|
2014-04-17 02:33:25 +00:00
|
|
|
|
ifp->condp()->iterateAndNext(*this);
|
2014-03-17 01:38:29 +00:00
|
|
|
|
|
|
|
|
|
// Recurse into the true case.
|
2014-04-17 02:33:25 +00:00
|
|
|
|
ifp->ifsp()->iterateAndNext(*this);
|
2014-03-17 01:38:29 +00:00
|
|
|
|
|
|
|
|
|
// If the last else is not an else if, recurse into that too.
|
|
|
|
|
if (ifp->elsesp() && !nextifp) {
|
2014-04-17 02:33:25 +00:00
|
|
|
|
ifp->elsesp()->iterateAndNext(*this);
|
2014-03-17 01:38:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build a bitmask of the true predicates
|
|
|
|
|
AstNode* predp = ifp->condp()->cloneTree(false);
|
|
|
|
|
if (propp) {
|
|
|
|
|
propp = new AstConcat(nodep->fileline(), predp, propp);
|
|
|
|
|
} else {
|
|
|
|
|
propp = predp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Record if this ends with an 'else' that does not have an if
|
|
|
|
|
if (ifp->elsesp() && !nextifp) {
|
|
|
|
|
hasDefaultElse = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ifp = nextifp;
|
|
|
|
|
} while (ifp);
|
|
|
|
|
|
|
|
|
|
AstNode *newifp = nodep->cloneTree(false);
|
|
|
|
|
bool allow_none = nodep->unique0Pragma();
|
|
|
|
|
|
|
|
|
|
// Note: if this ends with an 'else', then we don't need to validate that one of the
|
|
|
|
|
// predicates evaluates to true.
|
|
|
|
|
AstNode* ohot = ((allow_none || hasDefaultElse)
|
2016-11-05 14:06:43 +00:00
|
|
|
|
? static_cast<AstNode*>(new AstOneHot0(nodep->fileline(), propp))
|
|
|
|
|
: static_cast<AstNode*>(new AstOneHot (nodep->fileline(), propp)));
|
2014-03-17 01:38:29 +00:00
|
|
|
|
AstIf* checkifp = new AstIf (nodep->fileline(),
|
|
|
|
|
new AstLogNot (nodep->fileline(), ohot),
|
|
|
|
|
newFireAssert(nodep, "'unique if' statement violated"),
|
|
|
|
|
newifp);
|
|
|
|
|
checkifp->branchPred(AstBranchPred::BP_UNLIKELY);
|
|
|
|
|
nodep->replaceWith(checkifp);
|
|
|
|
|
pushDeletep(nodep);
|
|
|
|
|
} else {
|
2014-04-17 02:33:25 +00:00
|
|
|
|
nodep->iterateChildren(*this);
|
2014-03-17 01:38:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-03-06 21:43:38 +00:00
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
|
// VISITORS //========== Case assertions
|
2016-11-27 13:11:38 +00:00
|
|
|
|
virtual void visit(AstCase* nodep) {
|
2006-08-26 11:35:28 +00:00
|
|
|
|
nodep->iterateChildren(*this);
|
2012-04-29 12:55:33 +00:00
|
|
|
|
if (!nodep->user1SetOnce()) {
|
2006-08-26 11:35:28 +00:00
|
|
|
|
bool has_default=false;
|
|
|
|
|
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) {
|
|
|
|
|
if (itemp->isDefault()) has_default=true;
|
|
|
|
|
}
|
2010-12-26 02:58:28 +00:00
|
|
|
|
if (nodep->fullPragma() || nodep->priorityPragma()) {
|
2006-08-26 11:35:28 +00:00
|
|
|
|
// Simply need to add a default if there isn't one already
|
2011-08-05 01:15:24 +00:00
|
|
|
|
++m_statAsFull;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
if (!has_default) {
|
|
|
|
|
nodep->addItemsp(new AstCaseItem(nodep->fileline(), NULL/*DEFAULT*/,
|
|
|
|
|
newFireAssert(nodep, "synthesis full_case, but non-match found")));
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-26 02:58:28 +00:00
|
|
|
|
if (nodep->parallelPragma() || nodep->uniquePragma() || nodep->unique0Pragma()) {
|
2006-08-26 11:35:28 +00:00
|
|
|
|
// Need to check that one, and only one of the case items match at any moment
|
|
|
|
|
// If there's a default, we allow none to match, else exactly one must match
|
2011-08-05 01:15:24 +00:00
|
|
|
|
++m_statAsFull;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
if (!has_default && !nodep->itemsp()) {
|
|
|
|
|
// Not parallel, but harmlessly so.
|
|
|
|
|
} else {
|
|
|
|
|
AstNode* propp = NULL;
|
|
|
|
|
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) {
|
|
|
|
|
for (AstNode* icondp = itemp->condsp(); icondp!=NULL; icondp=icondp->nextp()) {
|
2016-12-03 19:49:51 +00:00
|
|
|
|
AstNode* onep;
|
|
|
|
|
AstConst* iconstp = icondp->castConst();
|
|
|
|
|
if (iconstp && iconstp->num().isFourState()
|
|
|
|
|
&& (nodep->casex() || nodep->casez() || nodep->caseInside())) {
|
|
|
|
|
V3Number nummask (itemp->fileline(), iconstp->width());
|
|
|
|
|
nummask.opBitsNonX(iconstp->num());
|
|
|
|
|
V3Number numval (itemp->fileline(), iconstp->width());
|
|
|
|
|
numval.opBitsOne(iconstp->num());
|
|
|
|
|
AstNode* and1p = new AstAnd(itemp->fileline(), nodep->exprp()->cloneTree(false),
|
|
|
|
|
new AstConst(itemp->fileline(), nummask));
|
|
|
|
|
AstNode* and2p = new AstAnd(itemp->fileline(),
|
|
|
|
|
new AstConst(itemp->fileline(), numval),
|
|
|
|
|
new AstConst(itemp->fileline(), nummask));
|
|
|
|
|
onep = AstEq::newTyped(itemp->fileline(), and1p, and2p);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
onep = AstEq::newTyped(icondp->fileline(),
|
|
|
|
|
nodep->exprp()->cloneTree(false),
|
|
|
|
|
icondp->cloneTree(false));
|
|
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
|
if (propp) propp = new AstConcat(icondp->fileline(), onep, propp);
|
|
|
|
|
else propp = onep;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-26 02:58:28 +00:00
|
|
|
|
bool allow_none = has_default || nodep->unique0Pragma();
|
|
|
|
|
AstNode* ohot = (allow_none
|
2016-11-05 14:06:43 +00:00
|
|
|
|
? static_cast<AstNode*>(new AstOneHot0(nodep->fileline(), propp))
|
|
|
|
|
: static_cast<AstNode*>(new AstOneHot (nodep->fileline(), propp)));
|
2006-08-26 11:35:28 +00:00
|
|
|
|
AstIf* ifp = new AstIf (nodep->fileline(),
|
|
|
|
|
new AstLogNot (nodep->fileline(), ohot),
|
|
|
|
|
newFireAssert(nodep, "synthesis parallel_case, but multiple matches found"),
|
|
|
|
|
NULL);
|
2010-02-02 01:15:48 +00:00
|
|
|
|
ifp->branchPred(AstBranchPred::BP_UNLIKELY);
|
2006-08-26 11:35:28 +00:00
|
|
|
|
nodep->addNotParallelp(ifp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// VISITORS //========== Statements
|
2016-11-27 13:11:38 +00:00
|
|
|
|
virtual void visit(AstDisplay* nodep) {
|
2007-03-06 21:43:38 +00:00
|
|
|
|
nodep->iterateChildren(*this);
|
|
|
|
|
// Replace the special types with standard text
|
2010-02-02 01:15:48 +00:00
|
|
|
|
if (nodep->displayType()==AstDisplayType::DT_INFO) {
|
2007-03-06 21:43:38 +00:00
|
|
|
|
replaceDisplay(nodep, "-Info");
|
2010-02-02 01:15:48 +00:00
|
|
|
|
} else if (nodep->displayType()==AstDisplayType::DT_WARNING) {
|
2007-03-06 21:43:38 +00:00
|
|
|
|
replaceDisplay(nodep, "%%Warning");
|
2010-02-02 01:15:48 +00:00
|
|
|
|
} else if (nodep->displayType()==AstDisplayType::DT_ERROR
|
|
|
|
|
|| nodep->displayType()==AstDisplayType::DT_FATAL) {
|
2007-03-06 21:43:38 +00:00
|
|
|
|
replaceDisplay(nodep, "%%Error");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-27 13:11:38 +00:00
|
|
|
|
virtual void visit(AstPslCover* nodep) {
|
2006-08-26 11:35:28 +00:00
|
|
|
|
nodep->iterateChildren(*this);
|
2008-08-06 16:52:39 +00:00
|
|
|
|
if (m_beginp && nodep->name() == "") nodep->name(m_beginp->name());
|
|
|
|
|
newPslAssertion(nodep, nodep->propp(), nodep->sentreep(),
|
2015-10-04 17:16:35 +00:00
|
|
|
|
nodep->stmtsp(), nodep->name()); VL_DANGLING(nodep);
|
2011-08-05 01:15:24 +00:00
|
|
|
|
++m_statAsCover;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
}
|
2016-11-27 13:11:38 +00:00
|
|
|
|
virtual void visit(AstVAssert* nodep) {
|
2007-03-06 21:43:38 +00:00
|
|
|
|
nodep->iterateChildren(*this);
|
2015-10-04 17:16:35 +00:00
|
|
|
|
newVAssertion(nodep, nodep->propp()); VL_DANGLING(nodep);
|
2011-08-05 01:15:24 +00:00
|
|
|
|
++m_statAsSV;
|
2007-03-06 21:43:38 +00:00
|
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
2016-11-27 13:11:38 +00:00
|
|
|
|
virtual void visit(AstNodeModule* nodep) {
|
2006-08-26 11:35:28 +00:00
|
|
|
|
m_modp = nodep;
|
|
|
|
|
//
|
|
|
|
|
nodep->iterateChildren(*this);
|
|
|
|
|
// Reset defaults
|
|
|
|
|
m_modp = NULL;
|
|
|
|
|
}
|
2016-11-27 13:11:38 +00:00
|
|
|
|
virtual void visit(AstBegin* nodep) {
|
2008-08-06 16:52:39 +00:00
|
|
|
|
// This code is needed rather than a visitor in V3Begin,
|
|
|
|
|
// because V3Assert is called before V3Begin
|
|
|
|
|
AstBegin* lastp = m_beginp;
|
|
|
|
|
{
|
|
|
|
|
m_beginp = nodep;
|
|
|
|
|
nodep->iterateChildren(*this);
|
|
|
|
|
}
|
|
|
|
|
m_beginp = lastp;
|
|
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
2016-11-27 13:11:38 +00:00
|
|
|
|
virtual void visit(AstNode* nodep) {
|
2006-08-26 11:35:28 +00:00
|
|
|
|
nodep->iterateChildren(*this);
|
|
|
|
|
}
|
|
|
|
|
public:
|
|
|
|
|
// CONSTRUCTORS
|
2015-10-04 02:33:06 +00:00
|
|
|
|
explicit AssertVisitor(AstNetlist* nodep) {
|
2008-08-06 16:52:39 +00:00
|
|
|
|
m_beginp = NULL;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
m_modp = NULL;
|
|
|
|
|
// Process
|
|
|
|
|
nodep->accept(*this);
|
|
|
|
|
}
|
|
|
|
|
virtual ~AssertVisitor() {
|
|
|
|
|
V3Stats::addStat("Assertions, PSL asserts", m_statAsPsl);
|
2007-03-06 21:43:38 +00:00
|
|
|
|
V3Stats::addStat("Assertions, SystemVerilog asserts", m_statAsSV);
|
2006-08-26 11:35:28 +00:00
|
|
|
|
V3Stats::addStat("Assertions, cover statements", m_statAsCover);
|
|
|
|
|
V3Stats::addStat("Assertions, full/parallel case", m_statAsFull);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
// Top Assert class
|
|
|
|
|
|
|
|
|
|
void V3Assert::assertAll(AstNetlist* nodep) {
|
|
|
|
|
UINFO(2,__FUNCTION__<<": "<<endl);
|
|
|
|
|
AssertVisitor visitor (nodep);
|
2015-03-12 23:47:54 +00:00
|
|
|
|
V3Global::dumpCheckGlobalTree("assert.tree", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3);
|
2006-08-26 11:35:28 +00:00
|
|
|
|
}
|