From e1789e7fb913f5bf4c7e2d6b39378a26f8bb9b7a Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 16 Dec 2011 19:09:48 -0800 Subject: [PATCH] V0.9: 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. --- libveriuser/getsimtime.c | 8 ++++---- libveriuser/veriusertfs.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libveriuser/getsimtime.c b/libveriuser/getsimtime.c index e016af08e..716480f4d 100644 --- a/libveriuser/getsimtime.c +++ b/libveriuser/getsimtime.c @@ -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) diff --git a/libveriuser/veriusertfs.c b/libveriuser/veriusertfs.c index 8c36039b8..31fb3d039 100644 --- a/libveriuser/veriusertfs.c +++ b/libveriuser/veriusertfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2009 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 @@ -403,7 +403,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;