Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

arm_conv_partial_fast_q31.c 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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_conv_partial_fast_q31.c
  9. *
  10. * Description: Fast Q31 Partial convolution.
  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 PartialConv
  46. * @{
  47. */
  48. /**
  49. * @brief Partial convolution 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.
  55. * @param[in] firstIndex is the first output sample to start with.
  56. * @param[in] numPoints is the number of output points to be computed.
  57. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  58. *
  59. * \par
  60. * See <code>arm_conv_partial_q31()</code> for a slower implementation of this function which uses a 64-bit accumulator to provide higher precision.
  61. */
  62. arm_status arm_conv_partial_fast_q31(
  63. q31_t * pSrcA,
  64. uint32_t srcALen,
  65. q31_t * pSrcB,
  66. uint32_t srcBLen,
  67. q31_t * pDst,
  68. uint32_t firstIndex,
  69. uint32_t numPoints)
  70. {
  71. q31_t *pIn1; /* inputA pointer */
  72. q31_t *pIn2; /* inputB pointer */
  73. q31_t *pOut = pDst; /* output pointer */
  74. q31_t *px; /* Intermediate inputA pointer */
  75. q31_t *py; /* Intermediate inputB pointer */
  76. q31_t *pSrc1, *pSrc2; /* Intermediate pointers */
  77. q31_t sum, acc0, acc1, acc2, acc3; /* Accumulators */
  78. q31_t x0, x1, x2, x3, c0;
  79. uint32_t j, k, count, check, blkCnt;
  80. int32_t blockSize1, blockSize2, blockSize3; /* loop counters */
  81. arm_status status; /* status of Partial convolution */
  82. /* Check for range of output samples to be calculated */
  83. if((firstIndex + numPoints) > ((srcALen + (srcBLen - 1u))))
  84. {
  85. /* Set status as ARM_MATH_ARGUMENT_ERROR */
  86. status = ARM_MATH_ARGUMENT_ERROR;
  87. }
  88. else
  89. {
  90. /* The algorithm implementation is based on the lengths of the inputs. */
  91. /* srcB is always made to slide across srcA. */
  92. /* So srcBLen is always considered as shorter or equal to srcALen */
  93. if(srcALen >= srcBLen)
  94. {
  95. /* Initialization of inputA pointer */
  96. pIn1 = pSrcA;
  97. /* Initialization of inputB pointer */
  98. pIn2 = pSrcB;
  99. }
  100. else
  101. {
  102. /* Initialization of inputA pointer */
  103. pIn1 = pSrcB;
  104. /* Initialization of inputB pointer */
  105. pIn2 = pSrcA;
  106. /* srcBLen is always considered as shorter or equal to srcALen */
  107. j = srcBLen;
  108. srcBLen = srcALen;
  109. srcALen = j;
  110. }
  111. /* Conditions to check which loopCounter holds
  112. * the first and last indices of the output samples to be calculated. */
  113. check = firstIndex + numPoints;
  114. blockSize3 = ((int32_t) check - (int32_t) srcALen);
  115. blockSize3 = (blockSize3 > 0) ? blockSize3 : 0;
  116. blockSize1 = (((int32_t) srcBLen - 1) - (int32_t) firstIndex);
  117. blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1u)) ? blockSize1 :
  118. (int32_t) numPoints) : 0;
  119. blockSize2 = (int32_t) check - ((blockSize3 + blockSize1) +
  120. (int32_t) firstIndex);
  121. blockSize2 = (blockSize2 > 0) ? blockSize2 : 0;
  122. /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */
  123. /* The function is internally
  124. * divided into three stages according to the number of multiplications that has to be
  125. * taken place between inputA samples and inputB samples. In the first stage of the
  126. * algorithm, the multiplications increase by one for every iteration.
  127. * In the second stage of the algorithm, srcBLen number of multiplications are done.
  128. * In the third stage of the algorithm, the multiplications decrease by one
  129. * for every iteration. */
  130. /* Set the output pointer to point to the firstIndex
  131. * of the output sample to be calculated. */
  132. pOut = pDst + firstIndex;
  133. /* --------------------------
  134. * Initializations of stage1
  135. * -------------------------*/
  136. /* sum = x[0] * y[0]
  137. * sum = x[0] * y[1] + x[1] * y[0]
  138. * ....
  139. * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0]
  140. */
  141. /* In this stage the MAC operations are increased by 1 for every iteration.
  142. The count variable holds the number of MAC operations performed.
  143. Since the partial convolution starts from firstIndex
  144. Number of Macs to be performed is firstIndex + 1 */
  145. count = 1u + firstIndex;
  146. /* Working pointer of inputA */
  147. px = pIn1;
  148. /* Working pointer of inputB */
  149. pSrc2 = pIn2 + firstIndex;
  150. py = pSrc2;
  151. /* ------------------------
  152. * Stage1 process
  153. * ----------------------*/
  154. /* The first loop starts here */
  155. while(blockSize1 > 0)
  156. {
  157. /* Accumulator is made zero for every iteration */
  158. sum = 0;
  159. /* Apply loop unrolling and compute 4 MACs simultaneously. */
  160. k = count >> 2u;
  161. /* First part of the processing with loop unrolling. Compute 4 MACs at a time.
  162. ** a second loop below computes MACs for the remaining 1 to 3 samples. */
  163. while(k > 0u)
  164. {
  165. /* x[0] * y[srcBLen - 1] */
  166. sum = (q31_t) ((((q63_t) sum << 32) +
  167. ((q63_t) * px++ * (*py--))) >> 32);
  168. /* x[1] * y[srcBLen - 2] */
  169. sum = (q31_t) ((((q63_t) sum << 32) +
  170. ((q63_t) * px++ * (*py--))) >> 32);
  171. /* x[2] * y[srcBLen - 3] */
  172. sum = (q31_t) ((((q63_t) sum << 32) +
  173. ((q63_t) * px++ * (*py--))) >> 32);
  174. /* x[3] * y[srcBLen - 4] */
  175. sum = (q31_t) ((((q63_t) sum << 32) +
  176. ((q63_t) * px++ * (*py--))) >> 32);
  177. /* Decrement the loop counter */
  178. k--;
  179. }
  180. /* If the count is not a multiple of 4, compute any remaining MACs here.
  181. ** No loop unrolling is used. */
  182. k = count % 0x4u;
  183. while(k > 0u)
  184. {
  185. /* Perform the multiply-accumulates */
  186. sum = (q31_t) ((((q63_t) sum << 32) +
  187. ((q63_t) * px++ * (*py--))) >> 32);
  188. /* Decrement the loop counter */
  189. k--;
  190. }
  191. /* Store the result in the accumulator in the destination buffer. */
  192. *pOut++ = sum << 1;
  193. /* Update the inputA and inputB pointers for next MAC calculation */
  194. py = ++pSrc2;
  195. px = pIn1;
  196. /* Increment the MAC count */
  197. count++;
  198. /* Decrement the loop counter */
  199. blockSize1--;
  200. }
  201. /* --------------------------
  202. * Initializations of stage2
  203. * ------------------------*/
  204. /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0]
  205. * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0]
  206. * ....
  207. * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0]
  208. */
  209. /* Working pointer of inputA */
  210. px = pIn1;
  211. /* Working pointer of inputB */
  212. pSrc2 = pIn2 + (srcBLen - 1u);
  213. py = pSrc2;
  214. /* count is index by which the pointer pIn1 to be incremented */
  215. count = 0u;
  216. /* -------------------
  217. * Stage2 process
  218. * ------------------*/
  219. /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed.
  220. * So, to loop unroll over blockSize2,
  221. * srcBLen should be greater than or equal to 4 */
  222. if(srcBLen >= 4u)
  223. {
  224. /* Loop unroll over blockSize2 */
  225. blkCnt = ((uint32_t) blockSize2 >> 2u);
  226. while(blkCnt > 0u)
  227. {
  228. /* Set all accumulators to zero */
  229. acc0 = 0;
  230. acc1 = 0;
  231. acc2 = 0;
  232. acc3 = 0;
  233. /* read x[0], x[1], x[2] samples */
  234. x0 = *(px++);
  235. x1 = *(px++);
  236. x2 = *(px++);
  237. /* Apply loop unrolling and compute 4 MACs simultaneously. */
  238. k = srcBLen >> 2u;
  239. /* First part of the processing with loop unrolling. Compute 4 MACs at a time.
  240. ** a second loop below computes MACs for the remaining 1 to 3 samples. */
  241. do
  242. {
  243. /* Read y[srcBLen - 1] sample */
  244. c0 = *(py--);
  245. /* Read x[3] sample */
  246. x3 = *(px++);
  247. /* Perform the multiply-accumulate */
  248. /* acc0 += x[0] * y[srcBLen - 1] */
  249. acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32);
  250. /* acc1 += x[1] * y[srcBLen - 1] */
  251. acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32);
  252. /* acc2 += x[2] * y[srcBLen - 1] */
  253. acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32);
  254. /* acc3 += x[3] * y[srcBLen - 1] */
  255. acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32);
  256. /* Read y[srcBLen - 2] sample */
  257. c0 = *(py--);
  258. /* Read x[4] sample */
  259. x0 = *(px++);
  260. /* Perform the multiply-accumulate */
  261. /* acc0 += x[1] * y[srcBLen - 2] */
  262. acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x1 * c0)) >> 32);
  263. /* acc1 += x[2] * y[srcBLen - 2] */
  264. acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x2 * c0)) >> 32);
  265. /* acc2 += x[3] * y[srcBLen - 2] */
  266. acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x3 * c0)) >> 32);
  267. /* acc3 += x[4] * y[srcBLen - 2] */
  268. acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x0 * c0)) >> 32);
  269. /* Read y[srcBLen - 3] sample */
  270. c0 = *(py--);
  271. /* Read x[5] sample */
  272. x1 = *(px++);
  273. /* Perform the multiply-accumulates */
  274. /* acc0 += x[2] * y[srcBLen - 3] */
  275. acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x2 * c0)) >> 32);
  276. /* acc1 += x[3] * y[srcBLen - 2] */
  277. acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x3 * c0)) >> 32);
  278. /* acc2 += x[4] * y[srcBLen - 2] */
  279. acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x0 * c0)) >> 32);
  280. /* acc3 += x[5] * y[srcBLen - 2] */
  281. acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x1 * c0)) >> 32);
  282. /* Read y[srcBLen - 4] sample */
  283. c0 = *(py--);
  284. /* Read x[6] sample */
  285. x2 = *(px++);
  286. /* Perform the multiply-accumulates */
  287. /* acc0 += x[3] * y[srcBLen - 4] */
  288. acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x3 * c0)) >> 32);
  289. /* acc1 += x[4] * y[srcBLen - 4] */
  290. acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x0 * c0)) >> 32);
  291. /* acc2 += x[5] * y[srcBLen - 4] */
  292. acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x1 * c0)) >> 32);
  293. /* acc3 += x[6] * y[srcBLen - 4] */
  294. acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x2 * c0)) >> 32);
  295. } while(--k);
  296. /* If the srcBLen is not a multiple of 4, compute any remaining MACs here.
  297. ** No loop unrolling is used. */
  298. k = srcBLen % 0x4u;
  299. while(k > 0u)
  300. {
  301. /* Read y[srcBLen - 5] sample */
  302. c0 = *(py--);
  303. /* Read x[7] sample */
  304. x3 = *(px++);
  305. /* Perform the multiply-accumulates */
  306. /* acc0 += x[4] * y[srcBLen - 5] */
  307. acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32);
  308. /* acc1 += x[5] * y[srcBLen - 5] */
  309. acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32);
  310. /* acc2 += x[6] * y[srcBLen - 5] */
  311. acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32);
  312. /* acc3 += x[7] * y[srcBLen - 5] */
  313. acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32);
  314. /* Reuse the present samples for the next MAC */
  315. x0 = x1;
  316. x1 = x2;
  317. x2 = x3;
  318. /* Decrement the loop counter */
  319. k--;
  320. }
  321. /* Store the result in the accumulator in the destination buffer. */
  322. *pOut++ = (q31_t) (acc0 << 1);
  323. *pOut++ = (q31_t) (acc1 << 1);
  324. *pOut++ = (q31_t) (acc2 << 1);
  325. *pOut++ = (q31_t) (acc3 << 1);
  326. /* Increment the pointer pIn1 index, count by 4 */
  327. count += 4u;
  328. /* Update the inputA and inputB pointers for next MAC calculation */
  329. px = pIn1 + count;
  330. py = pSrc2;
  331. /* Decrement the loop counter */
  332. blkCnt--;
  333. }
  334. /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here.
  335. ** No loop unrolling is used. */
  336. blkCnt = (uint32_t) blockSize2 % 0x4u;
  337. while(blkCnt > 0u)
  338. {
  339. /* Accumulator is made zero for every iteration */
  340. sum = 0;
  341. /* Apply loop unrolling and compute 4 MACs simultaneously. */
  342. k = srcBLen >> 2u;
  343. /* First part of the processing with loop unrolling. Compute 4 MACs at a time.
  344. ** a second loop below computes MACs for the remaining 1 to 3 samples. */
  345. while(k > 0u)
  346. {
  347. /* Perform the multiply-accumulates */
  348. sum = (q31_t) ((((q63_t) sum << 32) +
  349. ((q63_t) * px++ * (*py--))) >> 32);
  350. sum = (q31_t) ((((q63_t) sum << 32) +
  351. ((q63_t) * px++ * (*py--))) >> 32);
  352. sum = (q31_t) ((((q63_t) sum << 32) +
  353. ((q63_t) * px++ * (*py--))) >> 32);
  354. sum = (q31_t) ((((q63_t) sum << 32) +
  355. ((q63_t) * px++ * (*py--))) >> 32);
  356. /* Decrement the loop counter */
  357. k--;
  358. }
  359. /* If the srcBLen is not a multiple of 4, compute any remaining MACs here.
  360. ** No loop unrolling is used. */
  361. k = srcBLen % 0x4u;
  362. while(k > 0u)
  363. {
  364. /* Perform the multiply-accumulate */
  365. sum = (q31_t) ((((q63_t) sum << 32) +
  366. ((q63_t) * px++ * (*py--))) >> 32);
  367. /* Decrement the loop counter */
  368. k--;
  369. }
  370. /* Store the result in the accumulator in the destination buffer. */
  371. *pOut++ = sum << 1;
  372. /* Increment the MAC count */
  373. count++;
  374. /* Update the inputA and inputB pointers for next MAC calculation */
  375. px = pIn1 + count;
  376. py = pSrc2;
  377. /* Decrement the loop counter */
  378. blkCnt--;
  379. }
  380. }
  381. else
  382. {
  383. /* If the srcBLen is not a multiple of 4,
  384. * the blockSize2 loop cannot be unrolled by 4 */
  385. blkCnt = (uint32_t) blockSize2;
  386. while(blkCnt > 0u)
  387. {
  388. /* Accumulator is made zero for every iteration */
  389. sum = 0;
  390. /* srcBLen number of MACS should be performed */
  391. k = srcBLen;
  392. while(k > 0u)
  393. {
  394. /* Perform the multiply-accumulate */
  395. sum = (q31_t) ((((q63_t) sum << 32) +
  396. ((q63_t) * px++ * (*py--))) >> 32);
  397. /* Decrement the loop counter */
  398. k--;
  399. }
  400. /* Store the result in the accumulator in the destination buffer. */
  401. *pOut++ = sum << 1;
  402. /* Increment the MAC count */
  403. count++;
  404. /* Update the inputA and inputB pointers for next MAC calculation */
  405. px = pIn1 + count;
  406. py = pSrc2;
  407. /* Decrement the loop counter */
  408. blkCnt--;
  409. }
  410. }
  411. /* --------------------------
  412. * Initializations of stage3
  413. * -------------------------*/
  414. /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1]
  415. * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2]
  416. * ....
  417. * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2]
  418. * sum += x[srcALen-1] * y[srcBLen-1]
  419. */
  420. /* In this stage the MAC operations are decreased by 1 for every iteration.
  421. The count variable holds the number of MAC operations performed */
  422. count = srcBLen - 1u;
  423. /* Working pointer of inputA */
  424. pSrc1 = (pIn1 + srcALen) - (srcBLen - 1u);
  425. px = pSrc1;
  426. /* Working pointer of inputB */
  427. pSrc2 = pIn2 + (srcBLen - 1u);
  428. py = pSrc2;
  429. /* -------------------
  430. * Stage3 process
  431. * ------------------*/
  432. while(blockSize3 > 0)
  433. {
  434. /* Accumulator is made zero for every iteration */
  435. sum = 0;
  436. /* Apply loop unrolling and compute 4 MACs simultaneously. */
  437. k = count >> 2u;
  438. /* First part of the processing with loop unrolling. Compute 4 MACs at a time.
  439. ** a second loop below computes MACs for the remaining 1 to 3 samples. */
  440. while(k > 0u)
  441. {
  442. /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */
  443. sum = (q31_t) ((((q63_t) sum << 32) +
  444. ((q63_t) * px++ * (*py--))) >> 32);
  445. /* sum += x[srcALen - srcBLen + 2] * y[srcBLen - 2] */
  446. sum = (q31_t) ((((q63_t) sum << 32) +
  447. ((q63_t) * px++ * (*py--))) >> 32);
  448. /* sum += x[srcALen - srcBLen + 3] * y[srcBLen - 3] */
  449. sum = (q31_t) ((((q63_t) sum << 32) +
  450. ((q63_t) * px++ * (*py--))) >> 32);
  451. /* sum += x[srcALen - srcBLen + 4] * y[srcBLen - 4] */
  452. sum = (q31_t) ((((q63_t) sum << 32) +
  453. ((q63_t) * px++ * (*py--))) >> 32);
  454. /* Decrement the loop counter */
  455. k--;
  456. }
  457. /* If the count is not a multiple of 4, compute any remaining MACs here.
  458. ** No loop unrolling is used. */
  459. k = count % 0x4u;
  460. while(k > 0u)
  461. {
  462. /* Perform the multiply-accumulates */
  463. /* sum += x[srcALen-1] * y[srcBLen-1] */
  464. sum = (q31_t) ((((q63_t) sum << 32) +
  465. ((q63_t) * px++ * (*py--))) >> 32);
  466. /* Decrement the loop counter */
  467. k--;
  468. }
  469. /* Store the result in the accumulator in the destination buffer. */
  470. *pOut++ = sum << 1;
  471. /* Update the inputA and inputB pointers for next MAC calculation */
  472. px = ++pSrc1;
  473. py = pSrc2;
  474. /* Decrement the MAC count */
  475. count--;
  476. /* Decrement the loop counter */
  477. blockSize3--;
  478. }
  479. /* set status as ARM_MATH_SUCCESS */
  480. status = ARM_MATH_SUCCESS;
  481. }
  482. /* Return to application */
  483. return (status);
  484. }
  485. /**
  486. * @} end of PartialConv group
  487. */