forked from github/verilator
Support with %g.
This commit is contained in:
parent
5df3bbe188
commit
9ab3bcdde3
2
Changes
2
Changes
@ -12,6 +12,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||
|
||||
**** Support constants in sensitivity lists, bug412. [Jeremy Bennett]
|
||||
|
||||
**** Support $sscanf with %g. [Holger Wächtler]
|
||||
|
||||
**** Indicate 'exiting due to errors' if errors, not warnings. [Ruben Diez]
|
||||
|
||||
**** Fix bad result with if-else-return optimization, bug420. [Alex Solomatnikov]
|
||||
|
@ -598,6 +598,17 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
VL_SET_WQ(owp,ld);
|
||||
break;
|
||||
}
|
||||
case 'f':
|
||||
case 'e':
|
||||
case 'g': { // Real number
|
||||
_vl_vsss_skipspace(fp,floc,fromp);
|
||||
_vl_vsss_read(fp,floc,fromp, tmp, "+-.0123456789eE");
|
||||
if (!tmp[0]) goto done;
|
||||
union { double r; vlsint64_t ld; } u;
|
||||
u.r = strtod(tmp, NULL);
|
||||
VL_SET_WQ(owp,u.ld);
|
||||
break;
|
||||
}
|
||||
case 't': // FALLTHRU // Time
|
||||
case 'u': { // Unsigned decimal
|
||||
_vl_vsss_skipspace(fp,floc,fromp);
|
||||
|
@ -13,6 +13,7 @@ module t;
|
||||
reg [8*8:1] letterq;
|
||||
reg [16*8:1] letterw;
|
||||
reg [16*8:1] letterz;
|
||||
real r;
|
||||
|
||||
`ifdef TEST_VERBOSE
|
||||
`define verbose 1'b1
|
||||
@ -119,10 +120,11 @@ module t;
|
||||
if (letterq != 64'h13) $stop;
|
||||
if (letterw != 128'h55ce14f1a9c29e) $stop;
|
||||
|
||||
chars = $sscanf("d=-236123",
|
||||
"d=%d", letterq);
|
||||
chars = $sscanf("r=0.1 d=-236123",
|
||||
"r=%g d=%d", r, letterq);
|
||||
if (`verbose) $write("c=%0d d=%d\n", chars, letterq);
|
||||
if (chars != 1) $stop;
|
||||
if (chars != 2) $stop;
|
||||
if (r != 0.1) $stop;
|
||||
if (letterq != 64'hfffffffffffc65a5) $stop;
|
||||
|
||||
// $fscanf
|
||||
|
Loading…
Reference in New Issue
Block a user