mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Fix constification of $realtobits, $bitstoreal (#4522).
This commit is contained in:
parent
2385ab8294
commit
e49ae663a6
1
Changes
1
Changes
@ -15,6 +15,7 @@ Verilator 5.017 devel
|
||||
|
||||
* Add trace() API even when Verilated without --trace (#4462). [phelter]
|
||||
* Add warning on interface instantiation without parens (#4094). [Gökçe Aydos]
|
||||
* Fix constification of $realtobits, $bitstoreal (#4522). [Andrew Nolte]
|
||||
* Support randc (#4349).
|
||||
* Support resizing function call inout arguments (#4467).
|
||||
|
||||
|
@ -2388,19 +2388,23 @@ V3Number& V3Number::opRToIRoundS(const V3Number& lhs) {
|
||||
V3Number& V3Number::opRealToBits(const V3Number& lhs) {
|
||||
NUM_ASSERT_OP_ARGS1(lhs);
|
||||
NUM_ASSERT_DOUBLE_ARGS1(lhs);
|
||||
// Conveniently our internal format is identical so we can copy bits...
|
||||
if (lhs.width() != 64 || width() != 64) v3fatalSrc("Real operation on wrong sized number");
|
||||
m_data.setLogic();
|
||||
opAssign(lhs);
|
||||
return *this;
|
||||
union {
|
||||
double m_d;
|
||||
uint64_t m_v;
|
||||
} u;
|
||||
u.m_d = lhs.toDouble();
|
||||
return setQuad(u.m_v);
|
||||
}
|
||||
V3Number& V3Number::opBitsToRealD(const V3Number& lhs) {
|
||||
NUM_ASSERT_OP_ARGS1(lhs);
|
||||
// Conveniently our internal format is identical so we can copy bits...
|
||||
if (lhs.width() != 64 || width() != 64) v3fatalSrc("Real operation on wrong sized number");
|
||||
m_data.setDouble();
|
||||
opAssign(lhs);
|
||||
return *this;
|
||||
union {
|
||||
double m_d;
|
||||
uint64_t m_v;
|
||||
} u;
|
||||
u.m_v = lhs.toUQuad();
|
||||
return setDouble(u.m_d);
|
||||
}
|
||||
V3Number& V3Number::opNegateD(const V3Number& lhs) {
|
||||
NUM_ASSERT_OP_ARGS1(lhs);
|
||||
|
@ -97,6 +97,10 @@ module t (/*AUTOARG*/
|
||||
for (r=1.0; r<2.0; r=r+0.1) i++;
|
||||
if (i!=10) $stop;
|
||||
// bug
|
||||
ci64 = $realtobits(1.444);
|
||||
if (ci64 != 64'h3ff71a9fbe76c8b4) $stop;
|
||||
r = $bitstoreal(64'h3ff71a9fbe76c8b4);
|
||||
if (r != 1.444) $stop;
|
||||
r = $bitstoreal($realtobits(1.414));
|
||||
if (r != 1.414) $stop;
|
||||
// bug
|
||||
|
@ -23,6 +23,12 @@ package p2;
|
||||
function [3:0] plustwo(input [3:0] i);
|
||||
plustwo = i+2;
|
||||
endfunction
|
||||
|
||||
function automatic bit realCompare(real r);
|
||||
logic [63:0] b = $realtobits(r);
|
||||
return b > 0;
|
||||
endfunction
|
||||
|
||||
endpackage
|
||||
|
||||
module t (/*AUTOARG*/
|
||||
@ -55,10 +61,12 @@ endmodule
|
||||
module t2;
|
||||
import p::*;
|
||||
import p2::plustwo;
|
||||
import p2::realCompare;
|
||||
import p2::package2_type_t;
|
||||
package_type_t vp;
|
||||
package2_type_t vp2;
|
||||
initial begin
|
||||
bit x = realCompare(1.0);
|
||||
if (plusone(1) !== 2) $stop;
|
||||
if (plustwo(1) !== 3) $stop;
|
||||
if (p::pi !== 123 && p::pi !== 124) $stop; // may race with other initial, so either value
|
||||
|
Loading…
Reference in New Issue
Block a user