Received: from eggs.gnu.org ([208.118.235.92]:60750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URi22-00038J-Nz for qemu-devel@nongnu.org; Mon, 15 Apr 2013 07:57:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URi21-0003FR-5n for qemu-devel@nongnu.org; Mon, 15 Apr 2013 07:57:10 -0400 Received: from mail.rt-rk.ftn.uns.ac.rs ([147.91.177.140]:44565 helo=mail.rt-rk.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URi20-0003Eu-S8 for qemu-devel@nongnu.org; Mon, 15 Apr 2013 07:57:09 -0400 Received: from mail.rt-rk.com (mail.localdomain [127.0.0.1]) by mail.rt-rk.com (Postfix) with SMTP id 934B125BC96 for ; Mon, 15 Apr 2013 13:57:04 +0200 (CEST) From: Petar Jovanovic Date: Mon, 15 Apr 2013 13:54:07 +0200 Message-Id: <1366026847-7712-1-git-send-email-petar.jovanovic@rt-rk.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] =?utf-8?q?=5BPATCH=5D_target-mips=3A_fix_mipsdsp=5Fm?= =?utf-8?q?ul=5Fq15=5Fq15_and_tests_for_MAQ=5FSA=5FQ=5FPHL/PHR?= List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: petar.jovanovic@imgtec.com, aurelien@aurel32.net From: Petar Jovanovic The operands for MAQ_SA_W.PHL/MAQ_SA_W.PHR must in specified format. Otherwise, the results are unpredictable. Once the operands were correcte= d in the tests (part of this change), a bug in mipsdsp_mul_q15_q15 became visible. This change corrects the tests for MAQ_SA_W.PHL/MAQ_SA_W.PHR and fixes sign-related issue in mipsdsp_mul_q15_q15. It also removes unnecessary comment. Signed-off-by: Petar Jovanovic --- target-mips/dsp_helper.c | 14 +------------- tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c | 12 ++++++------ tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/target-mips/dsp_helper.c b/target-mips/dsp_helper.c index c7df595..a368062 100644 --- a/target-mips/dsp_helper.c +++ b/target-mips/dsp_helper.c @@ -269,18 +269,6 @@ static inline int32_t mipsdsp_sat32_acc_q31(int32_t = acc, int32_t a, temp31 =3D (temp_sum >> 31) & 0x01; result =3D temp_sum & 0xFFFFFFFF; =20 - /* FIXME - This sat function may wrong, because user manual wrote: - temp127..0 =E2=86=90 temp + ( (signA) || a31..0 - if ( temp32 =E2=89=A0 temp31 ) then - if ( temp32 =3D 0 ) then - temp31..0 =E2=86=90 0x80000000 - else - temp31..0 =E2=86=90 0x7FFFFFFF - endif - DSPControlouflag:16+acc =E2=86=90 1 - endif - */ if (temp32 !=3D temp31) { if (temp32 =3D=3D 0) { result =3D 0x7FFFFFFF; @@ -578,7 +566,7 @@ static inline int32_t mipsdsp_mul_q15_q15(int32_t ac,= uint16_t a, uint16_t b, temp =3D 0x7FFFFFFF; set_DSPControl_overflow_flag(1, 16 + ac, env); } else { - temp =3D ((uint32_t)a * (uint32_t)b) << 1; + temp =3D ((int16_t)a * (int16_t)b) << 1; } =20 return temp; diff --git a/tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c b/tests/tcg/mips/mi= ps32-dsp/maq_sa_w_phl.c index a756991..d83dce6 100644 --- a/tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c +++ b/tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c @@ -10,12 +10,12 @@ int main() int resulth, resultl; int resdsp; =20 - achi =3D 0x05; - acli =3D 0xB4CB; + achi =3D 0x00000000; + acli =3D 0x0000B4CB; rs =3D 0xFF060000; rt =3D 0xCB000000; - resulth =3D 0x00; - resultl =3D 0x7FFFFFFF; + resulth =3D 0x00000000; + resultl =3D 0x006838CB; =20 __asm ("mthi %2, $ac1\n\t" @@ -29,8 +29,8 @@ int main() assert(resulth =3D=3D acho); assert(resultl =3D=3D aclo); =20 - achi =3D 0x06; - acli =3D 0xB4CB; + achi =3D 0x00000000; + acli =3D 0x0000B4CB; rs =3D 0x80000000; rt =3D 0x80000000; resulth =3D 0x00; diff --git a/tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c b/tests/tcg/mips/mi= ps32-dsp/maq_sa_w_phr.c index d6498f8..d233111 100644 --- a/tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c +++ b/tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c @@ -10,12 +10,12 @@ int main() int resulth, resultl; int resdsp; =20 - achi =3D 0x05; - acli =3D 0xB4CB; - rs =3D 0xFF06; - rt =3D 0xCB00; - resulth =3D 0x00; - resultl =3D 0x7FFFFFFF; + achi =3D 0x00000000; + acli =3D 0x0000B4CB; + rs =3D 0x0000FF06; + rt =3D 0x0000CB00; + resulth =3D 0x00000000; + resultl =3D 0x006838CB; =20 __asm ("mthi %2, $ac1\n\t" @@ -29,12 +29,12 @@ int main() assert(resulth =3D=3D acho); assert(resultl =3D=3D aclo); =20 - achi =3D 0x06; - acli =3D 0xB4CB; - rs =3D 0x8000; - rt =3D 0x8000; - resulth =3D 0x00; - resultl =3D 0x7fffffff; + achi =3D 0x00000000; + acli =3D 0x0000B4CB; + rs =3D 0x00008000; + rt =3D 0x00008000; + resulth =3D 0x00000000; + resultl =3D 0x7FFFFFFF; resdsp =3D 0x01; =20 __asm --=20 1.7.9.5