1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_q7_to_q15.c
4 * Description: Converts the elements of the Q7 vector to Q15 vector
6 * $Date: 27. January 2017
9 * Target Processor: Cortex-M cores
10 * -------------------------------------------------------------------- */
12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
14 * SPDX-License-Identifier: Apache-2.0
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
20 * www.apache.org/licenses/LICENSE-2.0
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.
32 * @ingroup groupSupport
44 * @brief Converts the elements of the Q7 vector to Q15 vector.
45 * @param[in] *pSrc points to the Q7 input vector
46 * @param[out] *pDst points to the Q15 output vector
47 * @param[in] blockSize length of the input vector
52 * The equation used for the conversion process is:
55 * pDst[n] = (q15_t) pSrc[n] << 8; 0 <= n < blockSize.
66 q7_t
*pIn
= pSrc
; /* Src pointer */
67 uint32_t blkCnt
; /* loop counter */
69 #if defined (ARM_MATH_DSP)
74 /* Run the below code for Cortex-M4 and Cortex-M3 */
77 blkCnt
= blockSize
>> 2U;
79 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
80 ** a second loop below computes the remaining 1 to 3 samples. */
83 /* C = (q15_t) A << 8 */
84 /* convert from q7 to q15 and then store the results in the destination buffer */
85 in
= *__SIMD32(pIn
)++;
87 /* rotatate in by 8 and extend two q7_t values to q15_t values */
88 in1
= __SXTB16(__ROR(in
, 8));
90 /* extend remainig two q7_t values to q15_t values */
96 in1
= in1
& 0xFF00FF00;
97 in2
= in2
& 0xFF00FF00;
99 #ifndef ARM_MATH_BIG_ENDIAN
101 out2
= __PKHTB(in1
, in2
, 16);
102 out1
= __PKHBT(in2
, in1
, 16);
106 out1
= __PKHTB(in1
, in2
, 16);
107 out2
= __PKHBT(in2
, in1
, 16);
111 *__SIMD32(pDst
)++ = out1
;
112 *__SIMD32(pDst
)++ = out2
;
114 /* Decrement the loop counter */
118 /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
119 ** No loop unrolling is used. */
120 blkCnt
= blockSize
% 0x4U
;
124 /* Run the below code for Cortex-M0 */
126 /* Loop over blockSize number of values */
129 #endif /* #if defined (ARM_MATH_DSP) */
133 /* C = (q15_t) A << 8 */
134 /* convert from q7 to q15 and then store the results in the destination buffer */
135 *pDst
++ = (q15_t
) * pIn
++ << 8;
137 /* Decrement the loop counter */
144 * @} end of q7_to_x group