Aded CMSIS5 DSP and NN folder. Needs some work
Embed:
(wiki syntax)
Show/hide line numbers
arm_negate_q15.c
00001 /* ---------------------------------------------------------------------- 00002 * Project: CMSIS DSP Library 00003 * Title: arm_negate_q15.c 00004 * Description: Negates Q15 vectors 00005 * 00006 * $Date: 27. January 2017 00007 * $Revision: V.1.5.1 00008 * 00009 * Target Processor: Cortex-M cores 00010 * -------------------------------------------------------------------- */ 00011 /* 00012 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. 00013 * 00014 * SPDX-License-Identifier: Apache-2.0 00015 * 00016 * Licensed under the Apache License, Version 2.0 (the License); you may 00017 * not use this file except in compliance with the License. 00018 * You may obtain a copy of the License at 00019 * 00020 * www.apache.org/licenses/LICENSE-2.0 00021 * 00022 * Unless required by applicable law or agreed to in writing, software 00023 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00024 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00025 * See the License for the specific language governing permissions and 00026 * limitations under the License. 00027 */ 00028 00029 #include "arm_math.h" 00030 00031 /** 00032 * @ingroup groupMath 00033 */ 00034 00035 /** 00036 * @addtogroup negate 00037 * @{ 00038 */ 00039 00040 /** 00041 * @brief Negates the elements of a Q15 vector. 00042 * @param[in] *pSrc points to the input vector 00043 * @param[out] *pDst points to the output vector 00044 * @param[in] blockSize number of samples in the vector 00045 * @return none. 00046 * 00047 * \par Conditions for optimum performance 00048 * Input and output buffers should be aligned by 32-bit 00049 * 00050 * 00051 * <b>Scaling and Overflow Behavior:</b> 00052 * \par 00053 * The function uses saturating arithmetic. 00054 * The Q15 value -1 (0x8000) will be saturated to the maximum allowable positive value 0x7FFF. 00055 */ 00056 00057 void arm_negate_q15( 00058 q15_t * pSrc, 00059 q15_t * pDst, 00060 uint32_t blockSize) 00061 { 00062 uint32_t blkCnt; /* loop counter */ 00063 q15_t in; 00064 00065 #if defined (ARM_MATH_DSP) 00066 00067 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00068 00069 q31_t in1, in2; /* Temporary variables */ 00070 00071 00072 /*loop Unrolling */ 00073 blkCnt = blockSize >> 2U; 00074 00075 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00076 ** a second loop below computes the remaining 1 to 3 samples. */ 00077 while (blkCnt > 0U) 00078 { 00079 /* C = -A */ 00080 /* Read two inputs at a time */ 00081 in1 = _SIMD32_OFFSET(pSrc); 00082 in2 = _SIMD32_OFFSET(pSrc + 2); 00083 00084 /* negate two samples at a time */ 00085 in1 = __QSUB16(0, in1); 00086 00087 /* negate two samples at a time */ 00088 in2 = __QSUB16(0, in2); 00089 00090 /* store the result to destination 2 samples at a time */ 00091 _SIMD32_OFFSET(pDst) = in1; 00092 /* store the result to destination 2 samples at a time */ 00093 _SIMD32_OFFSET(pDst + 2) = in2; 00094 00095 00096 /* update pointers to process next samples */ 00097 pSrc += 4U; 00098 pDst += 4U; 00099 00100 /* Decrement the loop counter */ 00101 blkCnt--; 00102 } 00103 00104 /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 00105 ** No loop unrolling is used. */ 00106 blkCnt = blockSize % 0x4U; 00107 00108 #else 00109 00110 /* Run the below code for Cortex-M0 */ 00111 00112 /* Initialize blkCnt with number of samples */ 00113 blkCnt = blockSize; 00114 00115 #endif /* #if defined (ARM_MATH_DSP) */ 00116 00117 while (blkCnt > 0U) 00118 { 00119 /* C = -A */ 00120 /* Negate and then store the result in the destination buffer. */ 00121 in = *pSrc++; 00122 *pDst++ = (in == (q15_t) 0x8000) ? 0x7fff : -in; 00123 00124 /* Decrement the loop counter */ 00125 blkCnt--; 00126 } 00127 } 00128 00129 /** 00130 * @} end of negate group 00131 */ 00132
Generated on Tue Jul 12 2022 16:47:27 by 1.7.2