Fix some Coverity Prevent warnings

git-svn-id: file://localhost/svn/verilator/trunk/verilator@812 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
Wilson Snyder 2006-10-06 16:08:46 +00:00
parent 956c854662
commit 1c8fd37745
9 changed files with 23 additions and 19 deletions

View File

@ -1500,8 +1500,12 @@ silicon.
=item How do I generate waveforms (traces)? =item How do I generate waveforms (traces)?
Add the --trace switch to Verilator, and make sure the SystemPerl package Add the --trace switch to Verilator, and make sure the SystemPerl package
is installed (SystemC itself isn't required for C++ only tracing.) In your is installed (SystemC itself does not need to be installed for C++ only
top level C code, call Verilated::traceEverOn(true). tracing. You do not even need to compile SystemPerl; you may simply untar
the SystemPerl kit and point the SYSTEMPERL enviornment variable to the
untarred directory.)
In your top level C code, call Verilated::traceEverOn(true).
Then, in SystemC mode, create a SpTraceFile object. For an example, see Then, in SystemC mode, create a SpTraceFile object. For an example, see
the call to SpTraceFile in the test_sp/sc_main.cpp file of the the call to SpTraceFile in the test_sp/sc_main.cpp file of the

View File

@ -192,5 +192,5 @@ C<verilator>
###################################################################### ######################################################################
### Local Variables: ### Local Variables:
### compile-command: "$V4/bin/verilator_difftree ~/SandBox/workwsnyder/verilator/test_c/obj_dir/V*_03_*.tree $V4/test_c/obj_dir/V*_03_*.tree" ### compile-command: "$V4/bin/verilator_difftree $V4/test_c/obj_dir/V*_03_*.tree $V4N/test_c/obj_dir/V*_03_*.tree"
### End: ### End:

View File

@ -298,8 +298,10 @@ private:
// OPTIMIZE: We could substitute a constant for things in the sense list, for example // OPTIMIZE: We could substitute a constant for things in the sense list, for example
// always (posedge RESET) { if (RESET).... } we know RESET is true. // always (posedge RESET) { if (RESET).... } we know RESET is true.
// Summarize a long list of combo inputs as just "combo" // Summarize a long list of combo inputs as just "combo"
#ifndef __COVERITY__ // Else dead code on next line.
if (combo) nodep->sensesp()->addSensesp if (combo) nodep->sensesp()->addSensesp
(new AstSenItem(nodep->fileline(),AstSenItem::Combo())); (new AstSenItem(nodep->fileline(),AstSenItem::Combo()));
#endif
wantactivep = m_namer.getActive(nodep->fileline(), nodep->sensesp()); wantactivep = m_namer.getActive(nodep->fileline(), nodep->sensesp());
} }

View File

@ -224,12 +224,13 @@ private:
if (m_scopep) { if (m_scopep) {
nodep->unlinkFrBack(); nodep->unlinkFrBack();
m_modp->addStmtp(nodep); m_modp->addStmtp(nodep);
}
if (nodep->funcPublic()) { if (nodep->funcPublic()) {
// There may be multiple public functions by the same name; // There may be multiple public functions by the same name;
// record for later correction or making of shells // record for later correction or making of shells
m_modFuncs.insert(make_pair(nodep->name(), nodep)); m_modFuncs.insert(make_pair(nodep->name(), nodep));
nodep->name(m_scopep->nameDotless() +"__" + nodep->name()); nodep->name(m_scopep->nameDotless() +"__" + nodep->name());
}
} }
} }
} }

View File

@ -948,10 +948,7 @@ void EmitCStmts::displayArg(AstDisplay* dispp, AstNode** elistp, string fmt, cha
} else { } else {
string func; string func;
string nfmt = displayFormat(*elistp, fmt, fmtLetter, true, false); string nfmt = displayFormat(*elistp, fmt, fmtLetter, true, false);
if ((*elistp)->isQuad() && (fmtLetter=='d')) { // We don't need to check for fmtLetter=='d', as it is above.
nfmt+="ll";
func="(long long)("; // Must match %ll to avoid warnings
}
if ((*elistp)->isQuad() && (fmtLetter=='u'||fmtLetter=='o'||fmtLetter=='x')) { if ((*elistp)->isQuad() && (fmtLetter=='u'||fmtLetter=='o'||fmtLetter=='x')) {
nfmt+="ll"; nfmt+="ll";
func="(unsigned long long)("; // Must match %ull to avoid warnings func="(unsigned long long)("; // Must match %ull to avoid warnings

View File

@ -236,6 +236,9 @@ void V3Error::v3abort () {
} }
void V3Error::v3errorEnd (ostringstream& sstr) { void V3Error::v3errorEnd (ostringstream& sstr) {
#ifdef __COVERITY__
if (s_errorCode==V3ErrorCode::FATAL) __coverity_panic__(x);
#endif
if (s_errorCode!=V3ErrorCode::SUPPRESS || debug()) { if (s_errorCode!=V3ErrorCode::SUPPRESS || debug()) {
cerr<<msgPrefix()<<sstr.str(); cerr<<msgPrefix()<<sstr.str();
if (sstr.str()[sstr.str().length()-1] != '\n') { if (sstr.str()[sstr.str().length()-1] != '\n') {

View File

@ -111,7 +111,6 @@ private:
nodep->name(), nodep->modp()->origName()); nodep->name(), nodep->modp()->origName());
m_modp->addInlinesp(inlinep); // Must be parsed before any AstCells m_modp->addInlinesp(inlinep); // Must be parsed before any AstCells
// Create assignments to the pins // Create assignments to the pins
AstNode* assignlistsp = NULL;
for (AstPin* pinp = nodep->pinsp(); pinp; pinp=pinp->nextp()->castPin()) { for (AstPin* pinp = nodep->pinsp(); pinp; pinp=pinp->nextp()->castPin()) {
UINFO(6," Pin change from "<<pinp->modVarp()<<endl); UINFO(6," Pin change from "<<pinp->modVarp()<<endl);
// First, simplify it // First, simplify it
@ -142,13 +141,11 @@ private:
// Cleanup var names, etc, to not conflict // Cleanup var names, etc, to not conflict
m_cellp = nodep; m_cellp = nodep;
newmodp->iterateAndNext(*this); newmodp->iterateAndNext(*this);
if (assignlistsp) assignlistsp->iterateAndNext(*this); // And cleanup any varrefs under assigns we created...
m_cellp = NULL; m_cellp = NULL;
// Move statements to top module // Move statements to top module
if (debug()>=9) { newmodp->dumpTree(cout,"fixmod:"); } if (debug()>=9) { newmodp->dumpTree(cout,"fixmod:"); }
AstNode* stmtsp = newmodp->stmtsp(); AstNode* stmtsp = newmodp->stmtsp();
if (stmtsp) stmtsp->unlinkFrBackWithNext(); if (stmtsp) stmtsp->unlinkFrBackWithNext();
if (assignlistsp) m_modp->addStmtp(assignlistsp);
if (stmtsp) m_modp->addStmtp(stmtsp); if (stmtsp) m_modp->addStmtp(stmtsp);
// Remove the cell // Remove the cell
newmodp->deleteTree(); newmodp=NULL; // Clear any leftover ports, etc newmodp->deleteTree(); newmodp=NULL; // Clear any leftover ports, etc

View File

@ -104,7 +104,7 @@ private:
nodep->v3error("Arrayed variables may not be inputs nor outputs"); nodep->v3error("Arrayed variables may not be inputs nor outputs");
} }
if (m_ftaskp) nodep->funcLocal(true); if (m_ftaskp) nodep->funcLocal(true);
if (nodep && nodep->isSigPublic()) m_modp->modPublic(true); // Avoid flattening if signals are exposed if (nodep->isSigPublic()) m_modp->modPublic(true); // Avoid flattening if signals are exposed
} }
virtual void visit(AstNodeVarRef* nodep, AstNUser*) { virtual void visit(AstNodeVarRef* nodep, AstNUser*) {

View File

@ -298,9 +298,9 @@ private:
initp = NULL; if (nodep->backp()->nextp() == nodep) initp=nodep->backp(); initp = NULL; if (nodep->backp()->nextp() == nodep) initp=nodep->backp();
// Grab assignment // Grab assignment
AstNode* incp = NULL; // Should be last statement AstNode* incp = NULL; // Should be last statement
for (incp = nodep->bodysp(); incp->nextp(); incp = incp->nextp()) {} for (incp = nodep->bodysp(); incp && incp->nextp(); incp = incp->nextp()) {}
if (incp) V3Const::constifyTree(incp); if (incp) V3Const::constifyTree(incp);
for (incp = nodep->bodysp(); incp->nextp(); incp = incp->nextp()) {} // Again, as may have changed for (incp = nodep->bodysp(); incp && incp->nextp(); incp = incp->nextp()) {} // Again, as may have changed
// And check it // And check it
if (forUnrollCheck(nodep, initp, if (forUnrollCheck(nodep, initp,
nodep->precondsp(), nodep->condp(), nodep->precondsp(), nodep->condp(),