Skip to content
Permalink
Browse files
CMSIS-DSP: Customization of FFT tables.
Compilation symbols have been introduced to allow to include only the
FFT tables which are useful in a given application.

The README.md in DSP is giving more details.
  • Loading branch information
christophe0606 committed May 22, 2019
1 parent 26b680c commit e0181324e0eb1a2c84998eea1b28d098cbe085fb
Show file tree
Hide file tree
Showing 28 changed files with 37,066 additions and 35,236 deletions.
@@ -149,6 +149,7 @@ int32_t main(void)
printf("START\n");
#endif


/* Calculation of mean value of input */

/* x' = 1/blockSize * (x(0)* 1 + x(1) * 1 + ... + x(n-1) * 1) */
@@ -0,0 +1,16 @@
REM Example cmake command.
cmake -DBASICMATH=OFF ^
-DCOMPLEXMATH=OFF ^
-DCONTROLLER=OFF ^
-DFASTMATH=OFF ^
-DFILTERING=ON ^
-DMATRIX=OFF ^
-DSTATISTICS=OFF ^
-DSUPPORT=OFF ^
-DTRANSFORM=OFF ^
-DCONFIGTABLE=ON ^
-DARM_LMS_NORM_Q15=ON ^
-DCMAKE_TOOLCHAIN_FILE=../../../../armcc.cmake ^
-DNEON=ON ^
-DARM_CPU="cortex-a5" ^
-G "Unix Makefiles" ..
@@ -0,0 +1,6 @@
REM Example commands to run on ArmDS FVP

REM "C:\Program Files\ARM\Development Studio 2019.0\sw\models\bin\FVP_MPS2_Cortex-M7.exe" -a arm_variance_example

"C:\Program Files\ARM\Development Studio 2019.0\sw\models\bin\FVP_VE_Cortex-A5x1.exe" -a arm_variance_example

Large diffs are not rendered by default.

@@ -68,4 +68,34 @@ If you need to run on something different, you'll need to modfy configBoot. If y

configBoot is relying on some functions defined in configUtils and most of the customizations should be done here.

## Compilation symbols for tables

Some new compilations symbols have been introduced to avoid including all the tables if they are not needed.

If no new symbol is defined, everything will behave as usual. If ARM_DSP_CONFIG_TABLES is defined then the new symbols will be taken into account.

Then you can select all FFT tables or all interpolation tables by defining following compilation symbols:
ARM_ALL_FFT_TABLES : All FFT tables are included
ARM_ALL_FAST_TABLES : All interpolation tables are included

If more control is required, there are other symbols but it is not always easy to know which ones need to be enabled for a given use case.

If you use cmake, it is easy since high level options are defined and they will select the right compilation symbols. If you don't use cmake, you can just look at fft.cmake to see which compilation symbols are needed.

For instance, if you want to use the arm_rfft_fast_f32, in fft.cmake you'll see an option RFFT_FAST_F32_32.

We see that following symbols need to be enabled :

ARM_TABLE_TWIDDLECOEF_F32_16
ARM_TABLE_BITREVIDX_FLT_16
ARM_TABLE_TWIDDLECOEF_RFFT_F32_32
ARM_TABLE_TWIDDLECOEF_F32_16

In addition to that, ARM_DSP_CONFIG_TABLES must be enabled and finally ARM_FFT_ALLOW_TABLES must also be defined.

This last symbol is required because if you don't want to include the TransformFunctions in your build of CMSIS-DSP then all tables related to FFT must not be included. It is the purpose of this flag.





@@ -0,0 +1,16 @@
cmake_minimum_required (VERSION 3.6)

project(CMSISDSPBasicMath)


file(GLOB SRC "./*_*.c")

add_library(CMSISDSPBasicMath STATIC ${SRC})

configdsp(CMSISDSPBasicMath ..)

### Includes
target_include_directories(CMSISDSPBasicMath PUBLIC "${DSP}/../../Include")



@@ -2,9 +2,127 @@ cmake_minimum_required (VERSION 3.6)

project(CMSISDSP)

# Needed to find the config module
# Needed to find the config modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/..)

# Select which parts of the CMSIS-DSP must be compiled.
# There are some dependencies between the parts but they are not tracked
# by this cmake. So, enabling some functions may require to enable some
# other ones.
option(BASICMATH "Basic Math Functions" ON)
option(COMPLEXMATH "Complex Math Functions" ON)
option(CONTROLLER "Controller Functions" ON)
option(FASTMATH "Fast Math Functions" ON)
option(FILTERING "Filtering Functions" ON)
option(MATRIX "Matrix Functions" ON)
option(STATISTICS "Statistics Functions" ON)
option(SUPPORT "Support Functions" ON)
option(TRANSFORM "Transform Functions" ON)

# When OFF it is the default behavior : all tables are included.
option(CONFIGTABLE "Configuration of table allowed" OFF)

# When CONFIGTABLE is ON, select if all interpolation tables must be included
option(ALLFAST "All interpolation tables included" OFF)
# When CONFIGTABLE is ON, select if all FFT tables must be included
option(ALLFFT "All fft tables included" OFF)

# Features which require inclusion of a data table.
# Since some tables may be big, the corresponding feature can be
# disabled.
# Those options are taken into account only when CONFIGTABLE is ON
option(ARM_COS_F32 "cos f32" OFF)
option(ARM_COS_Q31 "cos q31" OFF)
option(ARM_COS_Q15 "cos q15" OFF)
option(ARM_SIN_F32 "sin f32" OFF)
option(ARM_SIN_Q31 "sin q31" OFF)
option(ARM_SIN_Q15 "sin q15" OFF)
option(ARM_SIN_COS_F32 "sin cos f32" OFF)
option(ARM_SIN_COS_Q31 "sin cos q31" OFF)

option(ARM_LMS_NORM_Q31 "lms norm q31" OFF)
option(ARM_LMS_NORM_Q15 "lms norm q15" OFF)

option(CFFT_F32_16 "cfft f32 16" OFF)
option(CFFT_F32_32 "cfft f32 32" OFF)
option(CFFT_F32_64 "cfft f32 64" OFF)
option(CFFT_F32_128 "cfft f32 128" OFF)
option(CFFT_F32_256 "cfft f32 256" OFF)
option(CFFT_F32_512 "cfft f32 512" OFF)
option(CFFT_F32_1024 "cfft f32 1024" OFF)
option(CFFT_F32_2048 "cfft f32 2048" OFF)
option(CFFT_F32_4096 "cfft f32 4096" OFF)

option(CFFT_Q31_16 "cfft q31 16" OFF)
option(CFFT_Q31_32 "cfft q31 32" OFF)
option(CFFT_Q31_64 "cfft q31 64" OFF)
option(CFFT_Q31_128 "cfft q31 128" OFF)
option(CFFT_Q31_256 "cfft q31 256" OFF)
option(CFFT_Q31_512 "cfft q31 512" OFF)
option(CFFT_Q31_1024 "cfft q31 1024" OFF)
option(CFFT_Q31_2048 "cfft q31 2048" OFF)
option(CFFT_Q31_4096 "cfft q31 4096" OFF)

option(CFFT_Q15_16 "cfft q15 16" OFF)
option(CFFT_Q15_32 "cfft q15 32" OFF)
option(CFFT_Q15_64 "cfft q15 64" OFF)
option(CFFT_Q15_128 "cfft q15 128" OFF)
option(CFFT_Q15_256 "cfft q15 256" OFF)
option(CFFT_Q15_512 "cfft q15 512" OFF)
option(CFFT_Q15_1024 "cfft q15 1024" OFF)
option(CFFT_Q15_2048 "cfft q15 2048" OFF)
option(CFFT_Q15_4096 "cfft q15 4096" OFF)

option(RFFT_FAST_F32_32 "rfft fast f32 32" OFF)
option(RFFT_FAST_F32_64 "rfft fast f32 64" OFF)
option(RFFT_FAST_F32_128 "rfft fast f32 128" OFF)
option(RFFT_FAST_F32_256 "rfft fast f32 256" OFF)
option(RFFT_FAST_F32_512 "rfft fast f32 512" OFF)
option(RFFT_FAST_F32_1024 "rfft fast f32 1024" OFF)
option(RFFT_FAST_F32_2048 "rfft fast f32 2048" OFF)
option(RFFT_FAST_F32_4096 "rfft fast f32 4096" OFF)


option(RFFT_F32_128 "rfft f32 128" OFF)
option(RFFT_F32_512 "rfft f32 512" OFF)
option(RFFT_F32_2048 "rfft f32 2048" OFF)
option(RFFT_F32_8192 "rfft f32 8192" OFF)

option(RFFT_Q31_32 "rfft q31 32" OFF)
option(RFFT_Q31_64 "rfft q31 64" OFF)
option(RFFT_Q31_128 "rfft q31 128" OFF)
option(RFFT_Q31_256 "rfft q31 256" OFF)
option(RFFT_Q31_512 "rfft q31 512" OFF)
option(RFFT_Q31_1024 "rfft q31 1024" OFF)
option(RFFT_Q31_2048 "rfft q31 2048" OFF)
option(RFFT_Q31_4096 "rfft q31 4096" OFF)
option(RFFT_Q31_8192 "rfft q31 8192" OFF)

option(RFFT_Q15_32 "rfft q15 32" OFF)
option(RFFT_Q15_64 "rfft q15 64" OFF)
option(RFFT_Q15_128 "rfft q15 128" OFF)
option(RFFT_Q15_256 "rfft q15 256" OFF)
option(RFFT_Q15_512 "rfft q15 512" OFF)
option(RFFT_Q15_1024 "rfft q15 1024" OFF)
option(RFFT_Q15_2048 "rfft q15 2048" OFF)
option(RFFT_Q15_4096 "rfft q15 4096" OFF)
option(RFFT_Q15_8192 "rfft q15 8192" OFF)

option(DCT4_F32_128 "dct4 f32 128" OFF)
option(DCT4_F32_512 "dct4 f32 512" OFF)
option(DCT4_F32_2048 "dct4 f32 2048" OFF)
option(DCT4_F32_8192 "dct4 f32 8192" OFF)

option(DCT4_Q31_128 "dct4 q31 128" OFF)
option(DCT4_Q31_512 "dct4 q31 512" OFF)
option(DCT4_Q31_2048 "dct4 q31 2048" OFF)
option(DCT4_Q31_8192 "dct4 q31 8192" OFF)

option(DCT4_Q15_128 "dct4 q15 128" OFF)
option(DCT4_Q15_512 "dct4 q15 512" OFF)
option(DCT4_Q15_2048 "dct4 q15 2048" OFF)
option(DCT4_Q15_8192 "dct4 q15 8192" OFF)


###########################
#
@@ -14,29 +132,92 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/..)

# DSP Sources
SET(DSP ".")
SET(COMMON "${DSP}/CommonTables")

file(GLOB SOURCES_STATS "${DSP}/StatisticsFunctions/*_*.c")
file(GLOB SOURCES_BASIC "${DSP}/BasicMathFunctions/*_*.c")
file(GLOB SOURCES_COMPLEX "${DSP}/ComplexMathFunctions/*_*.c")
file(GLOB SOURCES_FAST "${DSP}/FastMathFunctions/*_*.c")
file(GLOB SOURCES_FILTERING "${DSP}/FilteringFunctions/*_*.c")
file(GLOB SOURCES_MATRIX "${DSP}/MatrixFunctions/*_*.c")
file(GLOB SOURCES_STATS "${DSP}/StatisticsFunctions/*_*.c")
file(GLOB SOURCES_SUPPORT "${DSP}/SupportFunctions/*_*.c")
file(GLOB SOURCES_TRANSFORM "${DSP}/TransformFunctions/*_*.c")
add_library(CMSISDSP INTERFACE)

SET(CMSISDSPSRC ${SOURCES_MATRIX} ${SOURCES_FILTERING} ${SOURCES_SUPPORT} ${SOURCES_COMPLEX} ${SOURCES_TRANSFORM} ${SOURCES_FAST} ${SOURCES_BASIC} ${SOURCES_STATS})
include(config)

add_library(CMSISDSP STATIC ${COMMON}/arm_common_tables.c ${COMMON}/arm_const_structs.c)

include(config)
if (BASICMATH)
add_subdirectory(BasicMathFunctions)
target_link_libraries(CMSISDSP INTERFACE CMSISDSPBasicMath)
endif()

if (COMPLEXMATH)
add_subdirectory(ComplexMathFunctions)
target_link_libraries(CMSISDSP INTERFACE CMSISDSPComplexMath)
endif()

if (CONTROLLER)
add_subdirectory(ControllerFunctions)
# Fast tables inclusion is allowed
if (CONFIGTABLE)
target_compile_definitions(CMSISDSPController PUBLIC ARM_FAST_ALLOW_TABLES)
endif()
target_link_libraries(CMSISDSP INTERFACE CMSISDSPController)
endif()

if (FASTMATH)
add_subdirectory(FastMathFunctions)
# Fast tables inclusion is allowed
if (CONFIGTABLE)
target_compile_definitions(CMSISDSPFastMath PUBLIC ARM_FAST_ALLOW_TABLES)
endif()
target_link_libraries(CMSISDSP INTERFACE CMSISDSPFastMath)
endif()

if (FILTERING)
add_subdirectory(FilteringFunctions)
# Fast tables inclusion is allowed
if (CONFIGTABLE)
target_compile_definitions(CMSISDSPFiltering PUBLIC ARM_FAST_ALLOW_TABLES)
endif()
target_link_libraries(CMSISDSP INTERFACE CMSISDSPFiltering)
endif()

if (MATRIX)
add_subdirectory(MatrixFunctions)
target_link_libraries(CMSISDSP INTERFACE CMSISDSPMatrix)
endif()

if (STATISTICS)
add_subdirectory(StatisticsFunctions)
target_link_libraries(CMSISDSP INTERFACE CMSISDSPStatistics)
endif()

if (SUPPORT)
add_subdirectory(SupportFunctions)
target_link_libraries(CMSISDSP INTERFACE CMSISDSPSupport)
endif()

if (TRANSFORM)
add_subdirectory(TransformFunctions)
# FFT tables inclusion is allowed
if (CONFIGTABLE)
target_compile_definitions(CMSISDSPTransform PUBLIC ARM_FFT_ALLOW_TABLES)
endif()
target_link_libraries(CMSISDSP INTERFACE CMSISDSPTransform)
endif()

### Sources
target_sources(CMSISDSP PRIVATE ${CMSISDSPSRC})
if (FILTERING OR CONTROLLER OR FASTMATH OR TRANSFORM)
add_subdirectory(CommonTables)
if (TRANSFORM)
# FFT tables inclusion is allowed
if (CONFIGTABLE)
target_compile_definitions(CMSISDSPCommon PUBLIC ARM_FFT_ALLOW_TABLES)
endif()
endif()
if (FILTERING OR CONTROLLER OR FASTMATH)
# Select which tables to include
if (CONFIGTABLE)
target_compile_definitions(CMSISDSPCommon PUBLIC ARM_FAST_ALLOW_TABLES)
endif()
endif()
target_link_libraries(CMSISDSP INTERFACE CMSISDSPCommon)
endif()

### Includes
target_include_directories(CMSISDSP PUBLIC "${DSP}/../Include")
target_include_directories(CMSISDSP INTERFACE "${DSP}/../Include")



@@ -0,0 +1,31 @@
cmake_minimum_required (VERSION 3.6)

project(CMSISDSPCommon)



add_library(CMSISDSPCommon STATIC arm_common_tables.c)

if (CONFIGTABLE AND ALLFFT)
target_compile_definitions(CMSISDSPCommon PUBLIC ARM_ALL_FFT_TABLES)
endif()

if (CONFIGTABLE AND ALLFAST)
target_compile_definitions(CMSISDSPCommon PUBLIC ARM_ALL_FAST_TABLES)
endif()

include(fft)
fft(CMSISDSPCommon)

include(interpol)
interpol(CMSISDSPCommon)

target_sources(CMSISDSPCommon PRIVATE arm_const_structs.c)

configdsp(CMSISDSPCommon ..)

### Includes
target_include_directories(CMSISDSPCommon PUBLIC "${DSP}/../../Include")



0 comments on commit e018132

Please sign in to comment.