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_opt_q15.c 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  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_opt_q15.c
  9. *
  10. * Description: Partial convolution of Q15 sequences.
  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 Q15 sequences.
  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. * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  58. * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  59. * @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].
  60. *
  61. * \par Restrictions
  62. * If the silicon does not support unaligned memory access enable the macro UNALIGNED_SUPPORT_DISABLE
  63. * In this case input, output, state buffers should be aligned by 32-bit
  64. *
  65. * Refer to <code>arm_conv_partial_fast_q15()</code> for a faster but less precise version of this function for Cortex-M3 and Cortex-M4.
  66. *
  67. *
  68. */
  69. #ifndef UNALIGNED_SUPPORT_DISABLE
  70. arm_status arm_conv_partial_opt_q15(
  71. q15_t * pSrcA,
  72. uint32_t srcALen,
  73. q15_t * pSrcB,
  74. uint32_t srcBLen,
  75. q15_t * pDst,
  76. uint32_t firstIndex,
  77. uint32_t numPoints,
  78. q15_t * pScratch1,
  79. q15_t * pScratch2)
  80. {
  81. q15_t *pOut = pDst; /* output pointer */
  82. q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch1 */
  83. q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch1 */
  84. q63_t acc0, acc1, acc2, acc3; /* Accumulator */
  85. q31_t x1, x2, x3; /* Temporary variables to hold state and coefficient values */
  86. q31_t y1, y2; /* State variables */
  87. q15_t *pIn1; /* inputA pointer */
  88. q15_t *pIn2; /* inputB pointer */
  89. q15_t *px; /* Intermediate inputA pointer */
  90. q15_t *py; /* Intermediate inputB pointer */
  91. uint32_t j, k, blkCnt; /* loop counter */
  92. arm_status status; /* Status variable */
  93. uint32_t tapCnt; /* loop count */
  94. /* Check for range of output samples to be calculated */
  95. if((firstIndex + numPoints) > ((srcALen + (srcBLen - 1u))))
  96. {
  97. /* Set status as ARM_MATH_ARGUMENT_ERROR */
  98. status = ARM_MATH_ARGUMENT_ERROR;
  99. }
  100. else
  101. {
  102. /* The algorithm implementation is based on the lengths of the inputs. */
  103. /* srcB is always made to slide across srcA. */
  104. /* So srcBLen is always considered as shorter or equal to srcALen */
  105. if(srcALen >= srcBLen)
  106. {
  107. /* Initialization of inputA pointer */
  108. pIn1 = pSrcA;
  109. /* Initialization of inputB pointer */
  110. pIn2 = pSrcB;
  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. }
  123. /* Temporary pointer for scratch2 */
  124. py = pScratch2;
  125. /* pointer to take end of scratch2 buffer */
  126. pScr2 = pScratch2 + srcBLen - 1;
  127. /* points to smaller length sequence */
  128. px = pIn2;
  129. /* Apply loop unrolling and do 4 Copies simultaneously. */
  130. k = srcBLen >> 2u;
  131. /* First part of the processing with loop unrolling copies 4 data points at a time.
  132. ** a second loop below copies for the remaining 1 to 3 samples. */
  133. while(k > 0u)
  134. {
  135. /* copy second buffer in reversal manner */
  136. *pScr2-- = *px++;
  137. *pScr2-- = *px++;
  138. *pScr2-- = *px++;
  139. *pScr2-- = *px++;
  140. /* Decrement the loop counter */
  141. k--;
  142. }
  143. /* If the count is not a multiple of 4, copy remaining samples here.
  144. ** No loop unrolling is used. */
  145. k = srcBLen % 0x4u;
  146. while(k > 0u)
  147. {
  148. /* copy second buffer in reversal manner for remaining samples */
  149. *pScr2-- = *px++;
  150. /* Decrement the loop counter */
  151. k--;
  152. }
  153. /* Initialze temporary scratch pointer */
  154. pScr1 = pScratch1;
  155. /* Fill (srcBLen - 1u) zeros in scratch buffer */
  156. arm_fill_q15(0, pScr1, (srcBLen - 1u));
  157. /* Update temporary scratch pointer */
  158. pScr1 += (srcBLen - 1u);
  159. /* Copy bigger length sequence(srcALen) samples in scratch1 buffer */
  160. /* Copy (srcALen) samples in scratch buffer */
  161. arm_copy_q15(pIn1, pScr1, srcALen);
  162. /* Update pointers */
  163. pScr1 += srcALen;
  164. /* Fill (srcBLen - 1u) zeros at end of scratch buffer */
  165. arm_fill_q15(0, pScr1, (srcBLen - 1u));
  166. /* Update pointer */
  167. pScr1 += (srcBLen - 1u);
  168. /* Initialization of pIn2 pointer */
  169. pIn2 = py;
  170. pScratch1 += firstIndex;
  171. pOut = pDst + firstIndex;
  172. /* Actual convolution process starts here */
  173. blkCnt = (numPoints) >> 2;
  174. while(blkCnt > 0)
  175. {
  176. /* Initialze temporary scratch pointer as scratch1 */
  177. pScr1 = pScratch1;
  178. /* Clear Accumlators */
  179. acc0 = 0;
  180. acc1 = 0;
  181. acc2 = 0;
  182. acc3 = 0;
  183. /* Read two samples from scratch1 buffer */
  184. x1 = *__SIMD32(pScr1)++;
  185. /* Read next two samples from scratch1 buffer */
  186. x2 = *__SIMD32(pScr1)++;
  187. tapCnt = (srcBLen) >> 2u;
  188. while(tapCnt > 0u)
  189. {
  190. /* Read four samples from smaller buffer */
  191. y1 = _SIMD32_OFFSET(pIn2);
  192. y2 = _SIMD32_OFFSET(pIn2 + 2u);
  193. /* multiply and accumlate */
  194. acc0 = __SMLALD(x1, y1, acc0);
  195. acc2 = __SMLALD(x2, y1, acc2);
  196. /* pack input data */
  197. #ifndef ARM_MATH_BIG_ENDIAN
  198. x3 = __PKHBT(x2, x1, 0);
  199. #else
  200. x3 = __PKHBT(x1, x2, 0);
  201. #endif
  202. /* multiply and accumlate */
  203. acc1 = __SMLALDX(x3, y1, acc1);
  204. /* Read next two samples from scratch1 buffer */
  205. x1 = _SIMD32_OFFSET(pScr1);
  206. /* multiply and accumlate */
  207. acc0 = __SMLALD(x2, y2, acc0);
  208. acc2 = __SMLALD(x1, y2, acc2);
  209. /* pack input data */
  210. #ifndef ARM_MATH_BIG_ENDIAN
  211. x3 = __PKHBT(x1, x2, 0);
  212. #else
  213. x3 = __PKHBT(x2, x1, 0);
  214. #endif
  215. acc3 = __SMLALDX(x3, y1, acc3);
  216. acc1 = __SMLALDX(x3, y2, acc1);
  217. x2 = _SIMD32_OFFSET(pScr1 + 2u);
  218. #ifndef ARM_MATH_BIG_ENDIAN
  219. x3 = __PKHBT(x2, x1, 0);
  220. #else
  221. x3 = __PKHBT(x1, x2, 0);
  222. #endif
  223. acc3 = __SMLALDX(x3, y2, acc3);
  224. /* update scratch pointers */
  225. pIn2 += 4u;
  226. pScr1 += 4u;
  227. /* Decrement the loop counter */
  228. tapCnt--;
  229. }
  230. /* Update scratch pointer for remaining samples of smaller length sequence */
  231. pScr1 -= 4u;
  232. /* apply same above for remaining samples of smaller length sequence */
  233. tapCnt = (srcBLen) & 3u;
  234. while(tapCnt > 0u)
  235. {
  236. /* accumlate the results */
  237. acc0 += (*pScr1++ * *pIn2);
  238. acc1 += (*pScr1++ * *pIn2);
  239. acc2 += (*pScr1++ * *pIn2);
  240. acc3 += (*pScr1++ * *pIn2++);
  241. pScr1 -= 3u;
  242. /* Decrement the loop counter */
  243. tapCnt--;
  244. }
  245. blkCnt--;
  246. /* Store the results in the accumulators in the destination buffer. */
  247. #ifndef ARM_MATH_BIG_ENDIAN
  248. *__SIMD32(pOut)++ =
  249. __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16);
  250. *__SIMD32(pOut)++ =
  251. __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16);
  252. #else
  253. *__SIMD32(pOut)++ =
  254. __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16);
  255. *__SIMD32(pOut)++ =
  256. __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16);
  257. #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
  258. /* Initialization of inputB pointer */
  259. pIn2 = py;
  260. pScratch1 += 4u;
  261. }
  262. blkCnt = numPoints & 0x3;
  263. /* Calculate convolution for remaining samples of Bigger length sequence */
  264. while(blkCnt > 0)
  265. {
  266. /* Initialze temporary scratch pointer as scratch1 */
  267. pScr1 = pScratch1;
  268. /* Clear Accumlators */
  269. acc0 = 0;
  270. tapCnt = (srcBLen) >> 1u;
  271. while(tapCnt > 0u)
  272. {
  273. /* Read next two samples from scratch1 buffer */
  274. x1 = *__SIMD32(pScr1)++;
  275. /* Read two samples from smaller buffer */
  276. y1 = *__SIMD32(pIn2)++;
  277. acc0 = __SMLALD(x1, y1, acc0);
  278. /* Decrement the loop counter */
  279. tapCnt--;
  280. }
  281. tapCnt = (srcBLen) & 1u;
  282. /* apply same above for remaining samples of smaller length sequence */
  283. while(tapCnt > 0u)
  284. {
  285. /* accumlate the results */
  286. acc0 += (*pScr1++ * *pIn2++);
  287. /* Decrement the loop counter */
  288. tapCnt--;
  289. }
  290. blkCnt--;
  291. /* Store the result in the accumulator in the destination buffer. */
  292. *pOut++ = (q15_t) (__SSAT((acc0 >> 15), 16));
  293. /* Initialization of inputB pointer */
  294. pIn2 = py;
  295. pScratch1 += 1u;
  296. }
  297. /* set status as ARM_MATH_SUCCESS */
  298. status = ARM_MATH_SUCCESS;
  299. }
  300. /* Return to application */
  301. return (status);
  302. }
  303. #else
  304. arm_status arm_conv_partial_opt_q15(
  305. q15_t * pSrcA,
  306. uint32_t srcALen,
  307. q15_t * pSrcB,
  308. uint32_t srcBLen,
  309. q15_t * pDst,
  310. uint32_t firstIndex,
  311. uint32_t numPoints,
  312. q15_t * pScratch1,
  313. q15_t * pScratch2)
  314. {
  315. q15_t *pOut = pDst; /* output pointer */
  316. q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch1 */
  317. q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch1 */
  318. q63_t acc0, acc1, acc2, acc3; /* Accumulator */
  319. q15_t *pIn1; /* inputA pointer */
  320. q15_t *pIn2; /* inputB pointer */
  321. q15_t *px; /* Intermediate inputA pointer */
  322. q15_t *py; /* Intermediate inputB pointer */
  323. uint32_t j, k, blkCnt; /* loop counter */
  324. arm_status status; /* Status variable */
  325. uint32_t tapCnt; /* loop count */
  326. q15_t x10, x11, x20, x21; /* Temporary variables to hold srcA buffer */
  327. q15_t y10, y11; /* Temporary variables to hold srcB buffer */
  328. /* Check for range of output samples to be calculated */
  329. if((firstIndex + numPoints) > ((srcALen + (srcBLen - 1u))))
  330. {
  331. /* Set status as ARM_MATH_ARGUMENT_ERROR */
  332. status = ARM_MATH_ARGUMENT_ERROR;
  333. }
  334. else
  335. {
  336. /* The algorithm implementation is based on the lengths of the inputs. */
  337. /* srcB is always made to slide across srcA. */
  338. /* So srcBLen is always considered as shorter or equal to srcALen */
  339. if(srcALen >= srcBLen)
  340. {
  341. /* Initialization of inputA pointer */
  342. pIn1 = pSrcA;
  343. /* Initialization of inputB pointer */
  344. pIn2 = pSrcB;
  345. }
  346. else
  347. {
  348. /* Initialization of inputA pointer */
  349. pIn1 = pSrcB;
  350. /* Initialization of inputB pointer */
  351. pIn2 = pSrcA;
  352. /* srcBLen is always considered as shorter or equal to srcALen */
  353. j = srcBLen;
  354. srcBLen = srcALen;
  355. srcALen = j;
  356. }
  357. /* Temporary pointer for scratch2 */
  358. py = pScratch2;
  359. /* pointer to take end of scratch2 buffer */
  360. pScr2 = pScratch2 + srcBLen - 1;
  361. /* points to smaller length sequence */
  362. px = pIn2;
  363. /* Apply loop unrolling and do 4 Copies simultaneously. */
  364. k = srcBLen >> 2u;
  365. /* First part of the processing with loop unrolling copies 4 data points at a time.
  366. ** a second loop below copies for the remaining 1 to 3 samples. */
  367. while(k > 0u)
  368. {
  369. /* copy second buffer in reversal manner */
  370. *pScr2-- = *px++;
  371. *pScr2-- = *px++;
  372. *pScr2-- = *px++;
  373. *pScr2-- = *px++;
  374. /* Decrement the loop counter */
  375. k--;
  376. }
  377. /* If the count is not a multiple of 4, copy remaining samples here.
  378. ** No loop unrolling is used. */
  379. k = srcBLen % 0x4u;
  380. while(k > 0u)
  381. {
  382. /* copy second buffer in reversal manner for remaining samples */
  383. *pScr2-- = *px++;
  384. /* Decrement the loop counter */
  385. k--;
  386. }
  387. /* Initialze temporary scratch pointer */
  388. pScr1 = pScratch1;
  389. /* Fill (srcBLen - 1u) zeros in scratch buffer */
  390. arm_fill_q15(0, pScr1, (srcBLen - 1u));
  391. /* Update temporary scratch pointer */
  392. pScr1 += (srcBLen - 1u);
  393. /* Copy bigger length sequence(srcALen) samples in scratch1 buffer */
  394. /* Apply loop unrolling and do 4 Copies simultaneously. */
  395. k = srcALen >> 2u;
  396. /* First part of the processing with loop unrolling copies 4 data points at a time.
  397. ** a second loop below copies for the remaining 1 to 3 samples. */
  398. while(k > 0u)
  399. {
  400. /* copy second buffer in reversal manner */
  401. *pScr1++ = *pIn1++;
  402. *pScr1++ = *pIn1++;
  403. *pScr1++ = *pIn1++;
  404. *pScr1++ = *pIn1++;
  405. /* Decrement the loop counter */
  406. k--;
  407. }
  408. /* If the count is not a multiple of 4, copy remaining samples here.
  409. ** No loop unrolling is used. */
  410. k = srcALen % 0x4u;
  411. while(k > 0u)
  412. {
  413. /* copy second buffer in reversal manner for remaining samples */
  414. *pScr1++ = *pIn1++;
  415. /* Decrement the loop counter */
  416. k--;
  417. }
  418. /* Apply loop unrolling and do 4 Copies simultaneously. */
  419. k = (srcBLen - 1u) >> 2u;
  420. /* First part of the processing with loop unrolling copies 4 data points at a time.
  421. ** a second loop below copies for the remaining 1 to 3 samples. */
  422. while(k > 0u)
  423. {
  424. /* copy second buffer in reversal manner */
  425. *pScr1++ = 0;
  426. *pScr1++ = 0;
  427. *pScr1++ = 0;
  428. *pScr1++ = 0;
  429. /* Decrement the loop counter */
  430. k--;
  431. }
  432. /* If the count is not a multiple of 4, copy remaining samples here.
  433. ** No loop unrolling is used. */
  434. k = (srcBLen - 1u) % 0x4u;
  435. while(k > 0u)
  436. {
  437. /* copy second buffer in reversal manner for remaining samples */
  438. *pScr1++ = 0;
  439. /* Decrement the loop counter */
  440. k--;
  441. }
  442. /* Initialization of pIn2 pointer */
  443. pIn2 = py;
  444. pScratch1 += firstIndex;
  445. pOut = pDst + firstIndex;
  446. /* Actual convolution process starts here */
  447. blkCnt = (numPoints) >> 2;
  448. while(blkCnt > 0)
  449. {
  450. /* Initialze temporary scratch pointer as scratch1 */
  451. pScr1 = pScratch1;
  452. /* Clear Accumlators */
  453. acc0 = 0;
  454. acc1 = 0;
  455. acc2 = 0;
  456. acc3 = 0;
  457. /* Read two samples from scratch1 buffer */
  458. x10 = *pScr1++;
  459. x11 = *pScr1++;
  460. /* Read next two samples from scratch1 buffer */
  461. x20 = *pScr1++;
  462. x21 = *pScr1++;
  463. tapCnt = (srcBLen) >> 2u;
  464. while(tapCnt > 0u)
  465. {
  466. /* Read two samples from smaller buffer */
  467. y10 = *pIn2;
  468. y11 = *(pIn2 + 1u);
  469. /* multiply and accumlate */
  470. acc0 += (q63_t) x10 *y10;
  471. acc0 += (q63_t) x11 *y11;
  472. acc2 += (q63_t) x20 *y10;
  473. acc2 += (q63_t) x21 *y11;
  474. /* multiply and accumlate */
  475. acc1 += (q63_t) x11 *y10;
  476. acc1 += (q63_t) x20 *y11;
  477. /* Read next two samples from scratch1 buffer */
  478. x10 = *pScr1;
  479. x11 = *(pScr1 + 1u);
  480. /* multiply and accumlate */
  481. acc3 += (q63_t) x21 *y10;
  482. acc3 += (q63_t) x10 *y11;
  483. /* Read next two samples from scratch2 buffer */
  484. y10 = *(pIn2 + 2u);
  485. y11 = *(pIn2 + 3u);
  486. /* multiply and accumlate */
  487. acc0 += (q63_t) x20 *y10;
  488. acc0 += (q63_t) x21 *y11;
  489. acc2 += (q63_t) x10 *y10;
  490. acc2 += (q63_t) x11 *y11;
  491. acc1 += (q63_t) x21 *y10;
  492. acc1 += (q63_t) x10 *y11;
  493. /* Read next two samples from scratch1 buffer */
  494. x20 = *(pScr1 + 2);
  495. x21 = *(pScr1 + 3);
  496. /* multiply and accumlate */
  497. acc3 += (q63_t) x11 *y10;
  498. acc3 += (q63_t) x20 *y11;
  499. /* update scratch pointers */
  500. pIn2 += 4u;
  501. pScr1 += 4u;
  502. /* Decrement the loop counter */
  503. tapCnt--;
  504. }
  505. /* Update scratch pointer for remaining samples of smaller length sequence */
  506. pScr1 -= 4u;
  507. /* apply same above for remaining samples of smaller length sequence */
  508. tapCnt = (srcBLen) & 3u;
  509. while(tapCnt > 0u)
  510. {
  511. /* accumlate the results */
  512. acc0 += (*pScr1++ * *pIn2);
  513. acc1 += (*pScr1++ * *pIn2);
  514. acc2 += (*pScr1++ * *pIn2);
  515. acc3 += (*pScr1++ * *pIn2++);
  516. pScr1 -= 3u;
  517. /* Decrement the loop counter */
  518. tapCnt--;
  519. }
  520. blkCnt--;
  521. /* Store the results in the accumulators in the destination buffer. */
  522. *pOut++ = __SSAT((acc0 >> 15), 16);
  523. *pOut++ = __SSAT((acc1 >> 15), 16);
  524. *pOut++ = __SSAT((acc2 >> 15), 16);
  525. *pOut++ = __SSAT((acc3 >> 15), 16);
  526. /* Initialization of inputB pointer */
  527. pIn2 = py;
  528. pScratch1 += 4u;
  529. }
  530. blkCnt = numPoints & 0x3;
  531. /* Calculate convolution for remaining samples of Bigger length sequence */
  532. while(blkCnt > 0)
  533. {
  534. /* Initialze temporary scratch pointer as scratch1 */
  535. pScr1 = pScratch1;
  536. /* Clear Accumlators */
  537. acc0 = 0;
  538. tapCnt = (srcBLen) >> 1u;
  539. while(tapCnt > 0u)
  540. {
  541. /* Read next two samples from scratch1 buffer */
  542. x10 = *pScr1++;
  543. x11 = *pScr1++;
  544. /* Read two samples from smaller buffer */
  545. y10 = *pIn2++;
  546. y11 = *pIn2++;
  547. /* multiply and accumlate */
  548. acc0 += (q63_t) x10 *y10;
  549. acc0 += (q63_t) x11 *y11;
  550. /* Decrement the loop counter */
  551. tapCnt--;
  552. }
  553. tapCnt = (srcBLen) & 1u;
  554. /* apply same above for remaining samples of smaller length sequence */
  555. while(tapCnt > 0u)
  556. {
  557. /* accumlate the results */
  558. acc0 += (*pScr1++ * *pIn2++);
  559. /* Decrement the loop counter */
  560. tapCnt--;
  561. }
  562. blkCnt--;
  563. /* Store the result in the accumulator in the destination buffer. */
  564. *pOut++ = (q15_t) (__SSAT((acc0 >> 15), 16));
  565. /* Initialization of inputB pointer */
  566. pIn2 = py;
  567. pScratch1 += 1u;
  568. }
  569. /* set status as ARM_MATH_SUCCESS */
  570. status = ARM_MATH_SUCCESS;
  571. }
  572. /* Return to application */
  573. return (status);
  574. }
  575. #endif /* #ifndef UNALIGNED_SUPPORT_DISABLE */
  576. /**
  577. * @} end of PartialConv group
  578. */