Fix elaboration time errors, bug1429.

This commit is contained in:
Wilson Snyder 2019-08-04 22:34:54 -04:00
parent 7d4958264a
commit 81e806e895
9 changed files with 90 additions and 22 deletions

View File

@ -14,6 +14,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
**** Show included-from filenames in warnings, bug1439. [Todd Strader]
**** Fix elaboration time errors, bug1429. [Udi Finkelstein]
**** Fix not reporting some duplicate signals/ports, bug1462. [Peter Gerst]
**** Fix not in array context on non-power-of-two slices, msg2946. [Yu Sheng Lin]

View File

@ -2674,6 +2674,35 @@ public:
void filep(AstNodeVarRef* nodep) { setNOp3p(nodep); }
};
class AstElabDisplay : public AstNode {
// Parents: stmtlist
// Children: SFORMATF to generate print string
private:
AstDisplayType m_displayType;
public:
AstElabDisplay(FileLine* fileline, AstDisplayType dispType, AstNode* exprsp)
: AstNode(fileline) {
setOp1p(new AstSFormatF(fileline, AstSFormatF::NoFormat(), exprsp));
m_displayType = dispType;
}
ASTNODE_NODE_FUNCS(ElabDisplay)
virtual const char* broken() const { BROKEN_RTN(!fmtp()); return NULL; }
virtual string verilogKwd() const { return (string("$")+string(displayType().ascii())); }
virtual bool isGateOptimizable() const { return false; }
virtual bool isPredictOptimizable() const { return false; }
virtual bool isPure() const { return false; } // SPECIAL: $display has 'visual' ordering
virtual bool isOutputter() const { return true; } // SPECIAL: $display makes output
virtual bool isUnlikely() const { return true; }
virtual V3Hash sameHash() const { return V3Hash(displayType()); }
virtual bool same(const AstNode* samep) const {
return displayType()==static_cast<const AstElabDisplay*>(samep)->displayType(); }
virtual int instrCount() const { return instrCountPli(); }
AstDisplayType displayType() const { return m_displayType; }
void displayType(AstDisplayType type) { m_displayType = type; }
void fmtp(AstSFormatF* nodep) { addOp1p(nodep); } // op1 = To-String formatter
AstSFormatF* fmtp() const { return VN_CAST(op1p(), SFormatF); }
};
class AstSFormat : public AstNodeStmt {
// Parents: statement container
// Children: string to load

View File

@ -222,6 +222,9 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
virtual void visit(AstDisplay* nodep) {
visitNodeDisplay(nodep, nodep->filep(), nodep->fmtp()->text(), nodep->fmtp()->exprsp());
}
virtual void visit(AstElabDisplay* nodep) {
visitNodeDisplay(nodep, NULL, nodep->fmtp()->text(), nodep->fmtp()->exprsp());
}
virtual void visit(AstFScanF* nodep) {
visitNodeDisplay(nodep, nodep->filep(), nodep->text(), nodep->exprsp());
}

View File

@ -180,6 +180,11 @@ class EmitXmlFileVisitor : public AstNVisitor {
puts(" displaytype="); putsQuoted(nodep->verilogKwd());
outputChildrenEnd(nodep, "");
}
virtual void visit(AstElabDisplay* nodep) {
outputTag(nodep, "");
puts(" displaytype="); putsQuoted(nodep->verilogKwd());
outputChildrenEnd(nodep, "");
}
virtual void visit(AstExtend* nodep) {
outputTag(nodep, "");
puts(" width="); putsQuoted(cvtToStr(nodep->width()));

View File

@ -404,9 +404,6 @@ private:
nodep->scopeNamep(new AstScopeName(nodep->fileline()));
}
}
virtual void visit(AstDisplay* nodep) {
iterateChildren(nodep);
}
virtual void visit(AstUdpTable* nodep) {
UINFO(5,"UDPTABLE "<<nodep<<endl);

View File

@ -2295,6 +2295,30 @@ private:
// Just let all arguments seek their natural sizes
userIterateChildren(nodep, WidthVP(SELF, BOTH).p());
}
virtual void visit(AstElabDisplay* nodep) {
assertAtStatement(nodep);
// Just let all arguments seek their natural sizes
userIterateChildren(nodep, WidthVP(SELF, BOTH).p());
if (!m_paramsOnly) {
V3Const::constifyParamsEdit(nodep->fmtp()); // fmtp may change
switch (nodep->displayType()) {
case AstDisplayType::DT_INFO:
nodep->v3warn(USERINFO, nodep->fmtp()->text());
break;
case AstDisplayType::DT_ERROR:
nodep->v3warn(USERERROR, nodep->fmtp()->text());
break;
case AstDisplayType::DT_WARNING:
nodep->v3warn(USERWARN, nodep->fmtp()->text());
break;
case AstDisplayType::DT_FATAL:
nodep->v3warn(USERFATAL, nodep->fmtp()->text());
break;
default: UASSERT_OBJ(false, nodep, "Unexpected elaboration display type");
}
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
}
}
virtual void visit(AstFOpen* nodep) {
// Although a system function in IEEE, here a statement which sets the file pointer (MCD)
assertAtStatement(nodep);

View File

@ -2961,15 +2961,15 @@ elaboration_system_task<nodep>: // IEEE: elaboration_system_task (1800-2009)
elaboration_system_task_guts<nodep>: // IEEE: part of elaboration_system_task (1800-2009)
// // $fatal first argument is exit number, must be constant
yD_INFO parenE { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, NULL, NULL); }
| yD_INFO '(' exprList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, NULL, $3); }
| yD_WARNING parenE { $$ = new AstDisplay($1,AstDisplayType::DT_WARNING, NULL, NULL); }
| yD_WARNING '(' exprList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WARNING, NULL, $3); }
| yD_ERROR parenE { $$ = GRAMMARP->createDisplayError($1); }
| yD_ERROR '(' exprList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_ERROR, NULL, $3); $$->addNext(new AstStop($1)); }
| yD_FATAL parenE { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, NULL, NULL); $$->addNext(new AstStop($1)); }
| yD_FATAL '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, NULL, NULL); $$->addNext(new AstStop($1)); DEL($3); }
| yD_FATAL '(' expr ',' exprListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, NULL, $5); $$->addNext(new AstStop($1)); DEL($3); }
yD_INFO parenE { $$ = new AstElabDisplay($1, AstDisplayType::DT_INFO, NULL); }
| yD_INFO '(' exprList ')' { $$ = new AstElabDisplay($1, AstDisplayType::DT_INFO, $3); }
| yD_WARNING parenE { $$ = new AstElabDisplay($1, AstDisplayType::DT_WARNING, NULL); }
| yD_WARNING '(' exprList ')' { $$ = new AstElabDisplay($1, AstDisplayType::DT_WARNING, $3); }
| yD_ERROR parenE { $$ = new AstElabDisplay($1, AstDisplayType::DT_ERROR, NULL); }
| yD_ERROR '(' exprList ')' { $$ = new AstElabDisplay($1, AstDisplayType::DT_ERROR, $3); }
| yD_FATAL parenE { $$ = new AstElabDisplay($1, AstDisplayType::DT_FATAL, NULL); }
| yD_FATAL '(' expr ')' { $$ = new AstElabDisplay($1, AstDisplayType::DT_FATAL, NULL); DEL($3); }
| yD_FATAL '(' expr ',' exprListE ')' { $$ = new AstElabDisplay($1, AstDisplayType::DT_FATAL, $5); DEL($3); }
;
exprOrDataType<nodep>: // expr | data_type: combined to prevent conflicts

View File

@ -1,6 +1,18 @@
[0] -Info: t_assert_comp_bad.v:9: Assertion failed in top.t.genblk1: User compile-time info
[0] %Warning: t_assert_comp_bad.v:10: Assertion failed in top.t.genblk1: User compile-time warning
[0] %Warning: t_assert_comp_bad.v:11: Assertion failed in top.t.genblk1: 00000001
[0] %Error: t_assert_comp_bad.v:12: Assertion failed in top.t.genblk1: User compile-time error
%Error: t/t_assert_comp_bad.v:12: Verilog $stop
Aborting...
-Info: t/t_assert_comp_bad.v:9: User compile-time info
: ... In instance t
$info("User compile-time info");
^~~~~
%Warning-USERWARN: t/t_assert_comp_bad.v:10: User compile-time warning
: ... In instance t
$warning("User compile-time warning");
^~~~~~~~
... Use "/* verilator lint_off USERWARN */" and lint_on around source to disable this message.
%Warning-USERWARN: t/t_assert_comp_bad.v:11: 00000001
: ... In instance t
$warning(1);
^~~~~~~~
%Warning-USERERROR: t/t_assert_comp_bad.v:12: User compile-time error
: ... In instance t
$error("User compile-time error");
^~~~~~
%Error: Exiting due to

View File

@ -13,10 +13,6 @@ compile(
verilator_flags2 => ['--assert'],
nc_flags2 => ['+assert'],
vcs_flags2 => ['-assert svaext'],
);
execute(
check_finished => 0,
fails => 1,
expect_filename => $Self->{golden_filename},
);