00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2011 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 15. December 2011 00005 * $Revision: V2.0.0 00006 * 00007 * Project: Cortex-R DSP Library 00008 * Title: arm_negate_q15.c 00009 * 00010 * Description: Negates Q15 vectors. 00011 * 00012 * Target Processor: Cortex-R4/R5 00013 * 00014 * Version 1.0.0 2011/03/08 00015 * Alpha release. 00016 * 00017 * Version 1.0.1 2011/09/30 00018 * Beta release. 00019 * 00020 * Version 2.0.0 2011/12/15 00021 * Final release. 00022 * 00023 * -------------------------------------------------------------------- */ 00024 #include "arm_math.h" 00025 00052 void arm_negate_q15( 00053 q15_t * pSrc, 00054 q15_t * pDst, 00055 uint32_t blockSize) 00056 { 00057 uint32_t blkCnt; /* loop counter */ 00058 q15_t in; /* Temporary variables */ 00059 q31_t in1, in2, in3, in4; /* Temporary variables */ 00060 00061 00062 /*loop Unrolling */ 00063 blkCnt = blockSize >> 3u; 00064 00065 /* First part of the processing with loop unrolling. Compute 8 outputs at a time. 00066 ** a second loop below computes the remaining 1 to 7 samples. */ 00067 while(blkCnt > 0u) 00068 { 00069 /* C = -A */ 00070 /* Read two inputs at a time */ 00071 in1 = _SIMD32_OFFSET(pSrc); 00072 in2 = _SIMD32_OFFSET(pSrc + 2); 00073 00074 /* negate two samples at a time */ 00075 in1 = __QSUB16(0, in1); 00076 00077 /* Read two inputs at a time */ 00078 in3 = _SIMD32_OFFSET(pSrc + 4); 00079 00080 /* negate two samples at a time */ 00081 in2 = __QSUB16(0, in2); 00082 00083 /* Read two inputs at a time */ 00084 in4 = _SIMD32_OFFSET(pSrc + 6); 00085 00086 /* store the result to destination 2 samples at a time */ 00087 _SIMD32_OFFSET(pDst) = in1; 00088 00089 /* negate two samples at a time */ 00090 in3 = __QSUB16(0, in3); 00091 00092 /* store the result to destination 2 samples at a time */ 00093 _SIMD32_OFFSET(pDst + 2) = in2; 00094 00095 /* negate two samples at a time */ 00096 in4 = __QSUB16(0, in4); 00097 00098 /* store the result to destination 2 samples at a time */ 00099 _SIMD32_OFFSET(pDst + 4) = in3; 00100 00101 /* increment source pointer by 8 to process next samples */ 00102 pSrc += 8u; 00103 00104 /* store the result to destination 2 samples at a time */ 00105 _SIMD32_OFFSET(pDst + 6) = in4; 00106 00107 /* increment destination pointer by 8 */ 00108 pDst += 8u; 00109 00110 /* Decrement the loop counter */ 00111 blkCnt--; 00112 } 00113 00114 /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 00115 ** No loop unrolling is used. */ 00116 blkCnt = blockSize % 0x8u; 00117 00118 while(blkCnt > 0u) 00119 { 00120 /* C = -A */ 00121 /* Negate and then store the result in the destination buffer. */ 00122 in = *pSrc++; 00123 00124 *pDst++ = __QSUB16(0, in); 00125 00126 /* Decrement the loop counter */ 00127 blkCnt--; 00128 } 00129 } 00130