⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 在ADSP-2126x上编写的优化过的FFT程序(用c和汇编编写)。
💻 C
字号:
/*******************************************************************************
*
* Function:  main - Tests cfft_simd
*
* Description:  
*				This function is and example of how to use cfft_simd
*
* Author:	Darrel Judd
*				Judd Labs, Inc.
*				801-756-2057
*				drjudd@ieee.org
*
* Revisions:
*				Created June, 2003 - Darrel Judd
************************************************************************************/
//==================================================================================
//include files
//==================================================================================
#include "cfft_simd.h"
#include "benchmark.h"
#include <stdio.h>
//==================================================================================
// definitions
//==================================================================================
// size of the FFT
#define N (1024)
// pi is needed to calculate the input sine wave
#define pi (3.141592654)
//==================================================================================
// Global Varibles
//==================================================================================
// cfft_simd storage object
Tcfft_simd pm Rad2;
// intermediate storage used be cfft_simd
float refft[N];
// intermediate storage used be cfft_simd
float pm imfft[N];
// real twiddle factor array
float retwid[N/2+1];
// imaginary twiddle factor arry
float pm imtwid[N/2+1];
// real input data array aligned to a multiple of N
#pragma align 1024
float redata[N];
// imaginary input data array aligned to a multtiple of N
#pragma align 1024
float pm imdata[N];
// FFT size input, must be a power of 2
Tcfft_simd_size FFTSize = N1024;
//===================================================================================
// proto-types
//===================================================================================
void sinf_simd(float *x,float *y);
//===================================================================================
main()
{
	U32 i;
	// bench mark variables
	volatile S32 CycleCountInit,CycleCountFFT,CycleCountTwid;
	// calculate an input sine wave to transform
	float x[2];
	for(i=0;i<FFTSize;i=i+2)
	{
		x[0]=2*pi/N*i;
		x[1]=2*pi/N*(i+1);
		// calculate 2 at a time
		sinf_simd(x,&redata[i]);
	}
	// start the clock ticking
	CycleCountInit=count_start();
	// initialize the cfft_simd object
	cfft_simd_init(&Rad2,	// pointer to fft object
						FFTSize,					// size of fft, must be a power of 2
						redata,		// pointer to real input data of size N
						imdata,		// pointer to imag input data of size N
						retwid,		// pointer to real twiddle array of size N/2
						imtwid,		// pointer to imag twiddle array of size N/2
						refft,		// pointer to real temp array of size N
						imfft);		// pointer to imag temp array of size N
	// stop the clock and store the numbers of cycles executed
	CycleCountInit=count_end(CycleCountInit);
	// start the clock ticking again
	CycleCountTwid=count_start();
	// calculate the twiddle factors
	cfft_simd_twiddle_calc(&Rad2);
	// stop the clock and store the numbers of cycles executed
	CycleCountTwid=count_end(CycleCountTwid);
	// start the clock ticking again
	CycleCountFFT=count_start();
	// calculate the FFT
	cfft_simd(&Rad2);
	// stop the clock and store the numbers of cycles executed
	CycleCountFFT=count_end(CycleCountFFT);
	printf("Size of FFT = %d\n",FFTSize);
	printf("Number of cycles to initialize = %d\n",CycleCountInit);
	printf("Number of cycles to calculate twiddle factors = %d\n",CycleCountTwid);
	printf("Number of cycles to calculate the FFT = %d\n",CycleCountFFT);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -