tests: lib: cmsis_dsp: filtering: Add DECIM Q15 tests for 1.9.0
This commit adds the filtering DECIM Q15 test patterns and implementations for the CMSIS-DSP 1.9.0. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
parent
8084684537
commit
36ccd04997
7 changed files with 1662 additions and 1 deletions
|
@ -19,6 +19,12 @@ if(CONFIG_CMSIS_DSP_TEST_FILTERING_BIQUAD)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CONFIG_CMSIS_DSP_TEST_FILTERING_DECIM)
|
||||||
|
target_sources(app PRIVATE
|
||||||
|
src/decim_q15.c
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CONFIG_CMSIS_DSP_TEST_FILTERING_FIR)
|
if(CONFIG_CMSIS_DSP_TEST_FILTERING_FIR)
|
||||||
target_sources(app PRIVATE
|
target_sources(app PRIVATE
|
||||||
src/fir_q7.c
|
src/fir_q7.c
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
# Copyright (c) 2019 Stephanos Ioannidis <root@stephanos.io>
|
# Copyright (c) 2021 Stephanos Ioannidis <root@stephanos.io>
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
config CMSIS_DSP_TEST_FILTERING_BIQUAD
|
config CMSIS_DSP_TEST_FILTERING_BIQUAD
|
||||||
bool "Test: Filtering BIQUAD"
|
bool "Test: Filtering BIQUAD"
|
||||||
|
|
||||||
|
config CMSIS_DSP_TEST_FILTERING_DECIM
|
||||||
|
bool "Test: Filtering DECIM"
|
||||||
|
|
||||||
config CMSIS_DSP_TEST_FILTERING_FIR
|
config CMSIS_DSP_TEST_FILTERING_FIR
|
||||||
bool "Test: Filtering FIR"
|
bool "Test: Filtering FIR"
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,6 @@ CONFIG_CMSIS_DSP_FILTERING=y
|
||||||
|
|
||||||
# Test Options
|
# Test Options
|
||||||
CONFIG_CMSIS_DSP_TEST_FILTERING_BIQUAD=y
|
CONFIG_CMSIS_DSP_TEST_FILTERING_BIQUAD=y
|
||||||
|
CONFIG_CMSIS_DSP_TEST_FILTERING_DECIM=y
|
||||||
CONFIG_CMSIS_DSP_TEST_FILTERING_FIR=y
|
CONFIG_CMSIS_DSP_TEST_FILTERING_FIR=y
|
||||||
CONFIG_CMSIS_DSP_TEST_FILTERING_MISC=y
|
CONFIG_CMSIS_DSP_TEST_FILTERING_MISC=y
|
||||||
|
|
156
tests/lib/cmsis_dsp/filtering/src/decim_q15.c
Normal file
156
tests/lib/cmsis_dsp/filtering/src/decim_q15.c
Normal file
|
@ -0,0 +1,156 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 Stephanos Ioannidis <root@stephanos.io>
|
||||||
|
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ztest.h>
|
||||||
|
#include <zephyr.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <arm_math.h>
|
||||||
|
#include "../../common/test_common.h"
|
||||||
|
|
||||||
|
#include "decim_q15.pat"
|
||||||
|
|
||||||
|
#define SNR_ERROR_THRESH ((float32_t)70)
|
||||||
|
#define ABS_ERROR_THRESH_Q15 ((q15_t)5)
|
||||||
|
#define STATE_BUF_LEN (16 + 768 - 1)
|
||||||
|
|
||||||
|
static void test_arm_fir_decimate_q15(void)
|
||||||
|
{
|
||||||
|
uint32_t decim_factor, tap_count;
|
||||||
|
size_t sample_index, block_size, ref_size;
|
||||||
|
size_t sample_count = ARRAY_SIZE(in_config_decim) / 4;
|
||||||
|
size_t length = ARRAY_SIZE(ref_decim);
|
||||||
|
const uint32_t *config = in_config_decim;
|
||||||
|
const q15_t *input = in_val_decim;
|
||||||
|
const q15_t *coeff = in_coeff_decim;
|
||||||
|
const q15_t *ref = ref_decim;
|
||||||
|
q15_t *state, *output_buf, *output;
|
||||||
|
arm_status status;
|
||||||
|
arm_fir_decimate_instance_q15 inst;
|
||||||
|
|
||||||
|
/* Allocate buffers */
|
||||||
|
state = malloc(STATE_BUF_LEN * sizeof(q15_t));
|
||||||
|
zassert_not_null(state, ASSERT_MSG_BUFFER_ALLOC_FAILED);
|
||||||
|
|
||||||
|
output_buf = malloc(length * sizeof(q15_t));
|
||||||
|
zassert_not_null(output_buf, ASSERT_MSG_BUFFER_ALLOC_FAILED);
|
||||||
|
|
||||||
|
output = output_buf;
|
||||||
|
|
||||||
|
/* Enumerate samples */
|
||||||
|
for (sample_index = 0; sample_index < sample_count; sample_index++) {
|
||||||
|
/* Resolve sample configurations */
|
||||||
|
decim_factor = config[0];
|
||||||
|
tap_count = config[1];
|
||||||
|
block_size = config[2];
|
||||||
|
ref_size = config[3];
|
||||||
|
|
||||||
|
/* Initialise instance */
|
||||||
|
status = arm_fir_decimate_init_q15(&inst, tap_count,
|
||||||
|
decim_factor, coeff, state,
|
||||||
|
block_size);
|
||||||
|
|
||||||
|
zassert_equal(status, ARM_MATH_SUCCESS,
|
||||||
|
ASSERT_MSG_INCORRECT_COMP_RESULT);
|
||||||
|
|
||||||
|
/* Run test function */
|
||||||
|
arm_fir_decimate_q15(&inst, input, output, block_size);
|
||||||
|
|
||||||
|
/* Increment pointers */
|
||||||
|
input += block_size;
|
||||||
|
output += ref_size;
|
||||||
|
coeff += tap_count;
|
||||||
|
config += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate output */
|
||||||
|
zassert_true(
|
||||||
|
test_snr_error_q15(length, output_buf, ref, SNR_ERROR_THRESH),
|
||||||
|
ASSERT_MSG_SNR_LIMIT_EXCEED);
|
||||||
|
|
||||||
|
zassert_true(
|
||||||
|
test_near_equal_q15(length, output_buf, ref,
|
||||||
|
ABS_ERROR_THRESH_Q15),
|
||||||
|
ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
|
||||||
|
|
||||||
|
/* Free buffers */
|
||||||
|
free(state);
|
||||||
|
free(output_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_arm_fir_interpolate_q15(void)
|
||||||
|
{
|
||||||
|
uint32_t filter_length, tap_count;
|
||||||
|
size_t sample_index, block_size, ref_size;
|
||||||
|
size_t sample_count = ARRAY_SIZE(in_config_interp) / 4;
|
||||||
|
size_t length = ARRAY_SIZE(ref_interp);
|
||||||
|
const uint32_t *config = in_config_interp;
|
||||||
|
const q15_t *input = in_val_interp;
|
||||||
|
const q15_t *coeff = in_coeff_interp;
|
||||||
|
const q15_t *ref = ref_interp;
|
||||||
|
q15_t *state, *output_buf, *output;
|
||||||
|
arm_status status;
|
||||||
|
arm_fir_interpolate_instance_q15 inst;
|
||||||
|
|
||||||
|
/* Allocate buffers */
|
||||||
|
state = malloc(STATE_BUF_LEN * sizeof(q15_t));
|
||||||
|
zassert_not_null(state, ASSERT_MSG_BUFFER_ALLOC_FAILED);
|
||||||
|
|
||||||
|
output_buf = malloc(length * sizeof(q15_t));
|
||||||
|
zassert_not_null(output_buf, ASSERT_MSG_BUFFER_ALLOC_FAILED);
|
||||||
|
|
||||||
|
output = output_buf;
|
||||||
|
|
||||||
|
/* Enumerate samples */
|
||||||
|
for (sample_index = 0; sample_index < sample_count; sample_index++) {
|
||||||
|
/* Resolve sample configurations */
|
||||||
|
filter_length = config[0];
|
||||||
|
tap_count = config[1];
|
||||||
|
block_size = config[2];
|
||||||
|
ref_size = config[3];
|
||||||
|
|
||||||
|
/* Initialise instance */
|
||||||
|
status = arm_fir_interpolate_init_q15(&inst, filter_length,
|
||||||
|
tap_count, coeff,
|
||||||
|
state, block_size);
|
||||||
|
|
||||||
|
zassert_equal(status, ARM_MATH_SUCCESS,
|
||||||
|
ASSERT_MSG_INCORRECT_COMP_RESULT);
|
||||||
|
|
||||||
|
/* Run test function */
|
||||||
|
arm_fir_interpolate_q15(&inst, input, output, block_size);
|
||||||
|
|
||||||
|
/* Increment pointers */
|
||||||
|
input += block_size;
|
||||||
|
output += ref_size;
|
||||||
|
coeff += tap_count;
|
||||||
|
config += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate output */
|
||||||
|
zassert_true(
|
||||||
|
test_snr_error_q15(length, output_buf, ref, SNR_ERROR_THRESH),
|
||||||
|
ASSERT_MSG_SNR_LIMIT_EXCEED);
|
||||||
|
|
||||||
|
zassert_true(
|
||||||
|
test_near_equal_q15(length, output_buf, ref,
|
||||||
|
ABS_ERROR_THRESH_Q15),
|
||||||
|
ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
|
||||||
|
|
||||||
|
/* Free buffers */
|
||||||
|
free(state);
|
||||||
|
free(output_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_filtering_decim_q15(void)
|
||||||
|
{
|
||||||
|
ztest_test_suite(filtering_decim_q15,
|
||||||
|
ztest_unit_test(test_arm_fir_decimate_q15),
|
||||||
|
ztest_unit_test(test_arm_fir_interpolate_q15)
|
||||||
|
);
|
||||||
|
|
||||||
|
ztest_run_test_suite(filtering_decim_q15);
|
||||||
|
}
|
1465
tests/lib/cmsis_dsp/filtering/src/decim_q15.pat
generated
Normal file
1465
tests/lib/cmsis_dsp/filtering/src/decim_q15.pat
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -13,6 +13,8 @@ extern void test_filtering_biquad_f16(void);
|
||||||
extern void test_filtering_biquad_f32(void);
|
extern void test_filtering_biquad_f32(void);
|
||||||
extern void test_filtering_biquad_f64(void);
|
extern void test_filtering_biquad_f64(void);
|
||||||
|
|
||||||
|
extern void test_filtering_decim_q15(void);
|
||||||
|
|
||||||
extern void test_filtering_fir_q7(void);
|
extern void test_filtering_fir_q7(void);
|
||||||
extern void test_filtering_fir_q15(void);
|
extern void test_filtering_fir_q15(void);
|
||||||
extern void test_filtering_fir_q31(void);
|
extern void test_filtering_fir_q31(void);
|
||||||
|
@ -37,6 +39,10 @@ void test_main(void)
|
||||||
test_filtering_biquad_f64();
|
test_filtering_biquad_f64();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CMSIS_DSP_TEST_FILTERING_DECIM
|
||||||
|
test_filtering_decim_q15();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CMSIS_DSP_TEST_FILTERING_FIR
|
#ifdef CONFIG_CMSIS_DSP_TEST_FILTERING_FIR
|
||||||
test_filtering_fir_q7();
|
test_filtering_fir_q7();
|
||||||
test_filtering_fir_q15();
|
test_filtering_fir_q15();
|
||||||
|
|
|
@ -30,6 +30,30 @@ tests:
|
||||||
extra_configs:
|
extra_configs:
|
||||||
- CONFIG_CMSIS_DSP_TEST_FILTERING_BIQUAD=y
|
- CONFIG_CMSIS_DSP_TEST_FILTERING_BIQUAD=y
|
||||||
- CONFIG_FPU=y
|
- CONFIG_FPU=y
|
||||||
|
libraries.cmsis_dsp.filtering.decim:
|
||||||
|
filter: ((CONFIG_CPU_CORTEX_R or CONFIG_CPU_CORTEX_M) and TOOLCHAIN_HAS_NEWLIB == 1) or CONFIG_ARCH_POSIX
|
||||||
|
integration_platforms:
|
||||||
|
- frdm_k64f
|
||||||
|
- sam_e70_xplained
|
||||||
|
- mps2_an521
|
||||||
|
- native_posix
|
||||||
|
tags: cmsis_dsp
|
||||||
|
min_flash: 128
|
||||||
|
min_ram: 64
|
||||||
|
extra_args: CONF_FILE=prj_base.conf
|
||||||
|
extra_configs:
|
||||||
|
- CONFIG_CMSIS_DSP_TEST_FILTERING_DECIM=y
|
||||||
|
libraries.cmsis_dsp.filtering.decim.fpu:
|
||||||
|
filter: ((CONFIG_CPU_CORTEX_R or CONFIG_CPU_CORTEX_M) and CONFIG_CPU_HAS_FPU and TOOLCHAIN_HAS_NEWLIB == 1) or CONFIG_ARCH_POSIX
|
||||||
|
integration_platforms:
|
||||||
|
- mps2_an521_remote
|
||||||
|
tags: cmsis_dsp fpu
|
||||||
|
min_flash: 128
|
||||||
|
min_ram: 64
|
||||||
|
extra_args: CONF_FILE=prj_base.conf
|
||||||
|
extra_configs:
|
||||||
|
- CONFIG_CMSIS_DSP_TEST_FILTERING_DECIM=y
|
||||||
|
- CONFIG_FPU=y
|
||||||
libraries.cmsis_dsp.filtering.fir:
|
libraries.cmsis_dsp.filtering.fir:
|
||||||
filter: ((CONFIG_CPU_CORTEX_R or CONFIG_CPU_CORTEX_M) and TOOLCHAIN_HAS_NEWLIB == 1) or CONFIG_ARCH_POSIX
|
filter: ((CONFIG_CPU_CORTEX_R or CONFIG_CPU_CORTEX_M) and TOOLCHAIN_HAS_NEWLIB == 1) or CONFIG_ARCH_POSIX
|
||||||
integration_platforms:
|
integration_platforms:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue