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_dot_prod_q15.c 00009 * 00010 * Description: Processing function for the Q15 Complex Dot product 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 00059 void arm_cmplx_dot_prod_q15( 00060 q15_t * pSrcA, 00061 q15_t * pSrcB, 00062 uint32_t numSamples, 00063 q31_t * realResult, 00064 q31_t * imagResult) 00065 { 00066 q63_t real_sum = 0, imag_sum = 0; /* Temporary result storage */ 00067 00068 #ifndef ARM_MATH_CM0 00069 00070 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00071 uint32_t blkCnt; /* loop counter */ 00072 00073 00074 /*loop Unrolling */ 00075 blkCnt = numSamples >> 2u; 00076 00077 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00078 ** a second loop below computes the remaining 1 to 3 samples. */ 00079 while(blkCnt > 0u) 00080 { 00081 /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */ 00082 real_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00083 00084 /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */ 00085 imag_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00086 00087 real_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00088 imag_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00089 00090 real_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00091 imag_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00092 00093 real_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00094 imag_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00095 00096 /* Decrement the loop counter */ 00097 blkCnt--; 00098 } 00099 00100 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00101 ** No loop unrolling is used. */ 00102 blkCnt = numSamples % 0x4u; 00103 00104 while(blkCnt > 0u) 00105 { 00106 /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */ 00107 real_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00108 /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */ 00109 imag_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00110 00111 /* Decrement the loop counter */ 00112 blkCnt--; 00113 } 00114 00115 #else 00116 00117 /* Run the below code for Cortex-M0 */ 00118 00119 while(numSamples > 0u) 00120 { 00121 /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */ 00122 real_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00123 /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */ 00124 imag_sum += ((q31_t) * pSrcA++ * *pSrcB++); 00125 00126 /* Decrement the loop counter */ 00127 numSamples--; 00128 } 00129 00130 #endif /* #ifndef ARM_MATH_CM0 */ 00131 00132 /* Store the real and imaginary results in 8.24 format */ 00133 /* Convert real data in 34.30 to 8.24 by 6 right shifts */ 00134 *realResult = (q31_t) (real_sum) >> 6; 00135 /* Convert imaginary data in 34.30 to 8.24 by 6 right shifts */ 00136 *imagResult = (q31_t) (imag_sum) >> 6; 00137 } 00138