For UNUSED, ignore black boxed sys calls

This commit is contained in:
Wilson Snyder 2010-12-30 07:55:31 -05:00
parent 6283df7491
commit 2cb97f7475
9 changed files with 60 additions and 7 deletions

View File

@ -1679,6 +1679,22 @@ struct AstSFormat : public AstNode {
void lhsp(AstNode* nodep) { setOp3p(nodep); }
};
struct AstSysIgnore : public AstNode {
// Parents: stmtlist
// Children: varrefs or exprs
AstSysIgnore(FileLine* fileline, AstNode* exprsp)
: AstNode (fileline) { setNOp1p(exprsp); }
ASTNODE_NODE_FUNCS(SysIgnore, SYSIGNORE)
virtual string verilogKwd() const { return "$ignored"; }
virtual bool isGateOptimizable() const { return false; } // Though deleted before opt
virtual bool isPredictOptimizable() const { return false; } // Though deleted before opt
virtual bool isSplittable() const { return false; } // Though deleted before opt
virtual bool isOutputter() const { return true; } // Though deleted before opt
virtual int instrCount() const { return instrCountPli(); }
AstNode* exprsp() const { return op1p()->castNode(); } // op1 = Expressions to output
void exprsp(AstNode* nodep) { addOp1p(nodep); } // op1 = Expressions to output
};
struct AstFClose : public AstNodeStmt {
// Parents: stmtlist
// Children: file which must be a varref

View File

@ -1508,6 +1508,14 @@ private:
// If output of a presel didn't get consted, chances are V3Param didn't visit properly
virtual void visit(AstNodePreSel* nodep, AstNUser*) {}
// Ignored, can eliminate early
virtual void visit(AstSysIgnore* nodep, AstNUser*) {
nodep->iterateChildren(*this);
if (m_doNConst) {
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
}
}
//-----
// Jump elimination

View File

@ -276,6 +276,12 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
if (nodep->msbp()) { putbs(","); nodep->msbp()->iterateChildren(*this); }
puts(");\n");
}
virtual void visit(AstSysIgnore* nodep, AstNUser*) {
putfs(nodep,nodep->verilogKwd());
putbs(" (");
nodep->exprsp()->iterateChildren(*this);
puts(");\n");
}
virtual void visit(AstNodeFor* nodep, AstNUser*) {
putfs(nodep,"for (");
m_suppressSemi = true;

View File

@ -154,6 +154,12 @@ private:
}
m_setRefLvalue = last_setRefLvalue;
}
virtual void visit(AstSysIgnore* nodep, AstNUser*) {
// Can't know if lvalue or not; presume so as stricter
bool last_setRefLvalue = m_setRefLvalue;
nodep->iterateChildren(*this);
m_setRefLvalue = last_setRefLvalue;
}
virtual void visit(AstReadMem* nodep, AstNUser*) {
bool last_setRefLvalue = m_setRefLvalue;
{

View File

@ -197,6 +197,7 @@ private:
// STATE
vector<UndrivenVarEntry*> m_entryps; // Nodes to delete when we are finished
bool m_markBoth; // Mark as driven+used
// METHODS
static int debug() {
@ -242,8 +243,8 @@ private:
if (varrefp && constp && !constp->num().isFourState()) {
UndrivenVarEntry* entryp = getEntryp (varrefp->varp());
int lsb = constp->toUInt();
if (varrefp->lvalue()) entryp->drivenBit(lsb, nodep->width());
else entryp->usedBit(lsb, nodep->width());
if (m_markBoth || varrefp->lvalue()) entryp->drivenBit(lsb, nodep->width());
if (m_markBoth || !varrefp->lvalue()) entryp->usedBit(lsb, nodep->width());
} else {
// else other varrefs handled as unknown mess in AstVarRef
nodep->iterateChildren(*this);
@ -252,8 +253,16 @@ private:
virtual void visit(AstVarRef* nodep, AstNUser*) {
// Any variable
UndrivenVarEntry* entryp = getEntryp (nodep->varp());
if (nodep->lvalue()) entryp->drivenWhole();
else entryp->usedWhole();
if (m_markBoth || nodep->lvalue()) entryp->drivenWhole();
if (m_markBoth || !nodep->lvalue()) entryp->usedWhole();
}
// Don't know what black boxed calls do, assume in+out
virtual void visit(AstSysIgnore* nodep, AstNUser*) {
bool prevMark = m_markBoth;
m_markBoth = true;
nodep->iterateChildren(*this);
m_markBoth = prevMark;
}
// Until we support tables, primitives will have undriven and unused I/Os
@ -274,6 +283,7 @@ private:
public:
// CONSTUCTORS
UndrivenVisitor(AstNetlist* nodep) {
m_markBoth = false;
AstNode::user1ClearTree(); // user1p() used on entire tree
nodep->accept(*this);
}

View File

@ -809,6 +809,9 @@ private:
nodep->width(32,32);
}
}
virtual void visit(AstSysIgnore* nodep, AstNUser* vup) {
nodep->exprsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
}
virtual void visit(AstReadMem* nodep, AstNUser*) {
nodep->filenamep()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
nodep->memp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());

View File

@ -2063,8 +2063,8 @@ function_subroutine_callNoMethod<nodep>: // IEEE: function_subroutine_call (as f
system_t_call<nodep>: // IEEE: system_tf_call (as task)
//
yaD_IGNORE parenE { $$ = NULL; }
| yaD_IGNORE '(' exprList ')' { $$ = NULL; }
yaD_IGNORE parenE { $$ = new AstSysIgnore($<fl>1,NULL); }
| yaD_IGNORE '(' exprList ')' { $$ = new AstSysIgnore($<fl>1,$3); }
//
| yaD_DPI parenE { $$ = new AstTaskRef($<fl>1,*$1,NULL); }
| yaD_DPI '(' exprList ')' { $$ = new AstTaskRef($2,*$1,$3); }

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0.
compile (
v_flags2 => ["--lint-only -Wall -Wno-DECLFILENAME"],
v_flags2 => ["--lint-only --bbox-sys -Wall -Wno-DECLFILENAME"],
fails=>1,
verilator_make_gcc => 0,
make_top_shell => 0,

View File

@ -18,6 +18,10 @@ module t (/*AUTOARG*/
// Check we don't warn about unused UDP signals
udp_mux2 udpsub (out, in, in, in);
// Check ignoreds mark as used
reg sysused;
initial $bboxed(sysused);
endmodule
module sub;