Keyboard firmwares for Atmel AVR and Cortex-M
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

arm_correlate_fast_q31.c 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /* ----------------------------------------------------------------------
  2. * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
  3. *
  4. * $Date: 17. January 2013
  5. * $Revision: V1.4.1
  6. *
  7. * Project: CMSIS DSP Library
  8. * Title: arm_correlate_fast_q31.c
  9. *
  10. * Description: Fast Q31 Correlation.
  11. *
  12. * Target Processor: Cortex-M4/Cortex-M3
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions
  16. * are met:
  17. * - Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in
  21. * the documentation and/or other materials provided with the
  22. * distribution.
  23. * - Neither the name of ARM LIMITED nor the names of its contributors
  24. * may be used to endorse or promote products derived from this
  25. * software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  30. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  31. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  32. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  33. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  34. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  35. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  37. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGE.
  39. * -------------------------------------------------------------------- */
  40. #include "arm_math.h"
  41. /**
  42. * @ingroup groupFilters
  43. */
  44. /**
  45. * @addtogroup Corr
  46. * @{
  47. */
  48. /**
  49. * @brief Correlation of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4.
  50. * @param[in] *pSrcA points to the first input sequence.
  51. * @param[in] srcALen length of the first input sequence.
  52. * @param[in] *pSrcB points to the second input sequence.
  53. * @param[in] srcBLen length of the second input sequence.
  54. * @param[out] *pDst points to the location where the output result is written. Length 2 * max(srcALen, srcBLen) - 1.
  55. * @return none.
  56. *
  57. * @details
  58. * <b>Scaling and Overflow Behavior:</b>
  59. *
  60. * \par
  61. * This function is optimized for speed at the expense of fixed-point precision and overflow protection.
  62. * The result of each 1.31 x 1.31 multiplication is truncated to 2.30 format.
  63. * These intermediate results are accumulated in a 32-bit register in 2.30 format.
  64. * Finally, the accumulator is saturated and converted to a 1.31 result.
  65. *
  66. * \par
  67. * The fast version has the same overflow behavior as the standard version but provides less precision since it discards the low 32 bits of each multiplication result.
  68. * In order to avoid overflows completely the input signals must be scaled down.
  69. * The input signals should be scaled down to avoid intermediate overflows.
  70. * Scale down one of the inputs by 1/min(srcALen, srcBLen)to avoid overflows since a
  71. * maximum of min(srcALen, srcBLen) number of additions is carried internally.
  72. *
  73. * \par
  74. * See <code>arm_correlate_q31()</code> for a slower implementation of this function which uses 64-bit accumulation to provide higher precision.
  75. */
  76. void arm_correlate_fast_q31(
  77. q31_t * pSrcA,
  78. uint32_t srcALen,
  79. q31_t * pSrcB,
  80. uint32_t srcBLen,
  81. q31_t * pDst)
  82. {
  83. q31_t *pIn1; /* inputA pointer */
  84. q31_t *pIn2; /* inputB pointer */
  85. q31_t *pOut = pDst; /* output pointer */
  86. q31_t *px; /* Intermediate inputA pointer */
  87. q31_t *py; /* Intermediate inputB pointer */
  88. q31_t *pSrc1; /* Intermediate pointers */
  89. q31_t sum, acc0, acc1, acc2, acc3; /* Accumulators */
  90. q31_t x0, x1, x2, x3, c0; /* temporary variables for holding input and coefficient values */
  91. uint32_t j, k = 0u, count, blkCnt, outBlockSize, blockSize1, blockSize2, blockSize3; /* loop counter */
  92. int32_t inc = 1; /* Destination address modifier */
  93. /* The algorithm implementation is based on the lengths of the inputs. */
  94. /* srcB is always made to slide across srcA. */
  95. /* So srcBLen is always considered as shorter or equal to srcALen */
  96. if(srcALen >= srcBLen)
  97. {
  98. /* Initialization of inputA pointer */
  99. pIn1 = (pSrcA);
  100. /* Initialization of inputB pointer */
  101. pIn2 = (pSrcB);
  102. /* Number of output samples is calculated */
  103. outBlockSize = (2u * srcALen) - 1u;
  104. /* When srcALen > srcBLen, zero padding is done to srcB
  105. * to make their lengths equal.
  106. * Instead, (outBlockSize - (srcALen + srcBLen - 1))
  107. * number of output samples are made zero */
  108. j = outBlockSize - (srcALen + (srcBLen - 1u));
  109. /* Updating the pointer position to non zero value */
  110. pOut += j;
  111. }
  112. else
  113. {
  114. /* Initialization of inputA pointer */
  115. pIn1 = (pSrcB);
  116. /* Initialization of inputB pointer */
  117. pIn2 = (pSrcA);
  118. /* srcBLen is always considered as shorter or equal to srcALen */
  119. j = srcBLen;
  120. srcBLen = srcALen;
  121. srcALen = j;
  122. /* CORR(x, y) = Reverse order(CORR(y, x)) */
  123. /* Hence set the destination pointer to point to the last output sample */
  124. pOut = pDst + ((srcALen + srcBLen) - 2u);
  125. /* Destination address modifier is set to -1 */
  126. inc = -1;
  127. }
  128. /* The function is internally
  129. * divided into three parts according to the number of multiplications that has to be
  130. * taken place between inputA samples and inputB samples. In the first part of the
  131. * algorithm, the multiplications increase by one for every iteration.
  132. * In the second part of the algorithm, srcBLen number of multiplications are done.
  133. * In the third part of the algorithm, the multiplications decrease by one
  134. * for every iteration.*/
  135. /* The algorithm is implemented in three stages.
  136. * The loop counters of each stage is initiated here. */
  137. blockSize1 = srcBLen - 1u;
  138. blockSize2 = srcALen - (srcBLen - 1u);
  139. blockSize3 = blockSize1;
  140. /* --------------------------
  141. * Initializations of stage1
  142. * -------------------------*/
  143. /* sum = x[0] * y[srcBlen - 1]
  144. * sum = x[0] * y[srcBlen - 2] + x[1] * y[srcBlen - 1]
  145. * ....
  146. * sum = x[0] * y[0] + x[1] * y[1] +...+ x[srcBLen - 1] * y[srcBLen - 1]
  147. */
  148. /* In this stage the MAC operations are increased by 1 for every iteration.
  149. The count variable holds the number of MAC operations performed */
  150. count = 1u;
  151. /* Working pointer of inputA */
  152. px = pIn1;
  153. /* Working pointer of inputB */
  154. pSrc1 = pIn2 + (srcBLen - 1u);
  155. py = pSrc1;
  156. /* ------------------------
  157. * Stage1 process
  158. * ----------------------*/
  159. /* The first stage starts here */
  160. while(blockSize1 > 0u)
  161. {
  162. /* Accumulator is made zero for every iteration */
  163. sum = 0;
  164. /* Apply loop unrolling and compute 4 MACs simultaneously. */
  165. k = count >> 2;
  166. /* First part of the processing with loop unrolling. Compute 4 MACs at a time.
  167. ** a second loop below computes MACs for the remaining 1 to 3 samples. */
  168. while(k > 0u)
  169. {
  170. /* x[0] * y[srcBLen - 4] */
  171. sum = (q31_t) ((((q63_t) sum << 32) +
  172. ((q63_t) * px++ * (*py++))) >> 32);
  173. /* x[1] * y[srcBLen - 3] */
  174. sum = (q31_t) ((((q63_t) sum << 32) +
  175. ((q63_t) * px++ * (*py++))) >> 32);
  176. /* x[2] * y[srcBLen - 2] */
  177. sum = (q31_t) ((((q63_t) sum << 32) +
  178. ((q63_t) * px++ * (*py++))) >> 32);
  179. /* x[3] * y[srcBLen - 1] */
  180. sum = (q31_t) ((((q63_t) sum << 32) +
  181. ((q63_t) * px++ * (*py++))) >> 32);
  182. /* Decrement the loop counter */
  183. k--;
  184. }
  185. /* If the count is not a multiple of 4, compute any remaining MACs here.
  186. ** No loop unrolling is used. */
  187. k = count % 0x4u;
  188. while(k > 0u)
  189. {
  190. /* Perform the multiply-accumulates */
  191. /* x[0] * y[srcBLen - 1] */
  192. sum = (q31_t) ((((q63_t) sum << 32) +
  193. ((q63_t) * px++ * (*py++))) >> 32);
  194. /* Decrement the loop counter */
  195. k--;
  196. }
  197. /* Store the result in the accumulator in the destination buffer. */
  198. *pOut = sum << 1;
  199. /* Destination pointer is updated according to the address modifier, inc */
  200. pOut += inc;
  201. /* Update the inputA and inputB pointers for next MAC calculation */
  202. py = pSrc1 - count;
  203. px = pIn1;
  204. /* Increment the MAC count */
  205. count++;
  206. /* Decrement the loop counter */
  207. blockSize1--;
  208. }
  209. /* --------------------------
  210. * Initializations of stage2
  211. * ------------------------*/
  212. /* sum = x[0] * y[0] + x[1] * y[1] +...+ x[srcBLen-1] * y[srcBLen-1]
  213. * sum = x[1] * y[0] + x[2] * y[1] +...+ x[srcBLen] * y[srcBLen-1]
  214. * ....
  215. * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
  216. */
  217. /* Working pointer of inputA */
  218. px = pIn1;
  219. /* Working pointer of inputB */
  220. py = pIn2;
  221. /* count is index by which the pointer pIn1 to be incremented */
  222. count = 0u;
  223. /* -------------------
  224. * Stage2 process
  225. * ------------------*/
  226. /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed.
  227. * So, to loop unroll over blockSize2,
  228. * srcBLen should be greater than or equal to 4 */
  229. if(srcBLen >= 4u)
  230. {
  231. /* Loop unroll over blockSize2, by 4 */
  232. blkCnt = blockSize2 >> 2u;
  233. while(blkCnt > 0u)
  234. {
  235. /* Set all accumulators to zero */
  236. acc0 = 0;
  237. acc1 = 0;
  238. acc2 = 0;
  239. acc3 = 0;
  240. /* read x[0], x[1], x[2] samples */
  241. x0 = *(px++);
  242. x1 = *(px++);
  243. x2 = *(px++);
  244. /* Apply loop unrolling and compute 4 MACs simultaneously. */
  245. k = srcBLen >> 2u;
  246. /* First part of the processing with loop unrolling. Compute 4 MACs at a time.
  247. ** a second loop below computes MACs for the remaining 1 to 3 samples. */
  248. do
  249. {
  250. /* Read y[0] sample */
  251. c0 = *(py++);
  252. /* Read x[3] sample */
  253. x3 = *(px++);
  254. /* Perform the multiply-accumulate */
  255. /* acc0 += x[0] * y[0] */
  256. acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32);
  257. /* acc1 += x[1] * y[0] */
  258. acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32);
  259. /* acc2 += x[2] * y[0] */
  260. acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32);
  261. /* acc3 += x[3] * y[0] */
  262. acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32);
  263. /* Read y[1] sample */
  264. c0 = *(py++);
  265. /* Read x[4] sample */
  266. x0 = *(px++);
  267. /* Perform the multiply-accumulates */
  268. /* acc0 += x[1] * y[1] */
  269. acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x1 * c0)) >> 32);
  270. /* acc1 += x[2] * y[1] */
  271. acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x2 * c0)) >> 32);
  272. /* acc2 += x[3] * y[1] */
  273. acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x3 * c0)) >> 32);
  274. /* acc3 += x[4] * y[1] */
  275. acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x0 * c0)) >> 32);
  276. /* Read y[2] sample */
  277. c0 = *(py++);
  278. /* Read x[5] sample */
  279. x1 = *(px++);
  280. /* Perform the multiply-accumulates */
  281. /* acc0 += x[2] * y[2] */
  282. acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x2 * c0)) >> 32);
  283. /* acc1 += x[3] * y[2] */
  284. acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x3 * c0)) >> 32);
  285. /* acc2 += x[4] * y[2] */
  286. acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x0 * c0)) >> 32);
  287. /* acc3 += x[5] * y[2] */
  288. acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x1 * c0)) >> 32);
  289. /* Read y[3] sample */
  290. c0 = *(py++);
  291. /* Read x[6] sample */
  292. x2 = *(px++);
  293. /* Perform the multiply-accumulates */
  294. /* acc0 += x[3] * y[3] */
  295. acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x3 * c0)) >> 32);
  296. /* acc1 += x[4] * y[3] */
  297. acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x0 * c0)) >> 32);
  298. /* acc2 += x[5] * y[3] */
  299. acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x1 * c0)) >> 32);
  300. /* acc3 += x[6] * y[3] */
  301. acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x2 * c0)) >> 32);
  302. } while(--k);
  303. /* If the srcBLen is not a multiple of 4, compute any remaining MACs here.
  304. ** No loop unrolling is used. */
  305. k = srcBLen % 0x4u;
  306. while(k > 0u)
  307. {
  308. /* Read y[4] sample */
  309. c0 = *(py++);
  310. /* Read x[7] sample */
  311. x3 = *(px++);
  312. /* Perform the multiply-accumulates */
  313. /* acc0 += x[4] * y[4] */
  314. acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32);
  315. /* acc1 += x[5] * y[4] */
  316. acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32);
  317. /* acc2 += x[6] * y[4] */
  318. acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32);
  319. /* acc3 += x[7] * y[4] */
  320. acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32);
  321. /* Reuse the present samples for the next MAC */
  322. x0 = x1;
  323. x1 = x2;
  324. x2 = x3;
  325. /* Decrement the loop counter */
  326. k--;
  327. }
  328. /* Store the result in the accumulator in the destination buffer. */
  329. *pOut = (q31_t) (acc0 << 1);
  330. /* Destination pointer is updated according to the address modifier, inc */
  331. pOut += inc;
  332. *pOut = (q31_t) (acc1 << 1);
  333. pOut += inc;
  334. *pOut = (q31_t) (acc2 << 1);
  335. pOut += inc;
  336. *pOut = (q31_t) (acc3 << 1);
  337. pOut += inc;
  338. /* Increment the pointer pIn1 index, count by 4 */
  339. count += 4u;
  340. /* Update the inputA and inputB pointers for next MAC calculation */
  341. px = pIn1 + count;
  342. py = pIn2;
  343. /* Decrement the loop counter */
  344. blkCnt--;
  345. }
  346. /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here.
  347. ** No loop unrolling is used. */
  348. blkCnt = blockSize2 % 0x4u;
  349. while(blkCnt > 0u)
  350. {
  351. /* Accumulator is made zero for every iteration */
  352. sum = 0;
  353. /* Apply loop unrolling and compute 4 MACs simultaneously. */
  354. k = srcBLen >> 2u;
  355. /* First part of the processing with loop unrolling. Compute 4 MACs at a time.
  356. ** a second loop below computes MACs for the remaining 1 to 3 samples. */
  357. while(k > 0u)
  358. {
  359. /* Perform the multiply-accumulates */
  360. sum = (q31_t) ((((q63_t) sum << 32) +
  361. ((q63_t) * px++ * (*py++))) >> 32);
  362. sum = (q31_t) ((((q63_t) sum << 32) +
  363. ((q63_t) * px++ * (*py++))) >> 32);
  364. sum = (q31_t) ((((q63_t) sum << 32) +
  365. ((q63_t) * px++ * (*py++))) >> 32);
  366. sum = (q31_t) ((((q63_t) sum << 32) +
  367. ((q63_t) * px++ * (*py++))) >> 32);
  368. /* Decrement the loop counter */
  369. k--;
  370. }
  371. /* If the srcBLen is not a multiple of 4, compute any remaining MACs here.
  372. ** No loop unrolling is used. */
  373. k = srcBLen % 0x4u;
  374. while(k > 0u)
  375. {
  376. /* Perform the multiply-accumulate */
  377. sum = (q31_t) ((((q63_t) sum << 32) +
  378. ((q63_t) * px++ * (*py++))) >> 32);
  379. /* Decrement the loop counter */
  380. k--;
  381. }
  382. /* Store the result in the accumulator in the destination buffer. */
  383. *pOut = sum << 1;
  384. /* Destination pointer is updated according to the address modifier, inc */
  385. pOut += inc;
  386. /* Increment the MAC count */
  387. count++;
  388. /* Update the inputA and inputB pointers for next MAC calculation */
  389. px = pIn1 + count;
  390. py = pIn2;
  391. /* Decrement the loop counter */
  392. blkCnt--;
  393. }
  394. }
  395. else
  396. {
  397. /* If the srcBLen is not a multiple of 4,
  398. * the blockSize2 loop cannot be unrolled by 4 */
  399. blkCnt = blockSize2;
  400. while(blkCnt > 0u)
  401. {
  402. /* Accumulator is made zero for every iteration */
  403. sum = 0;
  404. /* Loop over srcBLen */
  405. k = srcBLen;
  406. while(k > 0u)
  407. {
  408. /* Perform the multiply-accumulate */
  409. sum = (q31_t) ((((q63_t) sum << 32) +
  410. ((q63_t) * px++ * (*py++))) >> 32);
  411. /* Decrement the loop counter */
  412. k--;
  413. }
  414. /* Store the result in the accumulator in the destination buffer. */
  415. *pOut = sum << 1;
  416. /* Destination pointer is updated according to the address modifier, inc */
  417. pOut += inc;
  418. /* Increment the MAC count */
  419. count++;
  420. /* Update the inputA and inputB pointers for next MAC calculation */
  421. px = pIn1 + count;
  422. py = pIn2;
  423. /* Decrement the loop counter */
  424. blkCnt--;
  425. }
  426. }
  427. /* --------------------------
  428. * Initializations of stage3
  429. * -------------------------*/
  430. /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
  431. * sum += x[srcALen-srcBLen+2] * y[0] + x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
  432. * ....
  433. * sum += x[srcALen-2] * y[0] + x[srcALen-1] * y[1]
  434. * sum += x[srcALen-1] * y[0]
  435. */
  436. /* In this stage the MAC operations are decreased by 1 for every iteration.
  437. The count variable holds the number of MAC operations performed */
  438. count = srcBLen - 1u;
  439. /* Working pointer of inputA */
  440. pSrc1 = ((pIn1 + srcALen) - srcBLen) + 1u;
  441. px = pSrc1;
  442. /* Working pointer of inputB */
  443. py = pIn2;
  444. /* -------------------
  445. * Stage3 process
  446. * ------------------*/
  447. while(blockSize3 > 0u)
  448. {
  449. /* Accumulator is made zero for every iteration */
  450. sum = 0;
  451. /* Apply loop unrolling and compute 4 MACs simultaneously. */
  452. k = count >> 2u;
  453. /* First part of the processing with loop unrolling. Compute 4 MACs at a time.
  454. ** a second loop below computes MACs for the remaining 1 to 3 samples. */
  455. while(k > 0u)
  456. {
  457. /* Perform the multiply-accumulates */
  458. /* sum += x[srcALen - srcBLen + 4] * y[3] */
  459. sum = (q31_t) ((((q63_t) sum << 32) +
  460. ((q63_t) * px++ * (*py++))) >> 32);
  461. /* sum += x[srcALen - srcBLen + 3] * y[2] */
  462. sum = (q31_t) ((((q63_t) sum << 32) +
  463. ((q63_t) * px++ * (*py++))) >> 32);
  464. /* sum += x[srcALen - srcBLen + 2] * y[1] */
  465. sum = (q31_t) ((((q63_t) sum << 32) +
  466. ((q63_t) * px++ * (*py++))) >> 32);
  467. /* sum += x[srcALen - srcBLen + 1] * y[0] */
  468. sum = (q31_t) ((((q63_t) sum << 32) +
  469. ((q63_t) * px++ * (*py++))) >> 32);
  470. /* Decrement the loop counter */
  471. k--;
  472. }
  473. /* If the count is not a multiple of 4, compute any remaining MACs here.
  474. ** No loop unrolling is used. */
  475. k = count % 0x4u;
  476. while(k > 0u)
  477. {
  478. /* Perform the multiply-accumulates */
  479. sum = (q31_t) ((((q63_t) sum << 32) +
  480. ((q63_t) * px++ * (*py++))) >> 32);
  481. /* Decrement the loop counter */
  482. k--;
  483. }
  484. /* Store the result in the accumulator in the destination buffer. */
  485. *pOut = sum << 1;
  486. /* Destination pointer is updated according to the address modifier, inc */
  487. pOut += inc;
  488. /* Update the inputA and inputB pointers for next MAC calculation */
  489. px = ++pSrc1;
  490. py = pIn2;
  491. /* Decrement the MAC count */
  492. count--;
  493. /* Decrement the loop counter */
  494. blockSize3--;
  495. }
  496. }
  497. /**
  498. * @} end of Corr group
  499. */