Skip to content

Commit e151221

Browse files
committed
NMSIS/DSP: Fix riscv_scale_q15 functional error with rv64p optimization
If the scale factor is negtive, the hight 16 bits of q31_t are all "1", pack two 16 bits value by "OR" will lead to missing the high part value. Signed-off-by: Jiandong Qiu <qiujiandong@nucleisys.com>
1 parent a271d13 commit e151221

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

NMSIS/DSP/Source/BasicMathFunctions/riscv_scale_q15.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ RISCV_DSP_ATTRIBUTE void riscv_scale_q15(
8181
#if __RISCV_XLEN == 64
8282
q31_t out32, tmpScale32;
8383
q63_t out64;
84-
tmpScale32 = (q31_t)scaleFract | ((q31_t)scaleFract << 16);
84+
tmpScale32 = __RV_PKBB16(scaleFract, scaleFract);
8585
#endif /* __RISCV_XLEN == 64 */
8686
q31_t inA1, inA2;
8787
q31_t out1, out2, out3, out4; /* Temporary output variables */

NMSIS/doc/source/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ This is the version of ``V1.5.0`` release.
5050
- Fix ``riscv_cfft_radix4_q31.c`` producing incorrect results
5151
- Fix ``riscv_power_q31`` output scaling, which should be in Q2.48 format
5252
- Fix ``riscv_cfft_q15`` using the wrong variable
53+
- Fix ``riscv_scale_q15`` functional error when optimized with rv64 P extension
5354
- Add ``riscv_vec_math.h`` and ``riscv_vec_math_f16.h`` providing f16/f32 RVV-accelerated math functions (exp, log, sin, cos, pow, tanh, etc.)
5455
- Add multiple library build configurations for Nuclei n100 and n200 CPU
5556
- Synchronize with the CMSIS-DSP v1.17.0 release, incorporating the following updates:

0 commit comments

Comments
 (0)