00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "arm_math.h"
00025
00057 void arm_cmplx_dot_prod_q15(
00058 q15_t * pSrcA,
00059 q15_t * pSrcB,
00060 uint32_t numSamples,
00061 q31_t * realResult,
00062 q31_t * imagResult)
00063 {
00064 q63_t real_sum = 0, imag_sum = 0;
00065 q31_t inA1, inA2;
00066 q31_t inB1, inB2;
00067 q31_t real1, real2, imag1, imag2;
00068
00069 uint32_t blkCnt;
00070 #ifndef ARM_MATH_BIG_ENDIAN
00071
00072 q15_t imagA1, imagB1;
00073
00074 #else
00075
00076 q15_t realA1, realB1;
00077
00078 #endif // #ifndef ARM_MATH_BIG_ENDIAN
00079
00080
00081
00082 blkCnt = numSamples >> 2u;
00083
00084
00085
00086 while(blkCnt > 0u)
00087 {
00088
00089 inA1 = _SIMD32_OFFSET(pSrcA);
00090
00091 inA2 = _SIMD32_OFFSET(pSrcA + 2);
00092
00093
00094 inB1 = _SIMD32_OFFSET(pSrcB);
00095
00096 #ifndef ARM_MATH_BIG_ENDIAN
00097
00098
00099 real1 = __PKHBT((q15_t)inA1, (q15_t)inA2, 16);
00100
00101 #else
00102
00103
00104 imag1 = __PKHBT((q15_t)inA1, (q15_t)inA2, 16);
00105
00106 #endif // #ifndef ARM_MATH_BIG_ENDIAN
00107
00108
00109 inB2 = _SIMD32_OFFSET(pSrcB + 2);
00110
00111 #ifndef ARM_MATH_BIG_ENDIAN
00112
00113
00114 imagA1 = *(pSrcA + 1);
00115
00116 real2 = __PKHBT((q15_t)inB1, (q15_t)inB2, 16);
00117
00118 imagB1 = *(pSrcB + 1);
00119
00120 imag1 = __PKHBT(imagA1, (q15_t)(inA2 >> 16), 16);
00121
00122 #else
00123
00124
00125 realA1 = *(pSrcA);
00126
00127 imag2 = __PKHBT((q15_t)inB1, (q15_t)inB2, 16);
00128
00129 realB1 = *(pSrcB);
00130
00131 real1 = __PKHBT(realA1, (q15_t)(inA2 >> 16), 16);
00132
00133 #endif // #ifndef ARM_MATH_BIG_ENDIAN
00134
00135
00136 inA1 = _SIMD32_OFFSET(pSrcA + 4);
00137
00138 #ifndef ARM_MATH_BIG_ENDIAN
00139
00140
00141 imag2 = __PKHBT(imagB1, (q15_t)(inB2 >> 16), 16);
00142
00143 #else
00144
00145
00146 real2 = __PKHBT(realB1, (q15_t)(inB2 >> 16), 16);
00147
00148 #endif // #ifndef ARM_MATH_BIG_ENDIAN
00149
00150
00151 imag_sum = __SMLALD(imag1, imag2, imag_sum);
00152
00153
00154 inA2 = _SIMD32_OFFSET(pSrcA + 6);
00155
00156 real_sum = __SMLALD(real1, real2, real_sum);
00157
00158 inB1 = _SIMD32_OFFSET(pSrcB + 4);
00159
00160 #ifndef ARM_MATH_BIG_ENDIAN
00161
00162
00163 real1 = __PKHBT((q15_t)inA1, (q15_t)inA2, 16);
00164
00165 #else
00166
00167
00168 imag1 = __PKHBT((q15_t)inA1, (q15_t)inA2, 16);
00169
00170 #endif // #ifndef ARM_MATH_BIG_ENDIAN
00171
00172
00173 inB2 = _SIMD32_OFFSET(pSrcB + 6);
00174
00175 #ifndef ARM_MATH_BIG_ENDIAN
00176
00177
00178 imagA1 = *(pSrcA + 5);
00179
00180 real2 = __PKHBT((q15_t)inB1, (q15_t)inB2, 16);
00181
00182 imagB1 = *(pSrcB + 5);
00183
00184 imag1 = __PKHBT(imagA1, (q15_t)(inA2 >> 16), 16);
00185 imag2 = __PKHBT(imagB1, (q15_t)(inB2 >> 16), 16);
00186
00187 #else
00188
00189
00190 realA1 = *(pSrcA + 4);
00191
00192 imag2 = __PKHBT((q15_t)inB1, (q15_t)inB2, 16);
00193
00194 realB1 = *(pSrcB + 4);
00195
00196 real1 = __PKHBT(realA1, (q15_t)(inA2 >> 16), 16);
00197 real2 = __PKHBT(realB1, (q15_t)(inB2 >> 16), 16);
00198
00199 #endif // #ifndef ARM_MATH_BIG_ENDIAN
00200
00201
00202 imag_sum = __SMLALD(imag1, imag2, imag_sum);
00203
00204 real_sum = __SMLALD(real1, real2, real_sum);
00205
00206
00207 pSrcA += 8u;
00208
00209 pSrcB += 8u;
00210
00211
00212 blkCnt--;
00213 }
00214
00215
00216
00217 blkCnt = numSamples % 0x4u;
00218
00219 while(blkCnt > 0u)
00220 {
00221
00222 real_sum += ((q31_t) * pSrcA++ * *pSrcB++);
00223
00224 imag_sum += ((q31_t) * pSrcA++ * *pSrcB++);
00225
00226
00227 blkCnt--;
00228 }
00229
00230
00231
00232 *realResult = (q31_t) (real_sum) >> 6;
00233
00234 *imagResult = (q31_t) (imag_sum) >> 6;
00235 }
00236