The CMSIS DSP 5 library

Dependents:   Nucleo-Heart-Rate ejercicioVrms2 PROYECTOFINAL ejercicioVrms ... more

Committer:
xorjoep
Date:
Thu Jun 21 11:56:27 2018 +0000
Revision:
3:4098b9d3d571
Parent:
1:24714b45cd1b
headers is a folder not a library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xorjoep 1:24714b45cd1b 1 /* ----------------------------------------------------------------------
xorjoep 1:24714b45cd1b 2 * Project: CMSIS DSP Library
xorjoep 1:24714b45cd1b 3 * Title: arm_conv_opt_q7.c
xorjoep 1:24714b45cd1b 4 * Description: Convolution of Q7 sequences
xorjoep 1:24714b45cd1b 5 *
xorjoep 1:24714b45cd1b 6 * $Date: 27. January 2017
xorjoep 1:24714b45cd1b 7 * $Revision: V.1.5.1
xorjoep 1:24714b45cd1b 8 *
xorjoep 1:24714b45cd1b 9 * Target Processor: Cortex-M cores
xorjoep 1:24714b45cd1b 10 * -------------------------------------------------------------------- */
xorjoep 1:24714b45cd1b 11 /*
xorjoep 1:24714b45cd1b 12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
xorjoep 1:24714b45cd1b 13 *
xorjoep 1:24714b45cd1b 14 * SPDX-License-Identifier: Apache-2.0
xorjoep 1:24714b45cd1b 15 *
xorjoep 1:24714b45cd1b 16 * Licensed under the Apache License, Version 2.0 (the License); you may
xorjoep 1:24714b45cd1b 17 * not use this file except in compliance with the License.
xorjoep 1:24714b45cd1b 18 * You may obtain a copy of the License at
xorjoep 1:24714b45cd1b 19 *
xorjoep 1:24714b45cd1b 20 * www.apache.org/licenses/LICENSE-2.0
xorjoep 1:24714b45cd1b 21 *
xorjoep 1:24714b45cd1b 22 * Unless required by applicable law or agreed to in writing, software
xorjoep 1:24714b45cd1b 23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
xorjoep 1:24714b45cd1b 24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
xorjoep 1:24714b45cd1b 25 * See the License for the specific language governing permissions and
xorjoep 1:24714b45cd1b 26 * limitations under the License.
xorjoep 1:24714b45cd1b 27 */
xorjoep 1:24714b45cd1b 28
xorjoep 1:24714b45cd1b 29 #include "arm_math.h"
xorjoep 1:24714b45cd1b 30
xorjoep 1:24714b45cd1b 31 /**
xorjoep 1:24714b45cd1b 32 * @ingroup groupFilters
xorjoep 1:24714b45cd1b 33 */
xorjoep 1:24714b45cd1b 34
xorjoep 1:24714b45cd1b 35 /**
xorjoep 1:24714b45cd1b 36 * @addtogroup Conv
xorjoep 1:24714b45cd1b 37 * @{
xorjoep 1:24714b45cd1b 38 */
xorjoep 1:24714b45cd1b 39
xorjoep 1:24714b45cd1b 40 /**
xorjoep 1:24714b45cd1b 41 * @brief Convolution of Q7 sequences.
xorjoep 1:24714b45cd1b 42 * @param[in] *pSrcA points to the first input sequence.
xorjoep 1:24714b45cd1b 43 * @param[in] srcALen length of the first input sequence.
xorjoep 1:24714b45cd1b 44 * @param[in] *pSrcB points to the second input sequence.
xorjoep 1:24714b45cd1b 45 * @param[in] srcBLen length of the second input sequence.
xorjoep 1:24714b45cd1b 46 * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
xorjoep 1:24714b45cd1b 47 * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
xorjoep 1:24714b45cd1b 48 * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
xorjoep 1:24714b45cd1b 49 * @return none.
xorjoep 1:24714b45cd1b 50 *
xorjoep 1:24714b45cd1b 51 * \par Restrictions
xorjoep 1:24714b45cd1b 52 * If the silicon does not support unaligned memory access enable the macro UNALIGNED_SUPPORT_DISABLE
xorjoep 1:24714b45cd1b 53 * In this case input, output, scratch1 and scratch2 buffers should be aligned by 32-bit
xorjoep 1:24714b45cd1b 54 *
xorjoep 1:24714b45cd1b 55 * @details
xorjoep 1:24714b45cd1b 56 * <b>Scaling and Overflow Behavior:</b>
xorjoep 1:24714b45cd1b 57 *
xorjoep 1:24714b45cd1b 58 * \par
xorjoep 1:24714b45cd1b 59 * The function is implemented using a 32-bit internal accumulator.
xorjoep 1:24714b45cd1b 60 * Both the inputs are represented in 1.7 format and multiplications yield a 2.14 result.
xorjoep 1:24714b45cd1b 61 * The 2.14 intermediate results are accumulated in a 32-bit accumulator in 18.14 format.
xorjoep 1:24714b45cd1b 62 * This approach provides 17 guard bits and there is no risk of overflow as long as <code>max(srcALen, srcBLen)<131072</code>.
xorjoep 1:24714b45cd1b 63 * The 18.14 result is then truncated to 18.7 format by discarding the low 7 bits and then saturated to 1.7 format.
xorjoep 1:24714b45cd1b 64 *
xorjoep 1:24714b45cd1b 65 */
xorjoep 1:24714b45cd1b 66
xorjoep 1:24714b45cd1b 67 void arm_conv_opt_q7(
xorjoep 1:24714b45cd1b 68 q7_t * pSrcA,
xorjoep 1:24714b45cd1b 69 uint32_t srcALen,
xorjoep 1:24714b45cd1b 70 q7_t * pSrcB,
xorjoep 1:24714b45cd1b 71 uint32_t srcBLen,
xorjoep 1:24714b45cd1b 72 q7_t * pDst,
xorjoep 1:24714b45cd1b 73 q15_t * pScratch1,
xorjoep 1:24714b45cd1b 74 q15_t * pScratch2)
xorjoep 1:24714b45cd1b 75 {
xorjoep 1:24714b45cd1b 76
xorjoep 1:24714b45cd1b 77 q15_t *pScr2, *pScr1; /* Intermediate pointers for scratch pointers */
xorjoep 1:24714b45cd1b 78 q15_t x4; /* Temporary input variable */
xorjoep 1:24714b45cd1b 79 q7_t *pIn1, *pIn2; /* inputA and inputB pointer */
xorjoep 1:24714b45cd1b 80 uint32_t j, k, blkCnt, tapCnt; /* loop counter */
xorjoep 1:24714b45cd1b 81 q7_t *px; /* Temporary input1 pointer */
xorjoep 1:24714b45cd1b 82 q15_t *py; /* Temporary input2 pointer */
xorjoep 1:24714b45cd1b 83 q31_t acc0, acc1, acc2, acc3; /* Accumulator */
xorjoep 1:24714b45cd1b 84 q31_t x1, x2, x3, y1; /* Temporary input variables */
xorjoep 1:24714b45cd1b 85 q7_t *pOut = pDst; /* output pointer */
xorjoep 1:24714b45cd1b 86 q7_t out0, out1, out2, out3; /* temporary variables */
xorjoep 1:24714b45cd1b 87
xorjoep 1:24714b45cd1b 88 /* The algorithm implementation is based on the lengths of the inputs. */
xorjoep 1:24714b45cd1b 89 /* srcB is always made to slide across srcA. */
xorjoep 1:24714b45cd1b 90 /* So srcBLen is always considered as shorter or equal to srcALen */
xorjoep 1:24714b45cd1b 91 if (srcALen >= srcBLen)
xorjoep 1:24714b45cd1b 92 {
xorjoep 1:24714b45cd1b 93 /* Initialization of inputA pointer */
xorjoep 1:24714b45cd1b 94 pIn1 = pSrcA;
xorjoep 1:24714b45cd1b 95
xorjoep 1:24714b45cd1b 96 /* Initialization of inputB pointer */
xorjoep 1:24714b45cd1b 97 pIn2 = pSrcB;
xorjoep 1:24714b45cd1b 98 }
xorjoep 1:24714b45cd1b 99 else
xorjoep 1:24714b45cd1b 100 {
xorjoep 1:24714b45cd1b 101 /* Initialization of inputA pointer */
xorjoep 1:24714b45cd1b 102 pIn1 = pSrcB;
xorjoep 1:24714b45cd1b 103
xorjoep 1:24714b45cd1b 104 /* Initialization of inputB pointer */
xorjoep 1:24714b45cd1b 105 pIn2 = pSrcA;
xorjoep 1:24714b45cd1b 106
xorjoep 1:24714b45cd1b 107 /* srcBLen is always considered as shorter or equal to srcALen */
xorjoep 1:24714b45cd1b 108 j = srcBLen;
xorjoep 1:24714b45cd1b 109 srcBLen = srcALen;
xorjoep 1:24714b45cd1b 110 srcALen = j;
xorjoep 1:24714b45cd1b 111 }
xorjoep 1:24714b45cd1b 112
xorjoep 1:24714b45cd1b 113 /* pointer to take end of scratch2 buffer */
xorjoep 1:24714b45cd1b 114 pScr2 = pScratch2;
xorjoep 1:24714b45cd1b 115
xorjoep 1:24714b45cd1b 116 /* points to smaller length sequence */
xorjoep 1:24714b45cd1b 117 px = pIn2 + srcBLen - 1;
xorjoep 1:24714b45cd1b 118
xorjoep 1:24714b45cd1b 119 /* Apply loop unrolling and do 4 Copies simultaneously. */
xorjoep 1:24714b45cd1b 120 k = srcBLen >> 2U;
xorjoep 1:24714b45cd1b 121
xorjoep 1:24714b45cd1b 122 /* First part of the processing with loop unrolling copies 4 data points at a time.
xorjoep 1:24714b45cd1b 123 ** a second loop below copies for the remaining 1 to 3 samples. */
xorjoep 1:24714b45cd1b 124 while (k > 0U)
xorjoep 1:24714b45cd1b 125 {
xorjoep 1:24714b45cd1b 126 /* copy second buffer in reversal manner */
xorjoep 1:24714b45cd1b 127 x4 = (q15_t) * px--;
xorjoep 1:24714b45cd1b 128 *pScr2++ = x4;
xorjoep 1:24714b45cd1b 129 x4 = (q15_t) * px--;
xorjoep 1:24714b45cd1b 130 *pScr2++ = x4;
xorjoep 1:24714b45cd1b 131 x4 = (q15_t) * px--;
xorjoep 1:24714b45cd1b 132 *pScr2++ = x4;
xorjoep 1:24714b45cd1b 133 x4 = (q15_t) * px--;
xorjoep 1:24714b45cd1b 134 *pScr2++ = x4;
xorjoep 1:24714b45cd1b 135
xorjoep 1:24714b45cd1b 136 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 137 k--;
xorjoep 1:24714b45cd1b 138 }
xorjoep 1:24714b45cd1b 139
xorjoep 1:24714b45cd1b 140 /* If the count is not a multiple of 4, copy remaining samples here.
xorjoep 1:24714b45cd1b 141 ** No loop unrolling is used. */
xorjoep 1:24714b45cd1b 142 k = srcBLen % 0x4U;
xorjoep 1:24714b45cd1b 143
xorjoep 1:24714b45cd1b 144 while (k > 0U)
xorjoep 1:24714b45cd1b 145 {
xorjoep 1:24714b45cd1b 146 /* copy second buffer in reversal manner for remaining samples */
xorjoep 1:24714b45cd1b 147 x4 = (q15_t) * px--;
xorjoep 1:24714b45cd1b 148 *pScr2++ = x4;
xorjoep 1:24714b45cd1b 149
xorjoep 1:24714b45cd1b 150 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 151 k--;
xorjoep 1:24714b45cd1b 152 }
xorjoep 1:24714b45cd1b 153
xorjoep 1:24714b45cd1b 154 /* Initialze temporary scratch pointer */
xorjoep 1:24714b45cd1b 155 pScr1 = pScratch1;
xorjoep 1:24714b45cd1b 156
xorjoep 1:24714b45cd1b 157 /* Fill (srcBLen - 1U) zeros in scratch buffer */
xorjoep 1:24714b45cd1b 158 arm_fill_q15(0, pScr1, (srcBLen - 1U));
xorjoep 1:24714b45cd1b 159
xorjoep 1:24714b45cd1b 160 /* Update temporary scratch pointer */
xorjoep 1:24714b45cd1b 161 pScr1 += (srcBLen - 1U);
xorjoep 1:24714b45cd1b 162
xorjoep 1:24714b45cd1b 163 /* Copy (srcALen) samples in scratch buffer */
xorjoep 1:24714b45cd1b 164 /* Apply loop unrolling and do 4 Copies simultaneously. */
xorjoep 1:24714b45cd1b 165 k = srcALen >> 2U;
xorjoep 1:24714b45cd1b 166
xorjoep 1:24714b45cd1b 167 /* First part of the processing with loop unrolling copies 4 data points at a time.
xorjoep 1:24714b45cd1b 168 ** a second loop below copies for the remaining 1 to 3 samples. */
xorjoep 1:24714b45cd1b 169 while (k > 0U)
xorjoep 1:24714b45cd1b 170 {
xorjoep 1:24714b45cd1b 171 /* copy second buffer in reversal manner */
xorjoep 1:24714b45cd1b 172 x4 = (q15_t) * pIn1++;
xorjoep 1:24714b45cd1b 173 *pScr1++ = x4;
xorjoep 1:24714b45cd1b 174 x4 = (q15_t) * pIn1++;
xorjoep 1:24714b45cd1b 175 *pScr1++ = x4;
xorjoep 1:24714b45cd1b 176 x4 = (q15_t) * pIn1++;
xorjoep 1:24714b45cd1b 177 *pScr1++ = x4;
xorjoep 1:24714b45cd1b 178 x4 = (q15_t) * pIn1++;
xorjoep 1:24714b45cd1b 179 *pScr1++ = x4;
xorjoep 1:24714b45cd1b 180
xorjoep 1:24714b45cd1b 181 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 182 k--;
xorjoep 1:24714b45cd1b 183 }
xorjoep 1:24714b45cd1b 184
xorjoep 1:24714b45cd1b 185 /* If the count is not a multiple of 4, copy remaining samples here.
xorjoep 1:24714b45cd1b 186 ** No loop unrolling is used. */
xorjoep 1:24714b45cd1b 187 k = srcALen % 0x4U;
xorjoep 1:24714b45cd1b 188
xorjoep 1:24714b45cd1b 189 while (k > 0U)
xorjoep 1:24714b45cd1b 190 {
xorjoep 1:24714b45cd1b 191 /* copy second buffer in reversal manner for remaining samples */
xorjoep 1:24714b45cd1b 192 x4 = (q15_t) * pIn1++;
xorjoep 1:24714b45cd1b 193 *pScr1++ = x4;
xorjoep 1:24714b45cd1b 194
xorjoep 1:24714b45cd1b 195 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 196 k--;
xorjoep 1:24714b45cd1b 197 }
xorjoep 1:24714b45cd1b 198
xorjoep 1:24714b45cd1b 199 #ifndef UNALIGNED_SUPPORT_DISABLE
xorjoep 1:24714b45cd1b 200
xorjoep 1:24714b45cd1b 201 /* Fill (srcBLen - 1U) zeros at end of scratch buffer */
xorjoep 1:24714b45cd1b 202 arm_fill_q15(0, pScr1, (srcBLen - 1U));
xorjoep 1:24714b45cd1b 203
xorjoep 1:24714b45cd1b 204 /* Update pointer */
xorjoep 1:24714b45cd1b 205 pScr1 += (srcBLen - 1U);
xorjoep 1:24714b45cd1b 206
xorjoep 1:24714b45cd1b 207 #else
xorjoep 1:24714b45cd1b 208
xorjoep 1:24714b45cd1b 209 /* Apply loop unrolling and do 4 Copies simultaneously. */
xorjoep 1:24714b45cd1b 210 k = (srcBLen - 1U) >> 2U;
xorjoep 1:24714b45cd1b 211
xorjoep 1:24714b45cd1b 212 /* First part of the processing with loop unrolling copies 4 data points at a time.
xorjoep 1:24714b45cd1b 213 ** a second loop below copies for the remaining 1 to 3 samples. */
xorjoep 1:24714b45cd1b 214 while (k > 0U)
xorjoep 1:24714b45cd1b 215 {
xorjoep 1:24714b45cd1b 216 /* copy second buffer in reversal manner */
xorjoep 1:24714b45cd1b 217 *pScr1++ = 0;
xorjoep 1:24714b45cd1b 218 *pScr1++ = 0;
xorjoep 1:24714b45cd1b 219 *pScr1++ = 0;
xorjoep 1:24714b45cd1b 220 *pScr1++ = 0;
xorjoep 1:24714b45cd1b 221
xorjoep 1:24714b45cd1b 222 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 223 k--;
xorjoep 1:24714b45cd1b 224 }
xorjoep 1:24714b45cd1b 225
xorjoep 1:24714b45cd1b 226 /* If the count is not a multiple of 4, copy remaining samples here.
xorjoep 1:24714b45cd1b 227 ** No loop unrolling is used. */
xorjoep 1:24714b45cd1b 228 k = (srcBLen - 1U) % 0x4U;
xorjoep 1:24714b45cd1b 229
xorjoep 1:24714b45cd1b 230 while (k > 0U)
xorjoep 1:24714b45cd1b 231 {
xorjoep 1:24714b45cd1b 232 /* copy second buffer in reversal manner for remaining samples */
xorjoep 1:24714b45cd1b 233 *pScr1++ = 0;
xorjoep 1:24714b45cd1b 234
xorjoep 1:24714b45cd1b 235 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 236 k--;
xorjoep 1:24714b45cd1b 237 }
xorjoep 1:24714b45cd1b 238
xorjoep 1:24714b45cd1b 239 #endif
xorjoep 1:24714b45cd1b 240
xorjoep 1:24714b45cd1b 241 /* Temporary pointer for scratch2 */
xorjoep 1:24714b45cd1b 242 py = pScratch2;
xorjoep 1:24714b45cd1b 243
xorjoep 1:24714b45cd1b 244 /* Initialization of pIn2 pointer */
xorjoep 1:24714b45cd1b 245 pIn2 = (q7_t *) py;
xorjoep 1:24714b45cd1b 246
xorjoep 1:24714b45cd1b 247 pScr2 = py;
xorjoep 1:24714b45cd1b 248
xorjoep 1:24714b45cd1b 249 /* Actual convolution process starts here */
xorjoep 1:24714b45cd1b 250 blkCnt = (srcALen + srcBLen - 1U) >> 2;
xorjoep 1:24714b45cd1b 251
xorjoep 1:24714b45cd1b 252 while (blkCnt > 0)
xorjoep 1:24714b45cd1b 253 {
xorjoep 1:24714b45cd1b 254 /* Initialze temporary scratch pointer as scratch1 */
xorjoep 1:24714b45cd1b 255 pScr1 = pScratch1;
xorjoep 1:24714b45cd1b 256
xorjoep 1:24714b45cd1b 257 /* Clear Accumlators */
xorjoep 1:24714b45cd1b 258 acc0 = 0;
xorjoep 1:24714b45cd1b 259 acc1 = 0;
xorjoep 1:24714b45cd1b 260 acc2 = 0;
xorjoep 1:24714b45cd1b 261 acc3 = 0;
xorjoep 1:24714b45cd1b 262
xorjoep 1:24714b45cd1b 263 /* Read two samples from scratch1 buffer */
xorjoep 1:24714b45cd1b 264 x1 = *__SIMD32(pScr1)++;
xorjoep 1:24714b45cd1b 265
xorjoep 1:24714b45cd1b 266 /* Read next two samples from scratch1 buffer */
xorjoep 1:24714b45cd1b 267 x2 = *__SIMD32(pScr1)++;
xorjoep 1:24714b45cd1b 268
xorjoep 1:24714b45cd1b 269 tapCnt = (srcBLen) >> 2U;
xorjoep 1:24714b45cd1b 270
xorjoep 1:24714b45cd1b 271 while (tapCnt > 0U)
xorjoep 1:24714b45cd1b 272 {
xorjoep 1:24714b45cd1b 273
xorjoep 1:24714b45cd1b 274 /* Read four samples from smaller buffer */
xorjoep 1:24714b45cd1b 275 y1 = _SIMD32_OFFSET(pScr2);
xorjoep 1:24714b45cd1b 276
xorjoep 1:24714b45cd1b 277 /* multiply and accumlate */
xorjoep 1:24714b45cd1b 278 acc0 = __SMLAD(x1, y1, acc0);
xorjoep 1:24714b45cd1b 279 acc2 = __SMLAD(x2, y1, acc2);
xorjoep 1:24714b45cd1b 280
xorjoep 1:24714b45cd1b 281 /* pack input data */
xorjoep 1:24714b45cd1b 282 #ifndef ARM_MATH_BIG_ENDIAN
xorjoep 1:24714b45cd1b 283 x3 = __PKHBT(x2, x1, 0);
xorjoep 1:24714b45cd1b 284 #else
xorjoep 1:24714b45cd1b 285 x3 = __PKHBT(x1, x2, 0);
xorjoep 1:24714b45cd1b 286 #endif
xorjoep 1:24714b45cd1b 287
xorjoep 1:24714b45cd1b 288 /* multiply and accumlate */
xorjoep 1:24714b45cd1b 289 acc1 = __SMLADX(x3, y1, acc1);
xorjoep 1:24714b45cd1b 290
xorjoep 1:24714b45cd1b 291 /* Read next two samples from scratch1 buffer */
xorjoep 1:24714b45cd1b 292 x1 = *__SIMD32(pScr1)++;
xorjoep 1:24714b45cd1b 293
xorjoep 1:24714b45cd1b 294 /* pack input data */
xorjoep 1:24714b45cd1b 295 #ifndef ARM_MATH_BIG_ENDIAN
xorjoep 1:24714b45cd1b 296 x3 = __PKHBT(x1, x2, 0);
xorjoep 1:24714b45cd1b 297 #else
xorjoep 1:24714b45cd1b 298 x3 = __PKHBT(x2, x1, 0);
xorjoep 1:24714b45cd1b 299 #endif
xorjoep 1:24714b45cd1b 300
xorjoep 1:24714b45cd1b 301 acc3 = __SMLADX(x3, y1, acc3);
xorjoep 1:24714b45cd1b 302
xorjoep 1:24714b45cd1b 303 /* Read four samples from smaller buffer */
xorjoep 1:24714b45cd1b 304 y1 = _SIMD32_OFFSET(pScr2 + 2U);
xorjoep 1:24714b45cd1b 305
xorjoep 1:24714b45cd1b 306 acc0 = __SMLAD(x2, y1, acc0);
xorjoep 1:24714b45cd1b 307
xorjoep 1:24714b45cd1b 308 acc2 = __SMLAD(x1, y1, acc2);
xorjoep 1:24714b45cd1b 309
xorjoep 1:24714b45cd1b 310 acc1 = __SMLADX(x3, y1, acc1);
xorjoep 1:24714b45cd1b 311
xorjoep 1:24714b45cd1b 312 x2 = *__SIMD32(pScr1)++;
xorjoep 1:24714b45cd1b 313
xorjoep 1:24714b45cd1b 314 #ifndef ARM_MATH_BIG_ENDIAN
xorjoep 1:24714b45cd1b 315 x3 = __PKHBT(x2, x1, 0);
xorjoep 1:24714b45cd1b 316 #else
xorjoep 1:24714b45cd1b 317 x3 = __PKHBT(x1, x2, 0);
xorjoep 1:24714b45cd1b 318 #endif
xorjoep 1:24714b45cd1b 319
xorjoep 1:24714b45cd1b 320 acc3 = __SMLADX(x3, y1, acc3);
xorjoep 1:24714b45cd1b 321
xorjoep 1:24714b45cd1b 322 pScr2 += 4U;
xorjoep 1:24714b45cd1b 323
xorjoep 1:24714b45cd1b 324
xorjoep 1:24714b45cd1b 325 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 326 tapCnt--;
xorjoep 1:24714b45cd1b 327 }
xorjoep 1:24714b45cd1b 328
xorjoep 1:24714b45cd1b 329
xorjoep 1:24714b45cd1b 330
xorjoep 1:24714b45cd1b 331 /* Update scratch pointer for remaining samples of smaller length sequence */
xorjoep 1:24714b45cd1b 332 pScr1 -= 4U;
xorjoep 1:24714b45cd1b 333
xorjoep 1:24714b45cd1b 334
xorjoep 1:24714b45cd1b 335 /* apply same above for remaining samples of smaller length sequence */
xorjoep 1:24714b45cd1b 336 tapCnt = (srcBLen) & 3U;
xorjoep 1:24714b45cd1b 337
xorjoep 1:24714b45cd1b 338 while (tapCnt > 0U)
xorjoep 1:24714b45cd1b 339 {
xorjoep 1:24714b45cd1b 340
xorjoep 1:24714b45cd1b 341 /* accumlate the results */
xorjoep 1:24714b45cd1b 342 acc0 += (*pScr1++ * *pScr2);
xorjoep 1:24714b45cd1b 343 acc1 += (*pScr1++ * *pScr2);
xorjoep 1:24714b45cd1b 344 acc2 += (*pScr1++ * *pScr2);
xorjoep 1:24714b45cd1b 345 acc3 += (*pScr1++ * *pScr2++);
xorjoep 1:24714b45cd1b 346
xorjoep 1:24714b45cd1b 347 pScr1 -= 3U;
xorjoep 1:24714b45cd1b 348
xorjoep 1:24714b45cd1b 349 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 350 tapCnt--;
xorjoep 1:24714b45cd1b 351 }
xorjoep 1:24714b45cd1b 352
xorjoep 1:24714b45cd1b 353 blkCnt--;
xorjoep 1:24714b45cd1b 354
xorjoep 1:24714b45cd1b 355 /* Store the result in the accumulator in the destination buffer. */
xorjoep 1:24714b45cd1b 356 out0 = (q7_t) (__SSAT(acc0 >> 7U, 8));
xorjoep 1:24714b45cd1b 357 out1 = (q7_t) (__SSAT(acc1 >> 7U, 8));
xorjoep 1:24714b45cd1b 358 out2 = (q7_t) (__SSAT(acc2 >> 7U, 8));
xorjoep 1:24714b45cd1b 359 out3 = (q7_t) (__SSAT(acc3 >> 7U, 8));
xorjoep 1:24714b45cd1b 360
xorjoep 1:24714b45cd1b 361 *__SIMD32(pOut)++ = __PACKq7(out0, out1, out2, out3);
xorjoep 1:24714b45cd1b 362
xorjoep 1:24714b45cd1b 363 /* Initialization of inputB pointer */
xorjoep 1:24714b45cd1b 364 pScr2 = py;
xorjoep 1:24714b45cd1b 365
xorjoep 1:24714b45cd1b 366 pScratch1 += 4U;
xorjoep 1:24714b45cd1b 367
xorjoep 1:24714b45cd1b 368 }
xorjoep 1:24714b45cd1b 369
xorjoep 1:24714b45cd1b 370
xorjoep 1:24714b45cd1b 371 blkCnt = (srcALen + srcBLen - 1U) & 0x3;
xorjoep 1:24714b45cd1b 372
xorjoep 1:24714b45cd1b 373 /* Calculate convolution for remaining samples of Bigger length sequence */
xorjoep 1:24714b45cd1b 374 while (blkCnt > 0)
xorjoep 1:24714b45cd1b 375 {
xorjoep 1:24714b45cd1b 376 /* Initialze temporary scratch pointer as scratch1 */
xorjoep 1:24714b45cd1b 377 pScr1 = pScratch1;
xorjoep 1:24714b45cd1b 378
xorjoep 1:24714b45cd1b 379 /* Clear Accumlators */
xorjoep 1:24714b45cd1b 380 acc0 = 0;
xorjoep 1:24714b45cd1b 381
xorjoep 1:24714b45cd1b 382 tapCnt = (srcBLen) >> 1U;
xorjoep 1:24714b45cd1b 383
xorjoep 1:24714b45cd1b 384 while (tapCnt > 0U)
xorjoep 1:24714b45cd1b 385 {
xorjoep 1:24714b45cd1b 386 acc0 += (*pScr1++ * *pScr2++);
xorjoep 1:24714b45cd1b 387 acc0 += (*pScr1++ * *pScr2++);
xorjoep 1:24714b45cd1b 388
xorjoep 1:24714b45cd1b 389 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 390 tapCnt--;
xorjoep 1:24714b45cd1b 391 }
xorjoep 1:24714b45cd1b 392
xorjoep 1:24714b45cd1b 393 tapCnt = (srcBLen) & 1U;
xorjoep 1:24714b45cd1b 394
xorjoep 1:24714b45cd1b 395 /* apply same above for remaining samples of smaller length sequence */
xorjoep 1:24714b45cd1b 396 while (tapCnt > 0U)
xorjoep 1:24714b45cd1b 397 {
xorjoep 1:24714b45cd1b 398
xorjoep 1:24714b45cd1b 399 /* accumlate the results */
xorjoep 1:24714b45cd1b 400 acc0 += (*pScr1++ * *pScr2++);
xorjoep 1:24714b45cd1b 401
xorjoep 1:24714b45cd1b 402 /* Decrement the loop counter */
xorjoep 1:24714b45cd1b 403 tapCnt--;
xorjoep 1:24714b45cd1b 404 }
xorjoep 1:24714b45cd1b 405
xorjoep 1:24714b45cd1b 406 blkCnt--;
xorjoep 1:24714b45cd1b 407
xorjoep 1:24714b45cd1b 408 /* Store the result in the accumulator in the destination buffer. */
xorjoep 1:24714b45cd1b 409 *pOut++ = (q7_t) (__SSAT(acc0 >> 7U, 8));
xorjoep 1:24714b45cd1b 410
xorjoep 1:24714b45cd1b 411 /* Initialization of inputB pointer */
xorjoep 1:24714b45cd1b 412 pScr2 = py;
xorjoep 1:24714b45cd1b 413
xorjoep 1:24714b45cd1b 414 pScratch1 += 1U;
xorjoep 1:24714b45cd1b 415
xorjoep 1:24714b45cd1b 416 }
xorjoep 1:24714b45cd1b 417
xorjoep 1:24714b45cd1b 418 }
xorjoep 1:24714b45cd1b 419
xorjoep 1:24714b45cd1b 420
xorjoep 1:24714b45cd1b 421 /**
xorjoep 1:24714b45cd1b 422 * @} end of Conv group
xorjoep 1:24714b45cd1b 423 */