主题中讨论的其他部件:FFTLIB
工具/软件:
尊敬的 TI:
我要实施 FFT 算法 在上 C7x DSP 直接连接。 为此、我使用的是中的代码 FFTlib BSL 代码。 但是、在确定可以使用哪些代码来运行 FFT 算法时遇到问题。 根据我的理解、大部分代码仅适用于 针对 FFT 算法配置内核 但它本身不包含 FFT 算法。
有人能告诉我可以使用 TI 提供的哪些文件来满足我的需求吗?
此致、
M é lanie
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具/软件:
尊敬的 TI:
我要实施 FFT 算法 在上 C7x DSP 直接连接。 为此、我使用的是中的代码 FFTlib BSL 代码。 但是、在确定可以使用哪些代码来运行 FFT 算法时遇到问题。 根据我的理解、大部分代码仅适用于 针对 FFT 算法配置内核 但它本身不包含 FFT 算法。
有人能告诉我可以使用 TI 提供的哪些文件来满足我的需求吗?
此致、
M é lanie
您好 Melanie、 
这些是 FFTLIB 中支持的不同内核。 该库包含适用于整数和浮点数据类型的内核、支持复数和实值 1-D 输入。
这些实现可在 Processor SDK 中获得。 有关每个内核及关联的 API 的详细说明、请参阅用户指南、网址为:
“ https://software-dl.ti.com/jacinto7/esd/processor-sdk-rtos-j722s/10_01_00_04/exports/docs/fftlib/docs/user_guide/group__FFTLIB__fft1dBatched__i16sc__c16sc__o16sc.html “
例如、考虑内核: FFTLIB_fft1d_i16sc_c16sc_o16sc The corresponding execute function is: FFTLIB_fft1d_i16sc_c16sc_o16sc_kernel()此函数位于: ti-processor-sdk-rtos-j784s4-evm-10_01_00_04/fftlib/fftlib/fft7x/FFTLib_fft1d_i16sc_c16sc_o16sc/C71/FFTLib_fft1d_i16sc_c16sc_oc_ci src
为了参考 FFT 算法实现 、您可以在以下位置检查自然 C: ti-processor-sdk-rtos-j784s4-evm-10_01_00_04/fftlib/fftlib/fft/fft7x/FFTLib_fft1d_i16sc_c16sc_o16sc/ src FFTLib_fft1d_i16sc_c16sc_c_cn.c
此致、
Shabary S Sundar
您好 Sharaby、
我对这些函数的使用有几个问题。
首先、我们是否同意、为了在 CCS 上执行 FFT 算法、我必须按此顺序在 main.cpp 文件中调用以下函数:
- ffTLib_fft1d_i16sc_c16sc_o16sc_checkParams ()
- ffTLib_fft1d_i16sc_c16sc_o16sc_init ()
- ffTLib_fft1d_i16sc_c16sc_o16sc_kernel()
第二、我不理解背后的含义 pShift 参数(指向在 FFT 的每个阶段具有移位值的缓冲器的指针) ? 它代表什么? 它在 FFT 算法中有什么作用?
最后、是 FFTLIB_fft1d_i16sc_c16sc_o16sc_ci 文件 提供中函数的优化功能版本 ffTLib_fft1d_i16sc_c16sc_o16sc_cn.c 文件?
此致、
M é lanie
您好 Melanie、
首先、我们是否同意、为了在 CCS 上执行 FFT 算法、我必须按此顺序调用 main.cpp 文件中的以下函数:
是、 - ffTLib_fft1d_i16sc_c16sc_o16sc_checkParams () 函数检查传递给 init 和内核函数的参数的有效性。
- ffTLib_fft1d_i16sc_c16sc_o16sc_init () 此函数 用于设置流引擎的配置。
- ffTLib_fft1d_i16sc_c16sc_o16sc_kernel() 此函数是主内核计算函数。
其次、我不理解背后的含义 pShift 参数(指向在 FFT 的每个阶段具有移位值的缓冲器的指针) ? 它代表什么? 它在 FFT 算法中有什么作用? [/报价]在定点算术中、FFT 每个级的结果会幅度增加、从而导致溢出。 为防止出现这种情况、将使用
pshift参数对中间结果应用调节。[/quote]最后、就是 FFTLIB_fft1d_i16sc_c16sc_o16sc_ci 文件 提供中函数的优化功能版本 ffTLib_fft1d_i16sc_c16sc_o16sc_cn.c 文件? [/报价]是的、 ffTLib_fft1d_i16sc_c16sc_o16sc_ci 是 中函数的优化版本 ffTLib_fft1d_i16sc_c16sc_o16sc_cn.c 添加到工程。
此致、
Shabary S Sundar.
您好 Sharaby、
感谢您的回答
但是、在尝试使用这些函数时仍然会遇到问题。 我不理解输入数据 PX 和 PW 应提供什么。 您是否有包含此数据的文件?
我 在 FFTLib_fft1d_i16sc_c16sc_o16sc_idat.c 中只找到一些与 staticRefOutput、staticRefInput5、shiftVector4 命名 的数组、但不涉及 twiddle 因子数据
您好 Melanie、
但是、我在尝试使用这些函数时仍然遇到问题
请分享错误的屏幕截图。 您是否能够在 SDK 中运行 fftlib 而不会出现任何问题? 我只是想确认一下。
[报价 userid=“647126" url="“ url="~“~/support/processors-group/processors/f/processors-forum/1530231/tda4vm-how-to-run-an-fft-algorithm-on-c7x-with-fftlib/5898380 #5898380“]我不理解输入数据 PX 和 PW 应提供什么。 您是否有包含此数据的文件?
我 在 FFTLib_fft1d_i16sc_c16sc_o16sc_idat.c 中只找到一些与 staticRefOutput、staticRefInput5、shiftVector4 命名 的数组、但不涉及 twiddle 因子数据
[/报价]pX表示输入数据、而pW指由tw_gend.c文件中定义的函数生成的 Twiddle 因子。 idat.c文件中提供了输入测试数据。
此致、
Betsy Varughese.
您好 Betsy、
好的、因此我必须使用 void tw_gen (int16_t *pw、uint32_t numPoints) 函数。 但是,当我尝试在我的代码中使用它时,我得到这个错误:
"../main.cpp", line 31: error #20: identifier "tw_gen" is undefined

可以有人帮助我解决这个问题吗?
此致、
M é lanie
您好 Betsy、
我想我们没有正确地相互理解。 编译只包含基本 main() 函数的源文件时、一切都正常工作。 是的,我添加了库路径,你可以看到 : 
我的意思 是:“但是,我在尝试使用这些函数时仍然遇到问题“是我不熟悉用作函数输入参数的对象。
目前,我只是尝试使用 tw_gen() 函数生成 twiddle 因子。 下面是我的代码:
#include <fftlib.h>
#include <c7x.h>
#include "common/FFTLIB_bufParams.h" //utilisation type FFTLIB_bufParams1D_t
#include "common/FFTLIB_types.h" //utilisation FFTLIB_32
#include <cmath>
#include <math.h> //fonction pow()
using namespace std;
// utilisation des fonctions FFTLIB_fft1d_i16sc_c16sc_o16sc.h
int main(void){
/* --- PARAMETRES D ENTREES --- */
/* --- BUFFER D ENTREE X --- */
// Generation d une entree correspondant à un signal sinusoidale
/* --- BUFFER DE TWIDDLE FACTORS W --- */
// pW pointe vers un tableau contenant les twiddle factors
// les twiddle factors peuvent etre generes par la fonction tw_gen dans le dc file du folder test
int16_t *pW;
uint32_t numPoints = pow(2,13); // a voir, j'ai mis pareil que code
//tw_gen (pW, numPoints);
/* --- OBTENTION BUFFER DE SPLIT FACTORS --- */
// utiliser split_factor_gen_r2c
// Ordre des fonctions à utiliser
/*
* FFTLIB_fft1d_i16sc_c16sc_o16sc_checkParams() : function checks the validity of the parameters passed to init and kernel functions
* FFTLIB_fft1d_i16sc_c16sc_o16sc_init(): function setting up the configuration for the streaming engine
* FFTLIB_fft1d_i16sc_c16sc_o16sc_kernel() This function is the main kernel compute function
*
*/
return 0;
}
当我编译它的方式,我总是得到相同的消息:
**** Build of configuration Release for project Algo FFT TI **** "C:\\APP\\Atgl\\ti\\ccs1260\\ccs\\utils\\bin\\gmake" -k -j 16 all -O Building file: "../main.cpp" Invoking: C7000 Compiler "C:/Users/MyApp/Packages/ti-cgt-c7000_4.1.0.LTS/bin/cl7x" -mv7100 -O2 --include_path="C:/Users/T0314534/MyApp/depots/stage_jacinto7/Algo FFT TI" --include_path="T:/Packages/ti-processor-sdk-rtos-j721e-evm-10_01_00_04/fftlib/test" --include_path="T:/Packages/ti-processor-sdk-rtos-j721e-evm-10_01_00_04/fftlib/src" --include_path="C:/Users/T0314534/MyApp/Packages/ti-cgt-c7000_4.1.0.LTS/include" --diag_warning=225 --diag_wrap=off --display_error_number --preproc_with_compile --preproc_dependency="main.d_raw" "../main.cpp" >> Compilation failure subdir_rules.mk:9: recipe for target 'main.obj' failed "../main.cpp", line 30: error #20: identifier "tw_gen" is undefined 1 error detected in the compilation of "../main.cpp". gmake: *** [main.obj] Error 1 gmake: Target 'all' not remade because of errors. **** Build Finished ****
我是否必须将 tw_gen() 函数的内容放在我的代码中才能使用它?
此致、
M é lanie ESTEVES
您好 Melanie、
很好、您已经添加了 include 和 library 路径。
这里是我的代码:
tw_gen()在.c 文件中定义、并且是从.cpp文件调用它。 因此、您必须 tw_gen()在 main.cpp 文件中声明、如下所示 ,
// Add this before calling main()
// Declare external C function from the .c file
extern "C" {
void tw_gen((int16_t *pW, uint32_t numPoints);
}
此致、
Betsy Varughese.
好的,所以如果我理解正确,为了使用例如 FFTLib_fft1d_i16sc_c16sc_o16sc_kernel() 函数,在给出用 tw_gen() 获得的*pw 参数之前,我必须转换 pw 值,使其介于–1 和 1 之间?
此外、对于 PS 参数 、我正在尝试使用数组 shiftVector4[] fTLib_fft1d_i16sc_c16sc_o16sc_idat.c 文件的副本。 为此,我 在我的项目中加入了 FFTLib_fft1d_i16sc_c16sc_o16sc_idat.c 文件,并在我的 main.cpp 中以这种方式声明了这个变量:
extern "C" {
static uint32_t shiftVector4;
}
**** Build of configuration Release for project Algo FFT TI **** "C:\\APP\\Atgl\\ti\\ccs1260\\ccs\\utils\\bin\\gmake" -k -j 16 all -O Building file: "../FFTLIB_fft1d_i16sc_c16sc_o16sc_idat.c" Invoking: C7000 Compiler "C:/Users/T0314534/MyApp/Packages/ti-cgt-c7000_4.1.0.LTS/bin/cl7x" -mv7100 -O2 --include_path="C:/Users/T0314534/MyApp/depots/stage_jacinto7/Algo FFT TI" --include_path="T:/Packages/ti-processor-sdk-rtos-j721e-evm-10_01_00_04/fftlib/test" --include_path="T:/Packages/ti-processor-sdk-rtos-j721e-evm-10_01_00_04/fftlib/src" --include_path="C:/Users/T0314534/MyApp/Packages/ti-cgt-c7000_4.1.0.LTS/include" --advice:performance=all --define=_INLINE --define=ALL_TEST_CASES --diag_warning=225 --diag_wrap=off --display_error_number --preproc_with_compile --preproc_dependency="FFTLIB_fft1d_i16sc_c16sc_o16sc_idat.d_raw" "../FFTLIB_fft1d_i16sc_c16sc_o16sc_idat.c" >> Compilation failure subdir_rules.mk:9: recipe for target 'FFTLIB_fft1d_i16sc_c16sc_o16sc_idat.obj' failed "../FFTLIB_fft1d_i16sc_c16sc_o16sc_idat.c", line 28: fatal error #1965: cannot open source file "FFTLIB_fft1d_i16sc_c16sc_o16sc_idat.h" 1 catastrophic error detected in the compilation of "../FFTLIB_fft1d_i16sc_c16sc_o16sc_idat.c". Compilation terminated. gmake: *** [FFTLIB_fft1d_i16sc_c16sc_o16sc_idat.obj] Error 1 gmake: Target 'all' not remade because of errors.
最后、 w HAT 是选择轮班次数的原因 ?
感谢您的帮助、
M é lanie
您好、Besty!
在等待您的回答时、我尝试自行解决问题。 我只是想和你核实一下它对你来说是否正确。
我在工程内部创建了一个名为的源文件 tw_gen.cpp 。 在里面,我把下面的代码:
/*
* tw_gen.cpp
*
* Created on: 9 juil. 2025
*
*/
//Fichier permettant d'utiliser la fonction déclarée dans le fichier :
#include <tw_gen.h>
static int16_t float2short (FFTLIB_D64 x){
x = floor (0.5 + x); // Explicit rounding to integer //
if (x >= 32767.0)
return 32767;
if (x <= -32768.0)
return -32768;
return (int16_t) x;
}
/* --- Fonction generant les twiddle factors */
void tw_gen (int16_t *pW, uint32_t numPoints){
int32_t i, j, k, t;
const FFTLIB_D64 PI = 3.141592654;
FFTLIB_D64 twF2sScale = 32767.5; /* Scale twiddle factors (max abs value of 1) to use full capacity of int16_t */
t = numPoints >> 2;
for (j = 1, k = 0; j <= numPoints >> 2; j = j << 2) {
for (i = 0; i < numPoints >> 2; i += j) {
pW[k] = float2short (twF2sScale * cos (2 * PI * i / numPoints));
pW[k + 1] = float2short (twF2sScale * (-sin (2 * PI * i / numPoints)));
pW[k + 2 * t] =
float2short (twF2sScale * cos (4 * PI * i / numPoints));
pW[k + 2 * t + 1] =
float2short (twF2sScale * (-sin (4 * PI * i / numPoints)));
pW[k + 4 * t] =
float2short (twF2sScale * cos (6 * PI * i / numPoints));
pW[k + 4 * t + 1] =
float2short (twF2sScale * (-sin (6 * PI * i / numPoints)));
k += 2;
}
k += (t) *4;
t = t >> 2;
}
}
extern void tw_gen (int16_t *pW, uint32_t numPoints);
这样,我就能够编译得出以前的错误消息
现在、我在理解如何初始化时遇到问题 PW 参数。
我在 FFTLib_fft1d_i16sc_c16sc_o16sc_d.c 文件中看到、这些参数是这样初始化的:
pX = (int16_t *) TI_memalign (
64, /* pX is required to be*/
numPoints * 2 * sizeof (int16_t)); /* 16-byte aligned for
* streaming engine use
* in kernel 它是唯一的初始化它吗? 如果是、的作用是什么 TI_memalign() 函数? 以及如何选择把大小作为参数之一?
此致、
M é lanie
再次大家好、
我尝试了您的解决方案、但它不起作用。
编译时出现以下问题:
**** Build of configuration Release for project Algo FFT TI **** "C:\\APP\\Atgl\\ti\\ccs1260\\ccs\\utils\\bin\\gmake" -k -j 16 all -O Building file: "../main.cpp" Invoking: C7000 Compiler "C:/Users/MyApp/Packages/ti-cgt-c7000_4.1.0.LTS/bin/cl7x" -mv7100 -O2 --include_path="C:/Users/T0314534/MyApp/depots/stage_jacinto7/Algo FFT TI" --include_path="T:/Packages/ti-processor-sdk-rtos-j721e-evm-10_01_00_04/fftlib/test" --include_path="T:/Packages/ti-processor-sdk-rtos-j721e-evm-10_01_00_04/fftlib/src" --include_path="C:/Users/T0314534/MyApp/Packages/ti-cgt-c7000_4.1.0.LTS/include" --advice:performance=all --diag_warning=225 --diag_wrap=off --display_error_number --preproc_with_compile --preproc_dependency="main.d_raw" "../main.cpp" Finished building: "../main.cpp" Building target: "Algo FFT TI.out" Invoking: C7000 Linker "C:/Users/MyApp/Packages/ti-cgt-c7000_4.1.0.LTS/bin/cl7x" -mv7100 -O2 --advice:performance=all --diag_warning=225 --diag_wrap=off --display_error_number -z -m"Algo FFT TI.map" -i"C:/Users/T0314534/MyApp/Packages/ti-cgt-c7000_4.1.0.LTS/lib" -i"T:/Packages/ti-processor-sdk-rtos-j721e-evm-10_01_00_04/fftlib/lib/Release" -i"C:/Users/T0314534/MyApp/Packages/ti-cgt-c7000_4.1.0.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="Algo FFT TI_linkInfo.xml" --rom_model -o "Algo FFT TI.out" "./main.obj" "../lnk.cmd" -llibc.a -lFFTLIB_C7100.lib -lFFTLIB_common_C7100.lib -lFFTLIB_test_common_C7100.lib <Linking> undefined first referenced symbol in file --------- ---------------- tw_gen ./main.obj error #10234-D: unresolved symbols remain error #10010: errors encountered during linking; "Algo FFT TI.out" not built >> Compilation failure makefile:138: recipe for target 'Algo FFT TI.out' failed gmake[1]: *** [Algo FFT TI.out] Error 1 makefile:134: recipe for target 'all' failed gmake: *** [all] Error 2 **** Build Finished ****
您好 Melanie、
是的、正确。 请 按以下方式进行初始化:-
“ PW =(int16_t *) TI_memalign (64、numPoints * 2 * sizeof (int16_t));“
的角色是什么 TI_memalign() 函数? [/报价]
TI_memalign()使用目标或memalign()主机上的 L2SRAM 分配具有给定对齐方式的内存。(请参阅 TI_memory.c)此致、
Betsy Varughese.
您好 Melanie、
PS 参数
在 idat.c 文件中、它被声明为static、这使得它对该文件私有。 如果您需要从其他文件访问它、以这种方式声明它将不起作用。
您可以尝试以下操作:
//idat.c
uint32_t shiftVector4[] = {0, 0, 0};
// main.cpp
extern "C" {
extern uint32_t shiftVector4[];
}
[引述 userid=“647126" url="“ url="~“~/support/processors-group/processors/f/processors-forum/1530231/tda4vm-how-to-run-an-fft-algorithm-on-c7x-with-fftlib/5918129 #5918129“] w HAT 是选择轮班次数的原因 ?
该参数告诉我们在每个 FFT 阶段缩放/右移数据的量、以避免溢出和经过数值切割。
此致、
Betsy Varugese
您好 Betsy、
是的、抱歉、PS 我指的是 pShift 参数。
我确实删除了静态类型,以便能够在另一个源文件中使用它。 然后我添加了您给我的代码行。 然后、我 在工程中添加了 FFTLib_fft1d_i16sc_c16sc_o16sc_idat.c 文件。 但是,我得到了我在上一条消息中提出的问题。
但是、我设法以自己的方式使用这些数据。
现在、我还需要做的是初始化 pBlock 参数。 我有几个问题:
此致、
M é lanie
好的、在 TI 函数内部、我看到了这些行:
__SE_TEMPLATE_v1 se0_param = __gen_SE_TEMPLATE_v1 ();
__SE_TEMPLATE_v1 se1_param = __gen_SE_TEMPLATE_v1 ();
__SA_TEMPLATE_v1 sa0_param = __gen_SA_TEMPLATE_v1 ();
因此、这意味着使用了 3 个 SE/SA 参数? 我是否必须使用 TI_memalign() 函数来进行分配?
请参阅“/ti-processor-sdk-rtos-j784s4-evm-10_01_00_04/fftlib/fftb/ftb/c7x/FFTLib_fft1d_i16sc_c16sc_o16sc/FFTLib_fft1d_i16sc_c16sc_o16sc.h"<xmt-block0>“ src
/* PBLOCK has to accommodate certain number of SE/SA configurations */ #define FFTLIB_FFT1D_I16SC_C16SC_O16SC_PBLOCK_SIZE (9 * SE_PARAM_SIZE)
并检查用户的相应“d.c 文件“。
uint8_t FFTLIB_fft1d_i16sc_c16sc_o16sc_pBlock
[FFTLIB_FFT1D_I16SC_C16SC_O16SC_PBLOCK_SIZE];
此致、
Betsy Varughese.
我有这些线
我用你的信息来初始化 pBlock 的方式,是正确的吗?:
extern "C" {
uint8_t FFTLIB_fft1d_i16sc_c16sc_o16sc_pBlock[FFTLIB_FFT1D_I16SC_C16SC_O16SC_PBLOCK_SIZE];
}
uint8_t *pBlock;
pBlock = FFTLIB_fft1d_i16sc_c16sc_o16sc_pBlock;是的、我理解这一点、但我的问题是如何知道“ 在代码中需要使用多少次 SE/SA 参数“?
我将使用中的函数 FFTLIB_fft1d_i16sc_c16sc_o16sc_ci.cpp 添加到工程
这是我的代码、但是 i 缺少 pBlock 的初始化 :
#include <fftlib.h>
#include <c7x.h>
#include "common/FFTLIB_bufParams.h" //utilisation type FFTLIB_bufParams1D_t
#include "common/FFTLIB_types.h" //utilisation FFTLIB_32
#include <cmath>
#include <math.h> //fonction pow()
#include "common/TI_memory.h" // fonction TI_memalign()
#include <iostream>
#include <cstring> //pour utilisation memcmp()
/*
* Utilisation des fonctions FFTLIB_fft1d_i16sc_c16sc_o16sc.h
*/
using namespace std;
// Ici j'indique au compilateur que le contenu de cette fonction se trouve dans un autre fichier source
// ici comme je suis dans un fichier C++, ca implique qu elle se trouve ailleurs mais dans un autre fichier C++ aussi
extern void tw_gen (int16_t *pW, uint32_t numPoints);
// Piste abandonnee a cause d erreurs successives d acces a des headers
// Utilisation du tableau de shift d'un autre fichier source C : idat.c
// => Necessite d'utiliser mot clef "extern" pour que le compilateur trouve la def de la variable
// + "C" parce que la def se trouve dans un fichier.c et que nous on code dans un fichier C++
//extern "C" {
// static uint32_t shiftVector4;
//}
// Declaration en variable globale des data d entree TI
int16_t staticRefInput4[] = {
-108, -126, 109, 86, 56, 62, -46, 8, -88, -101, -78, -127, 67, -33, -12, 97, 117, 109, 32, 91, -44, -118, 117, 72, 20, -43,
-66, -77, 82, 19, 31, -84, -22, -115, -46, -114, -30, -73, -115, 25, 118, 25, -18, 92, 61, 90, 67, -39, -21, 88, 11, 85,
-72, 86, 34, -107, -11, -113, -54, 125, -37, 3, 86, 38, -124, 89, 12, 90, 9, -13, -12, 22, 14, 17, -109, 84, 22, -16,
2, -79, 128, 76, 52, -53, -38, -105, 113, 106, 63, -110, -85, -68, -50, -82, 71, -124, 93, -16, 42, -122, 78, -70, -64, -45,
-118, 57, -127, 124, -17, -65, 117, -40, 12, 68, -70, -76, 6, -18, -96, -3, -70, -113, -111, 51, 92, -8, 104, -108};
uint32_t shiftVector4[] = {0, 0, 0};
int main(void){
/* --- PARAMETRES D ENTREES --- */
//Pas utilisable car aucun tableau d entree de TI contient 2^13 valeurs
//uint32_t numPoints = pow(2,13); // a voir, j'ai mis pareil que code
// je mets un nbr de points me permettant d utiliser les tableaux du idat.c
uint32_t numPoints = sizeof(staticRefInput4) / sizeof(staticRefInput4[0]);
cout << " Le nombre de points de la FFT est : " << numPoints << endl;
uint32_t numShifts = 3; // voir rep TI pour raisonnement derriere le choix de cette valeur, j ai mis le meme nombre que dans shiftVector4
/* --- BUFFER D ENTREE X --- */
/* --- Creation de pX --- */
// D apres FFTLIB_fft1d_i16sc_c16sc_o16sc_idat.c file, on doit aligner le buffer d entree sur 16 bytes
int16_t *pX = (int16_t *) TI_memalign (64, numPoints * sizeof (int16_t)); //placement pour respect contrainte
//utilisation d'un memcpy pour recup les valeurs de data de TI
memcpy(pX,staticRefInput4, sizeof(staticRefInput4));
// Verification des copies de staticRefInput4 dans pX STATUT : OK !
// for(int k=0; k<numPoints; k++){
//
// cout << " La " << k << "ème valeur vaut " << pX[k] << endl;
// }
/* --- Creation de bufParamsX --- */
FFTLIB_bufParams1D_t *bufParamsX;
bufParamsX -> data_type = FFTLIB_INT16;
bufParamsX -> dim_x = numPoints; //nombre d elements du buffer dans la direction X (donc ici en 1 dimension)
/* --- BUFFER DE TWIDDLE FACTORS W --- */
/* --- Creation de pW --- */
// pW pointe vers un tableau contenant les twiddle factors
// les twiddle factors peuvent etre generes par la fonction tw_gen dans le dc file du folder test
// Pour initialisation @ pW : utilisation de la fonction TI_memalign() du header TI_memory.h
// Analyse : j ai l impression que c est une forme d allocation memoire "optimisee" a verifier
int16_t *pW = (int16_t *) TI_memalign ( 64, numPoints * 2 * sizeof (int16_t)); //allocation memoire pour stocker les twiddle factors
tw_gen (pW, numPoints); //generation des twiddle factors
// Je verifie qu on a bien genere les facteurs
int pw_nb = numPoints * 2;
// cout << " Le nombre de twiddle factors est de : " << pw_nb << endl;
// for(int i=0; i< pw_nb; i+=2){ //pas de 2 pour l'incrementateur pour lire d'un coup partieR et I
//
// cout << "La partieR du twiddle est :" << pW[i] << endl;
// cout << "La partieI du twiddle est :" << pW[i+1] << endl;
// }
// Res : on obtient des valeurs correspondants a des entiers 16 bits Q15
// De ce que je vois, pas besoin de conv de sorte a avoir des valeurs entre -1 et 1 pour utiliser les fonctions pour le FFT
/* --- Creation de bufParamsW --- */
FFTLIB_bufParams1D_t *bufParamsW;
bufParamsW -> data_type = FFTLIB_INT16;
bufParamsW -> dim_x = numPoints * 2;
/* --- OBTENTION BUFFER DE SPLIT FACTORS --- */
/* --- Creation de pShift --- */
// methode 1 : utilisation TI_memalign()
uint32_t *pShift = (uint32_t *) TI_memalign (64, numShifts * sizeof (uint32_t));
//utilisation d'un memcpy pour recup les valeurs de data de TI
memcpy(pShift,shiftVector4, sizeof(shiftVector4));
// Verification des copies
// for(int n=0; n<numShifts; n++){
//
// cout << " La " << n << " ème valeur vaut " << pShift[n] << endl;
// }
/* --- Creation de bufParamsShift --- */
FFTLIB_bufParams1D_t *bufParamsShift;
bufParamsShift -> data_type = FFTLIB_INT32;
bufParamsShift -> dim_x = numShifts;
// Pour le moment methode abandonnee
// methode 2 : utilisation de tableau de split factors fournis par TI dans file : FFTLIB_fft1d_i16sc_c16sc_o16sc_idat.c
// => Implique l'ajout du predefined symbol ALL_TEST_CASES pour y avoir acces
//uint32_t *pShift;
//pShift = shiftVector4; //on recupere les donnees du fichier idat.c
// methode 3 : utilisation de la fonction split_factor_gen_r2c()
/* --- OBTENTION BUFFER DE SORTIE Y --- */
/* --- Creation de pY --- */
// Pour moi, faut juste allouer de l espace memoire pour stocker les res de la FFT => fait via TI_memalign()
int16_t *pY = (int16_t *) TI_memalign (64, numPoints * sizeof (int16_t));
/* --- Creation de bufParamsY --- */
FFTLIB_bufParams1D_t *bufParamsY;
bufParamsY -> data_type = FFTLIB_INT16;
bufParamsY -> dim_x = numPoints;
/* --- OBTENTION BUFFER PBLOCK --- */
// role de pBlock : j ai l impression que c est un buffer utilise par les streaming engines
// OUI : doit pouvoir stocker les parametres des streaming engines
void *pBlock;
/****** DEBUT IMPLEMENTATION ALGO FFT ******/
// Ordre des fonctions à utiliser
/*
* FFTLIB_fft1d_i16sc_c16sc_o16sc_checkParams() : function checks the validity of the parameters passed to init and kernel functions
* FFTLIB_fft1d_i16sc_c16sc_o16sc_init(): function setting up the configuration for the streaming engine
* FFTLIB_fft1d_i16sc_c16sc_o16sc_kernel() This function is the main kernel compute function
*
*/
// Indicateur etat apres chaque passage dans fonctions TI
FFTLIB_STATUS status = FFTLIB_SUCCESS; //initialise a l etat de succes
/* --- CHECK DE LA VALIDITE DES PARAMATRES POUR INIT() ET KERNEL() FUNCTIONS --- */
if(status == FFTLIB_SUCCESS){
FFTLIB_fft1d_i16sc_c16sc_o16sc_checkParams (pX, bufParamsX, pW, bufParamsW, pY, bufParamsY, pShift, bufParamsShift, pBlock);
}
else{
cout << "Des paramètres d'entrée ne sont pas valides" << endl;
exit(EXIT_FAILURE);
}
/* --- INITIALISATION --- */
FFTLIB_fft1d_i16sc_c16sc_o16sc_init (pX, bufParamsX, pW, bufParamsW, pY, bufParamsY, pShift, bufParamsShift, pBlock);
return 0;
}您好 Melanie、
我用你的 iinformation 来初始化 pBlock、这是正确的吗?:
您从哪个文件中声明了变量—它是来自当前 CCS 工程中的文件还是来自 d.c?
或者、可以直接将所有这些行添加到 main.cpp 中。(请参阅 d.c 中的示例以了解如何在其中调用函数。)
uint8_t FFTLIB_fft1d_i16sc_c16sc_o16sc_pBlock
[FFTLIB_FFT1D_I16SC_C16SC_O16SC_PBLOCK_SIZE]; // Directly use the same name or replace it with your preference
//Example funtion call - init()
status_opt = FFTLIB_fft1d_i16sc_c16sc_o16sc_init (
(int16_t *) pX, &bufParamsData, (int16_t *) pW, &bufParamsData,
(int16_t *) pY, &bufParamsData, (uint32_t *) pShift,
&bufParamsShift, FFTLIB_fft1d_i16sc_c16sc_o16sc_pBlock);
// Kernel
status_opt = FFTLIB_fft1d_i16sc_c16sc_o16sc_kernel (
(int16_t *) pX, &bufParamsData, (int16_t *) pW, &bufParamsData,
(int16_t *) pY, &bufParamsData, (uint32_t *) pShift,
&bufParamsShift, FFTLIB_fft1d_i16sc_c16sc_o16sc_pBlock);
如果您仍然遇到任何问题、请告诉我。
请注意、
Betsy Varughese.
您好 Betsy、
我在运行代码时尝试单步执行代码的每一行以识别问题。
下面是我得到的一些信息:
在释放模式下:
No source available for "TI_memalign() at C:\Users\MyApp\depots\stage_jacinto7\Algo FFT TI\Release\Algo FFT TI.out:{3} 0x70037f80{4}" C71X_0: Trouble Reading Memory Block at 0x2200150a2afa9596 on Page 0 of Length 0x8: (Error -1344 - (0:0:0)) Register or Memory request has failed due to a Transaction Error. This may be the result of reading from a write only register, writing to a read only register, or accessing a memory location that is not assigned. No user action required. (Emulation package 12.6.0.00029) C71X_0: Trouble Reading Memory Block at 0x70045b28 on Page 0 of Length 0x8: (Error -1351 - (0:0:0)) Register or Memory request has timed out. The CPU is executing a High Priority Interrupt, this is typically due to a Double Page Fault. Choose 'Force' to force the CPU into a state that allows debug of why the HPI is active. (Emulation package 12.6.0.00029)
首先、我怀疑 与初始化变量相关的某些存储器区域的大小有问题。 但是、在检查后、我发现创建变量不会超过为不同段分配的大小。 所以我不知道问题来自哪里:(
您好 Melanie、
您能否更新代码中的以下内容并尝试?
“1"我们“我们应该 在状态中捕获 FFTLIB_fft1d_i16sc_c16sc_o16sc_init () 的返回值,尝试使用,
status = FFTLIB_fft1d_i16sc_c16sc_o16sc_init (pX, bufParamsX, pW, bufParamsW, pY, bufParamsY, pShift, bufParamsShift, pBlock);
“2"注“注释“FFTLIB_fft1d_i16sc_c16sc_o16sc_checkParams()“并尝试(参见 d.c、它不调用 checkparams()、并且在下面进行保护
pX = (int16_t *) TI_memalign (
64, /* pX is required to be*/
numPoints * 2 * sizeof (int16_t)); /* 16-byte aligned for
* streaming engine use
* in kernel */
pY = (int16_t *) TI_memalign (64, numPoints * 2 * sizeof (int16_t));
pW = (int16_t *) TI_memalign (64, numPoints * 2 * sizeof (int16_t));
pShift = (uint32_t *) TI_memalign (64, numShifts * sizeof (uint32_t));
bufParamsData.dim_x = numPoints * 2;
bufParamsData.data_type = FFTLIB_INT16;
bufParamsShift.dim_x = numShifts;
bufParamsShift.data_type = FFTLIB_UINT32;
你好 Betsy!
好的,所以我遵循了前两个指令:我对 checkParams() 函数进行了注释,并在 status 变量中输入 init() 函数的返回值。 这样、问题确实消失了、状态为 FFTLIB_SUCCESS。
然而,我非常不同意你的报价“ 见 d.c ,它不调用 checkparams() 并在 FFTLIB_CHECK_PARAMS || FFTLIB_FFT1D_I16SC_C16SC_O16SC_CHECK_PARAMS ....保护...“。 当我看着身体函数时 ffTLib_fft1d_i16sc_c16sc_o16sc_d ()、 我可以看到他们通过调用 fft1d_i16sc_c16sc_o16sc_getTestParams () 来检查参数
此外、您能否解释一下为什么要使用 FFTLIB_fft1d_i16sc_c16sc_o16sc_checkParams 函数导致代码在循环中运行?
此致
您好 Melanie、
对混淆表示道歉 — 我所指的是以下 API、它位于 CI.cpp 内。
#if defined(FFTLIB_CHECK_PARAMS) || \
defined(FFTLIB_FFT1D_I16SC_C16SC_O16SC_CHECK_PARAMS)
status = FFTLIB_fft1d_i16sc_c16sc_o16sc_checkParams (
pX, bufParamsX, pW, bufParamsW, pY, bufParamsY, pShift, bufParamsShift,
pBlock);
if (status == FFTLIB_SUCCESS)
#endif
此致、
Betsy Varughese.
您好 Betsy、
如果我错了、告诉我、但如果到目前为止代码是在循环中运行的、那是因为编译器没有的定义 FFTLIB_fft1d_i16sc_c16sc_o16sc_checkParams 因为 以下预定义符号均未声明: FFTLIB_CHECK_PARAMS ||FFTLIB_FFT1D_I16SC_C16SC_O16SC_CHECK_PARAMS
因此,我试图添加其中一个: 
然后,我没有评论的使用 FFTLIB_fft1d_i16sc_c16sc_o16sc_checkParams 在 main() 函数中。 然而,我又收到了上一个问题,你能解释为什么?
此致
您好 Melanie、
感谢您提供详细信息。
我回来给您、因为我在尝试使用时遇到了相同的问题 ffTLib_fft1d_i16sc_c16sc_o16sc_kernel() 测量输出。 显然,我回评论了 FFTLIB_fft1d_i16sc_c16sc_o16sc_checkParams 传递函数
启用内核后是否会遇到相同的问题? 您能否验证输入和 twiddle 因子值是否正确生成?
您能告诉我 numPoints 的价值吗?
我会检查代码并返回给您。
此致、
Betsy Varughese.
您好 Melanie、
您能尝试一下下面的代码
#include <fftlib.h>
#include <c7x.h>
#include "common/FFTLIB_bufParams.h"
#include "common/FFTLIB_types.h"
#include <cmath>
#include <math.h>
#include "common/TI_memory.h"
#include <iostream>
#include <cstring>
#include <tw_gen.h>
using namespace std;
extern void tw_gen (int16_t *pW, uint32_t numPoints);
uint8_t FFTLIB_fft1d_i16sc_c16sc_o16sc_pBlock[FFTLIB_FFT1D_I16SC_C16SC_O16SC_PBLOCK_SIZE];
int16_t pX[] = {
-108, -126, 109, 86, 56, 62, -46, 8, -88, -101, -78, -127, 67, -33, -12, 97, 117, 109, 32, 91, -44, -118, 117, 72, 20, -43,
-66, -77, 82, 19, 31, -84, -22, -115, -46, -114, -30, -73, -115, 25, 118, 25, -18, 92, 61, 90, 67, -39, -21, 88, 11, 85,
-72, 86, 34, -107, -11, -113, -54, 125, -37, 3, 86, 38, -124, 89, 12, 90, 9, -13, -12, 22, 14, 17, -109, 84, 22, -16,
2, -79, 128, 76, 52, -53, -38, -105, 113, 106, 63, -110, -85, -68, -50, -82, 71, -124, 93, -16, 42, -122, 78, -70, -64, -45,
-118, 57, -127, 124, -17, -65, 117, -40, 12, 68, -70, -76, 6, -18, -96, -3, -70, -113, -111, 51, 92, -8, 104, -108};
const uint32_t pShift[] = {0, 0, 0};
const uint32_t numPoints = 64;
const uint32_t numShifts = 3;
int main(){
int16_t *pY, *pW;
FFTLIB_STATUS status = FFTLIB_SUCCESS;
pY = (int16_t *) TI_memalign (64, numPoints * 2 * sizeof (int16_t));
pW = (int16_t *) TI_memalign (64, numPoints * 2 * sizeof (int16_t));
FFTLIB_bufParams1D_t bufParamsData;
FFTLIB_bufParams1D_t bufParamsShift;
bufParamsData.dim_x = numPoints * 2;
bufParamsData.data_type = FFTLIB_INT16;
bufParamsShift.dim_x = numShifts;
bufParamsShift.data_type = FFTLIB_UINT32;
tw_gen (pW, numPoints);
status = FFTLIB_fft1d_i16sc_c16sc_o16sc_init (
(int16_t *) pX, &bufParamsData, (int16_t *) pW, &bufParamsData,
(int16_t *) pY, &bufParamsData, (uint32_t *) pShift,
&bufParamsShift, FFTLIB_fft1d_i16sc_c16sc_o16sc_pBlock);
if(status == FFTLIB_SUCCESS){
status = FFTLIB_fft1d_i16sc_c16sc_o16sc_kernel (
(int16_t *) pX, &bufParamsData, (int16_t *) pW, &bufParamsData,
(int16_t *) pY, &bufParamsData, (uint32_t *) pShift,
&bufParamsShift, FFTLIB_fft1d_i16sc_c16sc_o16sc_pBlock);
}
return 0;
}
此致、
Betsy Varughese.
尊敬的 Besty:
我在收到您的答案之前发现了问题。
我认为有 2 个可能的问题:
-我想我是以错误的方式声明 1D 缓冲区的。 事实上,我看到了这个警告:“缓冲区 bufParamsData 在其值被设置之前被使用“。 因此、我使用了中使用的方法 D.C 文件 。 这是你最后一次给我的方法。 您是否认为问题 可能来自该问题?
-而且,我对缓冲区的 data_type 字段输入了错误的数据类型: “bufParamsY"。“。
现在,包括 checkParams() 和 kernel() 函数在内的所有函数都在工作。 不再存在 代码在循环中运行的任何问题、因此非常棒。
我还通过将 memcmp () 与 py 和 staticRefOutput4 一起使用来检查 FFT 算法的输出缓冲区的值是否正确,并且它们匹配
此致、
M é lanie