Loading...
Searching...
No Matches
NE10_fir_init.c
/*
* Copyright 2012-15 ARM Limited and Contributors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of ARM Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LIMITED AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL ARM LIMITED AND CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <string.h>
#include "NE10_types.h"
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)
{
/* Assign filter taps */
S->numTaps = numTaps;
/* Assign coefficient pointer */
S->pCoeffs = pCoeffs;
/* Clear state buffer and the size of state buffer is (blockSize + numTaps - 1) */
memset (pState, 0, (numTaps + (blockSize - 1u)) * sizeof (ne10_float32_t));
/* Assign state pointer */
S->pState = pState;
return NE10_OK;
}
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)
{
ne10_result_t status;
/* The size of the input block must be a multiple of the decimation factor */
if ( (blockSize % M) != 0u)
{
/* Set status as NE10_ERR */
status = NE10_ERR;
}
else
{
/* Assign filter taps */
S->numTaps = numTaps;
/* Assign coefficient pointer */
S->pCoeffs = pCoeffs;
/* Clear state buffer and size is always (blockSize + numTaps - 1) */
memset (pState, 0, (numTaps + (blockSize - 1u)) * sizeof (ne10_float32_t));
/* Assign state pointer */
S->pState = pState;
/* Assign Decimation Factor */
S->M = M;
status = NE10_OK;
}
return (status);
}
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)
{
ne10_result_t status;
/* The filter length must be a multiple of the interpolation factor */
if ( (numTaps % L) != 0u)
{
/* Set status as NE10_ERR */
status = NE10_ERR;
}
else
{
/* Assign coefficient pointer */
S->pCoeffs = pCoeffs;
/* Assign Interpolation factor */
S->L = L;
/* Assign polyPhaseLength */
S->phaseLength = numTaps / L;
/* Clear state buffer and size of state array is always phaseLength + blockSize - 1 */
memset (pState, 0,
(blockSize +
( (ne10_uint32_t) S->phaseLength - 1u)) * sizeof (ne10_float32_t));
/* Assign state pointer */
S->pState = pState;
status = NE10_OK;
}
return (status);
}
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)
{
/* Assign filter taps */
S->numStages = numStages;
/* Assign coefficient pointer */
S->pCoeffs = pCoeffs;
/* Clear state buffer and size is always numStages */
memset (pState, 0, (numStages) * sizeof (ne10_float32_t));
/* Assign state pointer */
S->pState = pState;
return NE10_OK;
}
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)
{
/* Assign filter taps */
S->numTaps = numTaps;
/* Assign coefficient pointer */
S->pCoeffs = pCoeffs;
/* Assign TapDelay pointer */
S->pTapDelay = pTapDelay;
/* Assign MaxDelay */
S->maxDelay = maxDelay;
/* reset the stateIndex to 0 */
S->stateIndex = 0u;
/* Clear state buffer and size is always maxDelay + blockSize */
memset (pState, 0, (maxDelay + blockSize) * sizeof (ne10_float32_t));
/* Assign state pointer */
S->pState = pState;
return NE10_OK;
}
ne10_fir_decimate_instance_f32_t
Instance structure for the floating-point FIR Decimation.
Definition NE10_types.h:385
ne10_fir_decimate_instance_f32_t::M
ne10_uint8_t M
Decimation Factor.
Definition NE10_types.h:386
ne10_fir_decimate_instance_f32_t::pState
ne10_float32_t * pState
Points to the state variable array.
Definition NE10_types.h:389
ne10_fir_decimate_instance_f32_t::pCoeffs
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition NE10_types.h:388
ne10_fir_decimate_instance_f32_t::numTaps
ne10_uint16_t numTaps
Length of the filter.
Definition NE10_types.h:387
ne10_fir_instance_f32_t
Instance structure for the floating-point FIR filter.
Definition NE10_types.h:365
ne10_fir_instance_f32_t::pState
ne10_float32_t * pState
Points to the state variable array.
Definition NE10_types.h:367
ne10_fir_instance_f32_t::numTaps
ne10_uint16_t numTaps
Length of the filter.
Definition NE10_types.h:366
ne10_fir_instance_f32_t::pCoeffs
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition NE10_types.h:368
ne10_fir_interpolate_instance_f32_t
Instance structure for the floating-point FIR Interpolation.
Definition NE10_types.h:396
ne10_fir_interpolate_instance_f32_t::pCoeffs
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition NE10_types.h:399
ne10_fir_interpolate_instance_f32_t::pState
ne10_float32_t * pState
Points to the state variable array.
Definition NE10_types.h:400
ne10_fir_interpolate_instance_f32_t::phaseLength
ne10_uint16_t phaseLength
Length of each polyphase filter component.
Definition NE10_types.h:398
ne10_fir_interpolate_instance_f32_t::L
ne10_uint8_t L
Interpolation Factor.
Definition NE10_types.h:397
ne10_fir_lattice_instance_f32_t
Instance structure for the floating point FIR Lattice filter.
Definition NE10_types.h:375
ne10_fir_lattice_instance_f32_t::pState
ne10_float32_t * pState
Points to the state variable array.
Definition NE10_types.h:377
ne10_fir_lattice_instance_f32_t::pCoeffs
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition NE10_types.h:378
ne10_fir_lattice_instance_f32_t::numStages
ne10_uint16_t numStages
numStages of the of lattice filter.
Definition NE10_types.h:376
ne10_fir_sparse_instance_f32_t
Instance structure for the floating-point FIR Sparse filter.
Definition NE10_types.h:407
ne10_fir_sparse_instance_f32_t::numTaps
ne10_uint16_t numTaps
Length of the filter.
Definition NE10_types.h:408
ne10_fir_sparse_instance_f32_t::maxDelay
ne10_uint16_t maxDelay
the largest number of delay line values .
Definition NE10_types.h:412
ne10_fir_sparse_instance_f32_t::pCoeffs
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition NE10_types.h:411
ne10_fir_sparse_instance_f32_t::stateIndex
ne10_uint16_t stateIndex
Index pointer for the state buffer .
Definition NE10_types.h:409
ne10_fir_sparse_instance_f32_t::pState
ne10_float32_t * pState
Points to the state variable array.
Definition NE10_types.h:410
ne10_fir_sparse_instance_f32_t::pTapDelay
ne10_int32_t * pTapDelay
Pointer to the array containing positions of the non-zero tap values.
Definition NE10_types.h:413