你好
我在 cmsis dsp 源中发现了一些奇怪的东西。
我正在使用
STM32f429 和 LITTLE ENDIAN 以及 cmsis dsp 库 V.1.5.1。
在 cmsis dsp 库(arm_mult_q31.c)中:
void arm_mult_q31( q31_t * pSrcA, q31_t * pSrcB, q31_t * pDst, uint32_t blockSize)
{
...
而 (blkCnt > 0U)
{
/* C = A * B */
/* 将输入相乘,然后将结果存储在目标缓冲区中。*/
inA1 = *pSrcA++;
inA2 = *pSrcA++;
inA3 = *pSrcA++;
inA4 = *pSrcA++;
inB1 = *pSrcB++;
inB2 = *pSrcB++;
inB3 = *pSrcB++;
inB4 = *pSrcB++;
out1 = ((q63_t)inA1 * inB1) >> 32;
out2 = ((q63_t)inA2 * inB2) >> 32;
out3 = ((q63_t)inA3 * inB3) >> 32;
out4 = ((q63_t)inA4 * inB4) >> 32;
out1 = __SSAT(out1, 31);
out2 = __SSAT(out2, 31);
out3 = __SSAT(out3, 31);
out4 = __SSAT(out4, 31);
*pDst++ = out1 << 1U;
*pDst++ = 输出 2 << 1U;
*pDst++ = 输出 3 << 1U;
*pDst++ = out4 << 1U;
/* 递减 blockSize 循环计数器 */
blkCnt--;
}
...
}
如果是Little Endian,应该修改如下。我的想法错了吗?
小端案例:
//out1 = ((q63_t)inA1 * inB1) >> 32;
//out2 = ((q63_t)inA2 * inB2) >> 32;
//out3 = ((q63_t)inA3 * inB3) >> 32;
//out4 = ((q63_t)inA4 * inB4) >> 32;
out1 = ((q63_t)inA1 * inB1);
out2 = ((q63_t)inA2 * inB2);
out3 = ((q63_t)inA3 * inB3);
out4 = ((q63_t)inA4 * inB4);
out1 = __SSAT(out1, 31);
out2 = __SSAT(out2, 31);
out3 = __SSAT(out3, 31);
out4 = __SSAT(out4, 31);
//*pDst++ = out1 << 1U;
//*pDst++ = out2 << 1U;
//*pDst++ = out3 << 1U;
//*pDst++ = out4 << 1U;
0