More refinements on negative real variable delays.
This should do the rounding correctly on real negative delay values.
This commit is contained in:
parent
441f173ced
commit
5463e5e66b
10
vvp/delay.cc
10
vvp/delay.cc
|
|
@ -24,6 +24,7 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
void vvp_delay_t::calculate_min_delay_()
|
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. */
|
should be rounded and converted to an integer delay. */
|
||||||
vvp_time64_t val = 0;
|
vvp_time64_t val = 0;
|
||||||
if (bit > -0.5) {
|
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) {
|
} else if (bit != bit) {
|
||||||
// For a NaN we use the default (0).
|
// For a NaN we use the default (0).
|
||||||
} else {
|
} else {
|
||||||
vvp_vector4_t vec4(8*sizeof(vvp_time64_t), bit);
|
vvp_vector4_t vec4(8*sizeof(vvp_time64_t),
|
||||||
vvp_time64_t bval = 0;
|
floor(-bit * round_ + 0.5) * -1 * scale_);
|
||||||
vector4_to_value(vec4, bval);
|
vector4_to_value(vec4, val);
|
||||||
val = bval * round_ * scale_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (port.port()) {
|
switch (port.port()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue