From 6cb3d86d15f6daff4ffb05dea0c83797011a35ce Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 22 Jul 2008 10:42:13 -0700 Subject: [PATCH] Update %cvt/vr to use new double to vector conversion (constructor). This patch updates the %cvt/vr command to use the new double to vector constructor. This allows the resulting bit pattern to be larger than a long. The old method was producing incorrect results without a warning for large bit values. --- vvp/vthread.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/vvp/vthread.cc b/vvp/vthread.cc index f8a6d5b49..31d1c8602 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -1371,14 +1371,12 @@ bool of_CVT_RI(vthread_t thr, vvp_code_t cp) bool of_CVT_VR(vthread_t thr, vvp_code_t cp) { double r = thr->words[cp->bit_idx[1]].w_real; - long rl = lround(r); unsigned base = cp->bit_idx[0]; unsigned wid = cp->number; - - for (unsigned idx = 0 ; idx < wid ; idx += 1) { - thr_put_bit(thr, base+idx, (rl&1)? BIT4_1 : BIT4_0); - rl >>= 1; - } + vvp_vector4_t tmp(wid, r); + /* Make sure there is enough space for the new vector. */ + thr_check_addr(thr, base+wid-1); + thr->bits4.set_vec(base, tmp); return true; }