Fix rounding in trace , bug946.

This commit is contained in:
Wilson Snyder 2015-07-21 13:22:08 -04:00
parent 06d5a7b2bf
commit 1891cfd79a
2 changed files with 3 additions and 1 deletions

View File

@ -13,6 +13,8 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix dpi imports inside generates. [Michael Tresidder]
**** Fix rounding in trace $timescale, bug946. [Frederic Requin]
* Verilator 3.874 2015-06-06

View File

@ -378,7 +378,7 @@ string VerilatedVcd::doubleToTimescale (double value) {
else if (value>=1e-12) { suffixp="ps"; value *= 1e12; }
else if (value>=1e-15) { suffixp="fs"; value *= 1e15; }
else if (value>=1e-18) { suffixp="as"; value *= 1e18; }
char valuestr[100]; sprintf(valuestr,"%d%s",(int)(value), suffixp);
char valuestr[100]; sprintf(valuestr,"%3.0f%s", value, suffixp);
return valuestr; // Gets converted to string, so no ref to stack
}