CMSIS DSP Software Library: arm_cmplx_mult_real_q15.c Source File

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

- File List
- Globals

# arm_cmplx_mult_real_q15.c

Go to the documentation of this file.

    00001 /* ----------------------------------------------------------------------
    00002 * Copyright (C) 2010 ARM Limited. All rights reserved.
    00003 *
    00004 * $Date:        15. July 2011
    00005 * $Revision:    V1.0.10
    00006 *
    00007 * Project:      CMSIS DSP Library
    00008 * Title:        arm_cmplx_mult_real_q15.c
    00009 *
    00010 * Description:  Q15 complex by real multiplication
    00011 *
    00012 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
    00013 *
    00014 * Version 1.0.10 2011/7/15
    00015 *    Big Endian support added and Merged M0 and M3/M4 Source code.
    00016 *
    00017 * Version 1.0.3 2010/11/29
    00018 *    Re-organized the CMSIS folders and updated documentation.
    00019 *
    00020 * Version 1.0.2 2010/11/11
    00021 *    Documentation updated.
    00022 *
    00023 * Version 1.0.1 2010/10/05
    00024 *    Production release and review comments incorporated.
    00025 *
    00026 * Version 1.0.0 2010/09/20
    00027 *    Production release and review comments incorporated.
    00028 * -------------------------------------------------------------------- */
    00029
    00030 #include "arm_math.h"
    00031
    00056 void arm_cmplx_mult_real_q15(
    00057   q15_t * pSrcCmplx,
    00058   q15_t * pSrcReal,
    00059   q15_t * pCmplxDst,
    00060   uint32_t numSamples)
    00061 {
    00062   q15_t in;                                      /* Temporary variable to store input value */
    00063
    00064 #ifndef ARM_MATH_CM0
    00065
    00066   /* Run the below code for Cortex-M4 and Cortex-M3 */
    00067   uint32_t blkCnt;                               /* loop counters */
    00068
    00069   /* loop Unrolling */
    00070   blkCnt = numSamples >> 2u;
    00071
    00072   /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.
    00073    ** a second loop below computes the remaining 1 to 3 samples. */
    00074   while(blkCnt > 0u)
    00075   {
    00076     /* C[2 * i] = A[2 * i] * B[i].            */
    00077     /* C[2 * i + 1] = A[2 * i + 1] * B[i].        */
    00078     in = *pSrcReal++;
    00079     /* store the result in the destination buffer. */
    00080     *pCmplxDst++ =
    00081       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00082     *pCmplxDst++ =
    00083       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00084
    00085     in = *pSrcReal++;
    00086     *pCmplxDst++ =
    00087       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00088     *pCmplxDst++ =
    00089       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00090
    00091     in = *pSrcReal++;
    00092     *pCmplxDst++ =
    00093       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00094     *pCmplxDst++ =
    00095       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00096
    00097     in = *pSrcReal++;
    00098     *pCmplxDst++ =
    00099       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00100     *pCmplxDst++ =
    00101       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00102
    00103     /* Decrement the numSamples loop counter */
    00104     blkCnt--;
    00105   }
    00106
    00107   /* If the numSamples is not a multiple of 4, compute any remaining output samples here.
    00108    ** No loop unrolling is used. */
    00109   blkCnt = numSamples % 0x4u;
    00110
    00111   while(blkCnt > 0u)
    00112   {
    00113     /* C[2 * i] = A[2 * i] * B[i].            */
    00114     /* C[2 * i + 1] = A[2 * i + 1] * B[i].        */
    00115     in = *pSrcReal++;
    00116     /* store the result in the destination buffer. */
    00117     *pCmplxDst++ =
    00118       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00119     *pCmplxDst++ =
    00120       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00121
    00122     /* Decrement the numSamples loop counter */
    00123     blkCnt--;
    00124   }
    00125
    00126 #else
    00127
    00128   /* Run the below code for Cortex-M0 */
    00129
    00130   while(numSamples > 0u)
    00131   {
    00132     /* realOut = realA * realB.            */
    00133     /* imagOut = imagA * realB.                */
    00134     in = *pSrcReal++;
    00135     /* store the result in the destination buffer. */
    00136     *pCmplxDst++ =
    00137       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00138     *pCmplxDst++ =
    00139       (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
    00140
    00141     /* Decrement the numSamples loop counter */
    00142     numSamples--;
    00143   }
    00144
    00145 #endif /* #ifndef ARM_MATH_CM0 */
    00146
    00147 }
    00148

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines