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.
This commit is contained in:
Cary R 2008-07-22 10:42:13 -07:00 committed by Stephen Williams
parent 7a4f85d382
commit 6cb3d86d15
1 changed files with 4 additions and 6 deletions

View File

@ -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;
}