1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_float_to_q15.c
4 * Description: Converts the elements of the floating-point vector to Q15 vector
5 *
6 * $Date: 23 April 2021
7 * $Revision: V1.9.0
8 *
9 * Target Processor: Cortex-M and Cortex-A cores
10 * -------------------------------------------------------------------- */
11 /*
12 * Copyright (C) 2010-2021 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_f16.h"
30
31 #if defined(ARM_FLOAT16_SUPPORTED)
32
33
34 /**
35 @ingroup groupSupport
36 */
37
38 /**
39 * @defgroup f16_to_x Convert 16-bit floating point value
40 */
41
42 /**
43 @addtogroup f16_to_x
44 @{
45 */
46
47 /**
48 @brief Converts the elements of the f16 vector to f32 vector.
49 @param[in] pSrc points to the f16 input vector
50 @param[out] pDst points to the f32 output vector
51 @param[in] blockSize number of samples in each vector
52
53 */
54
55 #if defined(ARM_MATH_MVE_FLOAT16) && !defined(ARM_MATH_AUTOVECTORIZE) && defined(ARM_DSP_BUILT_WITH_GCC)
56 #pragma message "Scalar version of arm_f16_to_float built. Helium version has build issues with gcc."
57 #endif
58
59 #if defined(ARM_MATH_MVE_FLOAT16) && !defined(ARM_MATH_AUTOVECTORIZE) && !defined(ARM_DSP_BUILT_WITH_GCC)
60
arm_f16_to_float(const float16_t * pSrc,float32_t * pDst,uint32_t blockSize)61 ARM_DSP_ATTRIBUTE void arm_f16_to_float(
62 const float16_t * pSrc,
63 float32_t * pDst,
64 uint32_t blockSize)
65 {
66 int32_t blkCnt; /* loop counters */
67 float16x8_t vecDst;
68 float32x4x2_t tmp;
69
70 blkCnt = blockSize >> 3;
71 while (blkCnt > 0)
72 {
73 vecDst = vldrhq_f16(pSrc);
74 pSrc += 8;
75
76 tmp.val[0] = vcvtbq_f32_f16(vecDst);
77 tmp.val[1] = vcvttq_f32_f16(vecDst);
78 vst2q(pDst,tmp);
79
80 pDst += 8;
81 /*
82 * Decrement the blockSize loop counter
83 */
84 blkCnt--;
85 }
86 /*
87 * tail
88 * (will be merged thru tail predication)
89 */
90 blkCnt = blockSize & 7;
91 while (blkCnt > 0)
92 {
93
94 *pDst++ = (float32_t) *pSrc++;
95 /*
96 * Decrement the loop counter
97 */
98 blkCnt--;
99 }
100 }
101
102 #else
arm_f16_to_float(const float16_t * pSrc,float32_t * pDst,uint32_t blockSize)103 ARM_DSP_ATTRIBUTE void arm_f16_to_float(
104 const float16_t * pSrc,
105 float32_t * pDst,
106 uint32_t blockSize)
107 {
108 const float16_t *pIn = pSrc; /* Src pointer */
109 uint32_t blkCnt; /* loop counter */
110
111 /*
112 * Loop over blockSize number of values
113 */
114 blkCnt = blockSize;
115
116 while (blkCnt > 0U)
117 {
118
119 *pDst++ = (float32_t) * pIn++;
120 /*
121 * Decrement the loop counter
122 */
123 blkCnt--;
124 }
125 }
126 #endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */
127
128 /**
129 @} end of f16_to_x group
130 */
131
132 #endif /* #if defined(ARM_FLOAT16_SUPPORTED) */
133
134