Fix display %m names inside named blocks.

git-svn-id: file://localhost/svn/verilator/trunk/verilator@897 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
Wilson Snyder 2007-03-06 18:53:24 +00:00
parent d6cb175f96
commit 98282114c9
6 changed files with 31 additions and 4 deletions

View File

@ -19,6 +19,8 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix "Loops detected" assertion when model exceeds 4GB. [David Hewson]
**** Fix display %m names inside named blocks.
* Verilator 3.633 2/7/2007
*** Add --trace-depth option for minimizing VCD file size. [Emerson Suguimoto]

View File

@ -1265,6 +1265,7 @@ public:
AstNode* scopeAttrp() const { return op3p(); }
AstText* scopeTextp() const { return op3p()->castText(); }
void scopeAttrp(AstNode* nodep) { addOp3p(nodep); }
bool needScopeTracking() { return name().find("%m") != string::npos; }
};
struct AstFClose : public AstNodeStmt {

View File

@ -131,6 +131,18 @@ private:
nodep->replaceWith(newp);
nodep->deleteTree(); nodep=NULL;
}
virtual void visit(AstDisplay* nodep, AstNUser*) {
// If there's a %m in the display text, we add a special node that will contain the name()
// Similar code in V3Inline
if (m_beginScope != "" && nodep->needScopeTracking()) {
// To keep correct visual order, must add before other Text's
AstNode* afterp = nodep->scopeAttrp();
if (afterp) afterp->unlinkFrBackWithNext();
nodep->scopeAttrp(new AstText(nodep->fileline(), (string)"."+AstNode::prettyName(m_beginScope)));
if (afterp) nodep->scopeAttrp(afterp);
}
nodep->iterateChildren(*this);
}
virtual void visit(AstNode* nodep, AstNUser*) {
nodep->iterateChildren(*this);
}

View File

@ -235,8 +235,8 @@ private:
}
virtual void visit(AstDisplay* nodep, AstNUser*) {
// If there's a %m in the display text, we add a special node that will contain the name()
if (m_cellp
&& nodep->name().find("%m") != string::npos) {
// Similar code in V3Begin
if (m_cellp && nodep->needScopeTracking()) {
// To keep correct visual order, must add before other Text's
AstNode* afterp = nodep->scopeAttrp();
if (afterp) afterp->unlinkFrBackWithNext();

View File

@ -15,7 +15,9 @@ execute (
expect=>quotemeta(
'[0] In TOP.v: Hi
[0] In TOP.v.sub
[0] In TOP.v.sub.subblock
[0] In TOP.v.sub2
[0] In TOP.v.sub2.subblock2
[0] %X=0c %D=12 %0X=c %0O=14 %B=001100
[0] %x=0c %d=12 %0x=c %0o=14 %b=001100
[0] %x=00abbbbcccc %0x=abbbbcccc %o=00527356746314 %b=00000101010111011101110111100110011001100

View File

@ -44,13 +44,23 @@ endmodule
module sub;
task write_m;
$write("[%0t] In %m\n", $time);
begin
$write("[%0t] In %m\n", $time);
begin : subblock
$write("[%0t] In %m\n", $time);
end
end
endtask
endmodule
module sub2;
// verilator no_inline_module
task write_m;
$write("[%0t] In %m\n", $time);
begin
$write("[%0t] In %m\n", $time);
begin : subblock2
$write("[%0t] In %m\n", $time);
end
end
endtask
endmodule