]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/dsp/cmsis_dsp/FilteringFunctions/arm_conv_partial_q7.c
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[qmk_firmware.git] / tmk_core / tool / mbed / mbed-sdk / libraries / dsp / cmsis_dsp / FilteringFunctions / arm_conv_partial_q7.c
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_q7.c   
9 *   
10 * Description:  Partial convolution of Q7 sequences.   
11 *   
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
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
41 #include "arm_math.h"
42
43 /**   
44  * @ingroup groupFilters   
45  */
46
47 /**   
48  * @addtogroup PartialConv   
49  * @{   
50  */
51
52 /**   
53  * @brief Partial convolution of Q7 sequences.   
54  * @param[in]       *pSrcA points to the first input sequence.   
55  * @param[in]       srcALen length of the first input sequence.   
56  * @param[in]       *pSrcB points to the second input sequence.   
57  * @param[in]       srcBLen length of the second input sequence.   
58  * @param[out]      *pDst points to the location where the output result is written.   
59  * @param[in]       firstIndex is the first output sample to start with.   
60  * @param[in]       numPoints is the number of output points to be computed.   
61  * @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].   
62  *  
63  * \par    
64  * Refer the function <code>arm_conv_partial_opt_q7()</code> for a faster implementation of this function.
65  *  
66  */
67
68 arm_status arm_conv_partial_q7(
69   q7_t * pSrcA,
70   uint32_t srcALen,
71   q7_t * pSrcB,
72   uint32_t srcBLen,
73   q7_t * pDst,
74   uint32_t firstIndex,
75   uint32_t numPoints)
76 {
77
78
79 #ifndef ARM_MATH_CM0_FAMILY
80
81   /* Run the below code for Cortex-M4 and Cortex-M3 */
82
83   q7_t *pIn1;                                    /* inputA pointer */
84   q7_t *pIn2;                                    /* inputB pointer */
85   q7_t *pOut = pDst;                             /* output pointer */
86   q7_t *px;                                      /* Intermediate inputA pointer */
87   q7_t *py;                                      /* Intermediate inputB pointer */
88   q7_t *pSrc1, *pSrc2;                           /* Intermediate pointers */
89   q31_t sum, acc0, acc1, acc2, acc3;             /* Accumulator */
90   q31_t input1, input2;
91   q15_t in1, in2;
92   q7_t x0, x1, x2, x3, c0, c1;
93   uint32_t j, k, count, check, blkCnt;
94   int32_t blockSize1, blockSize2, blockSize3;    /* loop counter */
95   arm_status status;
96
97
98   /* Check for range of output samples to be calculated */
99   if((firstIndex + numPoints) > ((srcALen + (srcBLen - 1u))))
100   {
101     /* Set status as ARM_MATH_ARGUMENT_ERROR */
102     status = ARM_MATH_ARGUMENT_ERROR;
103   }
104   else
105   {
106
107     /* The algorithm implementation is based on the lengths of the inputs. */
108     /* srcB is always made to slide across srcA. */
109     /* So srcBLen is always considered as shorter or equal to srcALen */
110     if(srcALen >= srcBLen)
111     {
112       /* Initialization of inputA pointer */
113       pIn1 = pSrcA;
114
115       /* Initialization of inputB pointer */
116       pIn2 = pSrcB;
117     }
118     else
119     {
120       /* Initialization of inputA pointer */
121       pIn1 = pSrcB;
122
123       /* Initialization of inputB pointer */
124       pIn2 = pSrcA;
125
126       /* srcBLen is always considered as shorter or equal to srcALen */
127       j = srcBLen;
128       srcBLen = srcALen;
129       srcALen = j;
130     }
131
132     /* Conditions to check which loopCounter holds   
133      * the first and last indices of the output samples to be calculated. */
134     check = firstIndex + numPoints;
135     blockSize3 = ((int32_t) check - (int32_t) srcALen);
136     blockSize3 = (blockSize3 > 0) ? blockSize3 : 0;
137     blockSize1 = (((int32_t) srcBLen - 1) - (int32_t) firstIndex);
138     blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1u)) ? blockSize1 :
139                                      (int32_t) numPoints) : 0;
140     blockSize2 = (int32_t) check - ((blockSize3 + blockSize1) +
141                                     (int32_t) firstIndex);
142     blockSize2 = (blockSize2 > 0) ? blockSize2 : 0;
143
144     /* 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] */
145     /* The function is internally   
146      * divided into three stages according to the number of multiplications that has to be   
147      * taken place between inputA samples and inputB samples. In the first stage of the   
148      * algorithm, the multiplications increase by one for every iteration.   
149      * In the second stage of the algorithm, srcBLen number of multiplications are done.   
150      * In the third stage of the algorithm, the multiplications decrease by one   
151      * for every iteration. */
152
153     /* Set the output pointer to point to the firstIndex   
154      * of the output sample to be calculated. */
155     pOut = pDst + firstIndex;
156
157     /* --------------------------   
158      * Initializations of stage1   
159      * -------------------------*/
160
161     /* sum = x[0] * y[0]   
162      * sum = x[0] * y[1] + x[1] * y[0]   
163      * ....   
164      * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0]   
165      */
166
167     /* In this stage the MAC operations are increased by 1 for every iteration.   
168        The count variable holds the number of MAC operations performed.   
169        Since the partial convolution starts from from firstIndex   
170        Number of Macs to be performed is firstIndex + 1 */
171     count = 1u + firstIndex;
172
173     /* Working pointer of inputA */
174     px = pIn1;
175
176     /* Working pointer of inputB */
177     pSrc2 = pIn2 + firstIndex;
178     py = pSrc2;
179
180     /* ------------------------   
181      * Stage1 process   
182      * ----------------------*/
183
184     /* The first stage starts here */
185     while(blockSize1 > 0)
186     {
187       /* Accumulator is made zero for every iteration */
188       sum = 0;
189
190       /* Apply loop unrolling and compute 4 MACs simultaneously. */
191       k = count >> 2u;
192
193       /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.   
194        ** a second loop below computes MACs for the remaining 1 to 3 samples. */
195       while(k > 0u)
196       {
197         /* x[0] , x[1] */
198         in1 = (q15_t) * px++;
199         in2 = (q15_t) * px++;
200         input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
201
202         /* y[srcBLen - 1] , y[srcBLen - 2] */
203         in1 = (q15_t) * py--;
204         in2 = (q15_t) * py--;
205         input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
206
207         /* x[0] * y[srcBLen - 1] */
208         /* x[1] * y[srcBLen - 2] */
209         sum = __SMLAD(input1, input2, sum);
210
211         /* x[2] , x[3] */
212         in1 = (q15_t) * px++;
213         in2 = (q15_t) * px++;
214         input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
215
216         /* y[srcBLen - 3] , y[srcBLen - 4] */
217         in1 = (q15_t) * py--;
218         in2 = (q15_t) * py--;
219         input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
220
221         /* x[2] * y[srcBLen - 3] */
222         /* x[3] * y[srcBLen - 4] */
223         sum = __SMLAD(input1, input2, sum);
224
225         /* Decrement the loop counter */
226         k--;
227       }
228
229       /* If the count is not a multiple of 4, compute any remaining MACs here.   
230        ** No loop unrolling is used. */
231       k = count % 0x4u;
232
233       while(k > 0u)
234       {
235         /* Perform the multiply-accumulates */
236         sum += ((q31_t) * px++ * *py--);
237
238         /* Decrement the loop counter */
239         k--;
240       }
241
242       /* Store the result in the accumulator in the destination buffer. */
243       *pOut++ = (q7_t) (__SSAT(sum >> 7, 8));
244
245       /* Update the inputA and inputB pointers for next MAC calculation */
246       py = ++pSrc2;
247       px = pIn1;
248
249       /* Increment the MAC count */
250       count++;
251
252       /* Decrement the loop counter */
253       blockSize1--;
254     }
255
256     /* --------------------------   
257      * Initializations of stage2   
258      * ------------------------*/
259
260     /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0]   
261      * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0]   
262      * ....   
263      * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0]   
264      */
265
266     /* Working pointer of inputA */
267     px = pIn1;
268
269     /* Working pointer of inputB */
270     pSrc2 = pIn2 + (srcBLen - 1u);
271     py = pSrc2;
272
273     /* count is index by which the pointer pIn1 to be incremented */
274     count = 0u;
275
276     /* -------------------   
277      * Stage2 process   
278      * ------------------*/
279
280     /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed.   
281      * So, to loop unroll over blockSize2,   
282      * srcBLen should be greater than or equal to 4 */
283     if(srcBLen >= 4u)
284     {
285       /* Loop unroll over blockSize2, by 4 */
286       blkCnt = ((uint32_t) blockSize2 >> 2u);
287
288       while(blkCnt > 0u)
289       {
290         /* Set all accumulators to zero */
291         acc0 = 0;
292         acc1 = 0;
293         acc2 = 0;
294         acc3 = 0;
295
296         /* read x[0], x[1], x[2] samples */
297         x0 = *(px++);
298         x1 = *(px++);
299         x2 = *(px++);
300
301         /* Apply loop unrolling and compute 4 MACs simultaneously. */
302         k = srcBLen >> 2u;
303
304         /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.   
305          ** a second loop below computes MACs for the remaining 1 to 3 samples. */
306         do
307         {
308           /* Read y[srcBLen - 1] sample */
309           c0 = *(py--);
310           /* Read y[srcBLen - 2] sample */
311           c1 = *(py--);
312
313           /* Read x[3] sample */
314           x3 = *(px++);
315
316           /* x[0] and x[1] are packed */
317           in1 = (q15_t) x0;
318           in2 = (q15_t) x1;
319
320           input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
321
322           /* y[srcBLen - 1]   and y[srcBLen - 2] are packed */
323           in1 = (q15_t) c0;
324           in2 = (q15_t) c1;
325
326           input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
327
328           /* acc0 += x[0] * y[srcBLen - 1] + x[1] * y[srcBLen - 2]  */
329           acc0 = __SMLAD(input1, input2, acc0);
330
331           /* x[1] and x[2] are packed */
332           in1 = (q15_t) x1;
333           in2 = (q15_t) x2;
334
335           input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
336
337           /* acc1 += x[1] * y[srcBLen - 1] + x[2] * y[srcBLen - 2]  */
338           acc1 = __SMLAD(input1, input2, acc1);
339
340           /* x[2] and x[3] are packed */
341           in1 = (q15_t) x2;
342           in2 = (q15_t) x3;
343
344           input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
345
346           /* acc2 += x[2] * y[srcBLen - 1] + x[3] * y[srcBLen - 2]  */
347           acc2 = __SMLAD(input1, input2, acc2);
348
349           /* Read x[4] sample */
350           x0 = *(px++);
351
352           /* x[3] and x[4] are packed */
353           in1 = (q15_t) x3;
354           in2 = (q15_t) x0;
355
356           input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
357
358           /* acc3 += x[3] * y[srcBLen - 1] + x[4] * y[srcBLen - 2]  */
359           acc3 = __SMLAD(input1, input2, acc3);
360
361           /* Read y[srcBLen - 3] sample */
362           c0 = *(py--);
363           /* Read y[srcBLen - 4] sample */
364           c1 = *(py--);
365
366           /* Read x[5] sample */
367           x1 = *(px++);
368
369           /* x[2] and x[3] are packed */
370           in1 = (q15_t) x2;
371           in2 = (q15_t) x3;
372
373           input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
374
375           /* y[srcBLen - 3] and y[srcBLen - 4] are packed */
376           in1 = (q15_t) c0;
377           in2 = (q15_t) c1;
378
379           input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
380
381           /* acc0 += x[2] * y[srcBLen - 3] + x[3] * y[srcBLen - 4]  */
382           acc0 = __SMLAD(input1, input2, acc0);
383
384           /* x[3] and x[4] are packed */
385           in1 = (q15_t) x3;
386           in2 = (q15_t) x0;
387
388           input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
389
390           /* acc1 += x[3] * y[srcBLen - 3] + x[4] * y[srcBLen - 4]  */
391           acc1 = __SMLAD(input1, input2, acc1);
392
393           /* x[4] and x[5] are packed */
394           in1 = (q15_t) x0;
395           in2 = (q15_t) x1;
396
397           input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
398
399           /* acc2 += x[4] * y[srcBLen - 3] + x[5] * y[srcBLen - 4]  */
400           acc2 = __SMLAD(input1, input2, acc2);
401
402           /* Read x[6] sample */
403           x2 = *(px++);
404
405           /* x[5] and x[6] are packed */
406           in1 = (q15_t) x1;
407           in2 = (q15_t) x2;
408
409           input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
410
411           /* acc3 += x[5] * y[srcBLen - 3] + x[6] * y[srcBLen - 4]  */
412           acc3 = __SMLAD(input1, input2, acc3);
413
414         } while(--k);
415
416         /* If the srcBLen is not a multiple of 4, compute any remaining MACs here.   
417          ** No loop unrolling is used. */
418         k = srcBLen % 0x4u;
419
420         while(k > 0u)
421         {
422           /* Read y[srcBLen - 5] sample */
423           c0 = *(py--);
424
425           /* Read x[7] sample */
426           x3 = *(px++);
427
428           /* Perform the multiply-accumulates */
429           /* acc0 +=  x[4] * y[srcBLen - 5] */
430           acc0 += ((q31_t) x0 * c0);
431           /* acc1 +=  x[5] * y[srcBLen - 5] */
432           acc1 += ((q31_t) x1 * c0);
433           /* acc2 +=  x[6] * y[srcBLen - 5] */
434           acc2 += ((q31_t) x2 * c0);
435           /* acc3 +=  x[7] * y[srcBLen - 5] */
436           acc3 += ((q31_t) x3 * c0);
437
438           /* Reuse the present samples for the next MAC */
439           x0 = x1;
440           x1 = x2;
441           x2 = x3;
442
443           /* Decrement the loop counter */
444           k--;
445         }
446
447         /* Store the result in the accumulator in the destination buffer. */
448         *pOut++ = (q7_t) (__SSAT(acc0 >> 7, 8));
449         *pOut++ = (q7_t) (__SSAT(acc1 >> 7, 8));
450         *pOut++ = (q7_t) (__SSAT(acc2 >> 7, 8));
451         *pOut++ = (q7_t) (__SSAT(acc3 >> 7, 8));
452
453         /* Increment the pointer pIn1 index, count by 4 */
454         count += 4u;
455
456         /* Update the inputA and inputB pointers for next MAC calculation */
457         px = pIn1 + count;
458         py = pSrc2;
459
460
461         /* Decrement the loop counter */
462         blkCnt--;
463       }
464
465       /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here.   
466        ** No loop unrolling is used. */
467       blkCnt = (uint32_t) blockSize2 % 0x4u;
468
469       while(blkCnt > 0u)
470       {
471         /* Accumulator is made zero for every iteration */
472         sum = 0;
473
474         /* Apply loop unrolling and compute 4 MACs simultaneously. */
475         k = srcBLen >> 2u;
476
477         /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.   
478          ** a second loop below computes MACs for the remaining 1 to 3 samples. */
479         while(k > 0u)
480         {
481
482           /* Reading two inputs of SrcA buffer and packing */
483           in1 = (q15_t) * px++;
484           in2 = (q15_t) * px++;
485           input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
486
487           /* Reading two inputs of SrcB buffer and packing */
488           in1 = (q15_t) * py--;
489           in2 = (q15_t) * py--;
490           input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
491
492           /* Perform the multiply-accumulates */
493           sum = __SMLAD(input1, input2, sum);
494
495           /* Reading two inputs of SrcA buffer and packing */
496           in1 = (q15_t) * px++;
497           in2 = (q15_t) * px++;
498           input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
499
500           /* Reading two inputs of SrcB buffer and packing */
501           in1 = (q15_t) * py--;
502           in2 = (q15_t) * py--;
503           input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
504
505           /* Perform the multiply-accumulates */
506           sum = __SMLAD(input1, input2, sum);
507
508           /* Decrement the loop counter */
509           k--;
510         }
511
512         /* If the srcBLen is not a multiple of 4, compute any remaining MACs here.   
513          ** No loop unrolling is used. */
514         k = srcBLen % 0x4u;
515
516         while(k > 0u)
517         {
518           /* Perform the multiply-accumulates */
519           sum += ((q31_t) * px++ * *py--);
520
521           /* Decrement the loop counter */
522           k--;
523         }
524
525         /* Store the result in the accumulator in the destination buffer. */
526         *pOut++ = (q7_t) (__SSAT(sum >> 7, 8));
527
528         /* Increment the pointer pIn1 index, count by 1 */
529             count++;
530
531         /* Update the inputA and inputB pointers for next MAC calculation */
532         px = pIn1 + count;
533         py = pSrc2;     
534
535         /* Decrement the loop counter */
536         blkCnt--;
537       }
538     }
539     else
540     {
541       /* If the srcBLen is not a multiple of 4,   
542        * the blockSize2 loop cannot be unrolled by 4 */
543       blkCnt = (uint32_t) blockSize2;
544
545       while(blkCnt > 0u)
546       {
547         /* Accumulator is made zero for every iteration */
548         sum = 0;
549
550         /* srcBLen number of MACS should be performed */
551         k = srcBLen;
552
553         while(k > 0u)
554         {
555           /* Perform the multiply-accumulate */
556           sum += ((q31_t) * px++ * *py--);
557
558           /* Decrement the loop counter */
559           k--;
560         }
561
562         /* Store the result in the accumulator in the destination buffer. */
563         *pOut++ = (q7_t) (__SSAT(sum >> 7, 8));
564
565         /* Increment the MAC count */
566         count++;
567
568         /* Update the inputA and inputB pointers for next MAC calculation */
569         px = pIn1 + count;
570         py = pSrc2;
571
572         /* Decrement the loop counter */
573         blkCnt--;
574       }
575     }
576
577
578     /* --------------------------   
579      * Initializations of stage3   
580      * -------------------------*/
581
582     /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1]   
583      * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2]   
584      * ....   
585      * sum +=  x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2]   
586      * sum +=  x[srcALen-1] * y[srcBLen-1]   
587      */
588
589     /* In this stage the MAC operations are decreased by 1 for every iteration.   
590        The count variable holds the number of MAC operations performed */
591     count = srcBLen - 1u;
592
593     /* Working pointer of inputA */
594     pSrc1 = (pIn1 + srcALen) - (srcBLen - 1u);
595     px = pSrc1;
596
597     /* Working pointer of inputB */
598     pSrc2 = pIn2 + (srcBLen - 1u);
599     py = pSrc2;
600
601     /* -------------------   
602      * Stage3 process   
603      * ------------------*/
604
605     while(blockSize3 > 0)
606     {
607       /* Accumulator is made zero for every iteration */
608       sum = 0;
609
610       /* Apply loop unrolling and compute 4 MACs simultaneously. */
611       k = count >> 2u;
612
613       /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.   
614        ** a second loop below computes MACs for the remaining 1 to 3 samples. */
615       while(k > 0u)
616       {
617         /* Reading two inputs, x[srcALen - srcBLen + 1] and x[srcALen - srcBLen + 2] of SrcA buffer and packing */
618         in1 = (q15_t) * px++;
619         in2 = (q15_t) * px++;
620         input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
621
622         /* Reading two inputs, y[srcBLen - 1] and y[srcBLen - 2] of SrcB buffer and packing */
623         in1 = (q15_t) * py--;
624         in2 = (q15_t) * py--;
625         input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
626
627         /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */
628         /* sum += x[srcALen - srcBLen + 2] * y[srcBLen - 2] */
629         sum = __SMLAD(input1, input2, sum);
630
631         /* Reading two inputs, x[srcALen - srcBLen + 3] and x[srcALen - srcBLen + 4] of SrcA buffer and packing */
632         in1 = (q15_t) * px++;
633         in2 = (q15_t) * px++;
634         input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
635
636         /* Reading two inputs, y[srcBLen - 3] and y[srcBLen - 4] of SrcB buffer and packing */
637         in1 = (q15_t) * py--;
638         in2 = (q15_t) * py--;
639         input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
640
641         /* sum += x[srcALen - srcBLen + 3] * y[srcBLen - 3] */
642         /* sum += x[srcALen - srcBLen + 4] * y[srcBLen - 4] */
643         sum = __SMLAD(input1, input2, sum);
644
645         /* Decrement the loop counter */
646         k--;
647       }
648
649       /* If the count is not a multiple of 4, compute any remaining MACs here.   
650        ** No loop unrolling is used. */
651       k = count % 0x4u;
652
653       while(k > 0u)
654       {
655         /* Perform the multiply-accumulates */
656         /* sum +=  x[srcALen-1] * y[srcBLen-1] */
657         sum += ((q31_t) * px++ * *py--);
658
659         /* Decrement the loop counter */
660         k--;
661       }
662
663       /* Store the result in the accumulator in the destination buffer. */
664       *pOut++ = (q7_t) (__SSAT(sum >> 7, 8));
665
666       /* Update the inputA and inputB pointers for next MAC calculation */
667       px = ++pSrc1;
668       py = pSrc2;
669
670       /* Decrement the MAC count */
671       count--;
672
673       /* Decrement the loop counter */
674       blockSize3--;
675
676     }
677
678     /* set status as ARM_MATH_SUCCESS */
679     status = ARM_MATH_SUCCESS;
680   }
681
682   /* Return to application */
683   return (status);
684
685 #else
686
687   /* Run the below code for Cortex-M0 */
688
689   q7_t *pIn1 = pSrcA;                            /* inputA pointer */
690   q7_t *pIn2 = pSrcB;                            /* inputB pointer */
691   q31_t sum;                                     /* Accumulator */
692   uint32_t i, j;                                 /* loop counters */
693   arm_status status;                             /* status of Partial convolution */
694
695   /* Check for range of output samples to be calculated */
696   if((firstIndex + numPoints) > ((srcALen + (srcBLen - 1u))))
697   {
698     /* Set status as ARM_ARGUMENT_ERROR */
699     status = ARM_MATH_ARGUMENT_ERROR;
700   }
701   else
702   {
703     /* Loop to calculate convolution for output length number of values */
704     for (i = firstIndex; i <= (firstIndex + numPoints - 1); i++)
705     {
706       /* Initialize sum with zero to carry on MAC operations */
707       sum = 0;
708
709       /* Loop to perform MAC operations according to convolution equation */
710       for (j = 0; j <= i; j++)
711       {
712         /* Check the array limitations */
713         if(((i - j) < srcBLen) && (j < srcALen))
714         {
715           /* z[i] += x[i-j] * y[j] */
716           sum += ((q15_t) pIn1[j] * (pIn2[i - j]));
717         }
718       }
719
720       /* Store the output in the destination buffer */
721       pDst[i] = (q7_t) __SSAT((sum >> 7u), 8u);
722     }
723     /* set status as ARM_SUCCESS as there are no argument errors */
724     status = ARM_MATH_SUCCESS;
725   }
726   return (status);
727
728 #endif /*  #ifndef ARM_MATH_CM0_FAMILY */
729
730 }
731
732 /**   
733  * @} end of PartialConv group   
734  */