Propagate real values properly

Be careful to include bitwise differences in double values, because
it is the bit pattern we are passing aroung, not the arithmetic value.

Signed-off-by: Stephen Williams <steve@icarus.com>
This commit is contained in:
Stephen Williams 2007-07-13 18:42:35 -07:00
parent acddb99305
commit b327b86e4a
1 changed files with 11 additions and 1 deletions

View File

@ -1760,12 +1760,22 @@ double vvp_fun_signal_real::real_value() const
return bits_;
}
/*
* Testing for equality, we want a bitwise test instead of an
* arithmetic test because we want to treat for example -0 different
* from +0.
*/
bool bits_equal(double a, double b)
{
return memcmp(&a, &b, sizeof a) == 0;
}
void vvp_fun_signal_real::recv_real(vvp_net_ptr_t ptr, double bit)
{
switch (ptr.port()) {
case 0:
if (!continuous_assign_active_) {
if (needs_init_ || (bits_ != bit)) {
if (needs_init_ || !bits_equal(bits_,bit)) {
bits_ = bit;
needs_init_ = false;
vvp_send_real(ptr.ptr()->out, bit);