Fix handling user-botch of %d to print real.

This commit is contained in:
Wilson Snyder 2019-12-08 22:48:44 -05:00
parent 62b0d15d2e
commit bd0eadb311
3 changed files with 7 additions and 0 deletions

View File

@ -741,6 +741,7 @@ vlsint32_t V3Number::toSInt() const {
vluint64_t V3Number::toUQuad() const {
UASSERT(!isFourState(), "toUQuad with 4-state "<<*this);
// We allow wide numbers that represent values <= 64 bits
if (isDouble()) return static_cast<vluint64_t>(toDouble());
for (int i=2; i<words(); ++i) {
if (m_value[i]) {
v3error("Value too wide for 64-bits expected in this context "<<*this);
@ -753,6 +754,7 @@ vluint64_t V3Number::toUQuad() const {
}
vlsint64_t V3Number::toSQuad() const {
if (isDouble()) return static_cast<vlsint64_t>(toDouble());
vluint64_t v = toUQuad();
vluint64_t signExtend = (-(v & (VL_ULL(1)<<(width()-1))));
vluint64_t extended = v | signExtend;

View File

@ -49,4 +49,5 @@ extra argument: 0000000000000000
[0] Embedded <#013> return
[0] Embedded
multiline
log10(2) = 2
*-* All Finished *-*

View File

@ -139,6 +139,10 @@ multiline", $time);
`ifndef NC // NC-Verilog 5.3 chokes on this test
if (str !== 32'h00_bf_11_0a) $stop;
`endif
// $itord conversion bug, note a %d instead of proper float
$display("log10(2) = %d", $log10(100));
$write("*-* All Finished *-*\n");
$finish;
end