| #include "edge-impulse-sdk/dsp/config.hpp" |
| #if EIDSP_LOAD_CMSIS_DSP_SOURCES |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/complex_math_functions.h" |
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) |
|
|
| void arm_cmplx_mult_real_q15( |
| const q15_t * pSrcCmplx, |
| const q15_t * pSrcReal, |
| q15_t * pCmplxDst, |
| uint32_t numSamples) |
| { |
| static const uint16_t stride_cmplx_x_real_16[8] = { |
| 0, 0, 1, 1, 2, 2, 3, 3 |
| }; |
| q15x8_t rVec; |
| q15x8_t cmplxVec; |
| q15x8_t dstVec; |
| uint16x8_t strideVec; |
| uint32_t blockSizeC = numSamples * CMPLX_DIM; |
| uint32_t blkCnt; |
| q15_t in; |
|
|
| |
| |
| |
| strideVec = vld1q(stride_cmplx_x_real_16); |
|
|
| blkCnt = blockSizeC >> 3; |
|
|
| while (blkCnt > 0U) |
| { |
| cmplxVec = vld1q(pSrcCmplx); |
| rVec = vldrhq_gather_shifted_offset_s16(pSrcReal, strideVec); |
| dstVec = vqdmulhq(cmplxVec, rVec); |
| vst1q(pCmplxDst, dstVec); |
|
|
| pSrcReal += 4; |
| pSrcCmplx += 8; |
| pCmplxDst += 8; |
| blkCnt --; |
| } |
|
|
| |
| blkCnt = (blockSizeC & 7) >> 1; |
| while (blkCnt > 0U) |
| { |
| |
| |
|
|
| in = *pSrcReal++; |
| |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
|
|
| |
| blkCnt--; |
| } |
| } |
| #else |
| void arm_cmplx_mult_real_q15( |
| const q15_t * pSrcCmplx, |
| const q15_t * pSrcReal, |
| q15_t * pCmplxDst, |
| uint32_t numSamples) |
| { |
| uint32_t blkCnt; |
| q15_t in; |
|
|
| #if defined (ARM_MATH_LOOPUNROLL) |
|
|
| #if defined (ARM_MATH_DSP) |
| q31_t inA1, inA2; |
| q31_t inB1; |
| q15_t out1, out2, out3, out4; |
| q31_t mul1, mul2, mul3, mul4; |
| #endif |
|
|
| |
| blkCnt = numSamples >> 2U; |
|
|
| while (blkCnt > 0U) |
| { |
| |
| |
|
|
| #if defined (ARM_MATH_DSP) |
| |
| inA1 = read_q15x2_ia (&pSrcCmplx); |
| inA2 = read_q15x2_ia (&pSrcCmplx); |
| |
| inB1 = read_q15x2_ia (&pSrcReal); |
|
|
| |
| #ifndef ARM_MATH_BIG_ENDIAN |
| mul1 = (q31_t) ((q15_t) (inA1) * (q15_t) (inB1)); |
| mul2 = (q31_t) ((q15_t) (inA1 >> 16) * (q15_t) (inB1)); |
| mul3 = (q31_t) ((q15_t) (inA2) * (q15_t) (inB1 >> 16)); |
| mul4 = (q31_t) ((q15_t) (inA2 >> 16) * (q15_t) (inB1 >> 16)); |
| #else |
| mul2 = (q31_t) ((q15_t) (inA1 >> 16) * (q15_t) (inB1 >> 16)); |
| mul1 = (q31_t) ((q15_t) inA1 * (q15_t) (inB1 >> 16)); |
| mul4 = (q31_t) ((q15_t) (inA2 >> 16) * (q15_t) inB1); |
| mul3 = (q31_t) ((q15_t) inA2 * (q15_t) inB1); |
| #endif |
|
|
| |
| out1 = (q15_t) __SSAT(mul1 >> 15U, 16); |
| out2 = (q15_t) __SSAT(mul2 >> 15U, 16); |
| out3 = (q15_t) __SSAT(mul3 >> 15U, 16); |
| out4 = (q15_t) __SSAT(mul4 >> 15U, 16); |
|
|
| |
| write_q15x2_ia (&pCmplxDst, __PKHBT(out1, out2, 16)); |
| write_q15x2_ia (&pCmplxDst, __PKHBT(out3, out4, 16)); |
|
|
| inA1 = read_q15x2_ia (&pSrcCmplx); |
| inA2 = read_q15x2_ia (&pSrcCmplx); |
| inB1 = read_q15x2_ia (&pSrcReal); |
|
|
| #ifndef ARM_MATH_BIG_ENDIAN |
| mul1 = (q31_t) ((q15_t) (inA1) * (q15_t) (inB1)); |
| mul2 = (q31_t) ((q15_t) (inA1 >> 16) * (q15_t) (inB1)); |
| mul3 = (q31_t) ((q15_t) (inA2) * (q15_t) (inB1 >> 16)); |
| mul4 = (q31_t) ((q15_t) (inA2 >> 16) * (q15_t) (inB1 >> 16)); |
| #else |
| mul2 = (q31_t) ((q15_t) (inA1 >> 16) * (q15_t) (inB1 >> 16)); |
| mul1 = (q31_t) ((q15_t) inA1 * (q15_t) (inB1 >> 16)); |
| mul4 = (q31_t) ((q15_t) (inA2 >> 16) * (q15_t) inB1); |
| mul3 = (q31_t) ((q15_t) inA2 * (q15_t) inB1); |
| #endif |
|
|
| out1 = (q15_t) __SSAT(mul1 >> 15U, 16); |
| out2 = (q15_t) __SSAT(mul2 >> 15U, 16); |
| out3 = (q15_t) __SSAT(mul3 >> 15U, 16); |
| out4 = (q15_t) __SSAT(mul4 >> 15U, 16); |
|
|
| write_q15x2_ia (&pCmplxDst, __PKHBT(out1, out2, 16)); |
| write_q15x2_ia (&pCmplxDst, __PKHBT(out3, out4, 16)); |
| #else |
| in = *pSrcReal++; |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
|
|
| in = *pSrcReal++; |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
|
|
| in = *pSrcReal++; |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
|
|
| in = *pSrcReal++; |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
| #endif |
|
|
| |
| blkCnt--; |
| } |
|
|
| |
| blkCnt = numSamples % 0x4U; |
|
|
| #else |
|
|
| |
| blkCnt = numSamples; |
|
|
| #endif |
|
|
| while (blkCnt > 0U) |
| { |
| |
| |
|
|
| in = *pSrcReal++; |
| |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
| *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); |
|
|
| |
| blkCnt--; |
| } |
|
|
| } |
| #endif |
|
|
| |
| |
| |
|
|
| #endif |
|
|