From 8cd50c163b48c4b787fbe5fe9944255ec33b7eb8 Mon Sep 17 00:00:00 2001 From: Cary R Date: Sun, 14 Dec 2008 12:46:23 -0800 Subject: [PATCH] Make the procedural shifts work with undefined shift values. This patch adds code to check for an undefined shift value in the procedural opcodes. When an undefined value is found 'bx is returned. --- vvp/vthread.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 250a43d7f..776c80af1 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -4126,7 +4126,11 @@ bool of_SHIFTL_I0(vthread_t thr, vvp_code_t cp) assert(base >= 4); thr_check_addr(thr, base+wid-1); - if (shift >= wid) { + if (thr_get_bit(thr, 4) == BIT4_1) { + // The result is 'bx if the shift amount is undefined. + vvp_vector4_t tmp (wid, BIT4_X); + thr->bits4.set_vec(base, tmp); + } else if (shift >= wid) { // Shift is so far that all value is shifted out. Write // in a constant 0 result. vvp_vector4_t tmp (wid, BIT4_0); @@ -4157,7 +4161,11 @@ bool of_SHIFTR_I0(vthread_t thr, vvp_code_t cp) unsigned wid = cp->number; unsigned long shift = thr->words[0].w_int; - if (shift > 0) { + if (thr_get_bit(thr, 4) == BIT4_1) { + // The result is 'bx if the shift amount is undefined. + vvp_vector4_t tmp (wid, BIT4_X); + thr->bits4.set_vec(base, tmp); + } else if (shift > 0) { unsigned idx; for (idx = 0 ; (idx+shift) < wid ; idx += 1) { unsigned src = base + idx + shift; @@ -4177,7 +4185,11 @@ bool of_SHIFTR_S_I0(vthread_t thr, vvp_code_t cp) unsigned long shift = thr->words[0].w_int; vvp_bit4_t sign = thr_get_bit(thr, base+wid-1); - if (shift >= wid) { + if (thr_get_bit(thr, 4) == BIT4_1) { + // The result is 'bx if the shift amount is undefined. + vvp_vector4_t tmp (wid, BIT4_X); + thr->bits4.set_vec(base, tmp); + } else if (shift >= wid) { for (unsigned idx = 0 ; idx < wid ; idx += 1) thr_put_bit(thr, base+idx, sign);