Fix constant propagation, bug1012.

This commit is contained in:
Wilson Snyder 2015-12-08 22:22:42 -05:00
parent ebad6cde36
commit 849c1e46a2
3 changed files with 12 additions and 3 deletions

View File

@ -31,6 +31,8 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix error instead of warning on large concat, msg1768. [Paul Rolfe]
**** Fix $bitstoreal constant propagation, bug1012. [Jonathan Kimmitt]
* Verilator 3.878 2015-11-01

View File

@ -1666,14 +1666,18 @@ V3Number& V3Number::opRealToBits (const V3Number& lhs) {
if (lhs.width()!=64 || this->width()!=64) {
m_fileline->v3fatalSrc("Real operation on wrong sized number");
}
return opAssign(lhs);
opAssign(lhs);
m_double = false;
return *this;
}
V3Number& V3Number::opBitsToRealD (const V3Number& lhs) {
// Conveniently our internal format is identical so we can copy bits...
if (lhs.width()!=64 || this->width()!=64) {
m_fileline->v3fatalSrc("Real operation on wrong sized number");
}
return opAssign(lhs);
opAssign(lhs);
m_double = true;
return *this;
}
V3Number& V3Number::opNegateD (const V3Number& lhs) {
return setDouble(- lhs.toDouble());

View File

@ -5,7 +5,7 @@
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
`define is_near_real(a,b) ($abs((a)-(b)) < (((a)/(b))*0.0001))
`define is_near_real(a,b) (( ((a)<(b)) ? (b)-(a) : (a)-(b)) < (((a)/(b))*0.0001))
module t (/*AUTOARG*/
// Inputs
@ -78,6 +78,9 @@ module t (/*AUTOARG*/
i=0;
for (r=1.0; r<2.0; r=r+0.1) i++;
if (i!=10) $stop;
// bug
r = $bitstoreal($realtobits(1.414));
if (r != 1.414) $stop;
end
// Test loop