To reduce error divide by an integer vs multiple by a fraction.

This same change was done in the vpi directory. This patch fixes the
issues in the libveriuser directory. This fixed a fail in the vpi
timescale test under MinGW.
This commit is contained in:
Cary R 2011-12-16 19:02:52 -08:00
parent 5d150c3151
commit d8bdea11c5
2 changed files with 6 additions and 6 deletions

View File

@ -36,8 +36,8 @@ scale(int high, int low, void*obj) {
scaled = high;
scaled = (scaled << 32) | low;
scaled *= pow(10, vpi_get(vpiTimePrecision,0) -
vpi_get(vpiTimeUnit,obj ? (vpiHandle)obj : hand));
scaled /= pow(10, vpi_get(vpiTimeUnit,obj ? (vpiHandle)obj : hand) -
vpi_get(vpiTimePrecision,0));
return scaled;
}
@ -129,8 +129,8 @@ void tf_scale_realdelay(void*obj, double real, double *areal)
{
vpiHandle hand = vpi_handle(vpiScope, vpi_handle(vpiSysTfCall,0));
*areal = real * pow(10, vpi_get(vpiTimePrecision, 0) -
vpi_get(vpiTimeUnit, hand));
*areal = real / pow(10, vpi_get(vpiTimeUnit, hand) -
vpi_get(vpiTimePrecision, 0));
}
void tf_unscale_realdelay(void*obj, double real, double *areal)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2010 Michael Ruff (mruff at chiaro.com)
* Copyright (c) 2002-2011 Michael Ruff (mruff at chiaro.com)
* Michael Runyan (mrunyan at chiaro.com)
*
* This source code is free software; you can redistribute it
@ -402,7 +402,7 @@ PLI_INT32 tf_isetrealdelay(double dly, void*obj)
/* Scale delay to SimTime */
ivl_u64_t delay = ((dly
* pow(10, tf_gettimeprecision() - tf_gettimeunit()))
/ pow(10, tf_gettimeunit() - tf_gettimeprecision()))
+ 0.5);
ti.high = delay >> 32 & 0xffffffff;
ti.low = delay & 0xffffffff;