1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_q31_to_f64.c
4 * Description: Converts the elements of the Q31 vector to 64 bit floating-point vector
5 *
6 * $Date: 18 August 2022
7 * $Revision: V1.0.0
8 *
9 * Target Processor: Cortex-M and Cortex-A cores
10 * -------------------------------------------------------------------- */
11 /*
12 * Copyright (C) 2010-2022 ARM Limited or its affiliates. All rights reserved.
13 *
14 * SPDX-License-Identifier: Apache-2.0
15 *
16 * Licensed under the Apache License, Version 2.0 (the License); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19 *
20 * www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 */
28
29 #include "dsp/support_functions.h"
30
31 /**
32 @ingroup groupSupport
33 */
34
35 /**
36 * @defgroup q31_to_x Convert 32-bit fixed point value
37 */
38
39 /**
40 @addtogroup q31_to_x
41 @{
42 */
43
44 /**
45 @brief Converts the elements of the Q31 vector to 64 bit floating-point vector.
46 @param[in] pSrc points to the Q31 input vector
47 @param[out] pDst points to the 64 bit floating-point output vector
48 @param[in] blockSize number of samples in each vector
49 @return none
50
51 @par Details
52 The equation used for the conversion process is:
53 <pre>
54 pDst[n] = (float64_t) pSrc[n] / 2147483648; 0 <= n < blockSize.
55 </pre>
56 */
57
arm_q31_to_f64(const q31_t * pSrc,float64_t * pDst,uint32_t blockSize)58 void arm_q31_to_f64(
59 const q31_t * pSrc,
60 float64_t * pDst,
61 uint32_t blockSize)
62 {
63 const q31_t *pIn = pSrc; /* Src pointer */
64 uint32_t blkCnt; /* loop counter */
65
66 #if defined (ARM_MATH_LOOPUNROLL)
67
68 /* Loop unrolling */
69 blkCnt = blockSize >> 2U;
70
71 while (blkCnt > 0U)
72 {
73 /* C = (float64_t) A / 2147483648 */
74
75 /* Convert from q31 to float and store result in destination buffer */
76 *pDst++ = ((float64_t) *pIn++ / 2147483648.0);
77 *pDst++ = ((float64_t) *pIn++ / 2147483648.0);
78 *pDst++ = ((float64_t) *pIn++ / 2147483648.0);
79 *pDst++ = ((float64_t) *pIn++ / 2147483648.0);
80
81 /* Decrement loop counter */
82 blkCnt--;
83 }
84
85 /* Loop unrolling: Compute remaining outputs */
86 blkCnt = blockSize % 0x4U;
87
88 #else
89
90 /* Initialize blkCnt with number of samples */
91 blkCnt = blockSize;
92
93 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
94
95 while (blkCnt > 0U)
96 {
97 /* C = (float64_t) A / 2147483648 */
98
99 /* Convert from q31 to float and store result in destination buffer */
100 *pDst++ = ((float64_t) *pIn++ / 2147483648.0);
101
102 /* Decrement loop counter */
103 blkCnt--;
104 }
105
106 }
107
108
109 /**
110 @} end of q31_to_x group
111 */
112