1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_copy_q7.c
4 * Description: Copies the elements of a Q7 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.h"
30
31 /**
32 @ingroup groupSupport
33 */
34
35 /**
36 @addtogroup copy
37 @{
38 */
39
40 /**
41 @brief Copies the elements of a Q7 vector.
42 @param[in] pSrc points to input vector
43 @param[out] pDst points to output vector
44 @param[in] blockSize number of samples in each vector
45 */
46 #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
arm_copy_q7(const q7_t * pSrc,q7_t * pDst,uint32_t blockSize)47 ARM_DSP_ATTRIBUTE void arm_copy_q7(
48 const q7_t * pSrc,
49 q7_t * pDst,
50 uint32_t blockSize)
51 {
52
53 uint32_t blkCnt;
54
55 blkCnt = blockSize >> 4;
56 while (blkCnt > 0U)
57 {
58
59 vstrbq_s8(pDst,vldrbq_s8(pSrc));
60 /*
61 * Decrement the blockSize loop counter
62 * Advance vector source and destination pointers
63 */
64 pSrc += 16;
65 pDst += 16;
66 blkCnt --;
67 }
68
69 blkCnt = blockSize & 0xF;
70 while (blkCnt > 0U)
71 {
72 /* C = A */
73
74 /* Copy and store result in destination buffer */
75 *pDst++ = *pSrc++;
76
77 /* Decrement loop counter */
78 blkCnt--;
79 }
80 }
81
82 #else
arm_copy_q7(const q7_t * pSrc,q7_t * pDst,uint32_t blockSize)83 ARM_DSP_ATTRIBUTE void arm_copy_q7(
84 const q7_t * pSrc,
85 q7_t * pDst,
86 uint32_t blockSize)
87 {
88 uint32_t blkCnt; /* Loop counter */
89
90 #if defined (ARM_MATH_LOOPUNROLL)
91
92 /* Loop unrolling: Compute 4 outputs at a time */
93 blkCnt = blockSize >> 2U;
94
95 while (blkCnt > 0U)
96 {
97 /* C = A */
98
99 /* read 4 samples at a time */
100 write_q7x4_ia (&pDst, read_q7x4_ia (&pSrc));
101
102 /* Decrement loop counter */
103 blkCnt--;
104 }
105
106 /* Loop unrolling: Compute remaining outputs */
107 blkCnt = blockSize % 0x4U;
108
109 #else
110
111 /* Initialize blkCnt with number of samples */
112 blkCnt = blockSize;
113
114 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
115
116 while (blkCnt > 0U)
117 {
118 /* C = A */
119
120 /* Copy and store result in destination buffer */
121 *pDst++ = *pSrc++;
122
123 /* Decrement loop counter */
124 blkCnt--;
125 }
126 }
127 #endif /* defined(ARM_MATH_MVEI) */
128
129 /**
130 @} end of BasicCopy group
131 */
132