mirror of
https://github.com/verilator/verilator.git
synced 2025-04-30 04:26:55 +00:00
Fix calling sformatf to display, and elab , bug1139.
This commit is contained in:
parent
473d555dc1
commit
b12dd526f9
2
Changes
2
Changes
@ -19,6 +19,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
|||||||
|
|
||||||
**** Fix internal error on interface arrays, bug1135. [John Stevenson]
|
**** Fix internal error on interface arrays, bug1135. [John Stevenson]
|
||||||
|
|
||||||
|
**** Fix calling sformatf to display, and elab $displays, bug1139. [Johan Bjork]
|
||||||
|
|
||||||
**** Fix realpath compile issue on MSVC++, bug1141. [Miodrag Milanovic]
|
**** Fix realpath compile issue on MSVC++, bug1141. [Miodrag Milanovic]
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,6 +91,11 @@ private:
|
|||||||
deque<V3Number*> m_numFreeps; ///< List of all numbers free and not in use
|
deque<V3Number*> m_numFreeps; ///< List of all numbers free and not in use
|
||||||
deque<V3Number*> m_numAllps; ///< List of all numbers free and in use
|
deque<V3Number*> m_numAllps; ///< List of all numbers free and in use
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
// V3Numbers that represents strings are a bit special and the API for V3Number does not allow changing them.
|
||||||
|
deque<V3Number*> m_stringNumbersp; // List of allocated string numbers
|
||||||
|
|
||||||
|
|
||||||
// Note level 8&9 include debugging each simulation value
|
// Note level 8&9 include debugging each simulation value
|
||||||
static int debug() {
|
static int debug() {
|
||||||
static int level = -1;
|
static int level = -1;
|
||||||
@ -726,6 +731,12 @@ private:
|
|||||||
if (!m_params) { badNodeType(nodep); return; }
|
if (!m_params) { badNodeType(nodep); return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void visit(AstScopeName *nodep) {
|
||||||
|
if (jumpingOver(nodep)) return;
|
||||||
|
if (!m_params) { badNodeType(nodep); return; }
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
|
||||||
virtual void visit(AstSFormatF *nodep) {
|
virtual void visit(AstSFormatF *nodep) {
|
||||||
if (jumpingOver(nodep)) return;
|
if (jumpingOver(nodep)) return;
|
||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
@ -743,11 +754,11 @@ private:
|
|||||||
} else if (!inPct) { // Normal text
|
} else if (!inPct) { // Normal text
|
||||||
result += *pos;
|
result += *pos;
|
||||||
} else { // Format character
|
} else { // Format character
|
||||||
AstNode* argp = nextArgp;
|
|
||||||
inPct = false;
|
inPct = false;
|
||||||
nextArgp = nextArgp->nextp();
|
|
||||||
|
|
||||||
if (V3Number::displayedFmtLegal(tolower(pos[0]))) {
|
if (V3Number::displayedFmtLegal(tolower(pos[0]))) {
|
||||||
|
AstNode* argp = nextArgp;
|
||||||
|
nextArgp = nextArgp->nextp();
|
||||||
V3Number* nump = fetchNumberNull(argp);
|
V3Number* nump = fetchNumberNull(argp);
|
||||||
if (!nump) {
|
if (!nump) {
|
||||||
clearOptimizable(nodep, "Argument for $display like statement is not constant");
|
clearOptimizable(nodep, "Argument for $display like statement is not constant");
|
||||||
@ -760,6 +771,10 @@ private:
|
|||||||
case '%':
|
case '%':
|
||||||
result += "%";
|
result += "%";
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
// This happens prior to AstScope so we don't know the scope name. Leave the %m in place.
|
||||||
|
result += "%m";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
clearOptimizable(nodep, "Unknown $display-like format code.");
|
clearOptimizable(nodep, "Unknown $display-like format code.");
|
||||||
break;
|
break;
|
||||||
@ -767,7 +782,11 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodep->text(result);
|
|
||||||
|
V3Number* resultNump = new V3Number(V3Number::String(), nodep->fileline(), result);
|
||||||
|
setNumber(nodep, resultNump);
|
||||||
|
m_stringNumbersp.push_back(resultNump);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,19 +795,20 @@ private:
|
|||||||
if (!optimizable()) return; // Accelerate
|
if (!optimizable()) return; // Accelerate
|
||||||
nodep->iterateChildren(*this);
|
nodep->iterateChildren(*this);
|
||||||
if (m_params) {
|
if (m_params) {
|
||||||
|
V3Number* textp = fetchNumber(nodep->fmtp());
|
||||||
switch (nodep->displayType()) {
|
switch (nodep->displayType()) {
|
||||||
case AstDisplayType::DT_DISPLAY: // FALLTHRU
|
case AstDisplayType::DT_DISPLAY: // FALLTHRU
|
||||||
case AstDisplayType::DT_INFO:
|
case AstDisplayType::DT_INFO:
|
||||||
v3warn(USERINFO, nodep->fmtp()->text());
|
v3warn(USERINFO, textp->toString());
|
||||||
break;
|
break;
|
||||||
case AstDisplayType::DT_ERROR:
|
case AstDisplayType::DT_ERROR:
|
||||||
v3warn(USERERROR, nodep->fmtp()->text());
|
v3warn(USERERROR, textp->toString());
|
||||||
break;
|
break;
|
||||||
case AstDisplayType::DT_WARNING:
|
case AstDisplayType::DT_WARNING:
|
||||||
v3warn(USERWARN, nodep->fmtp()->text());
|
v3warn(USERWARN, textp->toString());
|
||||||
break;
|
break;
|
||||||
case AstDisplayType::DT_FATAL:
|
case AstDisplayType::DT_FATAL:
|
||||||
v3warn(USERFATAL, nodep->fmtp()->text());
|
v3warn(USERFATAL, textp->toString());
|
||||||
break;
|
break;
|
||||||
case AstDisplayType::DT_WRITE: // FALLTHRU
|
case AstDisplayType::DT_WRITE: // FALLTHRU
|
||||||
default:
|
default:
|
||||||
@ -863,6 +883,10 @@ public:
|
|||||||
for (deque<V3Number*>::iterator it = m_numAllps.begin(); it != m_numAllps.end(); ++it) {
|
for (deque<V3Number*>::iterator it = m_numAllps.begin(); it != m_numAllps.end(); ++it) {
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
for (deque<V3Number*>::iterator it = m_stringNumbersp.begin(); it != m_stringNumbersp.end(); ++it) {
|
||||||
|
delete (*it);
|
||||||
|
}
|
||||||
|
m_stringNumbersp.clear();
|
||||||
m_numFreeps.clear();
|
m_numFreeps.clear();
|
||||||
m_numAllps.clear();
|
m_numAllps.clear();
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,13 @@ q{%Error: t/t_func_const_bad.v:\d+: Expecting expression to be constant, but can
|
|||||||
%Error: t/t_func_const_bad.v:\d+: ... Location of non-constant WHILE: Loop unrolling took too long; probably this is an infinite loop, or set --unroll-count above 1024
|
%Error: t/t_func_const_bad.v:\d+: ... Location of non-constant WHILE: Loop unrolling took too long; probably this is an infinite loop, or set --unroll-count above 1024
|
||||||
%Error: t/t_func_const_bad.v:\d+: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_stop'
|
%Error: t/t_func_const_bad.v:\d+: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_stop'
|
||||||
%Error: t/t_func_const_bad.v:\d+: ... Location of non-constant STOP: .stop executed during function constification; maybe indicates assertion firing
|
%Error: t/t_func_const_bad.v:\d+: ... Location of non-constant STOP: .stop executed during function constification; maybe indicates assertion firing
|
||||||
|
-Info: Printing in loop: 0
|
||||||
|
-Info: Printing in loop: 1
|
||||||
|
-Info: Printing in loop: 2
|
||||||
|
%Warning-USERFATAL: Fatal Error
|
||||||
|
%Warning-USERFATAL: Use ... verilator lint_off USERFATAL ... and lint_on around source to disable this message.
|
||||||
|
%Error: t/t_func_const_bad.v:\d+: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_fatal'
|
||||||
|
%Error: t/t_func_const_bad.v:\d+: ... Location of non-constant STOP: .stop executed during function constification; maybe indicates assertion firing
|
||||||
%Error: Exiting due to.*},
|
%Error: Exiting due to.*},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -45,4 +45,12 @@ module t;
|
|||||||
$stop;
|
$stop;
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
// Verify $fatal works with sformatf as argument
|
||||||
|
localparam BFATAL = f_bad_fatal(3);
|
||||||
|
function integer f_bad_fatal(input [31:0] a);
|
||||||
|
for (integer i=0;i<3;i++) begin
|
||||||
|
$display("Printing in loop: %s", $sformatf("%d", i));
|
||||||
|
end
|
||||||
|
$fatal(2, "%s", $sformatf("Fatal Error"));
|
||||||
|
endfunction
|
||||||
endmodule
|
endmodule
|
||||||
|
Loading…
Reference in New Issue
Block a user