diff options
Diffstat (limited to 'Drivers/CMSIS/DSP/Source/SupportFunctions')
22 files changed, 2998 insertions, 3924 deletions
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/CMakeLists.txt b/Drivers/CMSIS/DSP/Source/SupportFunctions/CMakeLists.txt index 41b13f2..4aae003 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/CMakeLists.txt +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/CMakeLists.txt @@ -1,28 +1,16 @@ -cmake_minimum_required (VERSION 3.14) - -project(CMSISDSPSupport) - -include(configLib) -include(configDsp) - -file(GLOB SRC "./*_*.c") - -add_library(CMSISDSPSupport STATIC ${SRC}) - -configLib(CMSISDSPSupport ${ROOT}) -configDsp(CMSISDSPSupport ${ROOT}) - -### Includes -target_include_directories(CMSISDSPSupport PUBLIC "${DSP}/Include") - -if ((NOT ARMAC5) AND (NOT DISABLEFLOAT16)) -target_sources(CMSISDSPSupport PRIVATE arm_copy_f16.c) -target_sources(CMSISDSPSupport PRIVATE arm_fill_f16.c) -target_sources(CMSISDSPSupport PRIVATE arm_f16_to_q15.c) -target_sources(CMSISDSPSupport PRIVATE arm_q15_to_f16.c) -target_sources(CMSISDSPSupport PRIVATE arm_float_to_f16.c) -target_sources(CMSISDSPSupport PRIVATE arm_f16_to_float.c) -target_sources(CMSISDSPSupport PRIVATE arm_weighted_sum_f16.c) -target_sources(CMSISDSPSupport PRIVATE arm_barycenter_f16.c) -endif() - +cmake_minimum_required (VERSION 3.6)
+
+project(CMSISDSPSupport)
+
+
+file(GLOB SRC "./*_*.c")
+
+add_library(CMSISDSPSupport STATIC ${SRC})
+
+configdsp(CMSISDSPSupport ..)
+
+### Includes
+target_include_directories(CMSISDSPSupport PUBLIC "${DSP}/../../Include")
+
+
+
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/SupportFunctions.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/SupportFunctions.c index ca8b1b6..d1ab9d4 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/SupportFunctions.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/SupportFunctions.c @@ -1,63 +1,48 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: SupportFunctions.c - * Description: Combination of all support function source files. - * - * $Date: 16. March 2020 - * $Revision: V1.1.0 - * - * Target Processor: Cortex-M cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2019-2020 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "arm_barycenter_f32.c" -#include "arm_bitonic_sort_f32.c" -#include "arm_bubble_sort_f32.c" -#include "arm_copy_f32.c" -#include "arm_copy_f64.c" -#include "arm_copy_q15.c" -#include "arm_copy_q31.c" -#include "arm_copy_q7.c" -#include "arm_fill_f32.c" -#include "arm_fill_f64.c" -#include "arm_fill_q15.c" -#include "arm_fill_q31.c" -#include "arm_fill_q7.c" -#include "arm_heap_sort_f32.c" -#include "arm_insertion_sort_f32.c" -#include "arm_merge_sort_f32.c" -#include "arm_merge_sort_init_f32.c" -#include "arm_quick_sort_f32.c" -#include "arm_selection_sort_f32.c" -#include "arm_sort_f32.c" -#include "arm_sort_init_f32.c" -#include "arm_weighted_sum_f32.c" - -#include "arm_float_to_q15.c" -#include "arm_float_to_q31.c" -#include "arm_float_to_q7.c" -#include "arm_q15_to_float.c" -#include "arm_q15_to_q31.c" -#include "arm_q15_to_q7.c" -#include "arm_q31_to_float.c" -#include "arm_q31_to_q15.c" -#include "arm_q31_to_q7.c" -#include "arm_q7_to_float.c" -#include "arm_q7_to_q15.c" -#include "arm_q7_to_q31.c" +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: SupportFunctions.c
+ * Description: Combination of all support function source files.
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.0.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_copy_f32.c"
+#include "arm_copy_q15.c"
+#include "arm_copy_q31.c"
+#include "arm_copy_q7.c"
+#include "arm_fill_f32.c"
+#include "arm_fill_q15.c"
+#include "arm_fill_q31.c"
+#include "arm_fill_q7.c"
+#include "arm_float_to_q15.c"
+#include "arm_float_to_q31.c"
+#include "arm_float_to_q7.c"
+#include "arm_q15_to_float.c"
+#include "arm_q15_to_q31.c"
+#include "arm_q15_to_q7.c"
+#include "arm_q31_to_float.c"
+#include "arm_q31_to_q15.c"
+#include "arm_q31_to_q7.c"
+#include "arm_q7_to_float.c"
+#include "arm_q7_to_q15.c"
+#include "arm_q7_to_q31.c"
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_f32.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_f32.c index d739f7c..a4eb606 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_f32.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_f32.c @@ -1,192 +1,152 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_copy_f32.c - * Description: Copies the elements of a floating-point vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @defgroup copy Vector Copy - - Copies sample by sample from source vector to destination vector. - - <pre> - pDst[n] = pSrc[n]; 0 <= n < blockSize. - </pre> - - There are separate functions for floating point, Q31, Q15, and Q7 data types. - */ - -/** - @addtogroup copy - @{ - */ - -/** - @brief Copies the elements of a floating-point vector. - @param[in] pSrc points to input vector - @param[out] pDst points to output vector - @param[in] blockSize number of samples in each vector - @return none - */ -#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) - -void arm_copy_f32( - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; - blkCnt = blockSize >> 2U; - - /* Compute 4 outputs at a time */ - while (blkCnt > 0U) - { - vstrwq_f32(pDst, vldrwq_f32(pSrc)); - /* - * Decrement the blockSize loop counter - * Advance vector source and destination pointers - */ - pSrc += 4; - pDst += 4; - blkCnt --; - } - - blkCnt = blockSize & 3; - - while (blkCnt > 0U) - { - /* C = A */ - - /* Copy and store result in destination buffer */ - *pDst++ = *pSrc++; - - /* Decrement loop counter */ - blkCnt--; - } - -} - -#else -#if defined(ARM_MATH_NEON_EXPERIMENTAL) -void arm_copy_f32( - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* loop counter */ - - float32x4_t inV; - - blkCnt = blockSize >> 2U; - - /* Compute 4 outputs at a time. - ** a second loop below computes the remaining 1 to 3 samples. */ - while (blkCnt > 0U) - { - /* C = A */ - /* Copy and then store the results in the destination buffer */ - inV = vld1q_f32(pSrc); - vst1q_f32(pDst, inV); - pSrc += 4; - pDst += 4; - - /* Decrement the loop counter */ - blkCnt--; - } - - /* If the blockSize is not a multiple of 4, compute any remaining output samples here. - ** No loop unrolling is used. */ - blkCnt = blockSize & 3; - - while (blkCnt > 0U) - { - /* C = A */ - /* Copy and then store the results in the destination buffer */ - *pDst++ = *pSrc++; - - /* Decrement the loop counter */ - blkCnt--; - } -} -#else -void arm_copy_f32( - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = A */ - - /* Copy and store result in destination buffer */ - *pDst++ = *pSrc++; - *pDst++ = *pSrc++; - *pDst++ = *pSrc++; - *pDst++ = *pSrc++; - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = A */ - - /* Copy and store result in destination buffer */ - *pDst++ = *pSrc++; - - /* Decrement loop counter */ - blkCnt--; - } -} -#endif /* #if defined(ARM_MATH_NEON) */ -#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */ - -/** - @} end of BasicCopy group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_copy_f32.c
+ * Description: Copies the elements of a floating-point vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @defgroup copy Vector Copy
+
+ Copies sample by sample from source vector to destination vector.
+
+ <pre>
+ pDst[n] = pSrc[n]; 0 <= n < blockSize.
+ </pre>
+
+ There are separate functions for floating point, Q31, Q15, and Q7 data types.
+ */
+
+/**
+ @addtogroup copy
+ @{
+ */
+
+/**
+ @brief Copies the elements of a floating-point vector.
+ @param[in] pSrc points to input vector
+ @param[out] pDst points to output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+ */
+
+#if defined(ARM_MATH_NEON_EXPERIMENTAL)
+void arm_copy_f32(
+ const float32_t * pSrc,
+ float32_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* loop counter */
+
+ float32x4_t inV;
+
+ blkCnt = blockSize >> 2U;
+
+ /* Compute 4 outputs at a time.
+ ** a second loop below computes the remaining 1 to 3 samples. */
+ while (blkCnt > 0U)
+ {
+ /* C = A */
+ /* Copy and then store the results in the destination buffer */
+ inV = vld1q_f32(pSrc);
+ vst1q_f32(pDst, inV);
+ pSrc += 4;
+ pDst += 4;
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+
+ /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
+ ** No loop unrolling is used. */
+ blkCnt = blockSize & 3;
+
+ while (blkCnt > 0U)
+ {
+ /* C = A */
+ /* Copy and then store the results in the destination buffer */
+ *pDst++ = *pSrc++;
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+}
+#else
+void arm_copy_f32(
+ const float32_t * pSrc,
+ float32_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = A */
+
+ /* Copy and store result in destination buffer */
+ *pDst++ = *pSrc++;
+ *pDst++ = *pSrc++;
+ *pDst++ = *pSrc++;
+ *pDst++ = *pSrc++;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = A */
+
+ /* Copy and store result in destination buffer */
+ *pDst++ = *pSrc++;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+}
+#endif /* #if defined(ARM_MATH_NEON) */
+/**
+ @} end of BasicCopy group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q15.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q15.c index 18f3387..0a356e7 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q15.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q15.c @@ -1,130 +1,96 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_copy_q15.c - * Description: Copies the elements of a Q15 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup copy - @{ - */ - -/** - @brief Copies the elements of a Q15 vector. - @param[in] pSrc points to input vector - @param[out] pDst points to output vector - @param[in] blockSize number of samples in each vector - @return none - */ -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_copy_q15( - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; - - blkCnt = blockSize >> 3; - while (blkCnt > 0U) - { - vstrhq_s16(pDst,vldrhq_s16(pSrc)); - /* - * Decrement the blockSize loop counter - * Advance vector source and destination pointers - */ - pSrc += 8; - pDst += 8; - blkCnt --; - } - - blkCnt = blockSize & 7; - while (blkCnt > 0U) - { - /* C = A */ - - /* Copy and store result in destination buffer */ - *pDst++ = *pSrc++; - - /* Decrement loop counter */ - blkCnt--; - } -} -#else -void arm_copy_q15( - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = A */ - - /* read 2 times 2 samples at a time */ - write_q15x2_ia (&pDst, read_q15x2_ia (&pSrc)); - write_q15x2_ia (&pDst, read_q15x2_ia (&pSrc)); - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = A */ - - /* Copy and store result in destination buffer */ - *pDst++ = *pSrc++; - - /* Decrement loop counter */ - blkCnt--; - } -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of BasicCopy group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_copy_q15.c
+ * Description: Copies the elements of a Q15 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup copy
+ @{
+ */
+
+/**
+ @brief Copies the elements of a Q15 vector.
+ @param[in] pSrc points to input vector
+ @param[out] pDst points to output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+ */
+
+void arm_copy_q15(
+ const q15_t * pSrc,
+ q15_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = A */
+
+ /* read 2 times 2 samples at a time */
+ write_q15x2_ia (&pDst, read_q15x2_ia ((q15_t **) &pSrc));
+ write_q15x2_ia (&pDst, read_q15x2_ia ((q15_t **) &pSrc));
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = A */
+
+ /* Copy and store result in destination buffer */
+ *pDst++ = *pSrc++;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+}
+
+/**
+ @} end of BasicCopy group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q31.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q31.c index 8e06bda..7221715 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q31.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q31.c @@ -1,135 +1,98 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_copy_q31.c - * Description: Copies the elements of a Q31 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup copy - @{ - */ - -/** - @brief Copies the elements of a Q31 vector. - @param[in] pSrc points to input vector - @param[out] pDst points to output vector - @param[in] blockSize number of samples in each vector - @return none - */ -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_copy_q31( - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; - blkCnt = blockSize >> 2U; - - /* Compute 4 outputs at a time */ - while (blkCnt > 0U) - { - vstrwq_s32(pDst,vldrwq_s32(pSrc)); - /* - * Decrement the blockSize loop counter - * Advance vector source and destination pointers - */ - pSrc += 4; - pDst += 4; - blkCnt --; - } - - blkCnt = blockSize & 3; - while (blkCnt > 0U) - { - /* C = A */ - - /* Copy and store result in destination buffer */ - *pDst++ = *pSrc++; - - /* Decrement loop counter */ - blkCnt--; - } - -} - -#else -void arm_copy_q31( - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = A */ - - /* Copy and store result in destination buffer */ - *pDst++ = *pSrc++; - *pDst++ = *pSrc++; - *pDst++ = *pSrc++; - *pDst++ = *pSrc++; - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = A */ - - /* Copy and store result in destination buffer */ - *pDst++ = *pSrc++; - - /* Decrement loop counter */ - blkCnt--; - } -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of BasicCopy group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_copy_q31.c
+ * Description: Copies the elements of a Q31 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup copy
+ @{
+ */
+
+/**
+ @brief Copies the elements of a Q31 vector.
+ @param[in] pSrc points to input vector
+ @param[out] pDst points to output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+ */
+
+void arm_copy_q31(
+ const q31_t * pSrc,
+ q31_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = A */
+
+ /* Copy and store result in destination buffer */
+ *pDst++ = *pSrc++;
+ *pDst++ = *pSrc++;
+ *pDst++ = *pSrc++;
+ *pDst++ = *pSrc++;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = A */
+
+ /* Copy and store result in destination buffer */
+ *pDst++ = *pSrc++;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+}
+
+/**
+ @} end of BasicCopy group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q7.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q7.c index 1918d3e..3d35888 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q7.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_copy_q7.c @@ -1,132 +1,95 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_copy_q7.c - * Description: Copies the elements of a Q7 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup copy - @{ - */ - -/** - @brief Copies the elements of a Q7 vector. - @param[in] pSrc points to input vector - @param[out] pDst points to output vector - @param[in] blockSize number of samples in each vector - @return none - */ -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_copy_q7( - const q7_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - - uint32_t blkCnt; - - blkCnt = blockSize >> 4; - while (blkCnt > 0U) - { - - vstrbq_s8(pDst,vldrbq_s8(pSrc)); - /* - * Decrement the blockSize loop counter - * Advance vector source and destination pointers - */ - pSrc += 16; - pDst += 16; - blkCnt --; - } - - blkCnt = blockSize & 0xF; - while (blkCnt > 0U) - { - /* C = A */ - - /* Copy and store result in destination buffer */ - *pDst++ = *pSrc++; - - /* Decrement loop counter */ - blkCnt--; - } -} - -#else -void arm_copy_q7( - const q7_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = A */ - - /* read 4 samples at a time */ - write_q7x4_ia (&pDst, read_q7x4_ia (&pSrc)); - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = A */ - - /* Copy and store result in destination buffer */ - *pDst++ = *pSrc++; - - /* Decrement loop counter */ - blkCnt--; - } -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of BasicCopy group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_copy_q7.c
+ * Description: Copies the elements of a Q7 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup copy
+ @{
+ */
+
+/**
+ @brief Copies the elements of a Q7 vector.
+ @param[in] pSrc points to input vector
+ @param[out] pDst points to output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+ */
+
+void arm_copy_q7(
+ const q7_t * pSrc,
+ q7_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = A */
+
+ /* read 4 samples at a time */
+ write_q7x4_ia (&pDst, read_q7x4_ia ((q7_t **) &pSrc));
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = A */
+
+ /* Copy and store result in destination buffer */
+ *pDst++ = *pSrc++;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+}
+
+/**
+ @} end of BasicCopy group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_f32.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_f32.c index 50cdd8f..e4f9301 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_f32.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_f32.c @@ -1,189 +1,151 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_fill_f32.c - * Description: Fills a constant value into a floating-point vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @defgroup Fill Vector Fill - - Fills the destination vector with a constant value. - - <pre> - pDst[n] = value; 0 <= n < blockSize. - </pre> - - There are separate functions for floating point, Q31, Q15, and Q7 data types. - */ - -/** - @addtogroup Fill - @{ - */ - -/** - @brief Fills a constant value into a floating-point vector. - @param[in] value input value to be filled - @param[out] pDst points to output vector - @param[in] blockSize number of samples in each vector - @return none - */ -#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_fill_f32( - float32_t value, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; - blkCnt = blockSize >> 2U; - - /* Compute 4 outputs at a time */ - while (blkCnt > 0U) - { - - vstrwq_f32(pDst,vdupq_n_f32(value)); - /* - * Decrement the blockSize loop counter - * Advance vector source and destination pointers - */ - pDst += 4; - blkCnt --; - } - - blkCnt = blockSize & 3; - - while (blkCnt > 0U) - { - /* C = value */ - - /* Fill value in destination buffer */ - *pDst++ = value; - - /* Decrement loop counter */ - blkCnt--; - } - -} -#else -#if defined(ARM_MATH_NEON_EXPERIMENTAL) -void arm_fill_f32( - float32_t value, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* loop counter */ - - - float32x4_t inV = vdupq_n_f32(value); - - blkCnt = blockSize >> 2U; - - /* Compute 4 outputs at a time. - ** a second loop below computes the remaining 1 to 3 samples. */ - while (blkCnt > 0U) - { - /* C = value */ - /* Fill the value in the destination buffer */ - vst1q_f32(pDst, inV); - pDst += 4; - - /* Decrement the loop counter */ - blkCnt--; - } - - /* If the blockSize is not a multiple of 4, compute any remaining output samples here. - ** No loop unrolling is used. */ - blkCnt = blockSize & 3; - - while (blkCnt > 0U) - { - /* C = value */ - /* Fill the value in the destination buffer */ - *pDst++ = value; - - /* Decrement the loop counter */ - blkCnt--; - } -} -#else -void arm_fill_f32( - float32_t value, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = value */ - - /* Fill value in destination buffer */ - *pDst++ = value; - *pDst++ = value; - *pDst++ = value; - *pDst++ = value; - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = value */ - - /* Fill value in destination buffer */ - *pDst++ = value; - - /* Decrement loop counter */ - blkCnt--; - } -} -#endif /* #if defined(ARM_MATH_NEON) */ -#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */ - -/** - @} end of Fill group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_fill_f32.c
+ * Description: Fills a constant value into a floating-point vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @defgroup Fill Vector Fill
+
+ Fills the destination vector with a constant value.
+
+ <pre>
+ pDst[n] = value; 0 <= n < blockSize.
+ </pre>
+
+ There are separate functions for floating point, Q31, Q15, and Q7 data types.
+ */
+
+/**
+ @addtogroup Fill
+ @{
+ */
+
+/**
+ @brief Fills a constant value into a floating-point vector.
+ @param[in] value input value to be filled
+ @param[out] pDst points to output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+ */
+
+#if defined(ARM_MATH_NEON_EXPERIMENTAL)
+void arm_fill_f32(
+ float32_t value,
+ float32_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* loop counter */
+
+
+ float32x4_t inV = vdupq_n_f32(value);
+
+ blkCnt = blockSize >> 2U;
+
+ /* Compute 4 outputs at a time.
+ ** a second loop below computes the remaining 1 to 3 samples. */
+ while (blkCnt > 0U)
+ {
+ /* C = value */
+ /* Fill the value in the destination buffer */
+ vst1q_f32(pDst, inV);
+ pDst += 4;
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+
+ /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
+ ** No loop unrolling is used. */
+ blkCnt = blockSize & 3;
+
+ while (blkCnt > 0U)
+ {
+ /* C = value */
+ /* Fill the value in the destination buffer */
+ *pDst++ = value;
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+}
+#else
+void arm_fill_f32(
+ float32_t value,
+ float32_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = value */
+
+ /* Fill value in destination buffer */
+ *pDst++ = value;
+ *pDst++ = value;
+ *pDst++ = value;
+ *pDst++ = value;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = value */
+
+ /* Fill value in destination buffer */
+ *pDst++ = value;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+}
+#endif /* #if defined(ARM_MATH_NEON) */
+/**
+ @} end of Fill group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q15.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q15.c index 997a728..6296678 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q15.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q15.c @@ -1,134 +1,100 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_fill_q15.c - * Description: Fills a constant value into a Q15 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup Fill - @{ - */ - -/** - @brief Fills a constant value into a Q15 vector. - @param[in] value input value to be filled - @param[out] pDst points to output vector - @param[in] blockSize number of samples in each vector - @return none - */ -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_fill_q15( - q15_t value, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; - blkCnt = blockSize >> 3; - while (blkCnt > 0U) - { - - vstrhq_s16(pDst,vdupq_n_s16(value)); - /* - * Decrement the blockSize loop counter - * Advance vector source and destination pointers - */ - pDst += 8; - blkCnt --; - } - - blkCnt = blockSize & 7; - while (blkCnt > 0U) - { - /* C = value */ - - /* Fill value in destination buffer */ - *pDst++ = value; - - /* Decrement loop counter */ - blkCnt--; - } -} - -#else -void arm_fill_q15( - q15_t value, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - -#if defined (ARM_MATH_LOOPUNROLL) - q31_t packedValue; /* value packed to 32 bits */ - - /* Packing two 16 bit values to 32 bit value in order to use SIMD */ - packedValue = __PKHBT(value, value, 16U); - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = value */ - - /* fill 2 times 2 samples at a time */ - write_q15x2_ia (&pDst, packedValue); - write_q15x2_ia (&pDst, packedValue); - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = value */ - - /* Fill value in destination buffer */ - *pDst++ = value; - - /* Decrement loop counter */ - blkCnt--; - } -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of Fill group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_fill_q15.c
+ * Description: Fills a constant value into a Q15 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup Fill
+ @{
+ */
+
+/**
+ @brief Fills a constant value into a Q15 vector.
+ @param[in] value input value to be filled
+ @param[out] pDst points to output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+ */
+
+void arm_fill_q15(
+ q15_t value,
+ q15_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+ q31_t packedValue; /* value packed to 32 bits */
+
+ /* Packing two 16 bit values to 32 bit value in order to use SIMD */
+ packedValue = __PKHBT(value, value, 16U);
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = value */
+
+ /* fill 2 times 2 samples at a time */
+ write_q15x2_ia (&pDst, packedValue);
+ write_q15x2_ia (&pDst, packedValue);
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = value */
+
+ /* Fill value in destination buffer */
+ *pDst++ = value;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+}
+
+/**
+ @} end of Fill group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q31.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q31.c index 7da5fb6..001b862 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q31.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q31.c @@ -1,135 +1,98 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_fill_q31.c - * Description: Fills a constant value into a Q31 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup Fill - @{ - */ - -/** - @brief Fills a constant value into a Q31 vector. - @param[in] value input value to be filled - @param[out] pDst points to output vector - @param[in] blockSize number of samples in each vector - @return none - */ -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_fill_q31( - q31_t value, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; - blkCnt = blockSize >> 2U; - - /* Compute 4 outputs at a time */ - while (blkCnt > 0U) - { - - vstrwq_s32(pDst,vdupq_n_s32(value)); - /* - * Decrement the blockSize loop counter - * Advance vector source and destination pointers - */ - pDst += 4; - blkCnt --; - } - - blkCnt = blockSize & 3; - while (blkCnt > 0U) - { - /* C = value */ - - /* Fill value in destination buffer */ - *pDst++ = value; - - /* Decrement loop counter */ - blkCnt--; - } - -} - -#else -void arm_fill_q31( - q31_t value, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = value */ - - /* Fill value in destination buffer */ - *pDst++ = value; - *pDst++ = value; - *pDst++ = value; - *pDst++ = value; - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = value */ - - /* Fill value in destination buffer */ - *pDst++ = value; - - /* Decrement loop counter */ - blkCnt--; - } -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of Fill group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_fill_q31.c
+ * Description: Fills a constant value into a Q31 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup Fill
+ @{
+ */
+
+/**
+ @brief Fills a constant value into a Q31 vector.
+ @param[in] value input value to be filled
+ @param[out] pDst points to output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+ */
+
+void arm_fill_q31(
+ q31_t value,
+ q31_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = value */
+
+ /* Fill value in destination buffer */
+ *pDst++ = value;
+ *pDst++ = value;
+ *pDst++ = value;
+ *pDst++ = value;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = value */
+
+ /* Fill value in destination buffer */
+ *pDst++ = value;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+}
+
+/**
+ @} end of Fill group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q7.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q7.c index 830fc73..0c32aa0 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q7.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_fill_q7.c @@ -1,133 +1,99 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_fill_q7.c - * Description: Fills a constant value into a Q7 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup Fill - @{ - */ - -/** - @brief Fills a constant value into a Q7 vector. - @param[in] value input value to be filled - @param[out] pDst points to output vector - @param[in] blockSize number of samples in each vector - @return none - */ -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_fill_q7( - q7_t value, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; - - blkCnt = blockSize >> 4; - while (blkCnt > 0U) - { - - vstrbq_s8(pDst,vdupq_n_s8(value)); - /* - * Decrement the blockSize loop counter - * Advance vector source and destination pointers - */ - pDst += 16; - blkCnt --; - } - - blkCnt = blockSize & 0xF; - while (blkCnt > 0U) - { - /* C = value */ - - /* Fill value in destination buffer */ - *pDst++ = value; - - /* Decrement loop counter */ - blkCnt--; - } -} -#else -void arm_fill_q7( - q7_t value, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - -#if defined (ARM_MATH_LOOPUNROLL) - q31_t packedValue; /* value packed to 32 bits */ - - /* Packing four 8 bit values to 32 bit value in order to use SIMD */ - packedValue = __PACKq7(value, value, value, value); - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = value */ - - /* fill 4 samples at a time */ - write_q7x4_ia (&pDst, packedValue); - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = value */ - - /* Fill value in destination buffer */ - *pDst++ = value; - - /* Decrement loop counter */ - blkCnt--; - } -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of Fill group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_fill_q7.c
+ * Description: Fills a constant value into a Q7 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup Fill
+ @{
+ */
+
+/**
+ @brief Fills a constant value into a Q7 vector.
+ @param[in] value input value to be filled
+ @param[out] pDst points to output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+ */
+
+void arm_fill_q7(
+ q7_t value,
+ q7_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+ q31_t packedValue; /* value packed to 32 bits */
+
+ /* Packing four 8 bit values to 32 bit value in order to use SIMD */
+ packedValue = __PACKq7(value, value, value, value);
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = value */
+
+ /* fill 4 samples at a time */
+ write_q7x4_ia (&pDst, packedValue);
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = value */
+
+ /* Fill value in destination buffer */
+ *pDst++ = value;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+}
+
+/**
+ @} end of Fill group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q15.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q15.c index 8061c9f..a3c8bb2 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q15.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q15.c @@ -1,308 +1,244 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_float_to_q15.c - * Description: Converts the elements of the floating-point vector to Q15 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup float_to_x - @{ - */ - -/** - @brief Converts the elements of the floating-point vector to Q15 vector. - @param[in] pSrc points to the floating-point input vector - @param[out] pDst points to the Q15 output vector - @param[in] blockSize number of samples in each vector - @return none - - @par Details - The equation used for the conversion process is: - <pre> - pDst[n] = (q15_t)(pSrc[n] * 32768); 0 <= n < blockSize. - </pre> - - @par Scaling and Overflow Behavior - The function uses saturating arithmetic. - Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated. - - @note - In order to apply rounding, the library should be rebuilt with the ROUNDING macro - defined in the preprocessor section of project options. - */ - -#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_float_to_q15( - const float32_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; - float32_t maxQ = (float32_t) Q15_MAX; - f32x4x2_t tmp; - q15x8_t vecDst; -#ifdef ARM_MATH_ROUNDING - float32_t in; -#endif - - - blkCnt = blockSize >> 3; - while (blkCnt > 0U) - { - /* C = A * 32768 */ - /* convert from float to q15 and then store the results in the destination buffer */ - tmp = vld2q(pSrc); - - tmp.val[0] = vmulq(tmp.val[0], maxQ); - tmp.val[1] = vmulq(tmp.val[1], maxQ); - - vecDst = vqmovnbq(vecDst, vcvtaq_s32_f32(tmp.val[0])); - vecDst = vqmovntq(vecDst, vcvtaq_s32_f32(tmp.val[1])); - vst1q(pDst, vecDst); - /* - * Decrement the blockSize loop counter - */ - blkCnt--; - pDst += 8; - pSrc += 8; - } - - blkCnt = blockSize & 7; - while (blkCnt > 0U) - { - /* C = A * 32768 */ - - /* convert from float to Q15 and store result in destination buffer */ -#ifdef ARM_MATH_ROUNDING - - in = (*pSrc++ * 32768.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); - -#else - - /* C = A * 32768 */ - /* Convert from float to q15 and then store the results in the destination buffer */ - *pDst++ = (q15_t) __SSAT((q31_t) (*pSrc++ * 32768.0f), 16); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement loop counter */ - blkCnt--; - } -} - -#else -#if defined(ARM_MATH_NEON_EXPERIMENTAL) -void arm_float_to_q15( - const float32_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - const float32_t *pIn = pSrc; /* Src pointer */ - uint32_t blkCnt; /* loop counter */ - - float32x4_t inV; - #ifdef ARM_MATH_ROUNDING - float32x4_t zeroV = vdupq_n_f32(0.0f); - float32x4_t pHalf = vdupq_n_f32(0.5f / 32768.0f); - float32x4_t mHalf = vdupq_n_f32(-0.5f / 32768.0f); - float32x4_t r; - uint32x4_t cmp; - float32_t in; - #endif - - int32x4_t cvt; - int16x4_t outV; - - blkCnt = blockSize >> 2U; - - /* Compute 4 outputs at a time. - ** a second loop below computes the remaining 1 to 3 samples. */ - while (blkCnt > 0U) - { - -#ifdef ARM_MATH_ROUNDING - /* C = A * 32768 */ - /* Convert from float to q15 and then store the results in the destination buffer */ - inV = vld1q_f32(pIn); - cmp = vcgtq_f32(inV,zeroV); - r = vbslq_f32(cmp,pHalf,mHalf); - inV = vaddq_f32(inV, r); - - pIn += 4; - - cvt = vcvtq_n_s32_f32(inV,15); - outV = vqmovn_s32(cvt); - - vst1_s16(pDst, outV); - pDst += 4; - -#else - - /* C = A * 32768 */ - /* Convert from float to q15 and then store the results in the destination buffer */ - inV = vld1q_f32(pIn); - - cvt = vcvtq_n_s32_f32(inV,15); - outV = vqmovn_s32(cvt); - - vst1_s16(pDst, outV); - pDst += 4; - pIn += 4; - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement the loop counter */ - blkCnt--; - } - - /* If the blockSize is not a multiple of 4, compute any remaining output samples here. - ** No loop unrolling is used. */ - blkCnt = blockSize & 3; - - while (blkCnt > 0U) - { - -#ifdef ARM_MATH_ROUNDING - /* C = A * 32768 */ - /* Convert from float to q15 and then store the results in the destination buffer */ - in = *pIn++; - in = (in * 32768.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); - -#else - - /* C = A * 32768 */ - /* Convert from float to q15 and then store the results in the destination buffer */ - *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement the loop counter */ - blkCnt--; - } -} -#else -void arm_float_to_q15( - const float32_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const float32_t *pIn = pSrc; /* Source pointer */ - -#ifdef ARM_MATH_ROUNDING - float32_t in; -#endif /* #ifdef ARM_MATH_ROUNDING */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = A * 32768 */ - - /* convert from float to Q15 and store result in destination buffer */ -#ifdef ARM_MATH_ROUNDING - - in = (*pIn++ * 32768.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); - - in = (*pIn++ * 32768.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); - - in = (*pIn++ * 32768.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); - - in = (*pIn++ * 32768.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); - -#else - - *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16); - *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16); - *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16); - *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = A * 32768 */ - - /* convert from float to Q15 and store result in destination buffer */ -#ifdef ARM_MATH_ROUNDING - - in = (*pIn++ * 32768.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); - -#else - - /* C = A * 32768 */ - /* Convert from float to q15 and then store the results in the destination buffer */ - *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* #if defined(ARM_MATH_NEON) */ -#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */ - -/** - @} end of float_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_float_to_q15.c
+ * Description: Converts the elements of the floating-point vector to Q15 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup float_to_x
+ @{
+ */
+
+/**
+ @brief Converts the elements of the floating-point vector to Q15 vector.
+ @param[in] pSrc points to the floating-point input vector
+ @param[out] pDst points to the Q15 output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+
+ @par Details
+ The equation used for the conversion process is:
+ <pre>
+ pDst[n] = (q15_t)(pSrc[n] * 32768); 0 <= n < blockSize.
+ </pre>
+
+ @par Scaling and Overflow Behavior
+ The function uses saturating arithmetic.
+ Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated.
+
+ @note
+ In order to apply rounding, the library should be rebuilt with the ROUNDING macro
+ defined in the preprocessor section of project options.
+ */
+#if defined(ARM_MATH_NEON_EXPERIMENTAL)
+void arm_float_to_q15(
+ const float32_t * pSrc,
+ q15_t * pDst,
+ uint32_t blockSize)
+{
+ const float32_t *pIn = pSrc; /* Src pointer */
+ uint32_t blkCnt; /* loop counter */
+
+ float32_t in;
+ float32x4_t inV;
+ #ifdef ARM_MATH_ROUNDING
+ float32x4_t zeroV = vdupq_n_f32(0.0f);
+ float32x4_t pHalf = vdupq_n_f32(0.5f / 32768.0f);
+ float32x4_t mHalf = vdupq_n_f32(-0.5f / 32768.0f);
+ float32x4_t r;
+ uint32x4_t cmp;
+ #endif
+
+ int32x4_t cvt;
+ int16x4_t outV;
+
+ blkCnt = blockSize >> 2U;
+
+ /* Compute 4 outputs at a time.
+ ** a second loop below computes the remaining 1 to 3 samples. */
+ while (blkCnt > 0U)
+ {
+
+#ifdef ARM_MATH_ROUNDING
+ /* C = A * 32768 */
+ /* Convert from float to q15 and then store the results in the destination buffer */
+ inV = vld1q_f32(pIn);
+ cmp = vcgtq_f32(inV,zeroV);
+ r = vbslq_f32(cmp,pHalf,mHalf);
+ inV = vaddq_f32(inV, r);
+
+ pIn += 4;
+
+ cvt = vcvtq_n_s32_f32(inV,15);
+ outV = vqmovn_s32(cvt);
+
+ vst1_s16(pDst, outV);
+ pDst += 4;
+
+#else
+
+ /* C = A * 32768 */
+ /* Convert from float to q15 and then store the results in the destination buffer */
+ inV = vld1q_f32(pIn);
+
+ cvt = vcvtq_n_s32_f32(inV,15);
+ outV = vqmovn_s32(cvt);
+
+ vst1_s16(pDst, outV);
+ pDst += 4;
+ pIn += 4;
+
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+
+ /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
+ ** No loop unrolling is used. */
+ blkCnt = blockSize & 3;
+
+ while (blkCnt > 0U)
+ {
+
+#ifdef ARM_MATH_ROUNDING
+ /* C = A * 32768 */
+ /* Convert from float to q15 and then store the results in the destination buffer */
+ in = *pIn++;
+ in = (in * 32768.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
+
+#else
+
+ /* C = A * 32768 */
+ /* Convert from float to q15 and then store the results in the destination buffer */
+ *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
+
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+}
+#else
+void arm_float_to_q15(
+ const float32_t * pSrc,
+ q15_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+ const float32_t *pIn = pSrc; /* Source pointer */
+
+#ifdef ARM_MATH_ROUNDING
+ float32_t in;
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = A * 32768 */
+
+ /* convert from float to Q15 and store result in destination buffer */
+#ifdef ARM_MATH_ROUNDING
+
+ in = (*pIn++ * 32768.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
+
+ in = (*pIn++ * 32768.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
+
+ in = (*pIn++ * 32768.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
+
+ in = (*pIn++ * 32768.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
+
+#else
+
+ *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
+ *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
+ *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
+ *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
+
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = A * 32768 */
+
+ /* convert from float to Q15 and store result in destination buffer */
+#ifdef ARM_MATH_ROUNDING
+
+ in = (*pIn++ * 32768.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
+
+#else
+
+ /* C = A * 32768 */
+ /* Convert from float to q15 and then store the results in the destination buffer */
+ *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
+
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+#endif /* #if defined(ARM_MATH_NEON) */
+
+/**
+ @} end of float_to_x group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q31.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q31.c index a222e49..214987f 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q31.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q31.c @@ -1,314 +1,252 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_float_to_q31.c - * Description: Converts the elements of the floating-point vector to Q31 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - * @defgroup float_to_x Convert 32-bit floating point value - */ - -/** - @addtogroup float_to_x - @{ - */ - -/** - @brief Converts the elements of the floating-point vector to Q31 vector. - @param[in] pSrc points to the floating-point input vector - @param[out] pDst points to the Q31 output vector - @param[in] blockSize number of samples in each vector - @return none - - @par Details - The equation used for the conversion process is: - <pre> - pDst[n] = (q31_t)(pSrc[n] * 2147483648); 0 <= n < blockSize. - </pre> - - @par Scaling and Overflow Behavior - The function uses saturating arithmetic. - Results outside of the allowable Q31 range[0x80000000 0x7FFFFFFF] are saturated. - - @note - In order to apply rounding, the library should be rebuilt with the ROUNDING macro - defined in the preprocessor section of project options. - */ - -#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_float_to_q31( - const float32_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; - float32_t maxQ = (float32_t) Q31_MAX; - f32x4_t vecDst; -#ifdef ARM_MATH_ROUNDING - float32_t in; -#endif - - - blkCnt = blockSize >> 2U; - - /* Compute 4 outputs at a time. */ - while (blkCnt > 0U) - { - - vecDst = vldrwq_f32(pSrc); - /* C = A * 2147483648 */ - /* convert from float to Q31 and then store the results in the destination buffer */ - vecDst = vmulq(vecDst, maxQ); - - vstrwq_s32(pDst, vcvtaq_s32_f32(vecDst)); - /* - * Decrement the blockSize loop counter - * Advance vector source and destination pointers - */ - pSrc += 4; - pDst += 4; - blkCnt --; - } - - blkCnt = blockSize & 3; - - while (blkCnt > 0U) - { - /* C = A * 2147483648 */ - - /* convert from float to Q31 and store result in destination buffer */ -#ifdef ARM_MATH_ROUNDING - - in = (*pSrc++ * 2147483648.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); - -#else - - /* C = A * 2147483648 */ - /* Convert from float to Q31 and then store the results in the destination buffer */ - *pDst++ = clip_q63_to_q31((q63_t) (*pSrc++ * 2147483648.0f)); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement loop counter */ - blkCnt--; - } -} -#else -#if defined(ARM_MATH_NEON) -void arm_float_to_q31( - const float32_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - const float32_t *pIn = pSrc; /* Src pointer */ - uint32_t blkCnt; /* loop counter */ - - float32x4_t inV; - #ifdef ARM_MATH_ROUNDING - float32_t in; - float32x4_t zeroV = vdupq_n_f32(0.0f); - float32x4_t pHalf = vdupq_n_f32(0.5f / 2147483648.0f); - float32x4_t mHalf = vdupq_n_f32(-0.5f / 2147483648.0f); - float32x4_t r; - uint32x4_t cmp; - #endif - - int32x4_t outV; - - blkCnt = blockSize >> 2U; - - /* Compute 4 outputs at a time. - ** a second loop below computes the remaining 1 to 3 samples. */ - while (blkCnt > 0U) - { - -#ifdef ARM_MATH_ROUNDING - - /* C = A * 32768 */ - /* Convert from float to Q31 and then store the results in the destination buffer */ - inV = vld1q_f32(pIn); - cmp = vcgtq_f32(inV,zeroV); - r = vbslq_f32(cmp,pHalf,mHalf); - inV = vaddq_f32(inV, r); - - pIn += 4; - - outV = vcvtq_n_s32_f32(inV,31); - - vst1q_s32(pDst, outV); - pDst += 4; - -#else - - /* C = A * 2147483648 */ - /* Convert from float to Q31 and then store the results in the destination buffer */ - inV = vld1q_f32(pIn); - - outV = vcvtq_n_s32_f32(inV,31); - - vst1q_s32(pDst, outV); - pDst += 4; - pIn += 4; - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement the loop counter */ - blkCnt--; - } - - /* If the blockSize is not a multiple of 4, compute any remaining output samples here. - ** No loop unrolling is used. */ - blkCnt = blockSize & 3; - - while (blkCnt > 0U) - { - -#ifdef ARM_MATH_ROUNDING - - /* C = A * 2147483648 */ - /* Convert from float to Q31 and then store the results in the destination buffer */ - in = *pIn++; - in = (in * 2147483648.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); - -#else - - /* C = A * 2147483648 */ - /* Convert from float to Q31 and then store the results in the destination buffer */ - *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f)); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement the loop counter */ - blkCnt--; - } - - -} -#else -void arm_float_to_q31( - const float32_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const float32_t *pIn = pSrc; /* Source pointer */ - -#ifdef ARM_MATH_ROUNDING - float32_t in; -#endif /* #ifdef ARM_MATH_ROUNDING */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = A * 2147483648 */ - - /* convert from float to Q31 and store result in destination buffer */ -#ifdef ARM_MATH_ROUNDING - - in = (*pIn++ * 2147483648.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); - - in = (*pIn++ * 2147483648.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); - - in = (*pIn++ * 2147483648.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); - - in = (*pIn++ * 2147483648.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); - -#else - - /* C = A * 2147483648 */ - /* Convert from float to Q31 and then store the results in the destination buffer */ - *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f)); - *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f)); - *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f)); - *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f)); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = A * 2147483648 */ - - /* convert from float to Q31 and store result in destination buffer */ -#ifdef ARM_MATH_ROUNDING - - in = (*pIn++ * 2147483648.0f); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); - -#else - - /* C = A * 2147483648 */ - /* Convert from float to Q31 and then store the results in the destination buffer */ - *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f)); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* #if defined(ARM_MATH_NEON) */ -#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */ - -/** - @} end of float_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_float_to_q31.c
+ * Description: Converts the elements of the floating-point vector to Q31 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ * @defgroup float_to_x Convert 32-bit floating point value
+ */
+
+/**
+ @addtogroup float_to_x
+ @{
+ */
+
+/**
+ @brief Converts the elements of the floating-point vector to Q31 vector.
+ @param[in] pSrc points to the floating-point input vector
+ @param[out] pDst points to the Q31 output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+
+ @par Details
+ The equation used for the conversion process is:
+ <pre>
+ pDst[n] = (q31_t)(pSrc[n] * 2147483648); 0 <= n < blockSize.
+ </pre>
+
+ @par Scaling and Overflow Behavior
+ The function uses saturating arithmetic.
+ Results outside of the allowable Q31 range[0x80000000 0x7FFFFFFF] are saturated.
+
+ @note
+ In order to apply rounding, the library should be rebuilt with the ROUNDING macro
+ defined in the preprocessor section of project options.
+ */
+
+#if defined(ARM_MATH_NEON)
+void arm_float_to_q31(
+ const float32_t * pSrc,
+ q31_t * pDst,
+ uint32_t blockSize)
+{
+ const float32_t *pIn = pSrc; /* Src pointer */
+ uint32_t blkCnt; /* loop counter */
+
+ float32_t in;
+ float32x4_t inV;
+ #ifdef ARM_MATH_ROUNDING
+ float32x4_t zeroV = vdupq_n_f32(0.0f);
+ float32x4_t pHalf = vdupq_n_f32(0.5f / 2147483648.0f);
+ float32x4_t mHalf = vdupq_n_f32(-0.5f / 2147483648.0f);
+ float32x4_t r;
+ uint32x4_t cmp;
+ #endif
+
+ int32x4_t outV;
+
+ blkCnt = blockSize >> 2U;
+
+ /* Compute 4 outputs at a time.
+ ** a second loop below computes the remaining 1 to 3 samples. */
+ while (blkCnt > 0U)
+ {
+
+#ifdef ARM_MATH_ROUNDING
+
+ /* C = A * 32768 */
+ /* Convert from float to Q31 and then store the results in the destination buffer */
+ inV = vld1q_f32(pIn);
+ cmp = vcgtq_f32(inV,zeroV);
+ r = vbslq_f32(cmp,pHalf,mHalf);
+ inV = vaddq_f32(inV, r);
+
+ pIn += 4;
+
+ outV = vcvtq_n_s32_f32(inV,31);
+
+ vst1q_s32(pDst, outV);
+ pDst += 4;
+
+#else
+
+ /* C = A * 2147483648 */
+ /* Convert from float to Q31 and then store the results in the destination buffer */
+ inV = vld1q_f32(pIn);
+
+ outV = vcvtq_n_s32_f32(inV,31);
+
+ vst1q_s32(pDst, outV);
+ pDst += 4;
+ pIn += 4;
+
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+
+ /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
+ ** No loop unrolling is used. */
+ blkCnt = blockSize & 3;
+
+ while (blkCnt > 0U)
+ {
+
+#ifdef ARM_MATH_ROUNDING
+
+ /* C = A * 2147483648 */
+ /* Convert from float to Q31 and then store the results in the destination buffer */
+ in = *pIn++;
+ in = (in * 2147483648.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = clip_q63_to_q31((q63_t) (in));
+
+#else
+
+ /* C = A * 2147483648 */
+ /* Convert from float to Q31 and then store the results in the destination buffer */
+ *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
+
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+
+
+}
+#else
+void arm_float_to_q31(
+ const float32_t * pSrc,
+ q31_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+ const float32_t *pIn = pSrc; /* Source pointer */
+
+#ifdef ARM_MATH_ROUNDING
+ float32_t in;
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = A * 2147483648 */
+
+ /* convert from float to Q31 and store result in destination buffer */
+#ifdef ARM_MATH_ROUNDING
+
+ in = (*pIn++ * 2147483648.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = clip_q63_to_q31((q63_t) (in));
+
+ in = (*pIn++ * 2147483648.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = clip_q63_to_q31((q63_t) (in));
+
+ in = (*pIn++ * 2147483648.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = clip_q63_to_q31((q63_t) (in));
+
+ in = (*pIn++ * 2147483648.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = clip_q63_to_q31((q63_t) (in));
+
+#else
+
+ /* C = A * 2147483648 */
+ /* Convert from float to Q31 and then store the results in the destination buffer */
+ *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
+ *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
+ *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
+ *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
+
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = A * 2147483648 */
+
+ /* convert from float to Q31 and store result in destination buffer */
+#ifdef ARM_MATH_ROUNDING
+
+ in = (*pIn++ * 2147483648.0f);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = clip_q63_to_q31((q63_t) (in));
+
+#else
+
+ /* C = A * 2147483648 */
+ /* Convert from float to Q31 and then store the results in the destination buffer */
+ *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
+
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+#endif /* #if defined(ARM_MATH_NEON) */
+
+/**
+ @} end of float_to_x group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q7.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q7.c index 27af520..3b7d6c6 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q7.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_float_to_q7.c @@ -1,330 +1,253 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_float_to_q7.c - * Description: Converts the elements of the floating-point vector to Q7 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup float_to_x - @{ - */ - -/** - * @brief Converts the elements of the floating-point vector to Q7 vector. - * @param[in] *pSrc points to the floating-point input vector - * @param[out] *pDst points to the Q7 output vector - * @param[in] blockSize length of the input vector - * @return none. - * - *\par Description: - * \par - * The equation used for the conversion process is: - * <pre> - * pDst[n] = (q7_t)(pSrc[n] * 128); 0 <= n < blockSize. - * </pre> - * \par Scaling and Overflow Behavior: - * \par - * The function uses saturating arithmetic. - * Results outside of the allowable Q7 range [0x80 0x7F] will be saturated. - * \note - * In order to apply rounding, the library should be rebuilt with the ROUNDING macro - * defined in the preprocessor section of project options. - */ -#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_float_to_q7( - const float32_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* loop counters */ - float32_t maxQ = powf(2.0, 7); - f32x4x4_t tmp; - q15x8_t evVec, oddVec; - q7x16_t vecDst; - float32_t const *pSrcVec; -#ifdef ARM_MATH_ROUNDING - float32_t in; -#endif - - pSrcVec = (float32_t const *) pSrc; - blkCnt = blockSize >> 4; - while (blkCnt > 0U) { - tmp = vld4q(pSrcVec); - pSrcVec += 16; - /* - * C = A * 128.0 - * convert from float to q7 and then store the results in the destination buffer - */ - tmp.val[0] = vmulq(tmp.val[0], maxQ); - tmp.val[1] = vmulq(tmp.val[1], maxQ); - tmp.val[2] = vmulq(tmp.val[2], maxQ); - tmp.val[3] = vmulq(tmp.val[3], maxQ); - - /* - * convert and pack evens - */ - evVec = vqmovnbq(evVec, vcvtaq_s32_f32(tmp.val[0])); - evVec = vqmovntq(evVec, vcvtaq_s32_f32(tmp.val[2])); - /* - * convert and pack odds - */ - oddVec = vqmovnbq(oddVec, vcvtaq_s32_f32(tmp.val[1])); - oddVec = vqmovntq(oddVec, vcvtaq_s32_f32(tmp.val[3])); - /* - * merge - */ - vecDst = vqmovnbq(vecDst, evVec); - vecDst = vqmovntq(vecDst, oddVec); - - vst1q(pDst, vecDst); - pDst += 16; - /* - * Decrement the blockSize loop counter - */ - blkCnt--; - } - - blkCnt = blockSize & 0xF; - while (blkCnt > 0U) - { - /* C = A * 128 */ - - /* Convert from float to q7 and store result in destination buffer */ -#ifdef ARM_MATH_ROUNDING - - in = (*pSrcVec++ * 128); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); - -#else - - *pDst++ = (q7_t) __SSAT((q31_t) (*pSrcVec++ * 128.0f), 8); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement loop counter */ - blkCnt--; - } - -} -#else -#if defined(ARM_MATH_NEON) -void arm_float_to_q7( - const float32_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - const float32_t *pIn = pSrc; /* Src pointer */ - uint32_t blkCnt; /* loop counter */ - - float32x4_t inV; - #ifdef ARM_MATH_ROUNDING - float32_t in; - float32x4_t zeroV = vdupq_n_f32(0.0f); - float32x4_t pHalf = vdupq_n_f32(0.5f / 128.0f); - float32x4_t mHalf = vdupq_n_f32(-0.5f / 128.0f); - float32x4_t r; - uint32x4_t cmp; - #endif - - int16x4_t cvt1,cvt2; - int8x8_t outV; - - blkCnt = blockSize >> 3U; - - /* Compute 8 outputs at a time. - ** a second loop below computes the remaining 1 to 7 samples. */ - while (blkCnt > 0U) - { - -#ifdef ARM_MATH_ROUNDING - /* C = A * 128 */ - /* Convert from float to q7 and then store the results in the destination buffer */ - inV = vld1q_f32(pIn); - cmp = vcgtq_f32(inV,zeroV); - r = vbslq_f32(cmp,pHalf,mHalf); - inV = vaddq_f32(inV, r); - cvt1 = vqmovn_s32(vcvtq_n_s32_f32(inV,7)); - pIn += 4; - - inV = vld1q_f32(pIn); - cmp = vcgtq_f32(inV,zeroV); - r = vbslq_f32(cmp,pHalf,mHalf); - inV = vaddq_f32(inV, r); - cvt2 = vqmovn_s32(vcvtq_n_s32_f32(inV,7)); - pIn += 4; - - outV = vqmovn_s16(vcombine_s16(cvt1,cvt2)); - vst1_s8(pDst, outV); - pDst += 8; - -#else - - /* C = A * 128 */ - /* Convert from float to q7 and then store the results in the destination buffer */ - inV = vld1q_f32(pIn); - cvt1 = vqmovn_s32(vcvtq_n_s32_f32(inV,7)); - pIn += 4; - - inV = vld1q_f32(pIn); - cvt2 = vqmovn_s32(vcvtq_n_s32_f32(inV,7)); - pIn += 4; - - outV = vqmovn_s16(vcombine_s16(cvt1,cvt2)); - - vst1_s8(pDst, outV); - pDst += 8; -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement the loop counter */ - blkCnt--; - } - - /* If the blockSize is not a multiple of 4, compute any remaining output samples here. - ** No loop unrolling is used. */ - blkCnt = blockSize & 7; - - while (blkCnt > 0U) - { - -#ifdef ARM_MATH_ROUNDING - /* C = A * 128 */ - /* Convert from float to q7 and then store the results in the destination buffer */ - in = *pIn++; - in = (in * 128); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); - -#else - - /* C = A * 128 */ - /* Convert from float to q7 and then store the results in the destination buffer */ - *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement the loop counter */ - blkCnt--; - } - -} -#else -void arm_float_to_q7( - const float32_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const float32_t *pIn = pSrc; /* Source pointer */ - -#ifdef ARM_MATH_ROUNDING - float32_t in; -#endif /* #ifdef ARM_MATH_ROUNDING */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = A * 128 */ - - /* Convert from float to q7 and store result in destination buffer */ -#ifdef ARM_MATH_ROUNDING - - in = (*pIn++ * 128); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); - - in = (*pIn++ * 128); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); - - in = (*pIn++ * 128); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); - - in = (*pIn++ * 128); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); - -#else - - *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8); - *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8); - *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8); - *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = A * 128 */ - - /* Convert from float to q7 and store result in destination buffer */ -#ifdef ARM_MATH_ROUNDING - - in = (*pIn++ * 128); - in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); - -#else - - *pDst++ = (q7_t) __SSAT((q31_t) (*pIn++ * 128.0f), 8); - -#endif /* #ifdef ARM_MATH_ROUNDING */ - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* #if defined(ARM_MATH_NEON) */ -#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */ - -/** - @} end of float_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_float_to_q7.c
+ * Description: Converts the elements of the floating-point vector to Q7 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup float_to_x
+ @{
+ */
+
+/**
+ * @brief Converts the elements of the floating-point vector to Q7 vector.
+ * @param[in] *pSrc points to the floating-point input vector
+ * @param[out] *pDst points to the Q7 output vector
+ * @param[in] blockSize length of the input vector
+ * @return none.
+ *
+ *\par Description:
+ * \par
+ * The equation used for the conversion process is:
+ * <pre>
+ * pDst[n] = (q7_t)(pSrc[n] * 128); 0 <= n < blockSize.
+ * </pre>
+ * \par Scaling and Overflow Behavior:
+ * \par
+ * The function uses saturating arithmetic.
+ * Results outside of the allowable Q7 range [0x80 0x7F] will be saturated.
+ * \note
+ * In order to apply rounding, the library should be rebuilt with the ROUNDING macro
+ * defined in the preprocessor section of project options.
+ */
+
+#if defined(ARM_MATH_NEON)
+void arm_float_to_q7(
+ const float32_t * pSrc,
+ q7_t * pDst,
+ uint32_t blockSize)
+{
+ const float32_t *pIn = pSrc; /* Src pointer */
+ uint32_t blkCnt; /* loop counter */
+
+ float32_t in;
+ float32x4_t inV;
+ #ifdef ARM_MATH_ROUNDING
+ float32x4_t zeroV = vdupq_n_f32(0.0f);
+ float32x4_t pHalf = vdupq_n_f32(0.5f / 128.0f);
+ float32x4_t mHalf = vdupq_n_f32(-0.5f / 128.0f);
+ float32x4_t r;
+ uint32x4_t cmp;
+ #endif
+
+ int32x4_t cvt;
+ int16x4_t cvt1,cvt2;
+ int8x8_t outV;
+
+ blkCnt = blockSize >> 3U;
+
+ /* Compute 8 outputs at a time.
+ ** a second loop below computes the remaining 1 to 7 samples. */
+ while (blkCnt > 0U)
+ {
+
+#ifdef ARM_MATH_ROUNDING
+ /* C = A * 128 */
+ /* Convert from float to q7 and then store the results in the destination buffer */
+ inV = vld1q_f32(pIn);
+ cmp = vcgtq_f32(inV,zeroV);
+ r = vbslq_f32(cmp,pHalf,mHalf);
+ inV = vaddq_f32(inV, r);
+ cvt1 = vqmovn_s32(vcvtq_n_s32_f32(inV,7));
+ pIn += 4;
+
+ inV = vld1q_f32(pIn);
+ cmp = vcgtq_f32(inV,zeroV);
+ r = vbslq_f32(cmp,pHalf,mHalf);
+ inV = vaddq_f32(inV, r);
+ cvt2 = vqmovn_s32(vcvtq_n_s32_f32(inV,7));
+ pIn += 4;
+
+ outV = vqmovn_s16(vcombine_s16(cvt1,cvt2));
+ vst1_s8(pDst, outV);
+ pDst += 8;
+
+#else
+
+ /* C = A * 128 */
+ /* Convert from float to q7 and then store the results in the destination buffer */
+ inV = vld1q_f32(pIn);
+ cvt1 = vqmovn_s32(vcvtq_n_s32_f32(inV,7));
+ pIn += 4;
+
+ inV = vld1q_f32(pIn);
+ cvt2 = vqmovn_s32(vcvtq_n_s32_f32(inV,7));
+ pIn += 4;
+
+ outV = vqmovn_s16(vcombine_s16(cvt1,cvt2));
+
+ vst1_s8(pDst, outV);
+ pDst += 8;
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+
+ /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
+ ** No loop unrolling is used. */
+ blkCnt = blockSize & 7;
+
+ while (blkCnt > 0U)
+ {
+
+#ifdef ARM_MATH_ROUNDING
+ /* C = A * 128 */
+ /* Convert from float to q7 and then store the results in the destination buffer */
+ in = *pIn++;
+ in = (in * 128);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
+
+#else
+
+ /* C = A * 128 */
+ /* Convert from float to q7 and then store the results in the destination buffer */
+ *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
+
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+
+}
+#else
+void arm_float_to_q7(
+ const float32_t * pSrc,
+ q7_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+ const float32_t *pIn = pSrc; /* Source pointer */
+
+#ifdef ARM_MATH_ROUNDING
+ float32_t in;
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = A * 128 */
+
+ /* Convert from float to q7 and store result in destination buffer */
+#ifdef ARM_MATH_ROUNDING
+
+ in = (*pIn++ * 128);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
+
+ in = (*pIn++ * 128);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
+
+ in = (*pIn++ * 128);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
+
+ in = (*pIn++ * 128);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
+
+#else
+
+ *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
+ *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
+ *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
+ *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
+
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = A * 128 */
+
+ /* Convert from float to q7 and store result in destination buffer */
+#ifdef ARM_MATH_ROUNDING
+
+ in = (*pIn++ * 128);
+ in += in > 0.0f ? 0.5f : -0.5f;
+ *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
+
+#else
+
+ *pDst++ = (q7_t) __SSAT((q31_t) (*pIn++ * 128.0f), 8);
+
+#endif /* #ifdef ARM_MATH_ROUNDING */
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+#endif /* #if defined(ARM_MATH_NEON) */
+
+/**
+ @} end of float_to_x group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_float.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_float.c index 1a20def..a87946c 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_float.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_float.c @@ -1,207 +1,166 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_q15_to_float.c - * Description: Converts the elements of the Q15 vector to floating-point vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - * @defgroup q15_to_x Convert 16-bit fixed point value - */ - -/** - @addtogroup q15_to_x - @{ - */ - -/** - @brief Converts the elements of the Q15 vector to floating-point vector. - @param[in] pSrc points to the Q15 input vector - @param[out] pDst points to the floating-point output vector - @param[in] blockSize number of samples in each vector - @return none - - @par Details - The equation used for the conversion process is: - <pre> - pDst[n] = (float32_t) pSrc[n] / 32768; 0 <= n < blockSize. - </pre> - */ - -#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_q15_to_float( - const q15_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; - - q15x8_t vecDst; - q15_t const *pSrcVec; - - pSrcVec = (q15_t const *) pSrc; - blkCnt = blockSize >> 2; - while (blkCnt > 0U) - { - /* C = (float32_t) A / 32768 */ - /* convert from q15 to float and then store the results in the destination buffer */ - vecDst = vldrhq_s32(pSrcVec); - pSrcVec += 4; - vstrwq(pDst, vcvtq_n_f32_s32((int32x4_t)vecDst, 15)); - pDst += 4; - /* - * Decrement the blockSize loop counter - */ - blkCnt--; - } - - blkCnt = blockSize & 3; - while (blkCnt > 0U) - { - /* C = (float32_t) A / 32768 */ - - /* Convert from q15 to float and store result in destination buffer */ - *pDst++ = ((float32_t) *pSrcVec++ / 32768.0f); - - /* Decrement loop counter */ - blkCnt--; - } -} -#else -#if defined(ARM_MATH_NEON_EXPERIMENTAL) -void arm_q15_to_float( - const q15_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - const q15_t *pIn = pSrc; /* Src pointer */ - uint32_t blkCnt; /* loop counter */ - - int16x8_t inV; - int32x4_t inV0, inV1; - float32x4_t outV; - - blkCnt = blockSize >> 3U; - - /* Compute 8 outputs at a time. - ** a second loop below computes the remaining 1 to 7 samples. */ - while (blkCnt > 0U) - { - /* C = (float32_t) A / 32768 */ - /* convert from q15 to float and then store the results in the destination buffer */ - inV = vld1q_s16(pIn); - pIn += 8; - - inV0 = vmovl_s16(vget_low_s16(inV)); - inV1 = vmovl_s16(vget_high_s16(inV)); - - outV = vcvtq_n_f32_s32(inV0,15); - vst1q_f32(pDst, outV); - pDst += 4; - - outV = vcvtq_n_f32_s32(inV1,15); - vst1q_f32(pDst, outV); - pDst += 4; - - /* Decrement the loop counter */ - blkCnt--; - } - - /* If the blockSize is not a multiple of 8, compute any remaining output samples here. - ** No loop unrolling is used. */ - blkCnt = blockSize & 7; - - - while (blkCnt > 0U) - { - /* C = (float32_t) A / 32768 */ - /* convert from q15 to float and then store the results in the destination buffer */ - *pDst++ = ((float32_t) * pIn++ / 32768.0f); - - /* Decrement the loop counter */ - blkCnt--; - } -} -#else -void arm_q15_to_float( - const q15_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q15_t *pIn = pSrc; /* Source pointer */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = (float32_t) A / 32768 */ - - /* Convert from q15 to float and store result in destination buffer */ - *pDst++ = ((float32_t) * pIn++ / 32768.0f); - *pDst++ = ((float32_t) * pIn++ / 32768.0f); - *pDst++ = ((float32_t) * pIn++ / 32768.0f); - *pDst++ = ((float32_t) * pIn++ / 32768.0f); - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = (float32_t) A / 32768 */ - - /* Convert from q15 to float and store result in destination buffer */ - *pDst++ = ((float32_t) *pIn++ / 32768.0f); - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* #if defined(ARM_MATH_NEON) */ -#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */ - -/** - @} end of q15_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_q15_to_float.c
+ * Description: Converts the elements of the Q15 vector to floating-point vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ * @defgroup q15_to_x Convert 16-bit Integer value
+ */
+
+/**
+ @addtogroup q15_to_x
+ @{
+ */
+
+/**
+ @brief Converts the elements of the Q15 vector to floating-point vector.
+ @param[in] pSrc points to the Q15 input vector
+ @param[out] pDst points to the floating-point output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+
+ @par Details
+ The equation used for the conversion process is:
+ <pre>
+ pDst[n] = (float32_t) pSrc[n] / 32768; 0 <= n < blockSize.
+ </pre>
+ */
+
+#if defined(ARM_MATH_NEON_EXPERIMENTAL)
+void arm_q15_to_float(
+ const q15_t * pSrc,
+ float32_t * pDst,
+ uint32_t blockSize)
+{
+ const q15_t *pIn = pSrc; /* Src pointer */
+ uint32_t blkCnt; /* loop counter */
+
+ int16x8_t inV;
+ int32x4_t inV0, inV1;
+ float32x4_t outV;
+
+ blkCnt = blockSize >> 3U;
+
+ /* Compute 8 outputs at a time.
+ ** a second loop below computes the remaining 1 to 7 samples. */
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 32768 */
+ /* convert from q15 to float and then store the results in the destination buffer */
+ inV = vld1q_s16(pIn);
+ pIn += 8;
+
+ inV0 = vmovl_s16(vget_low_s16(inV));
+ inV1 = vmovl_s16(vget_high_s16(inV));
+
+ outV = vcvtq_n_f32_s32(inV0,15);
+ vst1q_f32(pDst, outV);
+ pDst += 4;
+
+ outV = vcvtq_n_f32_s32(inV1,15);
+ vst1q_f32(pDst, outV);
+ pDst += 4;
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+
+ /* If the blockSize is not a multiple of 8, compute any remaining output samples here.
+ ** No loop unrolling is used. */
+ blkCnt = blockSize & 7;
+
+
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 32768 */
+ /* convert from q15 to float and then store the results in the destination buffer */
+ *pDst++ = ((float32_t) * pIn++ / 32768.0f);
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+}
+#else
+void arm_q15_to_float(
+ const q15_t * pSrc,
+ float32_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+ const q15_t *pIn = pSrc; /* Source pointer */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 32768 */
+
+ /* Convert from q15 to float and store result in destination buffer */
+ *pDst++ = ((float32_t) * pIn++ / 32768.0f);
+ *pDst++ = ((float32_t) * pIn++ / 32768.0f);
+ *pDst++ = ((float32_t) * pIn++ / 32768.0f);
+ *pDst++ = ((float32_t) * pIn++ / 32768.0f);
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 32768 */
+
+ /* Convert from q15 to float and store result in destination buffer */
+ *pDst++ = ((float32_t) *pIn++ / 32768.0f);
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+#endif /* #if defined(ARM_MATH_NEON) */
+
+/**
+ @} end of q15_to_x group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_q31.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_q31.c index fc3c868..c745121 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_q31.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_q31.c @@ -1,182 +1,138 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_q15_to_q31.c - * Description: Converts the elements of the Q15 vector to Q31 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup q15_to_x - @{ - */ - -/** - @brief Converts the elements of the Q15 vector to Q31 vector. - @param[in] pSrc points to the Q15 input vector - @param[out] pDst points to the Q31 output vector - @param[in] blockSize number of samples in each vector - @return none - - @par Details - The equation used for the conversion process is: - <pre> - pDst[n] = (q31_t) pSrc[n] << 16; 0 <= n < blockSize. - </pre> - */ -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_q15_to_q31( - const q15_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - - uint32_t blkCnt; - - q31x4_t vecDst; - - blkCnt = blockSize>> 2; - while (blkCnt > 0U) - { - - /* C = (q31_t)A << 16 */ - /* convert from q15 to q31 and then store the results in the destination buffer */ - /* load q15 + 32-bit widening */ - vecDst = vldrhq_s32((q15_t const *) pSrc); - vecDst = vshlq_n(vecDst, 16); - vstrwq_s32(pDst, vecDst); - - /* - * Decrement the blockSize loop counter - * Advance vector source and destination pointers - */ - pDst += 4; - pSrc += 4; - blkCnt --; - } - - blkCnt = blockSize & 3; - while (blkCnt > 0U) - { - /* C = (q31_t) A << 16 */ - - /* Convert from q15 to q31 and store result in destination buffer */ - *pDst++ = (q31_t) *pSrc++ << 16; - - /* Decrement loop counter */ - blkCnt--; - } -} -#else -void arm_q15_to_q31( - const q15_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q15_t *pIn = pSrc; /* Source pointer */ - -#if defined (ARM_MATH_LOOPUNROLL) - q31_t in1, in2; - q31_t out1, out2, out3, out4; -#endif - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = (q31_t)A << 16 */ - - /* Convert from q15 to q31 and store result in destination buffer */ - in1 = read_q15x2_ia (&pIn); - in2 = read_q15x2_ia (&pIn); - -#ifndef ARM_MATH_BIG_ENDIAN - - /* extract lower 16 bits to 32 bit result */ - out1 = in1 << 16U; - /* extract upper 16 bits to 32 bit result */ - out2 = in1 & 0xFFFF0000; - /* extract lower 16 bits to 32 bit result */ - out3 = in2 << 16U; - /* extract upper 16 bits to 32 bit result */ - out4 = in2 & 0xFFFF0000; - -#else - - /* extract upper 16 bits to 32 bit result */ - out1 = in1 & 0xFFFF0000; - /* extract lower 16 bits to 32 bit result */ - out2 = in1 << 16U; - /* extract upper 16 bits to 32 bit result */ - out3 = in2 & 0xFFFF0000; - /* extract lower 16 bits to 32 bit result */ - out4 = in2 << 16U; - -#endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - - *pDst++ = out1; - *pDst++ = out2; - *pDst++ = out3; - *pDst++ = out4; - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = (q31_t) A << 16 */ - - /* Convert from q15 to q31 and store result in destination buffer */ - *pDst++ = (q31_t) *pIn++ << 16; - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of q15_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_q15_to_q31.c
+ * Description: Converts the elements of the Q15 vector to Q31 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup q15_to_x
+ @{
+ */
+
+/**
+ @brief Converts the elements of the Q15 vector to Q31 vector.
+ @param[in] pSrc points to the Q15 input vector
+ @param[out] pDst points to the Q31 output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+
+ @par Details
+ The equation used for the conversion process is:
+ <pre>
+ pDst[n] = (q31_t) pSrc[n] << 16; 0 <= n < blockSize.
+ </pre>
+ */
+
+void arm_q15_to_q31(
+ const q15_t * pSrc,
+ q31_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+ const q15_t *pIn = pSrc; /* Source pointer */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+ q31_t in1, in2;
+ q31_t out1, out2, out3, out4;
+#endif
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q31_t)A << 16 */
+
+ /* Convert from q15 to q31 and store result in destination buffer */
+ in1 = read_q15x2_ia ((q15_t **) &pIn);
+ in2 = read_q15x2_ia ((q15_t **) &pIn);
+
+#ifndef ARM_MATH_BIG_ENDIAN
+
+ /* extract lower 16 bits to 32 bit result */
+ out1 = in1 << 16U;
+ /* extract upper 16 bits to 32 bit result */
+ out2 = in1 & 0xFFFF0000;
+ /* extract lower 16 bits to 32 bit result */
+ out3 = in2 << 16U;
+ /* extract upper 16 bits to 32 bit result */
+ out4 = in2 & 0xFFFF0000;
+
+#else
+
+ /* extract upper 16 bits to 32 bit result */
+ out1 = in1 & 0xFFFF0000;
+ /* extract lower 16 bits to 32 bit result */
+ out2 = in1 << 16U;
+ /* extract upper 16 bits to 32 bit result */
+ out3 = in2 & 0xFFFF0000;
+ /* extract lower 16 bits to 32 bit result */
+ out4 = in2 << 16U;
+
+#endif /* #ifndef ARM_MATH_BIG_ENDIAN */
+
+ *pDst++ = out1;
+ *pDst++ = out2;
+ *pDst++ = out3;
+ *pDst++ = out4;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q31_t) A << 16 */
+
+ /* Convert from q15 to q31 and store result in destination buffer */
+ *pDst++ = (q31_t) *pIn++ << 16;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+
+/**
+ @} end of q15_to_x group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_q7.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_q7.c index eac8105..4f90d56 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_q7.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q15_to_q7.c @@ -1,190 +1,146 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_q15_to_q7.c - * Description: Converts the elements of the Q15 vector to Q7 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup q15_to_x - @{ - */ - -/** - @brief Converts the elements of the Q15 vector to Q7 vector. - @param[in] pSrc points to the Q15 input vector - @param[out] pDst points to the Q7 output vector - @param[in] blockSize number of samples in each vector - @return none - - @par Details - The equation used for the conversion process is: - <pre> - pDst[n] = (q7_t) pSrc[n] >> 8; 0 <= n < blockSize. - </pre> - */ -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_q15_to_q7( - const q15_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - - uint32_t blkCnt; /* loop counters */ - q15x8x2_t tmp; - q15_t const *pSrcVec; - q7x16_t vecDst; - - - pSrcVec = (q15_t const *) pSrc; - blkCnt = blockSize >> 4; - while (blkCnt > 0U) - { - /* C = (q7_t) A >> 8 */ - /* convert from q15 to q7 and then store the results in the destination buffer */ - tmp = vld2q(pSrcVec); - pSrcVec += 16; - vecDst = vqshrnbq_n_s16(vecDst, tmp.val[0], 8); - vecDst = vqshrntq_n_s16(vecDst, tmp.val[1], 8); - vst1q(pDst, vecDst); - pDst += 16; - /* - * Decrement the blockSize loop counter - */ - blkCnt--; - } - - blkCnt = blockSize & 0xF; - while (blkCnt > 0U) - { - /* C = (q7_t) A >> 8 */ - - /* Convert from q15 to q7 and store result in destination buffer */ - *pDst++ = (q7_t) (*pSrcVec++ >> 8); - - /* Decrement loop counter */ - blkCnt--; - } -} -#else -void arm_q15_to_q7( - const q15_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q15_t *pIn = pSrc; /* Source pointer */ - -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t in1, in2; - q31_t out1, out2; -#endif - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = (q7_t) A >> 8 */ - - /* Convert from q15 to q7 and store result in destination buffer */ -#if defined (ARM_MATH_DSP) - - in1 = read_q15x2_ia (&pIn); - in2 = read_q15x2_ia (&pIn); - -#ifndef ARM_MATH_BIG_ENDIAN - - out1 = __PKHTB(in2, in1, 16); - out2 = __PKHBT(in2, in1, 16); - -#else - - out1 = __PKHTB(in1, in2, 16); - out2 = __PKHBT(in1, in2, 16); - -#endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - - /* rotate packed value by 24 */ - out2 = ((uint32_t) out2 << 8) | ((uint32_t) out2 >> 24); - - /* anding with 0xff00ff00 to get two 8 bit values */ - out1 = out1 & 0xFF00FF00; - /* anding with 0x00ff00ff to get two 8 bit values */ - out2 = out2 & 0x00FF00FF; - - /* oring two values(contains two 8 bit values) to get four packed 8 bit values */ - out1 = out1 | out2; - - /* store 4 samples at a time to destiantion buffer */ - write_q7x4_ia (&pDst, out1); - -#else - - *pDst++ = (q7_t) (*pIn++ >> 8); - *pDst++ = (q7_t) (*pIn++ >> 8); - *pDst++ = (q7_t) (*pIn++ >> 8); - *pDst++ = (q7_t) (*pIn++ >> 8); - -#endif /* #if defined (ARM_MATH_DSP) */ - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = (q7_t) A >> 8 */ - - /* Convert from q15 to q7 and store result in destination buffer */ - *pDst++ = (q7_t) (*pIn++ >> 8); - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of q15_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_q15_to_q7.c
+ * Description: Converts the elements of the Q15 vector to Q7 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup q15_to_x
+ @{
+ */
+
+/**
+ @brief Converts the elements of the Q15 vector to Q7 vector.
+ @param[in] pSrc points to the Q15 input vector
+ @param[out] pDst points to the Q7 output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+
+ @par Details
+ The equation used for the conversion process is:
+ <pre>
+ pDst[n] = (q7_t) pSrc[n] >> 8; 0 <= n < blockSize.
+ </pre>
+ */
+
+void arm_q15_to_q7(
+ const q15_t * pSrc,
+ q7_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+ const q15_t *pIn = pSrc; /* Source pointer */
+
+#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP)
+ q31_t in1, in2;
+ q31_t out1, out2;
+#endif
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q7_t) A >> 8 */
+
+ /* Convert from q15 to q7 and store result in destination buffer */
+#if defined (ARM_MATH_DSP)
+
+ in1 = read_q15x2_ia ((q15_t **) &pIn);
+ in2 = read_q15x2_ia ((q15_t **) &pIn);
+
+#ifndef ARM_MATH_BIG_ENDIAN
+
+ out1 = __PKHTB(in2, in1, 16);
+ out2 = __PKHBT(in2, in1, 16);
+
+#else
+
+ out1 = __PKHTB(in1, in2, 16);
+ out2 = __PKHBT(in1, in2, 16);
+
+#endif /* #ifndef ARM_MATH_BIG_ENDIAN */
+
+ /* rotate packed value by 24 */
+ out2 = ((uint32_t) out2 << 8) | ((uint32_t) out2 >> 24);
+
+ /* anding with 0xff00ff00 to get two 8 bit values */
+ out1 = out1 & 0xFF00FF00;
+ /* anding with 0x00ff00ff to get two 8 bit values */
+ out2 = out2 & 0x00FF00FF;
+
+ /* oring two values(contains two 8 bit values) to get four packed 8 bit values */
+ out1 = out1 | out2;
+
+ /* store 4 samples at a time to destiantion buffer */
+ write_q7x4_ia (&pDst, out1);
+
+#else
+
+ *pDst++ = (q7_t) (*pIn++ >> 8);
+ *pDst++ = (q7_t) (*pIn++ >> 8);
+ *pDst++ = (q7_t) (*pIn++ >> 8);
+ *pDst++ = (q7_t) (*pIn++ >> 8);
+
+#endif /* #if defined (ARM_MATH_DSP) */
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q7_t) A >> 8 */
+
+ /* Convert from q15 to q7 and store result in destination buffer */
+ *pDst++ = (q7_t) (*pIn++ >> 8);
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+
+/**
+ @} end of q15_to_x group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_float.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_float.c index ce7ce42..8ff9e7b 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_float.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_float.c @@ -1,202 +1,159 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_q31_to_float.c - * Description: Converts the elements of the Q31 vector to floating-point vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - * @defgroup q31_to_x Convert 32-bit fixed point value - */ - -/** - @addtogroup q31_to_x - @{ - */ - -/** - @brief Converts the elements of the Q31 vector to floating-point vector. - @param[in] pSrc points to the Q31 input vector - @param[out] pDst points to the floating-point output vector - @param[in] blockSize number of samples in each vector - @return none - - @par Details - The equation used for the conversion process is: - <pre> - pDst[n] = (float32_t) pSrc[n] / 2147483648; 0 <= n < blockSize. - </pre> - */ -#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_q31_to_float( - const q31_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* loop counters */ - q31x4_t vecDst; - q31_t const *pSrcVec; - - pSrcVec = (q31_t const *) pSrc; - blkCnt = blockSize >> 2; - while (blkCnt > 0U) - { - /* C = (float32_t) A / 2147483648 */ - /* convert from q31 to float and then store the results in the destination buffer */ - vecDst = vld1q(pSrcVec); - pSrcVec += 4; - vstrwq(pDst, vcvtq_n_f32_s32(vecDst, 31)); - pDst += 4; - /* - * Decrement the blockSize loop counter - */ - blkCnt--; - } - /* - * tail - * (will be merged thru tail predication) - */ - blkCnt = blockSize & 3; - while (blkCnt > 0U) - { - /* C = (float32_t) A / 2147483648 */ - - /* Convert from q31 to float and store result in destination buffer */ - *pDst++ = ((float32_t) *pSrcVec++ / 2147483648.0f); - - /* Decrement loop counter */ - blkCnt--; - } -} - -#else -#if defined(ARM_MATH_NEON_EXPERIMENTAL) -void arm_q31_to_float( - const q31_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - const q31_t *pIn = pSrc; /* Src pointer */ - uint32_t blkCnt; /* loop counter */ - - int32x4_t inV; - float32x4_t outV; - - blkCnt = blockSize >> 2U; - - /* Compute 4 outputs at a time. - ** a second loop below computes the remaining 1 to 3 samples. */ - while (blkCnt > 0U) - { - /* C = (float32_t) A / 2147483648 */ - /* Convert from q31 to float and then store the results in the destination buffer */ - inV = vld1q_s32(pIn); - pIn += 4; - - outV = vcvtq_n_f32_s32(inV,31); - - vst1q_f32(pDst, outV); - pDst += 4; - - /* Decrement the loop counter */ - blkCnt--; - } - - /* If the blockSize is not a multiple of 4, compute any remaining output samples here. - ** No loop unrolling is used. */ - blkCnt = blockSize & 3; - - - while (blkCnt > 0U) - { - /* C = (float32_t) A / 2147483648 */ - /* Convert from q31 to float and then store the results in the destination buffer */ - *pDst++ = ((float32_t) * pIn++ / 2147483648.0f); - - /* Decrement the loop counter */ - blkCnt--; - } -} -#else -void arm_q31_to_float( - const q31_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - const q31_t *pIn = pSrc; /* Src pointer */ - uint32_t blkCnt; /* loop counter */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = (float32_t) A / 2147483648 */ - - /* Convert from q31 to float and store result in destination buffer */ - *pDst++ = ((float32_t) *pIn++ / 2147483648.0f); - *pDst++ = ((float32_t) *pIn++ / 2147483648.0f); - *pDst++ = ((float32_t) *pIn++ / 2147483648.0f); - *pDst++ = ((float32_t) *pIn++ / 2147483648.0f); - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = (float32_t) A / 2147483648 */ - - /* Convert from q31 to float and store result in destination buffer */ - *pDst++ = ((float32_t) *pIn++ / 2147483648.0f); - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* #if defined(ARM_MATH_NEON) */ -#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */ - -/** - @} end of q31_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_q31_to_float.c
+ * Description: Converts the elements of the Q31 vector to floating-point vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ * @defgroup q31_to_x Convert 32-bit Integer value
+ */
+
+/**
+ @addtogroup q31_to_x
+ @{
+ */
+
+/**
+ @brief Converts the elements of the Q31 vector to floating-point vector.
+ @param[in] pSrc points to the Q31 input vector
+ @param[out] pDst points to the floating-point output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+
+ @par Details
+ The equation used for the conversion process is:
+ <pre>
+ pDst[n] = (float32_t) pSrc[n] / 2147483648; 0 <= n < blockSize.
+ </pre>
+ */
+
+#if defined(ARM_MATH_NEON_EXPERIMENTAL)
+void arm_q31_to_float(
+ const q31_t * pSrc,
+ float32_t * pDst,
+ uint32_t blockSize)
+{
+ const q31_t *pIn = pSrc; /* Src pointer */
+ uint32_t blkCnt; /* loop counter */
+
+ int32x4_t inV;
+ float32x4_t outV;
+
+ blkCnt = blockSize >> 2U;
+
+ /* Compute 4 outputs at a time.
+ ** a second loop below computes the remaining 1 to 3 samples. */
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 2147483648 */
+ /* Convert from q31 to float and then store the results in the destination buffer */
+ inV = vld1q_s32(pIn);
+ pIn += 4;
+
+ outV = vcvtq_n_f32_s32(inV,31);
+
+ vst1q_f32(pDst, outV);
+ pDst += 4;
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+
+ /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
+ ** No loop unrolling is used. */
+ blkCnt = blockSize & 3;
+
+
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 2147483648 */
+ /* Convert from q31 to float and then store the results in the destination buffer */
+ *pDst++ = ((float32_t) * pIn++ / 2147483648.0f);
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+}
+#else
+void arm_q31_to_float(
+ const q31_t * pSrc,
+ float32_t * pDst,
+ uint32_t blockSize)
+{
+ const q31_t *pIn = pSrc; /* Src pointer */
+ uint32_t blkCnt; /* loop counter */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 2147483648 */
+
+ /* Convert from q31 to float and store result in destination buffer */
+ *pDst++ = ((float32_t) *pIn++ / 2147483648.0f);
+ *pDst++ = ((float32_t) *pIn++ / 2147483648.0f);
+ *pDst++ = ((float32_t) *pIn++ / 2147483648.0f);
+ *pDst++ = ((float32_t) *pIn++ / 2147483648.0f);
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 2147483648 */
+
+ /* Convert from q31 to float and store result in destination buffer */
+ *pDst++ = ((float32_t) *pIn++ / 2147483648.0f);
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+#endif /* #if defined(ARM_MATH_NEON) */
+
+/**
+ @} end of q31_to_x group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_q15.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_q15.c index a25a2bb..8dac98d 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_q15.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_q15.c @@ -1,181 +1,134 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_q31_to_q15.c - * Description: Converts the elements of the Q31 vector to Q15 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup q31_to_x - @{ - */ - -/** - @brief Converts the elements of the Q31 vector to Q15 vector. - @param[in] pSrc points to the Q31 input vector - @param[out] pDst points to the Q15 output vector - @param[in] blockSize number of samples in each vector - @return none - - @par Details - The equation used for the conversion process is: - <pre> - pDst[n] = (q15_t) pSrc[n] >> 16; 0 <= n < blockSize. - </pre> - */ -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_q31_to_q15( - const q31_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* loop counters */ - q31x4x2_t tmp; - q15x8_t vecDst; - q31_t const *pSrcVec; - - - pSrcVec = (q31_t const *) pSrc; - blkCnt = blockSize >> 3; - while (blkCnt > 0U) - { - /* C = (q15_t) A >> 16 */ - /* convert from q31 to q15 and then store the results in the destination buffer */ - tmp = vld2q(pSrcVec); - pSrcVec += 8; - vecDst = vshrnbq_n_s32(vecDst, tmp.val[0], 16); - vecDst = vshrntq_n_s32(vecDst, tmp.val[1], 16); - vst1q(pDst, vecDst); - pDst += 8; - /* - * Decrement the blockSize loop counter - */ - blkCnt--; - } - - /* - * tail - */ - blkCnt = blockSize & 7; - while (blkCnt > 0U) - { - /* C = (q15_t) (A >> 16) */ - - /* Convert from q31 to q15 and store result in destination buffer */ - *pDst++ = (q15_t) (*pSrcVec++ >> 16); - - /* Decrement loop counter */ - blkCnt--; - } -} - -#else -void arm_q31_to_q15( - const q31_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q31_t *pIn = pSrc; /* Source pointer */ - -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t in1, in2, in3, in4; - q31_t out1, out2; -#endif - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = (q15_t) (A >> 16) */ - - /* Convert from q31 to q15 and store result in destination buffer */ -#if defined (ARM_MATH_DSP) - - in1 = *pIn++; - in2 = *pIn++; - in3 = *pIn++; - in4 = *pIn++; - - /* pack two higher 16-bit values from two 32-bit values */ -#ifndef ARM_MATH_BIG_ENDIAN - out1 = __PKHTB(in2, in1, 16); - out2 = __PKHTB(in4, in3, 16); -#else - out1 = __PKHTB(in1, in2, 16); - out2 = __PKHTB(in3, in4, 16); -#endif /* #ifdef ARM_MATH_BIG_ENDIAN */ - - write_q15x2_ia (&pDst, out1); - write_q15x2_ia (&pDst, out2); - -#else - - *pDst++ = (q15_t) (*pIn++ >> 16); - *pDst++ = (q15_t) (*pIn++ >> 16); - *pDst++ = (q15_t) (*pIn++ >> 16); - *pDst++ = (q15_t) (*pIn++ >> 16); - -#endif /* #if defined (ARM_MATH_DSP) */ - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = (q15_t) (A >> 16) */ - - /* Convert from q31 to q15 and store result in destination buffer */ - *pDst++ = (q15_t) (*pIn++ >> 16); - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of q31_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_q31_to_q15.c
+ * Description: Converts the elements of the Q31 vector to Q15 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup q31_to_x
+ @{
+ */
+
+/**
+ @brief Converts the elements of the Q31 vector to Q15 vector.
+ @param[in] pSrc points to the Q31 input vector
+ @param[out] pDst points to the Q15 output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+
+ @par Details
+ The equation used for the conversion process is:
+ <pre>
+ pDst[n] = (q15_t) pSrc[n] >> 16; 0 <= n < blockSize.
+ </pre>
+ */
+
+void arm_q31_to_q15(
+ const q31_t * pSrc,
+ q15_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+ const q31_t *pIn = pSrc; /* Source pointer */
+
+#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP)
+ q31_t in1, in2, in3, in4;
+ q31_t out1, out2;
+#endif
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q15_t) (A >> 16) */
+
+ /* Convert from q31 to q15 and store result in destination buffer */
+#if defined (ARM_MATH_DSP)
+
+ in1 = *pIn++;
+ in2 = *pIn++;
+ in3 = *pIn++;
+ in4 = *pIn++;
+
+ /* pack two higher 16-bit values from two 32-bit values */
+#ifndef ARM_MATH_BIG_ENDIAN
+ out1 = __PKHTB(in2, in1, 16);
+ out2 = __PKHTB(in4, in3, 16);
+#else
+ out1 = __PKHTB(in1, in2, 16);
+ out2 = __PKHTB(in3, in4, 16);
+#endif /* #ifdef ARM_MATH_BIG_ENDIAN */
+
+ write_q15x2_ia (&pDst, out1);
+ write_q15x2_ia (&pDst, out2);
+
+#else
+
+ *pDst++ = (q15_t) (*pIn++ >> 16);
+ *pDst++ = (q15_t) (*pIn++ >> 16);
+ *pDst++ = (q15_t) (*pIn++ >> 16);
+ *pDst++ = (q15_t) (*pIn++ >> 16);
+
+#endif /* #if defined (ARM_MATH_DSP) */
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q15_t) (A >> 16) */
+
+ /* Convert from q31 to q15 and store result in destination buffer */
+ *pDst++ = (q15_t) (*pIn++ >> 16);
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+
+/**
+ @} end of q31_to_x group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_q7.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_q7.c index 16fbe18..80433d0 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_q7.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q31_to_q7.c @@ -1,169 +1,110 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_q31_to_q7.c - * Description: Converts the elements of the Q31 vector to Q7 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup q31_to_x - @{ - */ - -/** - @brief Converts the elements of the Q31 vector to Q7 vector. - @param[in] pSrc points to the Q31 input vector - @param[out] pDst points to the Q7 output vector - @param[in] blockSize number of samples in each vector - @return none - - @par Details - The equation used for the conversion process is: - <pre> - pDst[n] = (q7_t) pSrc[n] >> 24; 0 <= n < blockSize. - </pre> - */ -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_q31_to_q7( - const q31_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* loop counters */ - q31x4x4_t tmp; - q15x8_t evVec, oddVec; - q7x16_t vecDst; - q31_t const *pSrcVec; - - pSrcVec = (q31_t const *) pSrc; - blkCnt = blockSize >> 4; - while (blkCnt > 0U) - { - tmp = vld4q(pSrcVec); - pSrcVec += 16; - /* C = (q7_t) A >> 24 */ - /* convert from q31 to q7 and then store the results in the destination buffer */ - /* - * narrow and pack evens - */ - evVec = vshrnbq_n_s32(evVec, tmp.val[0], 16); - evVec = vshrntq_n_s32(evVec, tmp.val[2], 16); - /* - * narrow and pack odds - */ - oddVec = vshrnbq_n_s32(oddVec, tmp.val[1], 16); - oddVec = vshrntq_n_s32(oddVec, tmp.val[3], 16); - /* - * narrow & merge - */ - vecDst = vshrnbq_n_s16(vecDst, evVec, 8); - vecDst = vshrntq_n_s16(vecDst, oddVec, 8); - - vst1q(pDst, vecDst); - pDst += 16; - /* - * Decrement the blockSize loop counter - */ - blkCnt--; - } - /* - * tail - */ - blkCnt = blockSize & 0xF; - while (blkCnt > 0U) - { - /* C = (q7_t) (A >> 24) */ - - /* Convert from q31 to q7 and store result in destination buffer */ - *pDst++ = (q7_t) (*pSrcVec++ >> 24); - - /* Decrement loop counter */ - blkCnt--; - } -} -#else -void arm_q31_to_q7( - const q31_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q31_t *pIn = pSrc; /* Source pointer */ - -#if defined (ARM_MATH_LOOPUNROLL) - - q7_t out1, out2, out3, out4; - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = (q7_t) (A >> 24) */ - - /* Convert from q31 to q7 and store result in destination buffer */ - - out1 = (q7_t) (*pIn++ >> 24); - out2 = (q7_t) (*pIn++ >> 24); - out3 = (q7_t) (*pIn++ >> 24); - out4 = (q7_t) (*pIn++ >> 24); - write_q7x4_ia (&pDst, __PACKq7(out1, out2, out3, out4)); - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = (q7_t) (A >> 24) */ - - /* Convert from q31 to q7 and store result in destination buffer */ - *pDst++ = (q7_t) (*pIn++ >> 24); - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of q31_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_q31_to_q7.c
+ * Description: Converts the elements of the Q31 vector to Q7 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup q31_to_x
+ @{
+ */
+
+/**
+ @brief Converts the elements of the Q31 vector to Q7 vector.
+ @param[in] pSrc points to the Q31 input vector
+ @param[out] pDst points to the Q7 output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+
+ @par Details
+ The equation used for the conversion process is:
+ <pre>
+ pDst[n] = (q7_t) pSrc[n] >> 24; 0 <= n < blockSize.
+ </pre>
+ */
+
+void arm_q31_to_q7(
+ const q31_t * pSrc,
+ q7_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+ const q31_t *pIn = pSrc; /* Source pointer */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ q7_t out1, out2, out3, out4;
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q7_t) (A >> 24) */
+
+ /* Convert from q31 to q7 and store result in destination buffer */
+
+ out1 = (q7_t) (*pIn++ >> 24);
+ out2 = (q7_t) (*pIn++ >> 24);
+ out3 = (q7_t) (*pIn++ >> 24);
+ out4 = (q7_t) (*pIn++ >> 24);
+ write_q7x4_ia (&pDst, __PACKq7(out1, out2, out3, out4));
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q7_t) (A >> 24) */
+
+ /* Convert from q31 to q7 and store result in destination buffer */
+ *pDst++ = (q7_t) (*pIn++ >> 24);
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+
+/**
+ @} end of q31_to_x group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_float.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_float.c index 9cbf8ad..eee0d98 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_float.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_float.c @@ -1,218 +1,179 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_q7_to_float.c - * Description: Converts the elements of the Q7 vector to floating-point vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - * @defgroup q7_to_x Convert 8-bit fixed point value - */ - -/** - @addtogroup q7_to_x - @{ - */ - -/** - @brief Converts the elements of the Q7 vector to floating-point vector. - @param[in] pSrc points to the Q7 input vector - @param[out] pDst points to the floating-point output vector - @param[in] blockSize number of samples in each vector - @return none - - @par Details - The equation used for the conversion process is: - <pre> - pDst[n] = (float32_t) pSrc[n] / 128; 0 <= n < blockSize. - </pre> - */ -#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_q7_to_float( - const q7_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* loop counters */ - q7x16_t vecDst; - q7_t const *pSrcVec; - - pSrcVec = (q7_t const *) pSrc; - blkCnt = blockSize >> 2; - while (blkCnt > 0U) - { - /* C = (float32_t) A / 32768 */ - /* convert from q7 to float and then store the results in the destination buffer */ - vecDst = vldrbq_s32(pSrcVec); - pSrcVec += 4; - vstrwq(pDst, vcvtq_n_f32_s32((int32x4_t)vecDst, 7)); - pDst += 4; - /* - * Decrement the blockSize loop counter - */ - blkCnt--; - } - - blkCnt = blockSize & 3; - while (blkCnt > 0U) - { - /* C = (float32_t) A / 128 */ - - /* Convert from q7 to float and store result in destination buffer */ - *pDst++ = ((float32_t) * pSrcVec++ / 128.0f); - - /* Decrement loop counter */ - blkCnt--; - } -} -#else -#if defined(ARM_MATH_NEON) -void arm_q7_to_float( - const q7_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - const q7_t *pIn = pSrc; /* Src pointer */ - uint32_t blkCnt; /* loop counter */ - - int8x16_t inV; - int16x8_t inVLO, inVHI; - int32x4_t inVLL, inVLH, inVHL, inVHH; - float32x4_t outV; - - blkCnt = blockSize >> 4U; - - /* Compute 16 outputs at a time. - ** a second loop below computes the remaining 1 to 15 samples. */ - while (blkCnt > 0U) - { - /* C = (float32_t) A / 128 */ - /* Convert from q7 to float and then store the results in the destination buffer */ - inV = vld1q_s8(pIn); - pIn += 16; - - inVLO = vmovl_s8(vget_low_s8(inV)); - inVHI = vmovl_s8(vget_high_s8(inV)); - - inVLL = vmovl_s16(vget_low_s16(inVLO)); - inVLH = vmovl_s16(vget_high_s16(inVLO)); - inVHL = vmovl_s16(vget_low_s16(inVHI)); - inVHH = vmovl_s16(vget_high_s16(inVHI)); - - outV = vcvtq_n_f32_s32(inVLL,7); - vst1q_f32(pDst, outV); - pDst += 4; - - outV = vcvtq_n_f32_s32(inVLH,7); - vst1q_f32(pDst, outV); - pDst += 4; - - outV = vcvtq_n_f32_s32(inVHL,7); - vst1q_f32(pDst, outV); - pDst += 4; - - outV = vcvtq_n_f32_s32(inVHH,7); - vst1q_f32(pDst, outV); - pDst += 4; - - /* Decrement the loop counter */ - blkCnt--; - } - - /* If the blockSize is not a multiple of 16, compute any remaining output samples here. - ** No loop unrolling is used. */ - blkCnt = blockSize & 0xF; - - while (blkCnt > 0U) - { - /* C = (float32_t) A / 128 */ - /* Convert from q7 to float and then store the results in the destination buffer */ - *pDst++ = ((float32_t) * pIn++ / 128.0f); - - /* Decrement the loop counter */ - blkCnt--; - } -} -#else -void arm_q7_to_float( - const q7_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q7_t *pIn = pSrc; /* Source pointer */ - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = (float32_t) A / 128 */ - - /* Convert from q7 to float and store result in destination buffer */ - *pDst++ = ((float32_t) * pIn++ / 128.0f); - *pDst++ = ((float32_t) * pIn++ / 128.0f); - *pDst++ = ((float32_t) * pIn++ / 128.0f); - *pDst++ = ((float32_t) * pIn++ / 128.0f); - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = (float32_t) A / 128 */ - - /* Convert from q7 to float and store result in destination buffer */ - *pDst++ = ((float32_t) * pIn++ / 128.0f); - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* #if defined(ARM_MATH_NEON) */ -#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */ - -/** - @} end of q7_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_q7_to_float.c
+ * Description: Converts the elements of the Q7 vector to floating-point vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ * @defgroup q7_to_x Convert 8-bit Integer value
+ */
+
+/**
+ @addtogroup q7_to_x
+ @{
+ */
+
+/**
+ @brief Converts the elements of the Q7 vector to floating-point vector.
+ @param[in] pSrc points to the Q7 input vector
+ @param[out] pDst points to the floating-point output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+
+ @par Details
+ The equation used for the conversion process is:
+ <pre>
+ pDst[n] = (float32_t) pSrc[n] / 128; 0 <= n < blockSize.
+ </pre>
+ */
+
+#if defined(ARM_MATH_NEON)
+void arm_q7_to_float(
+ const q7_t * pSrc,
+ float32_t * pDst,
+ uint32_t blockSize)
+{
+ const q7_t *pIn = pSrc; /* Src pointer */
+ uint32_t blkCnt; /* loop counter */
+
+ int8x16_t inV;
+ int16x8_t inVLO, inVHI;
+ int32x4_t inVLL, inVLH, inVHL, inVHH;
+ float32x4_t outV;
+
+ blkCnt = blockSize >> 4U;
+
+ /* Compute 16 outputs at a time.
+ ** a second loop below computes the remaining 1 to 15 samples. */
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 128 */
+ /* Convert from q7 to float and then store the results in the destination buffer */
+ inV = vld1q_s8(pIn);
+ pIn += 16;
+
+ inVLO = vmovl_s8(vget_low_s8(inV));
+ inVHI = vmovl_s8(vget_high_s8(inV));
+
+ inVLL = vmovl_s16(vget_low_s16(inVLO));
+ inVLH = vmovl_s16(vget_high_s16(inVLO));
+ inVHL = vmovl_s16(vget_low_s16(inVHI));
+ inVHH = vmovl_s16(vget_high_s16(inVHI));
+
+ outV = vcvtq_n_f32_s32(inVLL,7);
+ vst1q_f32(pDst, outV);
+ pDst += 4;
+
+ outV = vcvtq_n_f32_s32(inVLH,7);
+ vst1q_f32(pDst, outV);
+ pDst += 4;
+
+ outV = vcvtq_n_f32_s32(inVHL,7);
+ vst1q_f32(pDst, outV);
+ pDst += 4;
+
+ outV = vcvtq_n_f32_s32(inVHH,7);
+ vst1q_f32(pDst, outV);
+ pDst += 4;
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+
+ /* If the blockSize is not a multiple of 16, compute any remaining output samples here.
+ ** No loop unrolling is used. */
+ blkCnt = blockSize & 0xF;
+
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 128 */
+ /* Convert from q7 to float and then store the results in the destination buffer */
+ *pDst++ = ((float32_t) * pIn++ / 128.0f);
+
+ /* Decrement the loop counter */
+ blkCnt--;
+ }
+}
+#else
+void arm_q7_to_float(
+ const q7_t * pSrc,
+ float32_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+ const q7_t *pIn = pSrc; /* Source pointer */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 128 */
+
+ /* Convert from q7 to float and store result in destination buffer */
+ *pDst++ = ((float32_t) * pIn++ / 128.0f);
+ *pDst++ = ((float32_t) * pIn++ / 128.0f);
+ *pDst++ = ((float32_t) * pIn++ / 128.0f);
+ *pDst++ = ((float32_t) * pIn++ / 128.0f);
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = (float32_t) A / 128 */
+
+ /* Convert from q7 to float and store result in destination buffer */
+ *pDst++ = ((float32_t) * pIn++ / 128.0f);
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+#endif /* #if defined(ARM_MATH_NEON) */
+
+/**
+ @} end of q7_to_x group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_q15.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_q15.c index be52531..78dae9e 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_q15.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_q15.c @@ -1,188 +1,143 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_q7_to_q15.c - * Description: Converts the elements of the Q7 vector to Q15 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup q7_to_x - @{ - */ - -/** - @brief Converts the elements of the Q7 vector to Q15 vector. - @param[in] pSrc points to the Q7 input vector - @param[out] pDst points to the Q15 output vector - @param[in] blockSize number of samples in each vector - @return none - - @par Details - The equation used for the conversion process is: - <pre> - pDst[n] = (q15_t) pSrc[n] << 8; 0 <= n < blockSize. - </pre> - */ - -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_q7_to_q15( - const q7_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - - uint32_t blkCnt; /* loop counters */ - q15x8_t vecDst; - q7_t const *pSrcVec; - - - pSrcVec = (q7_t const *) pSrc; - blkCnt = blockSize >> 3; - while (blkCnt > 0U) - { - /* C = (q15_t) A << 8 */ - /* convert from q7 to q15 and then store the results in the destination buffer */ - /* load q7 + 32-bit widening */ - vecDst = vldrbq_s16(pSrcVec); - pSrcVec += 8; - vecDst = vecDst << 8; - vstrhq(pDst, vecDst); - pDst += 8; - /* - * Decrement the blockSize loop counter - */ - blkCnt--; - } - - blkCnt = blockSize & 7; - while (blkCnt > 0U) - { - /* C = (q15_t) A << 8 */ - - /* Convert from q7 to q15 and store result in destination buffer */ - *pDst++ = (q15_t) * pSrcVec++ << 8; - - /* Decrement loop counter */ - blkCnt--; - } - -} -#else -void arm_q7_to_q15( - const q7_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q7_t *pIn = pSrc; /* Source pointer */ - -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t in; - q31_t in1, in2; - q31_t out1, out2; -#endif - -#if defined (ARM_MATH_LOOPUNROLL) - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = (q15_t) A << 8 */ - - /* Convert from q7 to q15 and store result in destination buffer */ -#if defined (ARM_MATH_DSP) - - in = read_q7x4_ia (&pIn); - - /* rotatate in by 8 and extend two q7_t values to q15_t values */ - in1 = __SXTB16(__ROR(in, 8)); - - /* extend remainig two q7_t values to q15_t values */ - in2 = __SXTB16(in); - - in1 = in1 << 8U; - in2 = in2 << 8U; - - in1 = in1 & 0xFF00FF00; - in2 = in2 & 0xFF00FF00; - -#ifndef ARM_MATH_BIG_ENDIAN - out2 = __PKHTB(in1, in2, 16); - out1 = __PKHBT(in2, in1, 16); -#else - out1 = __PKHTB(in1, in2, 16); - out2 = __PKHBT(in2, in1, 16); -#endif - - write_q15x2_ia (&pDst, out1); - write_q15x2_ia (&pDst, out2); - -#else - - *pDst++ = (q15_t) *pIn++ << 8; - *pDst++ = (q15_t) *pIn++ << 8; - *pDst++ = (q15_t) *pIn++ << 8; - *pDst++ = (q15_t) *pIn++ << 8; - -#endif /* #if defined (ARM_MATH_DSP) */ - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = (q15_t) A << 8 */ - - /* Convert from q7 to q15 and store result in destination buffer */ - *pDst++ = (q15_t) * pIn++ << 8; - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of q7_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_q7_to_q15.c
+ * Description: Converts the elements of the Q7 vector to Q15 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup q7_to_x
+ @{
+ */
+
+/**
+ @brief Converts the elements of the Q7 vector to Q15 vector.
+ @param[in] pSrc points to the Q7 input vector
+ @param[out] pDst points to the Q15 output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+
+ @par Details
+ The equation used for the conversion process is:
+ <pre>
+ pDst[n] = (q15_t) pSrc[n] << 8; 0 <= n < blockSize.
+ </pre>
+ */
+
+void arm_q7_to_q15(
+ const q7_t * pSrc,
+ q15_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+ const q7_t *pIn = pSrc; /* Source pointer */
+
+#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP)
+ q31_t in;
+ q31_t in1, in2;
+ q31_t out1, out2;
+#endif
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q15_t) A << 8 */
+
+ /* Convert from q7 to q15 and store result in destination buffer */
+#if defined (ARM_MATH_DSP)
+
+ in = read_q7x4_ia ((q7_t **) &pIn);
+
+ /* rotatate in by 8 and extend two q7_t values to q15_t values */
+ in1 = __SXTB16(__ROR(in, 8));
+
+ /* extend remainig two q7_t values to q15_t values */
+ in2 = __SXTB16(in);
+
+ in1 = in1 << 8U;
+ in2 = in2 << 8U;
+
+ in1 = in1 & 0xFF00FF00;
+ in2 = in2 & 0xFF00FF00;
+
+#ifndef ARM_MATH_BIG_ENDIAN
+ out2 = __PKHTB(in1, in2, 16);
+ out1 = __PKHBT(in2, in1, 16);
+#else
+ out1 = __PKHTB(in1, in2, 16);
+ out2 = __PKHBT(in2, in1, 16);
+#endif
+
+ write_q15x2_ia (&pDst, out1);
+ write_q15x2_ia (&pDst, out2);
+
+#else
+
+ *pDst++ = (q15_t) *pIn++ << 8;
+ *pDst++ = (q15_t) *pIn++ << 8;
+ *pDst++ = (q15_t) *pIn++ << 8;
+ *pDst++ = (q15_t) *pIn++ << 8;
+
+#endif /* #if defined (ARM_MATH_DSP) */
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q15_t) A << 8 */
+
+ /* Convert from q7 to q15 and store result in destination buffer */
+ *pDst++ = (q15_t) * pIn++ << 8;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+
+/**
+ @} end of q7_to_x group
+ */
diff --git a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_q31.c b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_q31.c index 01d5f2b..9d5cde9 100644 --- a/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_q31.c +++ b/Drivers/CMSIS/DSP/Source/SupportFunctions/arm_q7_to_q31.c @@ -1,164 +1,121 @@ -/* ---------------------------------------------------------------------- - * Project: CMSIS DSP Library - * Title: arm_q7_to_q31.c - * Description: Converts the elements of the Q7 vector to Q31 vector - * - * $Date: 23 April 2021 - * $Revision: V1.9.0 - * - * Target Processor: Cortex-M and Cortex-A cores - * -------------------------------------------------------------------- */ -/* - * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dsp/support_functions.h" - -/** - @ingroup groupSupport - */ - -/** - @addtogroup q7_to_x - @{ - */ - -/** - @brief Converts the elements of the Q7 vector to Q31 vector. - @param[in] pSrc points to the Q7 input vector - @param[out] pDst points to the Q31 output vector - @param[in] blockSize number of samples in each vector - @return none - - @par Details - The equation used for the conversion process is: - <pre> - pDst[n] = (q31_t) pSrc[n] << 24; 0 <= n < blockSize. - </pre> - */ -#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE) -void arm_q7_to_q31( - const q7_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; - q31x4_t vecDst; - - blkCnt = blockSize >> 2; - while (blkCnt > 0U) - { - - /* C = (q31_t)A << 16 */ - /* convert from q15 to q31 and then store the results in the destination buffer */ - /* load q15 + 32-bit widening */ - vecDst = vldrbq_s32((q7_t const *) pSrc); - vecDst = vshlq_n(vecDst, 24); - vstrwq_s32(pDst, vecDst); - - /* - * Decrement the blockSize loop counter - * Advance vector source and destination pointers - */ - pDst += 4; - pSrc += 4; - blkCnt --; - } - - blkCnt = blockSize & 3; - while (blkCnt > 0U) - { - /* C = (q31_t) A << 24 */ - - /* Convert from q7 to q31 and store result in destination buffer */ - *pDst++ = (q31_t) *pSrc++ << 24; - - /* Decrement loop counter */ - blkCnt--; - } -} - -#else -void arm_q7_to_q31( - const q7_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q7_t *pIn = pSrc; /* Source pointer */ - -#if defined (ARM_MATH_LOOPUNROLL) - - q31_t in; - - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = blockSize >> 2U; - - while (blkCnt > 0U) - { - /* C = (q31_t) A << 24 */ - - /* Convert from q7 to q31 and store result in destination buffer */ - in = read_q7x4_ia (&pIn); - -#ifndef ARM_MATH_BIG_ENDIAN - - *pDst++ = (__ROR(in, 8)) & 0xFF000000; - *pDst++ = (__ROR(in, 16)) & 0xFF000000; - *pDst++ = (__ROR(in, 24)) & 0xFF000000; - *pDst++ = (in & 0xFF000000); - -#else - - *pDst++ = (in & 0xFF000000); - *pDst++ = (__ROR(in, 24)) & 0xFF000000; - *pDst++ = (__ROR(in, 16)) & 0xFF000000; - *pDst++ = (__ROR(in, 8)) & 0xFF000000; - -#endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - - /* Decrement loop counter */ - blkCnt--; - } - - /* Loop unrolling: Compute remaining outputs */ - blkCnt = blockSize % 0x4U; - -#else - - /* Initialize blkCnt with number of samples */ - blkCnt = blockSize; - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - - while (blkCnt > 0U) - { - /* C = (q31_t) A << 24 */ - - /* Convert from q7 to q31 and store result in destination buffer */ - *pDst++ = (q31_t) * pIn++ << 24; - - /* Decrement loop counter */ - blkCnt--; - } - -} -#endif /* defined(ARM_MATH_MVEI) */ - -/** - @} end of q7_to_x group - */ +/* ----------------------------------------------------------------------
+ * Project: CMSIS DSP Library
+ * Title: arm_q7_to_q31.c
+ * Description: Converts the elements of the Q7 vector to Q31 vector
+ *
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
+ *
+ * Target Processor: Cortex-M cores
+ * -------------------------------------------------------------------- */
+/*
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "arm_math.h"
+
+/**
+ @ingroup groupSupport
+ */
+
+/**
+ @addtogroup q7_to_x
+ @{
+ */
+
+/**
+ @brief Converts the elements of the Q7 vector to Q31 vector.
+ @param[in] pSrc points to the Q7 input vector
+ @param[out] pDst points to the Q31 output vector
+ @param[in] blockSize number of samples in each vector
+ @return none
+
+ @par Details
+ The equation used for the conversion process is:
+ <pre>
+ pDst[n] = (q31_t) pSrc[n] << 24; 0 <= n < blockSize.
+ </pre>
+ */
+
+void arm_q7_to_q31(
+ const q7_t * pSrc,
+ q31_t * pDst,
+ uint32_t blockSize)
+{
+ uint32_t blkCnt; /* Loop counter */
+ const q7_t *pIn = pSrc; /* Source pointer */
+
+#if defined (ARM_MATH_LOOPUNROLL)
+
+ q31_t in;
+
+ /* Loop unrolling: Compute 4 outputs at a time */
+ blkCnt = blockSize >> 2U;
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q31_t) A << 24 */
+
+ /* Convert from q7 to q31 and store result in destination buffer */
+ in = read_q7x4_ia ((q7_t **) &pIn);
+
+#ifndef ARM_MATH_BIG_ENDIAN
+
+ *pDst++ = (__ROR(in, 8)) & 0xFF000000;
+ *pDst++ = (__ROR(in, 16)) & 0xFF000000;
+ *pDst++ = (__ROR(in, 24)) & 0xFF000000;
+ *pDst++ = (in & 0xFF000000);
+
+#else
+
+ *pDst++ = (in & 0xFF000000);
+ *pDst++ = (__ROR(in, 24)) & 0xFF000000;
+ *pDst++ = (__ROR(in, 16)) & 0xFF000000;
+ *pDst++ = (__ROR(in, 8)) & 0xFF000000;
+
+#endif /* #ifndef ARM_MATH_BIG_ENDIAN */
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+ /* Loop unrolling: Compute remaining outputs */
+ blkCnt = blockSize % 0x4U;
+
+#else
+
+ /* Initialize blkCnt with number of samples */
+ blkCnt = blockSize;
+
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
+
+ while (blkCnt > 0U)
+ {
+ /* C = (q31_t) A << 24 */
+
+ /* Convert from q7 to q31 and store result in destination buffer */
+ *pDst++ = (q31_t) * pIn++ << 24;
+
+ /* Decrement loop counter */
+ blkCnt--;
+ }
+
+}
+
+/**
+ @} end of q7_to_x group
+ */
|