V4.0.1 of the ARM CMSIS DSP libraries. Note that arm_bitreversal2.s, arm_cfft_f32.c and arm_rfft_fast_f32.c had to be removed. arm_bitreversal2.s will not assemble with the online tools. So, the fast f32 FFT functions are not yet available. All the other FFT functions are available.

Dependents:   MPU9150_Example fir_f32 fir_f32 MPU9150_nucleo_noni2cdev ... more

Committer:
emh203
Date:
Mon Jul 28 15:03:15 2014 +0000
Revision:
0:3d9c67d97d6f
1st working commit.   Had to remove arm_bitreversal2.s     arm_cfft_f32.c and arm_rfft_fast_f32.c.    The .s will not assemble.      For now I removed these functions so we could at least have a library for the other functions.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emh203 0:3d9c67d97d6f 1 /* ----------------------------------------------------------------------
emh203 0:3d9c67d97d6f 2 * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
emh203 0:3d9c67d97d6f 3 *
emh203 0:3d9c67d97d6f 4 * $Date: 12. March 2014
emh203 0:3d9c67d97d6f 5 * $Revision: V1.4.3
emh203 0:3d9c67d97d6f 6 *
emh203 0:3d9c67d97d6f 7 * Project: CMSIS DSP Library
emh203 0:3d9c67d97d6f 8 * Title: arm_conv_partial_opt_q7.c
emh203 0:3d9c67d97d6f 9 *
emh203 0:3d9c67d97d6f 10 * Description: Partial convolution of Q7 sequences.
emh203 0:3d9c67d97d6f 11 *
emh203 0:3d9c67d97d6f 12 * Target Processor: Cortex-M4/Cortex-M3
emh203 0:3d9c67d97d6f 13 *
emh203 0:3d9c67d97d6f 14 * Redistribution and use in source and binary forms, with or without
emh203 0:3d9c67d97d6f 15 * modification, are permitted provided that the following conditions
emh203 0:3d9c67d97d6f 16 * are met:
emh203 0:3d9c67d97d6f 17 * - Redistributions of source code must retain the above copyright
emh203 0:3d9c67d97d6f 18 * notice, this list of conditions and the following disclaimer.
emh203 0:3d9c67d97d6f 19 * - Redistributions in binary form must reproduce the above copyright
emh203 0:3d9c67d97d6f 20 * notice, this list of conditions and the following disclaimer in
emh203 0:3d9c67d97d6f 21 * the documentation and/or other materials provided with the
emh203 0:3d9c67d97d6f 22 * distribution.
emh203 0:3d9c67d97d6f 23 * - Neither the name of ARM LIMITED nor the names of its contributors
emh203 0:3d9c67d97d6f 24 * may be used to endorse or promote products derived from this
emh203 0:3d9c67d97d6f 25 * software without specific prior written permission.
emh203 0:3d9c67d97d6f 26 *
emh203 0:3d9c67d97d6f 27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
emh203 0:3d9c67d97d6f 28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
emh203 0:3d9c67d97d6f 29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
emh203 0:3d9c67d97d6f 30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
emh203 0:3d9c67d97d6f 31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
emh203 0:3d9c67d97d6f 32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
emh203 0:3d9c67d97d6f 33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
emh203 0:3d9c67d97d6f 34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
emh203 0:3d9c67d97d6f 35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
emh203 0:3d9c67d97d6f 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
emh203 0:3d9c67d97d6f 37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
emh203 0:3d9c67d97d6f 38 * POSSIBILITY OF SUCH DAMAGE.
emh203 0:3d9c67d97d6f 39 * -------------------------------------------------------------------- */
emh203 0:3d9c67d97d6f 40
emh203 0:3d9c67d97d6f 41 #include "arm_math.h"
emh203 0:3d9c67d97d6f 42
emh203 0:3d9c67d97d6f 43 /**
emh203 0:3d9c67d97d6f 44 * @ingroup groupFilters
emh203 0:3d9c67d97d6f 45 */
emh203 0:3d9c67d97d6f 46
emh203 0:3d9c67d97d6f 47 /**
emh203 0:3d9c67d97d6f 48 * @addtogroup PartialConv
emh203 0:3d9c67d97d6f 49 * @{
emh203 0:3d9c67d97d6f 50 */
emh203 0:3d9c67d97d6f 51
emh203 0:3d9c67d97d6f 52 /**
emh203 0:3d9c67d97d6f 53 * @brief Partial convolution of Q7 sequences.
emh203 0:3d9c67d97d6f 54 * @param[in] *pSrcA points to the first input sequence.
emh203 0:3d9c67d97d6f 55 * @param[in] srcALen length of the first input sequence.
emh203 0:3d9c67d97d6f 56 * @param[in] *pSrcB points to the second input sequence.
emh203 0:3d9c67d97d6f 57 * @param[in] srcBLen length of the second input sequence.
emh203 0:3d9c67d97d6f 58 * @param[out] *pDst points to the location where the output result is written.
emh203 0:3d9c67d97d6f 59 * @param[in] firstIndex is the first output sample to start with.
emh203 0:3d9c67d97d6f 60 * @param[in] numPoints is the number of output points to be computed.
emh203 0:3d9c67d97d6f 61 * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
emh203 0:3d9c67d97d6f 62 * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
emh203 0:3d9c67d97d6f 63 * @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].
emh203 0:3d9c67d97d6f 64 *
emh203 0:3d9c67d97d6f 65 * \par Restrictions
emh203 0:3d9c67d97d6f 66 * If the silicon does not support unaligned memory access enable the macro UNALIGNED_SUPPORT_DISABLE
emh203 0:3d9c67d97d6f 67 * In this case input, output, scratch1 and scratch2 buffers should be aligned by 32-bit
emh203 0:3d9c67d97d6f 68 *
emh203 0:3d9c67d97d6f 69 *
emh203 0:3d9c67d97d6f 70 *
emh203 0:3d9c67d97d6f 71 */
emh203 0:3d9c67d97d6f 72
emh203 0:3d9c67d97d6f 73
emh203 0:3d9c67d97d6f 74 #ifndef UNALIGNED_SUPPORT_DISABLE
emh203 0:3d9c67d97d6f 75
emh203 0:3d9c67d97d6f 76 arm_status arm_conv_partial_opt_q7(
emh203 0:3d9c67d97d6f 77 q7_t * pSrcA,
emh203 0:3d9c67d97d6f 78 uint32_t srcALen,
emh203 0:3d9c67d97d6f 79 q7_t * pSrcB,
emh203 0:3d9c67d97d6f 80 uint32_t srcBLen,
emh203 0:3d9c67d97d6f 81 q7_t * pDst,
emh203 0:3d9c67d97d6f 82 uint32_t firstIndex,
emh203 0:3d9c67d97d6f 83 uint32_t numPoints,
emh203 0:3d9c67d97d6f 84 q15_t * pScratch1,
emh203 0:3d9c67d97d6f 85 q15_t * pScratch2)
emh203 0:3d9c67d97d6f 86 {
emh203 0:3d9c67d97d6f 87
emh203 0:3d9c67d97d6f 88 q15_t *pScr2, *pScr1; /* Intermediate pointers for scratch pointers */
emh203 0:3d9c67d97d6f 89 q15_t x4; /* Temporary input variable */
emh203 0:3d9c67d97d6f 90 q7_t *pIn1, *pIn2; /* inputA and inputB pointer */
emh203 0:3d9c67d97d6f 91 uint32_t j, k, blkCnt, tapCnt; /* loop counter */
emh203 0:3d9c67d97d6f 92 q7_t *px; /* Temporary input1 pointer */
emh203 0:3d9c67d97d6f 93 q15_t *py; /* Temporary input2 pointer */
emh203 0:3d9c67d97d6f 94 q31_t acc0, acc1, acc2, acc3; /* Accumulator */
emh203 0:3d9c67d97d6f 95 q31_t x1, x2, x3, y1; /* Temporary input variables */
emh203 0:3d9c67d97d6f 96 arm_status status;
emh203 0:3d9c67d97d6f 97 q7_t *pOut = pDst; /* output pointer */
emh203 0:3d9c67d97d6f 98 q7_t out0, out1, out2, out3; /* temporary variables */
emh203 0:3d9c67d97d6f 99
emh203 0:3d9c67d97d6f 100 /* Check for range of output samples to be calculated */
emh203 0:3d9c67d97d6f 101 if((firstIndex + numPoints) > ((srcALen + (srcBLen - 1u))))
emh203 0:3d9c67d97d6f 102 {
emh203 0:3d9c67d97d6f 103 /* Set status as ARM_MATH_ARGUMENT_ERROR */
emh203 0:3d9c67d97d6f 104 status = ARM_MATH_ARGUMENT_ERROR;
emh203 0:3d9c67d97d6f 105 }
emh203 0:3d9c67d97d6f 106 else
emh203 0:3d9c67d97d6f 107 {
emh203 0:3d9c67d97d6f 108
emh203 0:3d9c67d97d6f 109 /* The algorithm implementation is based on the lengths of the inputs. */
emh203 0:3d9c67d97d6f 110 /* srcB is always made to slide across srcA. */
emh203 0:3d9c67d97d6f 111 /* So srcBLen is always considered as shorter or equal to srcALen */
emh203 0:3d9c67d97d6f 112 if(srcALen >= srcBLen)
emh203 0:3d9c67d97d6f 113 {
emh203 0:3d9c67d97d6f 114 /* Initialization of inputA pointer */
emh203 0:3d9c67d97d6f 115 pIn1 = pSrcA;
emh203 0:3d9c67d97d6f 116
emh203 0:3d9c67d97d6f 117 /* Initialization of inputB pointer */
emh203 0:3d9c67d97d6f 118 pIn2 = pSrcB;
emh203 0:3d9c67d97d6f 119 }
emh203 0:3d9c67d97d6f 120 else
emh203 0:3d9c67d97d6f 121 {
emh203 0:3d9c67d97d6f 122 /* Initialization of inputA pointer */
emh203 0:3d9c67d97d6f 123 pIn1 = pSrcB;
emh203 0:3d9c67d97d6f 124
emh203 0:3d9c67d97d6f 125 /* Initialization of inputB pointer */
emh203 0:3d9c67d97d6f 126 pIn2 = pSrcA;
emh203 0:3d9c67d97d6f 127
emh203 0:3d9c67d97d6f 128 /* srcBLen is always considered as shorter or equal to srcALen */
emh203 0:3d9c67d97d6f 129 j = srcBLen;
emh203 0:3d9c67d97d6f 130 srcBLen = srcALen;
emh203 0:3d9c67d97d6f 131 srcALen = j;
emh203 0:3d9c67d97d6f 132 }
emh203 0:3d9c67d97d6f 133
emh203 0:3d9c67d97d6f 134 /* pointer to take end of scratch2 buffer */
emh203 0:3d9c67d97d6f 135 pScr2 = pScratch2;
emh203 0:3d9c67d97d6f 136
emh203 0:3d9c67d97d6f 137 /* points to smaller length sequence */
emh203 0:3d9c67d97d6f 138 px = pIn2 + srcBLen - 1;
emh203 0:3d9c67d97d6f 139
emh203 0:3d9c67d97d6f 140 /* Apply loop unrolling and do 4 Copies simultaneously. */
emh203 0:3d9c67d97d6f 141 k = srcBLen >> 2u;
emh203 0:3d9c67d97d6f 142
emh203 0:3d9c67d97d6f 143 /* First part of the processing with loop unrolling copies 4 data points at a time.
emh203 0:3d9c67d97d6f 144 ** a second loop below copies for the remaining 1 to 3 samples. */
emh203 0:3d9c67d97d6f 145 while(k > 0u)
emh203 0:3d9c67d97d6f 146 {
emh203 0:3d9c67d97d6f 147 /* copy second buffer in reversal manner */
emh203 0:3d9c67d97d6f 148 x4 = (q15_t) * px--;
emh203 0:3d9c67d97d6f 149 *pScr2++ = x4;
emh203 0:3d9c67d97d6f 150 x4 = (q15_t) * px--;
emh203 0:3d9c67d97d6f 151 *pScr2++ = x4;
emh203 0:3d9c67d97d6f 152 x4 = (q15_t) * px--;
emh203 0:3d9c67d97d6f 153 *pScr2++ = x4;
emh203 0:3d9c67d97d6f 154 x4 = (q15_t) * px--;
emh203 0:3d9c67d97d6f 155 *pScr2++ = x4;
emh203 0:3d9c67d97d6f 156
emh203 0:3d9c67d97d6f 157 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 158 k--;
emh203 0:3d9c67d97d6f 159 }
emh203 0:3d9c67d97d6f 160
emh203 0:3d9c67d97d6f 161 /* If the count is not a multiple of 4, copy remaining samples here.
emh203 0:3d9c67d97d6f 162 ** No loop unrolling is used. */
emh203 0:3d9c67d97d6f 163 k = srcBLen % 0x4u;
emh203 0:3d9c67d97d6f 164
emh203 0:3d9c67d97d6f 165 while(k > 0u)
emh203 0:3d9c67d97d6f 166 {
emh203 0:3d9c67d97d6f 167 /* copy second buffer in reversal manner for remaining samples */
emh203 0:3d9c67d97d6f 168 x4 = (q15_t) * px--;
emh203 0:3d9c67d97d6f 169 *pScr2++ = x4;
emh203 0:3d9c67d97d6f 170
emh203 0:3d9c67d97d6f 171 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 172 k--;
emh203 0:3d9c67d97d6f 173 }
emh203 0:3d9c67d97d6f 174
emh203 0:3d9c67d97d6f 175 /* Initialze temporary scratch pointer */
emh203 0:3d9c67d97d6f 176 pScr1 = pScratch1;
emh203 0:3d9c67d97d6f 177
emh203 0:3d9c67d97d6f 178 /* Fill (srcBLen - 1u) zeros in scratch buffer */
emh203 0:3d9c67d97d6f 179 arm_fill_q15(0, pScr1, (srcBLen - 1u));
emh203 0:3d9c67d97d6f 180
emh203 0:3d9c67d97d6f 181 /* Update temporary scratch pointer */
emh203 0:3d9c67d97d6f 182 pScr1 += (srcBLen - 1u);
emh203 0:3d9c67d97d6f 183
emh203 0:3d9c67d97d6f 184 /* Copy (srcALen) samples in scratch buffer */
emh203 0:3d9c67d97d6f 185 /* Apply loop unrolling and do 4 Copies simultaneously. */
emh203 0:3d9c67d97d6f 186 k = srcALen >> 2u;
emh203 0:3d9c67d97d6f 187
emh203 0:3d9c67d97d6f 188 /* First part of the processing with loop unrolling copies 4 data points at a time.
emh203 0:3d9c67d97d6f 189 ** a second loop below copies for the remaining 1 to 3 samples. */
emh203 0:3d9c67d97d6f 190 while(k > 0u)
emh203 0:3d9c67d97d6f 191 {
emh203 0:3d9c67d97d6f 192 /* copy second buffer in reversal manner */
emh203 0:3d9c67d97d6f 193 x4 = (q15_t) * pIn1++;
emh203 0:3d9c67d97d6f 194 *pScr1++ = x4;
emh203 0:3d9c67d97d6f 195 x4 = (q15_t) * pIn1++;
emh203 0:3d9c67d97d6f 196 *pScr1++ = x4;
emh203 0:3d9c67d97d6f 197 x4 = (q15_t) * pIn1++;
emh203 0:3d9c67d97d6f 198 *pScr1++ = x4;
emh203 0:3d9c67d97d6f 199 x4 = (q15_t) * pIn1++;
emh203 0:3d9c67d97d6f 200 *pScr1++ = x4;
emh203 0:3d9c67d97d6f 201
emh203 0:3d9c67d97d6f 202 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 203 k--;
emh203 0:3d9c67d97d6f 204 }
emh203 0:3d9c67d97d6f 205
emh203 0:3d9c67d97d6f 206 /* If the count is not a multiple of 4, copy remaining samples here.
emh203 0:3d9c67d97d6f 207 ** No loop unrolling is used. */
emh203 0:3d9c67d97d6f 208 k = srcALen % 0x4u;
emh203 0:3d9c67d97d6f 209
emh203 0:3d9c67d97d6f 210 while(k > 0u)
emh203 0:3d9c67d97d6f 211 {
emh203 0:3d9c67d97d6f 212 /* copy second buffer in reversal manner for remaining samples */
emh203 0:3d9c67d97d6f 213 x4 = (q15_t) * pIn1++;
emh203 0:3d9c67d97d6f 214 *pScr1++ = x4;
emh203 0:3d9c67d97d6f 215
emh203 0:3d9c67d97d6f 216 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 217 k--;
emh203 0:3d9c67d97d6f 218 }
emh203 0:3d9c67d97d6f 219
emh203 0:3d9c67d97d6f 220 /* Fill (srcBLen - 1u) zeros at end of scratch buffer */
emh203 0:3d9c67d97d6f 221 arm_fill_q15(0, pScr1, (srcBLen - 1u));
emh203 0:3d9c67d97d6f 222
emh203 0:3d9c67d97d6f 223 /* Update pointer */
emh203 0:3d9c67d97d6f 224 pScr1 += (srcBLen - 1u);
emh203 0:3d9c67d97d6f 225
emh203 0:3d9c67d97d6f 226
emh203 0:3d9c67d97d6f 227 /* Temporary pointer for scratch2 */
emh203 0:3d9c67d97d6f 228 py = pScratch2;
emh203 0:3d9c67d97d6f 229
emh203 0:3d9c67d97d6f 230 /* Initialization of pIn2 pointer */
emh203 0:3d9c67d97d6f 231 pIn2 = (q7_t *) py;
emh203 0:3d9c67d97d6f 232
emh203 0:3d9c67d97d6f 233 pScr2 = py;
emh203 0:3d9c67d97d6f 234
emh203 0:3d9c67d97d6f 235 pOut = pDst + firstIndex;
emh203 0:3d9c67d97d6f 236
emh203 0:3d9c67d97d6f 237 pScratch1 += firstIndex;
emh203 0:3d9c67d97d6f 238
emh203 0:3d9c67d97d6f 239 /* Actual convolution process starts here */
emh203 0:3d9c67d97d6f 240 blkCnt = (numPoints) >> 2;
emh203 0:3d9c67d97d6f 241
emh203 0:3d9c67d97d6f 242
emh203 0:3d9c67d97d6f 243 while(blkCnt > 0)
emh203 0:3d9c67d97d6f 244 {
emh203 0:3d9c67d97d6f 245 /* Initialze temporary scratch pointer as scratch1 */
emh203 0:3d9c67d97d6f 246 pScr1 = pScratch1;
emh203 0:3d9c67d97d6f 247
emh203 0:3d9c67d97d6f 248 /* Clear Accumlators */
emh203 0:3d9c67d97d6f 249 acc0 = 0;
emh203 0:3d9c67d97d6f 250 acc1 = 0;
emh203 0:3d9c67d97d6f 251 acc2 = 0;
emh203 0:3d9c67d97d6f 252 acc3 = 0;
emh203 0:3d9c67d97d6f 253
emh203 0:3d9c67d97d6f 254 /* Read two samples from scratch1 buffer */
emh203 0:3d9c67d97d6f 255 x1 = *__SIMD32(pScr1)++;
emh203 0:3d9c67d97d6f 256
emh203 0:3d9c67d97d6f 257 /* Read next two samples from scratch1 buffer */
emh203 0:3d9c67d97d6f 258 x2 = *__SIMD32(pScr1)++;
emh203 0:3d9c67d97d6f 259
emh203 0:3d9c67d97d6f 260 tapCnt = (srcBLen) >> 2u;
emh203 0:3d9c67d97d6f 261
emh203 0:3d9c67d97d6f 262 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 263 {
emh203 0:3d9c67d97d6f 264
emh203 0:3d9c67d97d6f 265 /* Read four samples from smaller buffer */
emh203 0:3d9c67d97d6f 266 y1 = _SIMD32_OFFSET(pScr2);
emh203 0:3d9c67d97d6f 267
emh203 0:3d9c67d97d6f 268 /* multiply and accumlate */
emh203 0:3d9c67d97d6f 269 acc0 = __SMLAD(x1, y1, acc0);
emh203 0:3d9c67d97d6f 270 acc2 = __SMLAD(x2, y1, acc2);
emh203 0:3d9c67d97d6f 271
emh203 0:3d9c67d97d6f 272 /* pack input data */
emh203 0:3d9c67d97d6f 273 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 274 x3 = __PKHBT(x2, x1, 0);
emh203 0:3d9c67d97d6f 275 #else
emh203 0:3d9c67d97d6f 276 x3 = __PKHBT(x1, x2, 0);
emh203 0:3d9c67d97d6f 277 #endif
emh203 0:3d9c67d97d6f 278
emh203 0:3d9c67d97d6f 279 /* multiply and accumlate */
emh203 0:3d9c67d97d6f 280 acc1 = __SMLADX(x3, y1, acc1);
emh203 0:3d9c67d97d6f 281
emh203 0:3d9c67d97d6f 282 /* Read next two samples from scratch1 buffer */
emh203 0:3d9c67d97d6f 283 x1 = *__SIMD32(pScr1)++;
emh203 0:3d9c67d97d6f 284
emh203 0:3d9c67d97d6f 285 /* pack input data */
emh203 0:3d9c67d97d6f 286 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 287 x3 = __PKHBT(x1, x2, 0);
emh203 0:3d9c67d97d6f 288 #else
emh203 0:3d9c67d97d6f 289 x3 = __PKHBT(x2, x1, 0);
emh203 0:3d9c67d97d6f 290 #endif
emh203 0:3d9c67d97d6f 291
emh203 0:3d9c67d97d6f 292 acc3 = __SMLADX(x3, y1, acc3);
emh203 0:3d9c67d97d6f 293
emh203 0:3d9c67d97d6f 294 /* Read four samples from smaller buffer */
emh203 0:3d9c67d97d6f 295 y1 = _SIMD32_OFFSET(pScr2 + 2u);
emh203 0:3d9c67d97d6f 296
emh203 0:3d9c67d97d6f 297 acc0 = __SMLAD(x2, y1, acc0);
emh203 0:3d9c67d97d6f 298
emh203 0:3d9c67d97d6f 299 acc2 = __SMLAD(x1, y1, acc2);
emh203 0:3d9c67d97d6f 300
emh203 0:3d9c67d97d6f 301 acc1 = __SMLADX(x3, y1, acc1);
emh203 0:3d9c67d97d6f 302
emh203 0:3d9c67d97d6f 303 x2 = *__SIMD32(pScr1)++;
emh203 0:3d9c67d97d6f 304
emh203 0:3d9c67d97d6f 305 #ifndef ARM_MATH_BIG_ENDIAN
emh203 0:3d9c67d97d6f 306 x3 = __PKHBT(x2, x1, 0);
emh203 0:3d9c67d97d6f 307 #else
emh203 0:3d9c67d97d6f 308 x3 = __PKHBT(x1, x2, 0);
emh203 0:3d9c67d97d6f 309 #endif
emh203 0:3d9c67d97d6f 310
emh203 0:3d9c67d97d6f 311 acc3 = __SMLADX(x3, y1, acc3);
emh203 0:3d9c67d97d6f 312
emh203 0:3d9c67d97d6f 313 pScr2 += 4u;
emh203 0:3d9c67d97d6f 314
emh203 0:3d9c67d97d6f 315
emh203 0:3d9c67d97d6f 316 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 317 tapCnt--;
emh203 0:3d9c67d97d6f 318 }
emh203 0:3d9c67d97d6f 319
emh203 0:3d9c67d97d6f 320
emh203 0:3d9c67d97d6f 321
emh203 0:3d9c67d97d6f 322 /* Update scratch pointer for remaining samples of smaller length sequence */
emh203 0:3d9c67d97d6f 323 pScr1 -= 4u;
emh203 0:3d9c67d97d6f 324
emh203 0:3d9c67d97d6f 325
emh203 0:3d9c67d97d6f 326 /* apply same above for remaining samples of smaller length sequence */
emh203 0:3d9c67d97d6f 327 tapCnt = (srcBLen) & 3u;
emh203 0:3d9c67d97d6f 328
emh203 0:3d9c67d97d6f 329 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 330 {
emh203 0:3d9c67d97d6f 331
emh203 0:3d9c67d97d6f 332 /* accumlate the results */
emh203 0:3d9c67d97d6f 333 acc0 += (*pScr1++ * *pScr2);
emh203 0:3d9c67d97d6f 334 acc1 += (*pScr1++ * *pScr2);
emh203 0:3d9c67d97d6f 335 acc2 += (*pScr1++ * *pScr2);
emh203 0:3d9c67d97d6f 336 acc3 += (*pScr1++ * *pScr2++);
emh203 0:3d9c67d97d6f 337
emh203 0:3d9c67d97d6f 338 pScr1 -= 3u;
emh203 0:3d9c67d97d6f 339
emh203 0:3d9c67d97d6f 340 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 341 tapCnt--;
emh203 0:3d9c67d97d6f 342 }
emh203 0:3d9c67d97d6f 343
emh203 0:3d9c67d97d6f 344 blkCnt--;
emh203 0:3d9c67d97d6f 345
emh203 0:3d9c67d97d6f 346 /* Store the result in the accumulator in the destination buffer. */
emh203 0:3d9c67d97d6f 347 out0 = (q7_t) (__SSAT(acc0 >> 7u, 8));
emh203 0:3d9c67d97d6f 348 out1 = (q7_t) (__SSAT(acc1 >> 7u, 8));
emh203 0:3d9c67d97d6f 349 out2 = (q7_t) (__SSAT(acc2 >> 7u, 8));
emh203 0:3d9c67d97d6f 350 out3 = (q7_t) (__SSAT(acc3 >> 7u, 8));
emh203 0:3d9c67d97d6f 351
emh203 0:3d9c67d97d6f 352 *__SIMD32(pOut)++ = __PACKq7(out0, out1, out2, out3);
emh203 0:3d9c67d97d6f 353
emh203 0:3d9c67d97d6f 354 /* Initialization of inputB pointer */
emh203 0:3d9c67d97d6f 355 pScr2 = py;
emh203 0:3d9c67d97d6f 356
emh203 0:3d9c67d97d6f 357 pScratch1 += 4u;
emh203 0:3d9c67d97d6f 358
emh203 0:3d9c67d97d6f 359 }
emh203 0:3d9c67d97d6f 360
emh203 0:3d9c67d97d6f 361 blkCnt = (numPoints) & 0x3;
emh203 0:3d9c67d97d6f 362
emh203 0:3d9c67d97d6f 363 /* Calculate convolution for remaining samples of Bigger length sequence */
emh203 0:3d9c67d97d6f 364 while(blkCnt > 0)
emh203 0:3d9c67d97d6f 365 {
emh203 0:3d9c67d97d6f 366 /* Initialze temporary scratch pointer as scratch1 */
emh203 0:3d9c67d97d6f 367 pScr1 = pScratch1;
emh203 0:3d9c67d97d6f 368
emh203 0:3d9c67d97d6f 369 /* Clear Accumlators */
emh203 0:3d9c67d97d6f 370 acc0 = 0;
emh203 0:3d9c67d97d6f 371
emh203 0:3d9c67d97d6f 372 tapCnt = (srcBLen) >> 1u;
emh203 0:3d9c67d97d6f 373
emh203 0:3d9c67d97d6f 374 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 375 {
emh203 0:3d9c67d97d6f 376
emh203 0:3d9c67d97d6f 377 /* Read next two samples from scratch1 buffer */
emh203 0:3d9c67d97d6f 378 x1 = *__SIMD32(pScr1)++;
emh203 0:3d9c67d97d6f 379
emh203 0:3d9c67d97d6f 380 /* Read two samples from smaller buffer */
emh203 0:3d9c67d97d6f 381 y1 = *__SIMD32(pScr2)++;
emh203 0:3d9c67d97d6f 382
emh203 0:3d9c67d97d6f 383 acc0 = __SMLAD(x1, y1, acc0);
emh203 0:3d9c67d97d6f 384
emh203 0:3d9c67d97d6f 385 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 386 tapCnt--;
emh203 0:3d9c67d97d6f 387 }
emh203 0:3d9c67d97d6f 388
emh203 0:3d9c67d97d6f 389 tapCnt = (srcBLen) & 1u;
emh203 0:3d9c67d97d6f 390
emh203 0:3d9c67d97d6f 391 /* apply same above for remaining samples of smaller length sequence */
emh203 0:3d9c67d97d6f 392 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 393 {
emh203 0:3d9c67d97d6f 394
emh203 0:3d9c67d97d6f 395 /* accumlate the results */
emh203 0:3d9c67d97d6f 396 acc0 += (*pScr1++ * *pScr2++);
emh203 0:3d9c67d97d6f 397
emh203 0:3d9c67d97d6f 398 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 399 tapCnt--;
emh203 0:3d9c67d97d6f 400 }
emh203 0:3d9c67d97d6f 401
emh203 0:3d9c67d97d6f 402 blkCnt--;
emh203 0:3d9c67d97d6f 403
emh203 0:3d9c67d97d6f 404 /* Store the result in the accumulator in the destination buffer. */
emh203 0:3d9c67d97d6f 405 *pOut++ = (q7_t) (__SSAT(acc0 >> 7u, 8));
emh203 0:3d9c67d97d6f 406
emh203 0:3d9c67d97d6f 407 /* Initialization of inputB pointer */
emh203 0:3d9c67d97d6f 408 pScr2 = py;
emh203 0:3d9c67d97d6f 409
emh203 0:3d9c67d97d6f 410 pScratch1 += 1u;
emh203 0:3d9c67d97d6f 411
emh203 0:3d9c67d97d6f 412 }
emh203 0:3d9c67d97d6f 413
emh203 0:3d9c67d97d6f 414 /* set status as ARM_MATH_SUCCESS */
emh203 0:3d9c67d97d6f 415 status = ARM_MATH_SUCCESS;
emh203 0:3d9c67d97d6f 416
emh203 0:3d9c67d97d6f 417
emh203 0:3d9c67d97d6f 418 }
emh203 0:3d9c67d97d6f 419
emh203 0:3d9c67d97d6f 420 return (status);
emh203 0:3d9c67d97d6f 421
emh203 0:3d9c67d97d6f 422 }
emh203 0:3d9c67d97d6f 423
emh203 0:3d9c67d97d6f 424 #else
emh203 0:3d9c67d97d6f 425
emh203 0:3d9c67d97d6f 426 arm_status arm_conv_partial_opt_q7(
emh203 0:3d9c67d97d6f 427 q7_t * pSrcA,
emh203 0:3d9c67d97d6f 428 uint32_t srcALen,
emh203 0:3d9c67d97d6f 429 q7_t * pSrcB,
emh203 0:3d9c67d97d6f 430 uint32_t srcBLen,
emh203 0:3d9c67d97d6f 431 q7_t * pDst,
emh203 0:3d9c67d97d6f 432 uint32_t firstIndex,
emh203 0:3d9c67d97d6f 433 uint32_t numPoints,
emh203 0:3d9c67d97d6f 434 q15_t * pScratch1,
emh203 0:3d9c67d97d6f 435 q15_t * pScratch2)
emh203 0:3d9c67d97d6f 436 {
emh203 0:3d9c67d97d6f 437
emh203 0:3d9c67d97d6f 438 q15_t *pScr2, *pScr1; /* Intermediate pointers for scratch pointers */
emh203 0:3d9c67d97d6f 439 q15_t x4; /* Temporary input variable */
emh203 0:3d9c67d97d6f 440 q7_t *pIn1, *pIn2; /* inputA and inputB pointer */
emh203 0:3d9c67d97d6f 441 uint32_t j, k, blkCnt, tapCnt; /* loop counter */
emh203 0:3d9c67d97d6f 442 q7_t *px; /* Temporary input1 pointer */
emh203 0:3d9c67d97d6f 443 q15_t *py; /* Temporary input2 pointer */
emh203 0:3d9c67d97d6f 444 q31_t acc0, acc1, acc2, acc3; /* Accumulator */
emh203 0:3d9c67d97d6f 445 arm_status status;
emh203 0:3d9c67d97d6f 446 q7_t *pOut = pDst; /* output pointer */
emh203 0:3d9c67d97d6f 447 q15_t x10, x11, x20, x21; /* Temporary input variables */
emh203 0:3d9c67d97d6f 448 q15_t y10, y11; /* Temporary input variables */
emh203 0:3d9c67d97d6f 449
emh203 0:3d9c67d97d6f 450 /* Check for range of output samples to be calculated */
emh203 0:3d9c67d97d6f 451 if((firstIndex + numPoints) > ((srcALen + (srcBLen - 1u))))
emh203 0:3d9c67d97d6f 452 {
emh203 0:3d9c67d97d6f 453 /* Set status as ARM_MATH_ARGUMENT_ERROR */
emh203 0:3d9c67d97d6f 454 status = ARM_MATH_ARGUMENT_ERROR;
emh203 0:3d9c67d97d6f 455 }
emh203 0:3d9c67d97d6f 456 else
emh203 0:3d9c67d97d6f 457 {
emh203 0:3d9c67d97d6f 458
emh203 0:3d9c67d97d6f 459 /* The algorithm implementation is based on the lengths of the inputs. */
emh203 0:3d9c67d97d6f 460 /* srcB is always made to slide across srcA. */
emh203 0:3d9c67d97d6f 461 /* So srcBLen is always considered as shorter or equal to srcALen */
emh203 0:3d9c67d97d6f 462 if(srcALen >= srcBLen)
emh203 0:3d9c67d97d6f 463 {
emh203 0:3d9c67d97d6f 464 /* Initialization of inputA pointer */
emh203 0:3d9c67d97d6f 465 pIn1 = pSrcA;
emh203 0:3d9c67d97d6f 466
emh203 0:3d9c67d97d6f 467 /* Initialization of inputB pointer */
emh203 0:3d9c67d97d6f 468 pIn2 = pSrcB;
emh203 0:3d9c67d97d6f 469 }
emh203 0:3d9c67d97d6f 470 else
emh203 0:3d9c67d97d6f 471 {
emh203 0:3d9c67d97d6f 472 /* Initialization of inputA pointer */
emh203 0:3d9c67d97d6f 473 pIn1 = pSrcB;
emh203 0:3d9c67d97d6f 474
emh203 0:3d9c67d97d6f 475 /* Initialization of inputB pointer */
emh203 0:3d9c67d97d6f 476 pIn2 = pSrcA;
emh203 0:3d9c67d97d6f 477
emh203 0:3d9c67d97d6f 478 /* srcBLen is always considered as shorter or equal to srcALen */
emh203 0:3d9c67d97d6f 479 j = srcBLen;
emh203 0:3d9c67d97d6f 480 srcBLen = srcALen;
emh203 0:3d9c67d97d6f 481 srcALen = j;
emh203 0:3d9c67d97d6f 482 }
emh203 0:3d9c67d97d6f 483
emh203 0:3d9c67d97d6f 484 /* pointer to take end of scratch2 buffer */
emh203 0:3d9c67d97d6f 485 pScr2 = pScratch2;
emh203 0:3d9c67d97d6f 486
emh203 0:3d9c67d97d6f 487 /* points to smaller length sequence */
emh203 0:3d9c67d97d6f 488 px = pIn2 + srcBLen - 1;
emh203 0:3d9c67d97d6f 489
emh203 0:3d9c67d97d6f 490 /* Apply loop unrolling and do 4 Copies simultaneously. */
emh203 0:3d9c67d97d6f 491 k = srcBLen >> 2u;
emh203 0:3d9c67d97d6f 492
emh203 0:3d9c67d97d6f 493 /* First part of the processing with loop unrolling copies 4 data points at a time.
emh203 0:3d9c67d97d6f 494 ** a second loop below copies for the remaining 1 to 3 samples. */
emh203 0:3d9c67d97d6f 495 while(k > 0u)
emh203 0:3d9c67d97d6f 496 {
emh203 0:3d9c67d97d6f 497 /* copy second buffer in reversal manner */
emh203 0:3d9c67d97d6f 498 x4 = (q15_t) * px--;
emh203 0:3d9c67d97d6f 499 *pScr2++ = x4;
emh203 0:3d9c67d97d6f 500 x4 = (q15_t) * px--;
emh203 0:3d9c67d97d6f 501 *pScr2++ = x4;
emh203 0:3d9c67d97d6f 502 x4 = (q15_t) * px--;
emh203 0:3d9c67d97d6f 503 *pScr2++ = x4;
emh203 0:3d9c67d97d6f 504 x4 = (q15_t) * px--;
emh203 0:3d9c67d97d6f 505 *pScr2++ = x4;
emh203 0:3d9c67d97d6f 506
emh203 0:3d9c67d97d6f 507 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 508 k--;
emh203 0:3d9c67d97d6f 509 }
emh203 0:3d9c67d97d6f 510
emh203 0:3d9c67d97d6f 511 /* If the count is not a multiple of 4, copy remaining samples here.
emh203 0:3d9c67d97d6f 512 ** No loop unrolling is used. */
emh203 0:3d9c67d97d6f 513 k = srcBLen % 0x4u;
emh203 0:3d9c67d97d6f 514
emh203 0:3d9c67d97d6f 515 while(k > 0u)
emh203 0:3d9c67d97d6f 516 {
emh203 0:3d9c67d97d6f 517 /* copy second buffer in reversal manner for remaining samples */
emh203 0:3d9c67d97d6f 518 x4 = (q15_t) * px--;
emh203 0:3d9c67d97d6f 519 *pScr2++ = x4;
emh203 0:3d9c67d97d6f 520
emh203 0:3d9c67d97d6f 521 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 522 k--;
emh203 0:3d9c67d97d6f 523 }
emh203 0:3d9c67d97d6f 524
emh203 0:3d9c67d97d6f 525 /* Initialze temporary scratch pointer */
emh203 0:3d9c67d97d6f 526 pScr1 = pScratch1;
emh203 0:3d9c67d97d6f 527
emh203 0:3d9c67d97d6f 528 /* Fill (srcBLen - 1u) zeros in scratch buffer */
emh203 0:3d9c67d97d6f 529 arm_fill_q15(0, pScr1, (srcBLen - 1u));
emh203 0:3d9c67d97d6f 530
emh203 0:3d9c67d97d6f 531 /* Update temporary scratch pointer */
emh203 0:3d9c67d97d6f 532 pScr1 += (srcBLen - 1u);
emh203 0:3d9c67d97d6f 533
emh203 0:3d9c67d97d6f 534 /* Copy (srcALen) samples in scratch buffer */
emh203 0:3d9c67d97d6f 535 /* Apply loop unrolling and do 4 Copies simultaneously. */
emh203 0:3d9c67d97d6f 536 k = srcALen >> 2u;
emh203 0:3d9c67d97d6f 537
emh203 0:3d9c67d97d6f 538 /* First part of the processing with loop unrolling copies 4 data points at a time.
emh203 0:3d9c67d97d6f 539 ** a second loop below copies for the remaining 1 to 3 samples. */
emh203 0:3d9c67d97d6f 540 while(k > 0u)
emh203 0:3d9c67d97d6f 541 {
emh203 0:3d9c67d97d6f 542 /* copy second buffer in reversal manner */
emh203 0:3d9c67d97d6f 543 x4 = (q15_t) * pIn1++;
emh203 0:3d9c67d97d6f 544 *pScr1++ = x4;
emh203 0:3d9c67d97d6f 545 x4 = (q15_t) * pIn1++;
emh203 0:3d9c67d97d6f 546 *pScr1++ = x4;
emh203 0:3d9c67d97d6f 547 x4 = (q15_t) * pIn1++;
emh203 0:3d9c67d97d6f 548 *pScr1++ = x4;
emh203 0:3d9c67d97d6f 549 x4 = (q15_t) * pIn1++;
emh203 0:3d9c67d97d6f 550 *pScr1++ = x4;
emh203 0:3d9c67d97d6f 551
emh203 0:3d9c67d97d6f 552 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 553 k--;
emh203 0:3d9c67d97d6f 554 }
emh203 0:3d9c67d97d6f 555
emh203 0:3d9c67d97d6f 556 /* If the count is not a multiple of 4, copy remaining samples here.
emh203 0:3d9c67d97d6f 557 ** No loop unrolling is used. */
emh203 0:3d9c67d97d6f 558 k = srcALen % 0x4u;
emh203 0:3d9c67d97d6f 559
emh203 0:3d9c67d97d6f 560 while(k > 0u)
emh203 0:3d9c67d97d6f 561 {
emh203 0:3d9c67d97d6f 562 /* copy second buffer in reversal manner for remaining samples */
emh203 0:3d9c67d97d6f 563 x4 = (q15_t) * pIn1++;
emh203 0:3d9c67d97d6f 564 *pScr1++ = x4;
emh203 0:3d9c67d97d6f 565
emh203 0:3d9c67d97d6f 566 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 567 k--;
emh203 0:3d9c67d97d6f 568 }
emh203 0:3d9c67d97d6f 569
emh203 0:3d9c67d97d6f 570 /* Apply loop unrolling and do 4 Copies simultaneously. */
emh203 0:3d9c67d97d6f 571 k = (srcBLen - 1u) >> 2u;
emh203 0:3d9c67d97d6f 572
emh203 0:3d9c67d97d6f 573 /* First part of the processing with loop unrolling copies 4 data points at a time.
emh203 0:3d9c67d97d6f 574 ** a second loop below copies for the remaining 1 to 3 samples. */
emh203 0:3d9c67d97d6f 575 while(k > 0u)
emh203 0:3d9c67d97d6f 576 {
emh203 0:3d9c67d97d6f 577 /* copy second buffer in reversal manner */
emh203 0:3d9c67d97d6f 578 *pScr1++ = 0;
emh203 0:3d9c67d97d6f 579 *pScr1++ = 0;
emh203 0:3d9c67d97d6f 580 *pScr1++ = 0;
emh203 0:3d9c67d97d6f 581 *pScr1++ = 0;
emh203 0:3d9c67d97d6f 582
emh203 0:3d9c67d97d6f 583 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 584 k--;
emh203 0:3d9c67d97d6f 585 }
emh203 0:3d9c67d97d6f 586
emh203 0:3d9c67d97d6f 587 /* If the count is not a multiple of 4, copy remaining samples here.
emh203 0:3d9c67d97d6f 588 ** No loop unrolling is used. */
emh203 0:3d9c67d97d6f 589 k = (srcBLen - 1u) % 0x4u;
emh203 0:3d9c67d97d6f 590
emh203 0:3d9c67d97d6f 591 while(k > 0u)
emh203 0:3d9c67d97d6f 592 {
emh203 0:3d9c67d97d6f 593 /* copy second buffer in reversal manner for remaining samples */
emh203 0:3d9c67d97d6f 594 *pScr1++ = 0;
emh203 0:3d9c67d97d6f 595
emh203 0:3d9c67d97d6f 596 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 597 k--;
emh203 0:3d9c67d97d6f 598 }
emh203 0:3d9c67d97d6f 599
emh203 0:3d9c67d97d6f 600
emh203 0:3d9c67d97d6f 601 /* Temporary pointer for scratch2 */
emh203 0:3d9c67d97d6f 602 py = pScratch2;
emh203 0:3d9c67d97d6f 603
emh203 0:3d9c67d97d6f 604 /* Initialization of pIn2 pointer */
emh203 0:3d9c67d97d6f 605 pIn2 = (q7_t *) py;
emh203 0:3d9c67d97d6f 606
emh203 0:3d9c67d97d6f 607 pScr2 = py;
emh203 0:3d9c67d97d6f 608
emh203 0:3d9c67d97d6f 609 pOut = pDst + firstIndex;
emh203 0:3d9c67d97d6f 610
emh203 0:3d9c67d97d6f 611 pScratch1 += firstIndex;
emh203 0:3d9c67d97d6f 612
emh203 0:3d9c67d97d6f 613 /* Actual convolution process starts here */
emh203 0:3d9c67d97d6f 614 blkCnt = (numPoints) >> 2;
emh203 0:3d9c67d97d6f 615
emh203 0:3d9c67d97d6f 616
emh203 0:3d9c67d97d6f 617 while(blkCnt > 0)
emh203 0:3d9c67d97d6f 618 {
emh203 0:3d9c67d97d6f 619 /* Initialze temporary scratch pointer as scratch1 */
emh203 0:3d9c67d97d6f 620 pScr1 = pScratch1;
emh203 0:3d9c67d97d6f 621
emh203 0:3d9c67d97d6f 622 /* Clear Accumlators */
emh203 0:3d9c67d97d6f 623 acc0 = 0;
emh203 0:3d9c67d97d6f 624 acc1 = 0;
emh203 0:3d9c67d97d6f 625 acc2 = 0;
emh203 0:3d9c67d97d6f 626 acc3 = 0;
emh203 0:3d9c67d97d6f 627
emh203 0:3d9c67d97d6f 628 /* Read two samples from scratch1 buffer */
emh203 0:3d9c67d97d6f 629 x10 = *pScr1++;
emh203 0:3d9c67d97d6f 630 x11 = *pScr1++;
emh203 0:3d9c67d97d6f 631
emh203 0:3d9c67d97d6f 632 /* Read next two samples from scratch1 buffer */
emh203 0:3d9c67d97d6f 633 x20 = *pScr1++;
emh203 0:3d9c67d97d6f 634 x21 = *pScr1++;
emh203 0:3d9c67d97d6f 635
emh203 0:3d9c67d97d6f 636 tapCnt = (srcBLen) >> 2u;
emh203 0:3d9c67d97d6f 637
emh203 0:3d9c67d97d6f 638 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 639 {
emh203 0:3d9c67d97d6f 640
emh203 0:3d9c67d97d6f 641 /* Read four samples from smaller buffer */
emh203 0:3d9c67d97d6f 642 y10 = *pScr2;
emh203 0:3d9c67d97d6f 643 y11 = *(pScr2 + 1u);
emh203 0:3d9c67d97d6f 644
emh203 0:3d9c67d97d6f 645 /* multiply and accumlate */
emh203 0:3d9c67d97d6f 646 acc0 += (q31_t) x10 *y10;
emh203 0:3d9c67d97d6f 647 acc0 += (q31_t) x11 *y11;
emh203 0:3d9c67d97d6f 648 acc2 += (q31_t) x20 *y10;
emh203 0:3d9c67d97d6f 649 acc2 += (q31_t) x21 *y11;
emh203 0:3d9c67d97d6f 650
emh203 0:3d9c67d97d6f 651
emh203 0:3d9c67d97d6f 652 acc1 += (q31_t) x11 *y10;
emh203 0:3d9c67d97d6f 653 acc1 += (q31_t) x20 *y11;
emh203 0:3d9c67d97d6f 654
emh203 0:3d9c67d97d6f 655 /* Read next two samples from scratch1 buffer */
emh203 0:3d9c67d97d6f 656 x10 = *pScr1;
emh203 0:3d9c67d97d6f 657 x11 = *(pScr1 + 1u);
emh203 0:3d9c67d97d6f 658
emh203 0:3d9c67d97d6f 659 /* multiply and accumlate */
emh203 0:3d9c67d97d6f 660 acc3 += (q31_t) x21 *y10;
emh203 0:3d9c67d97d6f 661 acc3 += (q31_t) x10 *y11;
emh203 0:3d9c67d97d6f 662
emh203 0:3d9c67d97d6f 663 /* Read next two samples from scratch2 buffer */
emh203 0:3d9c67d97d6f 664 y10 = *(pScr2 + 2u);
emh203 0:3d9c67d97d6f 665 y11 = *(pScr2 + 3u);
emh203 0:3d9c67d97d6f 666
emh203 0:3d9c67d97d6f 667 /* multiply and accumlate */
emh203 0:3d9c67d97d6f 668 acc0 += (q31_t) x20 *y10;
emh203 0:3d9c67d97d6f 669 acc0 += (q31_t) x21 *y11;
emh203 0:3d9c67d97d6f 670 acc2 += (q31_t) x10 *y10;
emh203 0:3d9c67d97d6f 671 acc2 += (q31_t) x11 *y11;
emh203 0:3d9c67d97d6f 672 acc1 += (q31_t) x21 *y10;
emh203 0:3d9c67d97d6f 673 acc1 += (q31_t) x10 *y11;
emh203 0:3d9c67d97d6f 674
emh203 0:3d9c67d97d6f 675 /* Read next two samples from scratch1 buffer */
emh203 0:3d9c67d97d6f 676 x20 = *(pScr1 + 2);
emh203 0:3d9c67d97d6f 677 x21 = *(pScr1 + 3);
emh203 0:3d9c67d97d6f 678
emh203 0:3d9c67d97d6f 679 /* multiply and accumlate */
emh203 0:3d9c67d97d6f 680 acc3 += (q31_t) x11 *y10;
emh203 0:3d9c67d97d6f 681 acc3 += (q31_t) x20 *y11;
emh203 0:3d9c67d97d6f 682
emh203 0:3d9c67d97d6f 683 /* update scratch pointers */
emh203 0:3d9c67d97d6f 684
emh203 0:3d9c67d97d6f 685 pScr1 += 4u;
emh203 0:3d9c67d97d6f 686 pScr2 += 4u;
emh203 0:3d9c67d97d6f 687
emh203 0:3d9c67d97d6f 688 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 689 tapCnt--;
emh203 0:3d9c67d97d6f 690 }
emh203 0:3d9c67d97d6f 691
emh203 0:3d9c67d97d6f 692
emh203 0:3d9c67d97d6f 693
emh203 0:3d9c67d97d6f 694 /* Update scratch pointer for remaining samples of smaller length sequence */
emh203 0:3d9c67d97d6f 695 pScr1 -= 4u;
emh203 0:3d9c67d97d6f 696
emh203 0:3d9c67d97d6f 697
emh203 0:3d9c67d97d6f 698 /* apply same above for remaining samples of smaller length sequence */
emh203 0:3d9c67d97d6f 699 tapCnt = (srcBLen) & 3u;
emh203 0:3d9c67d97d6f 700
emh203 0:3d9c67d97d6f 701 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 702 {
emh203 0:3d9c67d97d6f 703
emh203 0:3d9c67d97d6f 704 /* accumlate the results */
emh203 0:3d9c67d97d6f 705 acc0 += (*pScr1++ * *pScr2);
emh203 0:3d9c67d97d6f 706 acc1 += (*pScr1++ * *pScr2);
emh203 0:3d9c67d97d6f 707 acc2 += (*pScr1++ * *pScr2);
emh203 0:3d9c67d97d6f 708 acc3 += (*pScr1++ * *pScr2++);
emh203 0:3d9c67d97d6f 709
emh203 0:3d9c67d97d6f 710 pScr1 -= 3u;
emh203 0:3d9c67d97d6f 711
emh203 0:3d9c67d97d6f 712 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 713 tapCnt--;
emh203 0:3d9c67d97d6f 714 }
emh203 0:3d9c67d97d6f 715
emh203 0:3d9c67d97d6f 716 blkCnt--;
emh203 0:3d9c67d97d6f 717
emh203 0:3d9c67d97d6f 718 /* Store the result in the accumulator in the destination buffer. */
emh203 0:3d9c67d97d6f 719 *pOut++ = (q7_t) (__SSAT(acc0 >> 7u, 8));
emh203 0:3d9c67d97d6f 720 *pOut++ = (q7_t) (__SSAT(acc1 >> 7u, 8));
emh203 0:3d9c67d97d6f 721 *pOut++ = (q7_t) (__SSAT(acc2 >> 7u, 8));
emh203 0:3d9c67d97d6f 722 *pOut++ = (q7_t) (__SSAT(acc3 >> 7u, 8));
emh203 0:3d9c67d97d6f 723
emh203 0:3d9c67d97d6f 724 /* Initialization of inputB pointer */
emh203 0:3d9c67d97d6f 725 pScr2 = py;
emh203 0:3d9c67d97d6f 726
emh203 0:3d9c67d97d6f 727 pScratch1 += 4u;
emh203 0:3d9c67d97d6f 728
emh203 0:3d9c67d97d6f 729 }
emh203 0:3d9c67d97d6f 730
emh203 0:3d9c67d97d6f 731 blkCnt = (numPoints) & 0x3;
emh203 0:3d9c67d97d6f 732
emh203 0:3d9c67d97d6f 733 /* Calculate convolution for remaining samples of Bigger length sequence */
emh203 0:3d9c67d97d6f 734 while(blkCnt > 0)
emh203 0:3d9c67d97d6f 735 {
emh203 0:3d9c67d97d6f 736 /* Initialze temporary scratch pointer as scratch1 */
emh203 0:3d9c67d97d6f 737 pScr1 = pScratch1;
emh203 0:3d9c67d97d6f 738
emh203 0:3d9c67d97d6f 739 /* Clear Accumlators */
emh203 0:3d9c67d97d6f 740 acc0 = 0;
emh203 0:3d9c67d97d6f 741
emh203 0:3d9c67d97d6f 742 tapCnt = (srcBLen) >> 1u;
emh203 0:3d9c67d97d6f 743
emh203 0:3d9c67d97d6f 744 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 745 {
emh203 0:3d9c67d97d6f 746
emh203 0:3d9c67d97d6f 747 /* Read next two samples from scratch1 buffer */
emh203 0:3d9c67d97d6f 748 x10 = *pScr1++;
emh203 0:3d9c67d97d6f 749 x11 = *pScr1++;
emh203 0:3d9c67d97d6f 750
emh203 0:3d9c67d97d6f 751 /* Read two samples from smaller buffer */
emh203 0:3d9c67d97d6f 752 y10 = *pScr2++;
emh203 0:3d9c67d97d6f 753 y11 = *pScr2++;
emh203 0:3d9c67d97d6f 754
emh203 0:3d9c67d97d6f 755 /* multiply and accumlate */
emh203 0:3d9c67d97d6f 756 acc0 += (q31_t) x10 *y10;
emh203 0:3d9c67d97d6f 757 acc0 += (q31_t) x11 *y11;
emh203 0:3d9c67d97d6f 758
emh203 0:3d9c67d97d6f 759 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 760 tapCnt--;
emh203 0:3d9c67d97d6f 761 }
emh203 0:3d9c67d97d6f 762
emh203 0:3d9c67d97d6f 763 tapCnt = (srcBLen) & 1u;
emh203 0:3d9c67d97d6f 764
emh203 0:3d9c67d97d6f 765 /* apply same above for remaining samples of smaller length sequence */
emh203 0:3d9c67d97d6f 766 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 767 {
emh203 0:3d9c67d97d6f 768
emh203 0:3d9c67d97d6f 769 /* accumlate the results */
emh203 0:3d9c67d97d6f 770 acc0 += (*pScr1++ * *pScr2++);
emh203 0:3d9c67d97d6f 771
emh203 0:3d9c67d97d6f 772 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 773 tapCnt--;
emh203 0:3d9c67d97d6f 774 }
emh203 0:3d9c67d97d6f 775
emh203 0:3d9c67d97d6f 776 blkCnt--;
emh203 0:3d9c67d97d6f 777
emh203 0:3d9c67d97d6f 778 /* Store the result in the accumulator in the destination buffer. */
emh203 0:3d9c67d97d6f 779 *pOut++ = (q7_t) (__SSAT(acc0 >> 7u, 8));
emh203 0:3d9c67d97d6f 780
emh203 0:3d9c67d97d6f 781 /* Initialization of inputB pointer */
emh203 0:3d9c67d97d6f 782 pScr2 = py;
emh203 0:3d9c67d97d6f 783
emh203 0:3d9c67d97d6f 784 pScratch1 += 1u;
emh203 0:3d9c67d97d6f 785
emh203 0:3d9c67d97d6f 786 }
emh203 0:3d9c67d97d6f 787
emh203 0:3d9c67d97d6f 788 /* set status as ARM_MATH_SUCCESS */
emh203 0:3d9c67d97d6f 789 status = ARM_MATH_SUCCESS;
emh203 0:3d9c67d97d6f 790
emh203 0:3d9c67d97d6f 791 }
emh203 0:3d9c67d97d6f 792
emh203 0:3d9c67d97d6f 793 return (status);
emh203 0:3d9c67d97d6f 794
emh203 0:3d9c67d97d6f 795 }
emh203 0:3d9c67d97d6f 796
emh203 0:3d9c67d97d6f 797 #endif /* #ifndef UNALIGNED_SUPPORT_DISABLE */
emh203 0:3d9c67d97d6f 798
emh203 0:3d9c67d97d6f 799
emh203 0:3d9c67d97d6f 800
emh203 0:3d9c67d97d6f 801 /**
emh203 0:3d9c67d97d6f 802 * @} end of PartialConv group
emh203 0:3d9c67d97d6f 803 */