diff options
author | joshua <joshua@joshuayun.com> | 2023-12-30 23:54:31 -0500 |
---|---|---|
committer | joshua <joshua@joshuayun.com> | 2023-12-30 23:54:31 -0500 |
commit | 86608c6770cf08c138a2bdab5855072f64be09ef (patch) | |
tree | 494a61b3ef37e76f9235a0d10f5c93d97290a35f /Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests | |
download | sdr-software-master.tar.gz |
Diffstat (limited to 'Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests')
4 files changed, 295 insertions, 0 deletions
diff --git a/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_templates.h b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_templates.h new file mode 100644 index 0000000..3b7f22f --- /dev/null +++ b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_templates.h @@ -0,0 +1,222 @@ +#ifndef _COMPLEX_MATH_TEMPLATES_H_
+#define _COMPLEX_MATH_TEMPLATES_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Includes */
+/*--------------------------------------------------------------------------------*/
+#include "test_templates.h"
+
+/*--------------------------------------------------------------------------------*/
+/* Group Specific Templates */
+/*--------------------------------------------------------------------------------*/
+
+/**
+ * Compare the real outputs from the function under test and the reference
+ * function.
+ */
+#define COMPLEX_MATH_COMPARE_RE_INTERFACE(block_size, output_type) \
+ TEST_ASSERT_BUFFERS_EQUAL( \
+ complex_math_output_ref_a.data_ptr, \
+ complex_math_output_fut_a.data_ptr, \
+ block_size * sizeof(output_type))
+
+/**
+ * Compare the real and imaginary outputs from the function under test and the
+ * reference function.
+ */
+#define COMPLEX_MATH_COMPARE_CMPLX_INTERFACE(block_size, output_type) \
+ do \
+ { \
+ COMPLEX_MATH_COMPARE_RE_INTERFACE(block_size * 2, output_type); \
+ } while (0)
+
+
+/*
+ * Comparison SNR thresholds for the data types used in complex_math_tests.
+ */
+#define COMPLEX_MATH_SNR_THRESHOLD_float32_t 120
+#define COMPLEX_MATH_SNR_THRESHOLD_q31_t 100
+#define COMPLEX_MATH_SNR_THRESHOLD_q15_t 75
+
+/**
+ * Compare reference and fut outputs using SNR.
+ *
+ * The output_suffix specifies which output buffers to use for the
+ * comparison. An output_suffix of 'a' expands to the following buffers:
+ *
+ * - complex_math_output_f32_ref_a
+ * - complex_math_output_f32_fut_a
+ * - complex_math_output_ref_a
+ * - complex_math_output_fut_a
+ *
+ * @note The outputs are converted to float32_t before comparison.
+ */
+#define COMPLEX_MATH_SNR_COMPARE_OUT_INTERFACE(block_size, \
+ output_type, \
+ output_suffix) \
+ do \
+ { \
+ TEST_CONVERT_AND_ASSERT_SNR( \
+ complex_math_output_f32_ref_##output_suffix, \
+ complex_math_output_ref_##output_suffix.data_ptr, \
+ complex_math_output_f32_fut_##output_suffix, \
+ complex_math_output_fut_##output_suffix.data_ptr, \
+ block_size, \
+ output_type, \
+ COMPLEX_MATH_SNR_THRESHOLD_##output_type \
+ ); \
+ } while (0)
+
+/**
+ * Specification of #COMPLEX_MATH_SNR_COMPARE_INTERFACE() for real outputs.
+ */
+#define COMPLEX_MATH_SNR_COMPARE_RE_INTERFACE(block_size, \
+ output_type) \
+ COMPLEX_MATH_SNR_COMPARE_OUT_INTERFACE(block_size, \
+ output_type, \
+ a)
+
+/**
+ * Specification of #COMPLEX_MATH_SNR_COMPARE_INTERFACE() for complex outputs.
+ */
+#define COMPLEX_MATH_SNR_COMPARE_CMPLX_INTERFACE(block_size, \
+ output_type) \
+ COMPLEX_MATH_SNR_COMPARE_OUT_INTERFACE(block_size * 2, \
+ output_type, \
+ a)
+
+/**
+ * Compare reference and fut split outputs using SNR.
+ *
+ * 'Split' refers to two separate output buffers; one for real and one for
+ * complex.
+ */
+#define COMPLEX_MATH_SNR_COMPARE_SPLIT_INTERFACE(block_size, \
+ output_type) \
+ do \
+ { \
+ COMPLEX_MATH_SNR_COMPARE_OUT_INTERFACE(block_size, \
+ output_type, \
+ a); \
+ COMPLEX_MATH_SNR_COMPARE_OUT_INTERFACE(block_size, \
+ output_type, \
+ b); \
+ } while (0)
+
+
+/*--------------------------------------------------------------------------------*/
+/* Input Interfaces */
+/*--------------------------------------------------------------------------------*/
+/*
+ * General:
+ * Input interfaces provide inputs to functions inside test templates. They
+ * ONLY provide the inputs. The output variables should be hard coded.
+ *
+ * The input interfaces must have the following format:
+ *
+ * ARM_xxx_INPUT_INTERFACE() or
+ * REF_xxx_INPUT_INTERFACE()
+ *
+ * The xxx must be lowercase, and is intended to be the indentifying substring
+ * in the function's name. Acceptable values are 'sub' or 'add' from the
+ * functions arm_add_q31.
+ */
+
+#define ARM_cmplx_conj_INPUT_INTERFACE(input, block_size) \
+ PAREN(input, complex_math_output_fut_a.data_ptr, block_size)
+
+#define REF_cmplx_conj_INPUT_INTERFACE(input, block_size) \
+ PAREN(input, complex_math_output_ref_a.data_ptr, block_size)
+
+#define ARM_cmplx_dot_prod_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, block_size, \
+ complex_math_output_fut_a.data_ptr, \
+ complex_math_output_fut_b.data_ptr)
+
+#define REF_cmplx_dot_prod_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, block_size, \
+ complex_math_output_ref_a.data_ptr, \
+ complex_math_output_ref_b.data_ptr)
+
+#define ARM_cmplx_mag_INPUT_INTERFACE(input, block_size) \
+ PAREN(input, complex_math_output_fut_a.data_ptr, block_size)
+
+#define REF_cmplx_mag_INPUT_INTERFACE(input, block_size) \
+ PAREN(input, complex_math_output_ref_a.data_ptr, block_size)
+
+#define ARM_cmplx_mag_squared_INPUT_INTERFACE(input, block_size) \
+ PAREN(input, complex_math_output_fut_a.data_ptr, block_size)
+
+#define REF_cmplx_mag_squared_INPUT_INTERFACE(input, block_size) \
+ PAREN(input, complex_math_output_ref_a.data_ptr, block_size)
+
+#define ARM_cmplx_mult_cmplx_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, complex_math_output_fut_a.data_ptr, block_size)
+
+#define REF_cmplx_mult_cmplx_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, complex_math_output_ref_a.data_ptr, block_size)
+
+#define ARM_cmplx_mult_real_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, complex_math_output_fut_a.data_ptr, block_size)
+
+#define REF_cmplx_mult_real_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, complex_math_output_ref_a.data_ptr, block_size)
+
+/*--------------------------------------------------------------------------------*/
+/* Test Templates */
+/*--------------------------------------------------------------------------------*/
+
+/**
+ * Specialization of #TEST_TEMPLATE_BUF1_BLK() for complex math tests.
+ *
+ * @note This macro relies on the existance of ARM_xxx_INPUT_INTERFACE and
+ * REF_xxx_INPUT_INTERFACEs.
+ */
+#define COMPLEX_MATH_DEFINE_TEST_TEMPLATE_BUF1_BLK(fn_name, \
+ suffix, \
+ input_type, \
+ output_type, \
+ comparison_interface) \
+ JTEST_DEFINE_TEST(arm_##fn_name##_##suffix##_test, \
+ arm_##fn_name##_##suffix) \
+ { \
+ TEST_TEMPLATE_BUF1_BLK( \
+ complex_math_f_all, \
+ complex_math_block_sizes, \
+ input_type, \
+ output_type, \
+ arm_##fn_name##_##suffix, \
+ ARM_##fn_name##_INPUT_INTERFACE, \
+ ref_##fn_name##_##suffix, \
+ REF_##fn_name##_INPUT_INTERFACE, \
+ comparison_interface); \
+ }
+
+/**
+ * Specialization of #TEST_TEMPLATE_BUF2_BLK1() for complex math tests.
+ *
+ * @note This macro relies on the existance of ARM_xxx_INPUT_INTERFACE and
+ * REF_xxx_INPUT_INTERFACEs.
+ */
+#define COMPLEX_MATH_DEFINE_TEST_TEMPLATE_BUF2_BLK(fn_name, \
+ suffix, \
+ input_type, \
+ output_type, \
+ comparison_interface) \
+ JTEST_DEFINE_TEST(arm_##fn_name##_##suffix##_test, \
+ arm_##fn_name##_##suffix) \
+ { \
+ TEST_TEMPLATE_BUF2_BLK( \
+ complex_math_f_all, \
+ complex_math_f_all, \
+ complex_math_block_sizes, \
+ input_type, \
+ output_type, \
+ arm_##fn_name##_##suffix, \
+ ARM_##fn_name##_INPUT_INTERFACE, \
+ ref_##fn_name##_##suffix, \
+ REF_##fn_name##_INPUT_INTERFACE, \
+ comparison_interface); \
+ }
+
+#endif /* _COMPLEX_MATH_TEMPLATES_H_ */
diff --git a/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_test_data.h b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_test_data.h new file mode 100644 index 0000000..df561b4 --- /dev/null +++ b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_test_data.h @@ -0,0 +1,50 @@ +#ifndef _COMPLEX_MATH_TEST_DATA_H_
+#define _COMPLEX_MATH_TEST_DATA_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Includes */
+/*--------------------------------------------------------------------------------*/
+
+#include "arr_desc.h"
+#include "arm_math.h"
+
+/*--------------------------------------------------------------------------------*/
+/* Macros and Defines */
+/*--------------------------------------------------------------------------------*/
+#define COMPLEX_MATH_MAX_INPUT_ELEMENTS 32
+#define COMPLEX_MATH_BIGGEST_INPUT_TYPE float32_t
+
+/*--------------------------------------------------------------------------------*/
+/* Decalare Variables */
+/*--------------------------------------------------------------------------------*/
+
+/* Input/Output Buffers */
+ARR_DESC_DECLARE(complex_math_output_fut_a);
+ARR_DESC_DECLARE(complex_math_output_fut_b);
+ARR_DESC_DECLARE(complex_math_output_ref_a);
+ARR_DESC_DECLARE(complex_math_output_ref_b);
+
+extern COMPLEX_MATH_BIGGEST_INPUT_TYPE
+complex_math_output_f32_ref_a[COMPLEX_MATH_MAX_INPUT_ELEMENTS * 2];
+
+extern COMPLEX_MATH_BIGGEST_INPUT_TYPE
+complex_math_output_f32_ref_b[COMPLEX_MATH_MAX_INPUT_ELEMENTS * 2];
+
+extern COMPLEX_MATH_BIGGEST_INPUT_TYPE
+complex_math_output_f32_fut_a[COMPLEX_MATH_MAX_INPUT_ELEMENTS * 2];
+
+extern COMPLEX_MATH_BIGGEST_INPUT_TYPE
+complex_math_output_f32_fut_b[COMPLEX_MATH_MAX_INPUT_ELEMENTS * 2];
+
+/* Block Sizes*/
+ARR_DESC_DECLARE(complex_math_block_sizes);
+
+/* Float Inputs */
+ARR_DESC_DECLARE(complex_math_zeros);
+ARR_DESC_DECLARE(complex_math_f_2);
+ARR_DESC_DECLARE(complex_math_f_15);
+ARR_DESC_DECLARE(complex_math_f_32);
+ARR_DESC_DECLARE(complex_math_f_all);
+
+
+#endif /* _COMPLEX_MATH_TEST_DATA_H_ */
diff --git a/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_test_group.h b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_test_group.h new file mode 100644 index 0000000..5c2ea1f --- /dev/null +++ b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_test_group.h @@ -0,0 +1,9 @@ +#ifndef _COMPLEX_MATH_TEST_GROUP_H_
+#define _COMPLEX_MATH_TEST_GROUP_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Declare Test Groups */
+/*--------------------------------------------------------------------------------*/
+JTEST_DECLARE_GROUP(complex_math_tests);
+
+#endif /* _COMPLEX_MATH_TEST_GROUP_H_ */
diff --git a/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_tests.h b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_tests.h new file mode 100644 index 0000000..ab4f0ae --- /dev/null +++ b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/complex_math_tests/complex_math_tests.h @@ -0,0 +1,14 @@ +#ifndef _COMPLEX_MATH_TESTS_H_
+#define _COMPLEX_MATH_TESTS_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Test/Group Declarations */
+/*--------------------------------------------------------------------------------*/
+JTEST_DECLARE_GROUP(cmplx_conj_tests);
+JTEST_DECLARE_GROUP(cmplx_dot_prod_tests);
+JTEST_DECLARE_GROUP(cmplx_mag_tests);
+JTEST_DECLARE_GROUP(cmplx_mag_squared_tests);
+JTEST_DECLARE_GROUP(cmplx_mult_cmplx_tests);
+JTEST_DECLARE_GROUP(cmplx_mult_real_tests);
+
+#endif /* _COMPLEX_MATH_TESTS_H_ */
|