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
|
|
|
|
//
|
|
|
|
|
// AUTHORS: Wilson Snyder with Paul Wasson, Duane Gabli
|
|
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2010-01-06 02:15:06 +00:00
|
|
|
|
// Copyright 2005-2010 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.
|
|
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
// Pre steps:
|
|
|
|
|
// Attach clocks to each assertion
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
|
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 "V3AssertPre.h"
|
|
|
|
|
#include "V3Ast.h"
|
|
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
// Assert class functions
|
|
|
|
|
|
|
|
|
|
class AssertPreVisitor : public AstNVisitor {
|
|
|
|
|
// Removes clocks and other pre-optimizations
|
|
|
|
|
// Eventually inlines calls to sequences, properties, etc.
|
|
|
|
|
// We're not parsing the tree, or anything more complicated.
|
|
|
|
|
private:
|
|
|
|
|
// NODE STATE/TYPES
|
|
|
|
|
// STATE
|
|
|
|
|
// Reset each module:
|
2008-11-20 12:55:54 +00:00
|
|
|
|
AstNodeSenItem* m_seniDefaultp; // Default sensitivity (from AstDefClock)
|
2006-08-26 11:35:28 +00:00
|
|
|
|
// Reset each assertion:
|
2008-11-20 12:55:54 +00:00
|
|
|
|
AstNodeSenItem* m_senip; // Last sensitivity
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
|
|
// METHODS
|
2009-01-21 21:56:50 +00:00
|
|
|
|
static int debug() {
|
|
|
|
|
static int level = -1;
|
|
|
|
|
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
|
AstSenTree* newSenTree(AstNode* nodep) {
|
|
|
|
|
// Create sentree based on clocked or default clock
|
|
|
|
|
// Return NULL for always
|
|
|
|
|
AstSenTree* newp = NULL;
|
2008-11-20 12:55:54 +00:00
|
|
|
|
AstNodeSenItem* senip = m_senip ? m_senip : m_seniDefaultp;
|
2008-08-06 21:51:36 +00:00
|
|
|
|
if (!senip) {
|
|
|
|
|
nodep->v3error("Unsupported: Unclocked assertion");
|
|
|
|
|
newp = new AstSenTree(nodep->fileline(), NULL);
|
|
|
|
|
} else {
|
|
|
|
|
newp = new AstSenTree(nodep->fileline(), senip->cloneTree(true));
|
|
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
|
return newp;
|
|
|
|
|
}
|
2008-08-06 16:52:39 +00:00
|
|
|
|
void clearAssertInfo() {
|
|
|
|
|
m_senip = NULL;
|
|
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
|
|
// VISITORS //========== Statements
|
|
|
|
|
virtual void visit(AstPslDefClock* nodep, AstNUser*) {
|
|
|
|
|
nodep->iterateChildren(*this);
|
|
|
|
|
// Store the new default clock, reset on new module
|
|
|
|
|
m_seniDefaultp = nodep->sensesp();
|
|
|
|
|
// Trash it
|
|
|
|
|
nodep->unlinkFrBack();
|
|
|
|
|
pushDeletep(nodep); nodep=NULL;
|
|
|
|
|
}
|
2008-08-06 16:52:39 +00:00
|
|
|
|
virtual void visit(AstClocking* nodep, AstNUser*) {
|
|
|
|
|
UINFO(8," CLOCKING"<<nodep<<endl);
|
2008-08-06 21:51:36 +00:00
|
|
|
|
// Store the new default clock, reset on new module
|
|
|
|
|
m_seniDefaultp = nodep->sensesp();
|
|
|
|
|
// Trash it, keeping children
|
|
|
|
|
if (nodep->bodysp()) {
|
|
|
|
|
nodep->replaceWith(nodep->bodysp()->unlinkFrBack());
|
|
|
|
|
} else {
|
|
|
|
|
nodep->unlinkFrBack();
|
2008-08-06 16:52:39 +00:00
|
|
|
|
}
|
|
|
|
|
pushDeletep(nodep); nodep=NULL;
|
|
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
|
|
virtual void visit(AstPslCover* nodep, AstNUser*) {
|
2008-08-06 16:52:39 +00:00
|
|
|
|
if (nodep->sentreep()) return; // Already processed
|
|
|
|
|
clearAssertInfo();
|
2006-08-26 11:35:28 +00:00
|
|
|
|
nodep->iterateChildren(*this);
|
|
|
|
|
nodep->sentreep(newSenTree(nodep));
|
2008-08-06 16:52:39 +00:00
|
|
|
|
clearAssertInfo();
|
2006-08-26 11:35:28 +00:00
|
|
|
|
}
|
|
|
|
|
virtual void visit(AstPslAssert* nodep, AstNUser*) {
|
2008-08-06 16:52:39 +00:00
|
|
|
|
if (nodep->sentreep()) return; // Already processed
|
|
|
|
|
clearAssertInfo();
|
2006-08-26 11:35:28 +00:00
|
|
|
|
nodep->iterateChildren(*this);
|
|
|
|
|
nodep->sentreep(newSenTree(nodep));
|
2008-08-06 16:52:39 +00:00
|
|
|
|
clearAssertInfo();
|
2006-08-26 11:35:28 +00:00
|
|
|
|
}
|
|
|
|
|
virtual void visit(AstPslClocked* nodep, AstNUser*) {
|
|
|
|
|
nodep->iterateChildren(*this);
|
|
|
|
|
if (m_senip) {
|
2010-01-16 01:07:16 +00:00
|
|
|
|
nodep->v3error("Unsupported: Only one PSL clock allowed per assertion");
|
2006-08-26 11:35:28 +00:00
|
|
|
|
}
|
2008-08-06 16:52:39 +00:00
|
|
|
|
// Block is the new expression to evaluate
|
2006-08-26 11:35:28 +00:00
|
|
|
|
AstNode* blockp = nodep->propp()->unlinkFrBack();
|
2008-08-06 16:52:39 +00:00
|
|
|
|
if (nodep->disablep()) {
|
|
|
|
|
blockp = new AstAnd(nodep->disablep()->fileline(),
|
|
|
|
|
new AstNot(nodep->disablep()->fileline(),
|
|
|
|
|
nodep->disablep()->unlinkFrBack()),
|
|
|
|
|
blockp);
|
|
|
|
|
}
|
|
|
|
|
// Unlink and just keep a pointer to it, convert to sentree as needed
|
2006-08-26 11:35:28 +00:00
|
|
|
|
m_senip = nodep->sensesp();
|
|
|
|
|
nodep->replaceWith(blockp);
|
|
|
|
|
pushDeletep(nodep); nodep=NULL;
|
|
|
|
|
}
|
2009-11-07 11:20:20 +00:00
|
|
|
|
virtual void visit(AstNodeModule* nodep, AstNUser*) {
|
2006-08-26 11:35:28 +00:00
|
|
|
|
nodep->iterateChildren(*this);
|
|
|
|
|
// Reset defaults
|
|
|
|
|
m_seniDefaultp = NULL;
|
|
|
|
|
}
|
|
|
|
|
virtual void visit(AstNode* nodep, AstNUser*) {
|
|
|
|
|
nodep->iterateChildren(*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// CONSTRUCTORS
|
|
|
|
|
AssertPreVisitor(AstNetlist* nodep) {
|
|
|
|
|
m_seniDefaultp = NULL;
|
2008-08-06 16:52:39 +00:00
|
|
|
|
clearAssertInfo();
|
2006-08-26 11:35:28 +00:00
|
|
|
|
// Process
|
|
|
|
|
nodep->accept(*this);
|
|
|
|
|
}
|
|
|
|
|
virtual ~AssertPreVisitor() {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
// Top Assert class
|
|
|
|
|
|
|
|
|
|
void V3AssertPre::assertPreAll(AstNetlist* nodep) {
|
|
|
|
|
UINFO(2,__FUNCTION__<<": "<<endl);
|
|
|
|
|
AssertPreVisitor visitor (nodep);
|
|
|
|
|
}
|