Project Ne10
An open, optimized software library for the ARM architecture.
NE10_fir_init.c
Go to the documentation of this file.
1 /*
2  * Copyright 2012-16 ARM Limited and Contributors.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of ARM Limited nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY ARM LIMITED AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL ARM LIMITED AND CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include <string.h>
29 
30 #include "NE10_types.h"
31 
54  ne10_uint16_t numTaps,
55  ne10_float32_t * pCoeffs,
56  ne10_float32_t * pState,
57  ne10_uint32_t blockSize)
58 {
59  /* Assign filter taps */
60  S->numTaps = numTaps;
61 
62  /* Assign coefficient pointer */
63  S->pCoeffs = pCoeffs;
64 
65  /* Clear state buffer and the size of state buffer is (blockSize + numTaps - 1) */
66  memset (pState, 0, (numTaps + (blockSize - 1u)) * sizeof (ne10_float32_t));
67 
68  /* Assign state pointer */
69  S->pState = pState;
70  return NE10_OK;
71 }
72 
100  ne10_uint16_t numTaps,
101  ne10_uint8_t M,
102  ne10_float32_t * pCoeffs,
103  ne10_float32_t * pState,
104  ne10_uint32_t blockSize)
105 {
106  ne10_result_t status;
107 
108  /* The size of the input block must be a multiple of the decimation factor */
109  if ( (blockSize % M) != 0u)
110  {
111  /* Set status as NE10_ERR */
112  status = NE10_ERR;
113  }
114  else
115  {
116  /* Assign filter taps */
117  S->numTaps = numTaps;
118 
119  /* Assign coefficient pointer */
120  S->pCoeffs = pCoeffs;
121 
122  /* Clear state buffer and size is always (blockSize + numTaps - 1) */
123  memset (pState, 0, (numTaps + (blockSize - 1u)) * sizeof (ne10_float32_t));
124 
125  /* Assign state pointer */
126  S->pState = pState;
127 
128  /* Assign Decimation Factor */
129  S->M = M;
130 
131  status = NE10_OK;
132  }
133 
134  return (status);
135 
136 }
137 
166  ne10_uint8_t L,
167  ne10_uint16_t numTaps,
168  ne10_float32_t * pCoeffs,
169  ne10_float32_t * pState,
170  ne10_uint32_t blockSize)
171 {
172  ne10_result_t status;
173 
174  /* The filter length must be a multiple of the interpolation factor */
175  if ( (numTaps % L) != 0u)
176  {
177  /* Set status as NE10_ERR */
178  status = NE10_ERR;
179  }
180  else
181  {
182 
183  /* Assign coefficient pointer */
184  S->pCoeffs = pCoeffs;
185 
186  /* Assign Interpolation factor */
187  S->L = L;
188 
189  /* Assign polyPhaseLength */
190  S->phaseLength = numTaps / L;
191 
192  /* Clear state buffer and size of state array is always phaseLength + blockSize - 1 */
193  memset (pState, 0,
194  (blockSize +
195  ( (ne10_uint32_t) S->phaseLength - 1u)) * sizeof (ne10_float32_t));
196 
197  /* Assign state pointer */
198  S->pState = pState;
199 
200  status = NE10_OK;
201  }
202 
203  return (status);
204 
205 }
206 
219  ne10_uint16_t numStages,
220  ne10_float32_t * pCoeffs,
221  ne10_float32_t * pState)
222 {
223  /* Assign filter taps */
224  S->numStages = numStages;
225 
226  /* Assign coefficient pointer */
227  S->pCoeffs = pCoeffs;
228 
229  /* Clear state buffer and size is always numStages */
230  memset (pState, 0, (numStages) * sizeof (ne10_float32_t));
231 
232  /* Assign state pointer */
233  S->pState = pState;
234 
235  return NE10_OK;
236 }
237 
262  ne10_uint16_t numTaps,
263  ne10_float32_t * pCoeffs,
264  ne10_float32_t * pState,
265  ne10_int32_t * pTapDelay,
266  ne10_uint16_t maxDelay,
267  ne10_uint32_t blockSize)
268 {
269  /* Assign filter taps */
270  S->numTaps = numTaps;
271 
272  /* Assign coefficient pointer */
273  S->pCoeffs = pCoeffs;
274 
275  /* Assign TapDelay pointer */
276  S->pTapDelay = pTapDelay;
277 
278  /* Assign MaxDelay */
279  S->maxDelay = maxDelay;
280 
281  /* reset the stateIndex to 0 */
282  S->stateIndex = 0u;
283 
284  /* Clear state buffer and size is always maxDelay + blockSize */
285  memset (pState, 0, (maxDelay + blockSize) * sizeof (ne10_float32_t));
286 
287  /* Assign state pointer */
288  S->pState = pState;
289 
290  return NE10_OK;
291 }
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition: NE10_types.h:385
Instance structure for the floating-point FIR Sparse filter.
Definition: NE10_types.h:403
ne10_result_t ne10_fir_init_float(ne10_fir_instance_f32_t *S, ne10_uint16_t numTaps, ne10_float32_t *pCoeffs, ne10_float32_t *pState, ne10_uint32_t blockSize)
Definition: NE10_fir_init.c:53
uint8_t ne10_uint8_t
Definition: NE10_types.h:73
ne10_result_t ne10_fir_sparse_init_float(ne10_fir_sparse_instance_f32_t *S, ne10_uint16_t numTaps, ne10_float32_t *pCoeffs, ne10_float32_t *pState, ne10_int32_t *pTapDelay, ne10_uint16_t maxDelay, ne10_uint32_t blockSize)
Initialization function for the floating-point sparse FIR filter.
int32_t ne10_int32_t
Definition: NE10_types.h:76
ne10_uint16_t numTaps
Length of the filter.
Definition: NE10_types.h:384
ne10_result_t ne10_fir_interpolate_init_float(ne10_fir_interpolate_instance_f32_t *S, ne10_uint8_t L, ne10_uint16_t numTaps, ne10_float32_t *pCoeffs, ne10_float32_t *pState, ne10_uint32_t blockSize)
Initialization function for the floating-point FIR interpolator.
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition: NE10_types.h:375
ne10_result_t ne10_fir_lattice_init_float(ne10_fir_lattice_instance_f32_t *S, ne10_uint16_t numStages, ne10_float32_t *pCoeffs, ne10_float32_t *pState)
Initialization function for the floating-point FIR lattice filter.
ne10_uint16_t phaseLength
Length of each polyphase filter component.
Definition: NE10_types.h:395
float ne10_float32_t
Definition: NE10_types.h:80
ne10_float32_t * pState
Points to the state variable array.
Definition: NE10_types.h:407
uint16_t ne10_uint16_t
Definition: NE10_types.h:75
ne10_uint16_t numTaps
Length of the filter.
Definition: NE10_types.h:363
uint32_t ne10_uint32_t
Definition: NE10_types.h:77
ne10_result_t ne10_fir_decimate_init_float(ne10_fir_decimate_instance_f32_t *S, ne10_uint16_t numTaps, ne10_uint8_t M, ne10_float32_t *pCoeffs, ne10_float32_t *pState, ne10_uint32_t blockSize)
Initialization function for the floating-point FIR decimator.
Definition: NE10_fir_init.c:98
Instance structure for the floating-point FIR Interpolation.
Definition: NE10_types.h:392
ne10_float32_t * pState
Points to the state variable array.
Definition: NE10_types.h:374
Instance structure for the floating-point FIR filter.
Definition: NE10_types.h:361
ne10_uint8_t L
Interpolation Factor.
Definition: NE10_types.h:394
ne10_float32_t * pState
Points to the state variable array.
Definition: NE10_types.h:386
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition: NE10_types.h:396
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition: NE10_types.h:365
ne10_float32_t * pState
Points to the state variable array.
Definition: NE10_types.h:364
Instance structure for the floating point FIR Lattice filter.
Definition: NE10_types.h:371
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition: NE10_types.h:408
Instance structure for the floating-point FIR Decimation.
Definition: NE10_types.h:381
ne10_uint16_t numTaps
Length of the filter.
Definition: NE10_types.h:405
ne10_uint16_t numStages
numStages of the of lattice filter.
Definition: NE10_types.h:373
ne10_uint16_t maxDelay
the largest number of delay line values .
Definition: NE10_types.h:409
#define NE10_ERR
Definition: NE10_types.h:66
#define NE10_OK
Definition: NE10_types.h:65
ne10_float32_t * pState
Points to the state variable array.
Definition: NE10_types.h:397
ne10_int32_t * pTapDelay
Pointer to the array containing positions of the non-zero tap values.
Definition: NE10_types.h:410
ne10_uint8_t M
Decimation Factor.
Definition: NE10_types.h:383
ne10_uint16_t stateIndex
Index pointer for the state buffer .
Definition: NE10_types.h:406
int ne10_result_t
Definition: NE10_types.h:82