From 4796690c71e262dab9dedf138aeae7d95c52a8bd Mon Sep 17 00:00:00 2001 From: Max Chou Date: Fri, 29 May 2026 11:15:19 -0700 Subject: [PATCH] rvp: Fix multiply-accumulate result extraction shift amount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrects shift amount for extracting bits [47:16] from 48-bit multiply-accumulate products. Implementation used 32-bit shift but spec requires 16-bit shift to extract high portion. Fixed instructions: - MHACC.H0: P-ext spec - MHACC.H1: P-ext spec - MHACCSU.H0: P-ext spec - MHACCSU.H1: P-ext spec Changed: mres >> 32 → mres >> 16 Signed-off-by: Max Chou --- riscv/insns/mhacc_h0.h | 2 +- riscv/insns/mhacc_h1.h | 2 +- riscv/insns/mhaccsu_h0.h | 2 +- riscv/insns/mhaccsu_h1.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/riscv/insns/mhacc_h0.h b/riscv/insns/mhacc_h0.h index 699e9165..bb254534 100644 --- a/riscv/insns/mhacc_h0.h +++ b/riscv/insns/mhacc_h0.h @@ -1,4 +1,4 @@ require_extension('P'); require_rv32; sreg_t mres = sext32(RS1) * sext32(P_FIELD(RS2, 0, 16)); -WRITE_RD(RD + (mres >> 32)); \ No newline at end of file +WRITE_RD(RD + (mres >> 16)); \ No newline at end of file diff --git a/riscv/insns/mhacc_h1.h b/riscv/insns/mhacc_h1.h index ea228fe6..7565c358 100644 --- a/riscv/insns/mhacc_h1.h +++ b/riscv/insns/mhacc_h1.h @@ -1,4 +1,4 @@ require_extension('P'); require_rv32; sreg_t mres = sext32(RS1) * sext32(P_FIELD(RS2, 1, 16)); -WRITE_RD(RD + (mres >> 32)); \ No newline at end of file +WRITE_RD(RD + (mres >> 16)); \ No newline at end of file diff --git a/riscv/insns/mhaccsu_h0.h b/riscv/insns/mhaccsu_h0.h index e89f309b..d455141d 100644 --- a/riscv/insns/mhaccsu_h0.h +++ b/riscv/insns/mhaccsu_h0.h @@ -1,4 +1,4 @@ require_extension('P'); require_rv32; sreg_t mres = sext32(RS1) * (uint32_t)P_FIELD(RS2, 0, 16); -WRITE_RD(RD + (mres >> 32)); \ No newline at end of file +WRITE_RD(RD + (mres >> 16)); \ No newline at end of file diff --git a/riscv/insns/mhaccsu_h1.h b/riscv/insns/mhaccsu_h1.h index e49a15f6..d990e49b 100644 --- a/riscv/insns/mhaccsu_h1.h +++ b/riscv/insns/mhaccsu_h1.h @@ -1,4 +1,4 @@ require_extension('P'); require_rv32; sreg_t mres = sext32(RS1) * (uint32_t)P_FIELD(RS2, 1, 16); -WRITE_RD(RD + (mres >> 32)); \ No newline at end of file +WRITE_RD(RD + (mres >> 16)); \ No newline at end of file