From 12c588fc350bfff062ce596d779054e56bc82409 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 11 Oct 2013 17:29:56 -0700 Subject: [PATCH] Mostly fix a portability problem in $rtoi (run time) --- vpi/sys_convert.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vpi/sys_convert.c b/vpi/sys_convert.c index 40c3c7a1a..01f12013f 100644 --- a/vpi/sys_convert.c +++ b/vpi/sys_convert.c @@ -215,8 +215,10 @@ static PLI_INT32 sys_rtoi_calltf(ICARUS_VPI_CONST PLI_BYTE8*user) res.aval = ~(PLI_INT32)0; res.bval = ~(PLI_INT32)0; } else { - if (val >= 0.0) res.aval = (PLI_UINT32) val; - else res.aval = - (PLI_UINT32) -val; + /* This is not 100% correct since large real values may break this + * code. See the verinum code for a more rigorous implementation. */ + if (val >= 0.0) res.aval = (PLI_UINT64) val; + else res.aval = - (PLI_UINT64) -val; res.bval = 0; }