1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_fill_q31.c
4 * Description: Fills a constant value into a Q31 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 Fill
37 @{
38 */
39
40 /**
41 @brief Fills a constant value into a Q31 vector.
42 @param[in] value input value to be filled
43 @param[out] pDst points to output vector
44 @param[in] blockSize number of samples in each vector
45 @return none
46 */
47 #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
arm_fill_q31(q31_t value,q31_t * pDst,uint32_t blockSize)48 void arm_fill_q31(
49 q31_t value,
50 q31_t * pDst,
51 uint32_t blockSize)
52 {
53 uint32_t blkCnt;
54 blkCnt = blockSize >> 2U;
55
56 /* Compute 4 outputs at a time */
57 while (blkCnt > 0U)
58 {
59
60 vstrwq_s32(pDst,vdupq_n_s32(value));
61 /*
62 * Decrement the blockSize loop counter
63 * Advance vector source and destination pointers
64 */
65 pDst += 4;
66 blkCnt --;
67 }
68
69 blkCnt = blockSize & 3;
70 while (blkCnt > 0U)
71 {
72 /* C = value */
73
74 /* Fill value in destination buffer */
75 *pDst++ = value;
76
77 /* Decrement loop counter */
78 blkCnt--;
79 }
80
81 }
82
83 #else
arm_fill_q31(q31_t value,q31_t * pDst,uint32_t blockSize)84 void arm_fill_q31(
85 q31_t value,
86 q31_t * pDst,
87 uint32_t blockSize)
88 {
89 uint32_t blkCnt; /* Loop counter */
90
91 #if defined (ARM_MATH_LOOPUNROLL)
92
93 /* Loop unrolling: Compute 4 outputs at a time */
94 blkCnt = blockSize >> 2U;
95
96 while (blkCnt > 0U)
97 {
98 /* C = value */
99
100 /* Fill value in destination buffer */
101 *pDst++ = value;
102 *pDst++ = value;
103 *pDst++ = value;
104 *pDst++ = value;
105
106 /* Decrement loop counter */
107 blkCnt--;
108 }
109
110 /* Loop unrolling: Compute remaining outputs */
111 blkCnt = blockSize % 0x4U;
112
113 #else
114
115 /* Initialize blkCnt with number of samples */
116 blkCnt = blockSize;
117
118 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
119
120 while (blkCnt > 0U)
121 {
122 /* C = value */
123
124 /* Fill value in destination buffer */
125 *pDst++ = value;
126
127 /* Decrement loop counter */
128 blkCnt--;
129 }
130 }
131 #endif /* defined(ARM_MATH_MVEI) */
132
133 /**
134 @} end of Fill group
135 */
136