Aded CMSIS5 DSP and NN folder. Needs some work
Embed:
(wiki syntax)
Show/hide line numbers
arm_q15_to_q31.c
00001 /* ---------------------------------------------------------------------- 00002 * Project: CMSIS DSP Library 00003 * Title: arm_q15_to_q31.c 00004 * Description: Converts the elements of the Q15 vector to Q31 vector 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 groupSupport 00033 */ 00034 00035 /** 00036 * @addtogroup q15_to_x 00037 * @{ 00038 */ 00039 00040 /** 00041 * @brief Converts the elements of the Q15 vector to Q31 vector. 00042 * @param[in] *pSrc points to the Q15 input vector 00043 * @param[out] *pDst points to the Q31 output vector 00044 * @param[in] blockSize length of the input vector 00045 * @return none. 00046 * 00047 * \par Description: 00048 * 00049 * The equation used for the conversion process is: 00050 * 00051 * <pre> 00052 * pDst[n] = (q31_t) pSrc[n] << 16; 0 <= n < blockSize. 00053 * </pre> 00054 * 00055 */ 00056 00057 00058 void arm_q15_to_q31( 00059 q15_t * pSrc, 00060 q31_t * pDst, 00061 uint32_t blockSize) 00062 { 00063 q15_t *pIn = pSrc; /* Src pointer */ 00064 uint32_t blkCnt; /* loop counter */ 00065 00066 #if defined (ARM_MATH_DSP) 00067 00068 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00069 q31_t in1, in2; 00070 q31_t out1, out2, out3, out4; 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 = (q31_t)A << 16 */ 00080 /* convert from q15 to q31 and then store the results in the destination buffer */ 00081 in1 = *__SIMD32(pIn)++; 00082 in2 = *__SIMD32(pIn)++; 00083 00084 #ifndef ARM_MATH_BIG_ENDIAN 00085 00086 /* extract lower 16 bits to 32 bit result */ 00087 out1 = in1 << 16U; 00088 /* extract upper 16 bits to 32 bit result */ 00089 out2 = in1 & 0xFFFF0000; 00090 /* extract lower 16 bits to 32 bit result */ 00091 out3 = in2 << 16U; 00092 /* extract upper 16 bits to 32 bit result */ 00093 out4 = in2 & 0xFFFF0000; 00094 00095 #else 00096 00097 /* extract upper 16 bits to 32 bit result */ 00098 out1 = in1 & 0xFFFF0000; 00099 /* extract lower 16 bits to 32 bit result */ 00100 out2 = in1 << 16U; 00101 /* extract upper 16 bits to 32 bit result */ 00102 out3 = in2 & 0xFFFF0000; 00103 /* extract lower 16 bits to 32 bit result */ 00104 out4 = in2 << 16U; 00105 00106 #endif // #ifndef ARM_MATH_BIG_ENDIAN 00107 00108 *pDst++ = out1; 00109 *pDst++ = out2; 00110 *pDst++ = out3; 00111 *pDst++ = out4; 00112 00113 /* Decrement the loop counter */ 00114 blkCnt--; 00115 } 00116 00117 /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 00118 ** No loop unrolling is used. */ 00119 blkCnt = blockSize % 0x4U; 00120 00121 #else 00122 00123 /* Run the below code for Cortex-M0 */ 00124 00125 /* Loop over blockSize number of values */ 00126 blkCnt = blockSize; 00127 00128 #endif /* #if defined (ARM_MATH_DSP) */ 00129 00130 while (blkCnt > 0U) 00131 { 00132 /* C = (q31_t)A << 16 */ 00133 /* convert from q15 to q31 and then store the results in the destination buffer */ 00134 *pDst++ = (q31_t) * pIn++ << 16; 00135 00136 /* Decrement the loop counter */ 00137 blkCnt--; 00138 } 00139 00140 } 00141 00142 /** 00143 * @} end of q15_to_x group 00144 */ 00145
Generated on Tue Jul 12 2022 16:47:27 by 1.7.2