forked from github/verilator
Fix $display with string without %s, bug1441.
This commit is contained in:
parent
d841e68f4f
commit
01725f662f
2
Changes
2
Changes
@ -14,6 +14,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
|||||||
|
|
||||||
**** Fix fault on $realtime with %t, bug1443. [Julien Margetts]
|
**** Fix fault on $realtime with %t, bug1443. [Julien Margetts]
|
||||||
|
|
||||||
|
**** Fix $display with string without %s, bug1441. [Denis Rystsov]
|
||||||
|
|
||||||
**** Fix parameter function string returns, bug1441. [Denis Rystsov]
|
**** Fix parameter function string returns, bug1441. [Denis Rystsov]
|
||||||
|
|
||||||
|
|
||||||
|
@ -341,13 +341,13 @@ private:
|
|||||||
AstNode *nextp = argp->nextp();
|
AstNode *nextp = argp->nextp();
|
||||||
argp->unlinkFrBack(); pushDeletep(argp); VL_DANGLING(argp);
|
argp->unlinkFrBack(); pushDeletep(argp); VL_DANGLING(argp);
|
||||||
argp = nextp;
|
argp = nextp;
|
||||||
} else {
|
} else {
|
||||||
newFormat.append("%h");
|
newFormat.append("%?"); // V3Width to figure it out
|
||||||
argp = argp->nextp();
|
argp = argp->nextp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newFormat;
|
return newFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void expectDescriptor(AstNode* nodep, AstNodeVarRef* filep) {
|
void expectDescriptor(AstNode* nodep, AstNodeVarRef* filep) {
|
||||||
|
@ -2179,6 +2179,17 @@ private:
|
|||||||
if (argp) argp = argp->nextp();
|
if (argp) argp = argp->nextp();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case '?': { // Unspecified by user, guess
|
||||||
|
if (argp && argp->isDouble()) {
|
||||||
|
ch = 'g';
|
||||||
|
} else if (argp && argp->isString()) {
|
||||||
|
ch = '@';
|
||||||
|
} else {
|
||||||
|
ch = 'h';
|
||||||
|
}
|
||||||
|
if (argp) argp = argp->nextp();
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: { // Most operators, just move to next argument
|
default: { // Most operators, just move to next argument
|
||||||
if (argp) argp=argp->nextp();
|
if (argp) argp=argp->nextp();
|
||||||
break;
|
break;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
String: ' 1'
|
String: ' 1'
|
||||||
|
foo(1): ' 1'
|
||||||
s f(1): ' 1'
|
s f(1): ' 1'
|
||||||
s parm: ' 1'
|
s parm: ' 1'
|
||||||
s strg: ' 1'
|
s strg: ' 1'
|
||||||
|
r: 1.234
|
||||||
*-* All Finished *-*
|
*-* All Finished *-*
|
||||||
|
@ -7,14 +7,16 @@ module t;
|
|||||||
function automatic string foo(int i);
|
function automatic string foo(int i);
|
||||||
return $sformatf("'%d'", i); // %0d does not work here
|
return $sformatf("'%d'", i); // %0d does not work here
|
||||||
endfunction
|
endfunction
|
||||||
|
real r = 1.234;
|
||||||
string bar = foo(1);
|
string bar = foo(1);
|
||||||
localparam string pbar = foo(1);
|
localparam string pbar = foo(1);
|
||||||
initial begin
|
initial begin
|
||||||
$write("String: "); $display("' 1'");
|
$write("String: "); $display("' 1'");
|
||||||
//$write("foo(1): "); $display(foo(1));
|
$write("foo(1): "); $display(foo(1));
|
||||||
$write("s f(1): "); $display("%s", foo(1));
|
$write("s f(1): "); $display("%s", foo(1));
|
||||||
$write("s parm: "); $display("%s", pbar);
|
$write("s parm: "); $display("%s", pbar);
|
||||||
$write("s strg: "); $display("%s", bar);
|
$write("s strg: "); $display("%s", bar);
|
||||||
|
$write("r: "); $display(r);
|
||||||
$write("*-* All Finished *-*\n");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user