forked from github/verilator
Support old-style (), bug467.
This commit is contained in:
parent
2f34132275
commit
f942aba855
2
Changes
2
Changes
@ -5,6 +5,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
* Verilator 3.891 devel
|
||||
|
||||
*** Support old-style $display($time), bug467. [John Demme]
|
||||
|
||||
**** With --bbox-unsup, suppress desassign and mixed edges, bug1120. [Galen Seitz]
|
||||
|
||||
**** Fix parsing sensitivity with &&, bug934. [Luke Yang]
|
||||
|
@ -2324,9 +2324,15 @@ class AstSFormatF : public AstNode {
|
||||
// Also used as "real" function for /*verilator sformat*/ functions
|
||||
string m_text;
|
||||
bool m_hidden; // Under display, etc
|
||||
bool m_hasFormat; // Has format code
|
||||
public:
|
||||
class NoFormat {};
|
||||
AstSFormatF(FileLine* fl, const string& text, bool hidden, AstNode* exprsp)
|
||||
: AstNode(fl), m_text(text), m_hidden(hidden) {
|
||||
: AstNode(fl), m_text(text), m_hidden(hidden), m_hasFormat(true) {
|
||||
dtypeSetString();
|
||||
addNOp1p(exprsp); addNOp2p(NULL); }
|
||||
AstSFormatF(FileLine* fl, NoFormat, AstNode* exprsp)
|
||||
: AstNode(fl), m_text(""), m_hidden(true), m_hasFormat(false) {
|
||||
dtypeSetString();
|
||||
addNOp1p(exprsp); addNOp2p(NULL); }
|
||||
ASTNODE_NODE_FUNCS(SFormatF)
|
||||
@ -2345,6 +2351,8 @@ public:
|
||||
bool formatScopeTracking() const { // Track scopeNamep(); Ok if false positive
|
||||
return (name().find("%m") != string::npos || name().find("%M") != string::npos); }
|
||||
bool hidden() const { return m_hidden; }
|
||||
void hasFormat(bool flag) { m_hasFormat=flag; }
|
||||
bool hasFormat() const { return m_hasFormat; }
|
||||
};
|
||||
|
||||
class AstDisplay : public AstNodeStmt {
|
||||
@ -2360,6 +2368,12 @@ public:
|
||||
setNOp3p(filep);
|
||||
m_displayType = dispType;
|
||||
}
|
||||
AstDisplay(FileLine* fileline, AstDisplayType dispType, AstNode* filep, AstNode* exprsp)
|
||||
: AstNodeStmt (fileline) {
|
||||
setOp1p(new AstSFormatF(fileline, AstSFormatF::NoFormat(), exprsp));
|
||||
setNOp3p(filep);
|
||||
m_displayType = dispType;
|
||||
}
|
||||
ASTNODE_NODE_FUNCS(Display)
|
||||
virtual void dump(ostream& str);
|
||||
virtual const char* broken() const { BROKEN_RTN(!fmtp()); return NULL; }
|
||||
|
@ -377,6 +377,17 @@ private:
|
||||
}
|
||||
virtual void visit(AstSFormatF* nodep) {
|
||||
nodep->iterateChildren(*this);
|
||||
// Cleanup old-school displays without format arguments
|
||||
if (!nodep->hasFormat()) {
|
||||
if (nodep->text()!="") nodep->v3fatalSrc("Non-format $sformatf should have \"\" format");
|
||||
if (nodep->exprsp()->castConst()
|
||||
&& nodep->exprsp()->castConst()->num().isFromString()) {
|
||||
AstConst* fmtp = nodep->exprsp()->unlinkFrBack()->castConst();
|
||||
nodep->text(fmtp->num().toString());
|
||||
pushDeletep(fmtp); VL_DANGLING(fmtp);
|
||||
}
|
||||
nodep->hasFormat(true);
|
||||
}
|
||||
string newFormat = expectFormat(nodep, nodep->text(), nodep->exprsp(), false);
|
||||
nodep->text(newFormat);
|
||||
if ((nodep->backp()->castDisplay() && nodep->backp()->castDisplay()->displayType().needScopeTracking())
|
||||
|
@ -2629,13 +2629,13 @@ system_t_call<nodep>: // IEEE: system_tf_call (as task)
|
||||
| yD_SWRITE '(' expr ',' str commaEListE ')' { $$ = new AstSFormat($1,$3,*$5,$6); }
|
||||
| yD_SYSTEM '(' expr ')' { $$ = new AstSystemT($1,$3); }
|
||||
//
|
||||
| yD_DISPLAY parenE { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,"", NULL,NULL); }
|
||||
| yD_DISPLAY '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,*$3,NULL,$4); }
|
||||
| yD_DISPLAY parenE { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,NULL,NULL); }
|
||||
| yD_DISPLAY '(' exprList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,NULL,$3); }
|
||||
| yD_WRITE parenE { $$ = NULL; } // NOP
|
||||
| yD_WRITE '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, *$3,NULL,$4); }
|
||||
| yD_FDISPLAY '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,"",$3,NULL); }
|
||||
| yD_FDISPLAY '(' expr ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,*$5,$3,$6); }
|
||||
| yD_FWRITE '(' expr ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, *$5,$3,$6); }
|
||||
| yD_WRITE '(' exprList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, NULL,$3); }
|
||||
| yD_FDISPLAY '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,$3,NULL); }
|
||||
| yD_FDISPLAY '(' expr ',' exprListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,$3,$5); }
|
||||
| yD_FWRITE '(' expr ',' exprListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, $3,$5); }
|
||||
| yD_INFO parenE { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, "", NULL,NULL); }
|
||||
| yD_INFO '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, *$3,NULL,$4); }
|
||||
| yD_WARNING parenE { $$ = new AstDisplay($1,AstDisplayType::DT_WARNING,"", NULL,NULL); }
|
||||
@ -3162,6 +3162,11 @@ cateList<nodep>:
|
||||
| cateList ',' stream_expression { $$ = new AstConcat($2,$1,$3); }
|
||||
;
|
||||
|
||||
exprListE<nodep>:
|
||||
/* empty */ { $$ = NULL; }
|
||||
| exprList { $$ = $1; }
|
||||
;
|
||||
|
||||
exprList<nodep>:
|
||||
expr { $$ = $1; }
|
||||
| exprList ',' expr { $$ = $1;$1->addNext($3); }
|
||||
|
@ -46,6 +46,7 @@ q{[0] In top.t: Hi
|
||||
hello, from a concatenated string.
|
||||
hello, from a concatenated format string [0].
|
||||
extra argument: 0000000000000000
|
||||
0000000000000000: pre argument
|
||||
[0] Embedded <#013> return
|
||||
[0] Embedded
|
||||
multiline
|
||||
|
@ -83,6 +83,7 @@ module t;
|
||||
$display("hel", "lo, fr", "om a concatenated string.");
|
||||
$write("hel", "lo, fr", "om a concatenated format string [%0t].\n", $time);
|
||||
$display("extra argument: ", $time);
|
||||
$display($time, ": pre argument");
|
||||
$write("[%0t] Embedded \r return\n", $time);
|
||||
$display("[%0t] Embedded\
|
||||
multiline", $time);
|
||||
|
@ -49,6 +49,7 @@ q{[0] In top.t: Hi
|
||||
hello, from a concatenated string.
|
||||
hello, from a concatenated format string [0].
|
||||
extra argument: 0000000000000000
|
||||
0000000000000000: pre argument
|
||||
[0] Embedded <#013> return
|
||||
[0] Embedded
|
||||
multiline
|
||||
|
Loading…
Reference in New Issue
Block a user