annotate f103c8/Drivers/CMSIS/DSP_Lib/Source/BasicMathFunctions/arm_mult_f32.c @ 2:0c59e7a7782a

Working on GPIO and RCC
author cin
date Mon, 16 Jan 2017 11:04:47 +0300
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
1 /* ----------------------------------------------------------------------
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
2 * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
3 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
4 * $Date: 19. March 2015
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
5 * $Revision: V.1.4.5
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
6 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
7 * Project: CMSIS DSP Library
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
8 * Title: arm_mult_f32.c
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
9 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
10 * Description: Floating-point vector multiplication.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
11 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
13 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
14 * Redistribution and use in source and binary forms, with or without
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
15 * modification, are permitted provided that the following conditions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
16 * are met:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
17 * - Redistributions of source code must retain the above copyright
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
18 * notice, this list of conditions and the following disclaimer.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
19 * - Redistributions in binary form must reproduce the above copyright
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
20 * notice, this list of conditions and the following disclaimer in
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
21 * the documentation and/or other materials provided with the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
22 * distribution.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
23 * - Neither the name of ARM LIMITED nor the names of its contributors
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
24 * may be used to endorse or promote products derived from this
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
25 * software without specific prior written permission.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
26 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
38 * POSSIBILITY OF SUCH DAMAGE.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
39 * -------------------------------------------------------------------- */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
40
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
41 #include "arm_math.h"
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
42
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
43 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
44 * @ingroup groupMath
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
45 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
46
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
47 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
48 * @defgroup BasicMult Vector Multiplication
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
49 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
50 * Element-by-element multiplication of two vectors.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
51 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
52 * <pre>
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
53 * pDst[n] = pSrcA[n] * pSrcB[n], 0 <= n < blockSize.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
54 * </pre>
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
55 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
56 * There are separate functions for floating-point, Q7, Q15, and Q31 data types.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
57 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
58
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
59 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
60 * @addtogroup BasicMult
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
61 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
62 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
63
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
64 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
65 * @brief Floating-point vector multiplication.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
66 * @param[in] *pSrcA points to the first input vector
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
67 * @param[in] *pSrcB points to the second input vector
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
68 * @param[out] *pDst points to the output vector
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
69 * @param[in] blockSize number of samples in each vector
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
70 * @return none.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
71 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
72
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
73 void arm_mult_f32(
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
74 float32_t * pSrcA,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
75 float32_t * pSrcB,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
76 float32_t * pDst,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
77 uint32_t blockSize)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
78 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
79 uint32_t blkCnt; /* loop counters */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
80 #ifndef ARM_MATH_CM0_FAMILY
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
81
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
82 /* Run the below code for Cortex-M4 and Cortex-M3 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
83 float32_t inA1, inA2, inA3, inA4; /* temporary input variables */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
84 float32_t inB1, inB2, inB3, inB4; /* temporary input variables */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
85 float32_t out1, out2, out3, out4; /* temporary output variables */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
86
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
87 /* loop Unrolling */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
88 blkCnt = blockSize >> 2u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
89
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
90 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
91 ** a second loop below computes the remaining 1 to 3 samples. */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
92 while(blkCnt > 0u)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
93 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
94 /* C = A * B */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
95 /* Multiply the inputs and store the results in output buffer */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
96 /* read sample from sourceA */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
97 inA1 = *pSrcA;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
98 /* read sample from sourceB */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
99 inB1 = *pSrcB;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
100 /* read sample from sourceA */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
101 inA2 = *(pSrcA + 1);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
102 /* read sample from sourceB */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
103 inB2 = *(pSrcB + 1);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
104
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
105 /* out = sourceA * sourceB */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
106 out1 = inA1 * inB1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
107
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
108 /* read sample from sourceA */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
109 inA3 = *(pSrcA + 2);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
110 /* read sample from sourceB */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
111 inB3 = *(pSrcB + 2);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
112
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
113 /* out = sourceA * sourceB */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
114 out2 = inA2 * inB2;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
115
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
116 /* read sample from sourceA */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
117 inA4 = *(pSrcA + 3);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
118
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
119 /* store result to destination buffer */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
120 *pDst = out1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
121
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
122 /* read sample from sourceB */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
123 inB4 = *(pSrcB + 3);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
124
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
125 /* out = sourceA * sourceB */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
126 out3 = inA3 * inB3;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
127
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
128 /* store result to destination buffer */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
129 *(pDst + 1) = out2;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
130
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
131 /* out = sourceA * sourceB */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
132 out4 = inA4 * inB4;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
133 /* store result to destination buffer */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
134 *(pDst + 2) = out3;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
135 /* store result to destination buffer */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
136 *(pDst + 3) = out4;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
137
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
138
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
139 /* update pointers to process next samples */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
140 pSrcA += 4u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
141 pSrcB += 4u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
142 pDst += 4u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
143
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
144 /* Decrement the blockSize loop counter */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
145 blkCnt--;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
146 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
147
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
148 /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
149 ** No loop unrolling is used. */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
150 blkCnt = blockSize % 0x4u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
151
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
152 #else
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
153
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
154 /* Run the below code for Cortex-M0 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
155
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
156 /* Initialize blkCnt with number of samples */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
157 blkCnt = blockSize;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
158
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
159 #endif /* #ifndef ARM_MATH_CM0_FAMILY */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
160
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
161 while(blkCnt > 0u)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
162 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
163 /* C = A * B */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
164 /* Multiply the inputs and store the results in output buffer */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
165 *pDst++ = (*pSrcA++) * (*pSrcB++);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
166
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
167 /* Decrement the blockSize loop counter */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
168 blkCnt--;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
169 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
170 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
171
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
172 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
173 * @} end of BasicMult group
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
174 */