- Main Page
- Modules
- Data Structures
- Files
- Examples

- File List
- Globals

# arm_fir_sparse_f32.c

Go to the documentation of this file.

    00001 /* ----------------------------------------------------------------------
    00002 * Copyright (C) 2010 ARM Limited. All rights reserved.
    00003 *
    00004 * $Date:        29. November 2010
    00005 * $Revision:    V1.0.3
    00006 *
    00007 * Project:      CMSIS DSP Library
    00008 * Title:        arm_fir_sparse_f32.c
    00009 *
    00010 * Description:  Floating-point sparse FIR filter processing function.
    00011 *
    00012 * Target Processor: Cortex-M4/Cortex-M3
    00013 *
    00014 * Version 1.0.3 2010/11/29
    00015 *    Re-organized the CMSIS folders and updated documentation.
    00016 *
    00017 * Version 1.0.2 2010/11/11
    00018 *    Documentation updated.
    00019 *
    00020 * Version 1.0.1 2010/10/05
    00021 *    Production release and review comments incorporated.
    00022 *
    00023 * Version 1.0.0 2010/09/20
    00024 *    Production release and review comments incorporated
    00025 *
    00026 * Version 0.0.7  2010/06/10
    00027 *    Misra-C changes done
    00028 * ------------------------------------------------------------------- */
    00029 #include "arm_math.h"
    00030
    00110 void arm_fir_sparse_f32(
    00111   arm_fir_sparse_instance_f32 * S,
    00112   float32_t * pSrc,
    00113   float32_t * pDst,
    00114   float32_t * pScratchIn,
    00115   uint32_t blockSize)
    00116 {
    00117
    00118   float32_t *pState = S->pState;                 /* State pointer */
    00119   float32_t *pCoeffs = S->pCoeffs;               /* Coefficient pointer */
    00120   float32_t *px;                                 /* Scratch buffer pointer */
    00121   float32_t *py = pState;                        /* Temporary pointers for state buffer */
    00122   float32_t *pb = pScratchIn;                    /* Temporary pointers for scratch buffer */
    00123   float32_t *pOut;                               /* Destination pointer */
    00124   int32_t *pTapDelay = S->pTapDelay;             /* Pointer to the array containing offset of the non-zero tap values. */
    00125   uint32_t delaySize = S->maxDelay + blockSize;  /* state length */
    00126   uint16_t numTaps = S->numTaps;                 /* Number of filter coefficients in the filter  */
    00127   int32_t readIndex;                             /* Read index of the state buffer */
    00128   uint32_t tapCnt, blkCnt;                       /* loop counters */
    00129   float32_t coeff = *pCoeffs++;                  /* Read the first coefficient value */
    00130
    00131
    00132
    00133   /* BlockSize of Input samples are copied into the state buffer */
    00134   /* StateIndex points to the starting position to write in the state buffer */
    00135   arm_circularWrite_f32((int32_t *) py, delaySize, &S->stateIndex, 1,
    00136                         (int32_t *) pSrc, 1, blockSize);
    00137
    00138
    00139   /* Read Index, from where the state buffer should be read, is calculated. */
    00140   readIndex = ((int32_t) S->stateIndex - (int32_t) blockSize) - *pTapDelay++;
    00141
    00142   /* Wraparound of readIndex */
    00143   if(readIndex < 0)
    00144   {
    00145     readIndex += (int32_t) delaySize;
    00146   }
    00147
    00148   /* Working pointer for state buffer is updated */
    00149   py = pState;
    00150
    00151   /* blockSize samples are read from the state buffer */
    00152   arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1,
    00153                        (int32_t *) pb, (int32_t *) pb, blockSize, 1,
    00154                        blockSize);
    00155
    00156   /* Working pointer for the scratch buffer */
    00157   px = pb;
    00158
    00159   /* Working pointer for destination buffer */
    00160   pOut = pDst;
    00161
    00162   /* Loop over the blockSize. Unroll by a factor of 4.
    00163    * Compute 4 Multiplications at a time. */
    00164   blkCnt = blockSize >> 2u;
    00165
    00166   while(blkCnt > 0u)
    00167   {
    00168     /* Perform Multiplications and store in destination buffer */
    00169     *pOut++ = *px++ * coeff;
    00170     *pOut++ = *px++ * coeff;
    00171     *pOut++ = *px++ * coeff;
    00172     *pOut++ = *px++ * coeff;
    00173
    00174     /* Decrement the loop counter */
    00175     blkCnt--;
    00176   }
    00177
    00178   /* If the blockSize is not a multiple of 4,
    00179    * compute the remaining samples */
    00180   blkCnt = blockSize % 0x4u;
    00181
    00182   while(blkCnt > 0u)
    00183   {
    00184     /* Perform Multiplications and store in destination buffer */
    00185     *pOut++ = *px++ * coeff;
    00186
    00187     /* Decrement the loop counter */
    00188     blkCnt--;
    00189   }
    00190
    00191   /* Load the coefficient value and
    00192    * increment the coefficient buffer for the next set of state values */
    00193   coeff = *pCoeffs++;
    00194
    00195   /* Read Index, from where the state buffer should be read, is calculated. */
    00196   readIndex = ((int32_t) S->stateIndex - (int32_t) blockSize) - *pTapDelay++;
    00197
    00198   /* Wraparound of readIndex */
    00199   if(readIndex < 0)
    00200   {
    00201     readIndex += (int32_t) delaySize;
    00202   }
    00203
    00204   /* Loop over the number of taps. */
    00205   tapCnt = (uint32_t) numTaps - 1u;
    00206
    00207   while(tapCnt > 0u)
    00208   {
    00209
    00210     /* Working pointer for state buffer is updated */
    00211     py = pState;
    00212
    00213     /* blockSize samples are read from the state buffer */
    00214     arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1,
    00215                          (int32_t *) pb, (int32_t *) pb, blockSize, 1,
    00216                          blockSize);
    00217
    00218     /* Working pointer for the scratch buffer */
    00219     px = pb;
    00220
    00221     /* Working pointer for destination buffer */
    00222     pOut = pDst;
    00223
    00224     /* Loop over the blockSize. Unroll by a factor of 4.
    00225      * Compute 4 MACS at a time. */
    00226     blkCnt = blockSize >> 2u;
    00227
    00228     while(blkCnt > 0u)
    00229     {
    00230       /* Perform Multiply-Accumulate */
    00231       *pOut++ += *px++ * coeff;
    00232       *pOut++ += *px++ * coeff;
    00233       *pOut++ += *px++ * coeff;
    00234       *pOut++ += *px++ * coeff;
    00235
    00236       /* Decrement the loop counter */
    00237       blkCnt--;
    00238     }
    00239
    00240     /* If the blockSize is not a multiple of 4,
    00241      * compute the remaining samples */
    00242     blkCnt = blockSize % 0x4u;
    00243
    00244     while(blkCnt > 0u)
    00245     {
    00246       /* Perform Multiply-Accumulate */
    00247       *pOut++ += *px++ * coeff;
    00248
    00249       /* Decrement the loop counter */
    00250       blkCnt--;
    00251     }
    00252
    00253     /* Load the coefficient value and
    00254      * increment the coefficient buffer for the next set of state values */
    00255     coeff = *pCoeffs++;
    00256
    00257     /* Read Index, from where the state buffer should be read, is calculated. */
    00258     readIndex = ((int32_t) S->stateIndex -
    00259                  (int32_t) blockSize) - *pTapDelay++;
    00260
    00261     /* Wraparound of readIndex */
    00262     if(readIndex < 0)
    00263     {
    00264       readIndex += (int32_t) delaySize;
    00265     }
    00266
    00267     /* Decrement the tap loop counter */
    00268     tapCnt--;
    00269   }
    00270
    00271 }
    00272

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines