More refinements on negative real variable delays.

This should do the rounding correctly on real negative delay
values.
This commit is contained in:
Cary R 2008-09-11 18:07:01 -07:00 committed by Stephen Williams
parent 441f173ced
commit 5463e5e66b
1 changed files with 5 additions and 5 deletions

View File

@ -24,6 +24,7 @@
#include <cstdlib>
#include <list>
#include <assert.h>
#include <math.h>
void vvp_delay_t::calculate_min_delay_()
{
@ -289,14 +290,13 @@ void vvp_fun_delay::recv_real(vvp_net_ptr_t port, double bit)
should be rounded and converted to an integer delay. */
vvp_time64_t val = 0;
if (bit > -0.5) {
val = (vvp_time64_t) (bit * round_ +0.5) * scale_;
val = (vvp_time64_t) (bit * round_ + 0.5) * scale_;
} else if (bit != bit) {
// For a NaN we use the default (0).
} else {
vvp_vector4_t vec4(8*sizeof(vvp_time64_t), bit);
vvp_time64_t bval = 0;
vector4_to_value(vec4, bval);
val = bval * round_ * scale_;
vvp_vector4_t vec4(8*sizeof(vvp_time64_t),
floor(-bit * round_ + 0.5) * -1 * scale_);
vector4_to_value(vec4, val);
}
switch (port.port()) {