Commit d6cdcb91 authored by knopp's avatar knopp

removed PHY/TOOLS/fft.c and all uses of this FFT implementation. All are...

removed PHY/TOOLS/fft.c and all uses of this FFT implementation. All are replaced by the faster versions in PHY/TOOLS/lte_dfts.c

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7390 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent f8bc7e38
......@@ -768,9 +768,7 @@ set(PHY_SRC
${OPENAIR1_DIR}/PHY/CODING/viterbi_lte.c
${OPENAIR1_DIR}/PHY/INIT/lte_init.c
${OPENAIR1_DIR}/PHY/INIT/lte_parms.c
${OPENAIR1_DIR}/PHY/INIT/init_top.c
${OPENAIR1_DIR}/PHY/TOOLS/file_output.c
${OPENAIR1_DIR}/PHY/TOOLS/fft.c
${OPENAIR1_DIR}/PHY/TOOLS/lte_dfts.c
${OPENAIR1_DIR}/PHY/TOOLS/log2_approx.c
${OPENAIR1_DIR}/PHY/TOOLS/cmult_sv.c
......
This diff is collapsed.
This diff is collapsed.
......@@ -133,14 +133,28 @@ int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms,
for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
// do ifft of channel estimate
fft((short*) &lte_eNb_srs->srs_ch_estimates[ind][aa][0],
(short*) lte_eNb_srs->srs_ch_estimates_time[ind][aa],
frame_parms->twiddle_ifft,
frame_parms->rev,
frame_parms->log2_symbol_size,
frame_parms->log2_symbol_size/2,
0);
switch(frame_parms->N_RB_DL) {
case 6:
dft128((int16_t*) &lte_eNb_srs->srs_ch_estimates[ind][aa][0],
(int16_t*) lte_eNb_srs->srs_ch_estimates_time[ind][aa],
1);
break;
case 25:
dft512((int16_t*) &lte_eNb_srs->srs_ch_estimates[ind][aa][0],
(int16_t*) lte_eNb_srs->srs_ch_estimates_time[ind][aa],
1);
break;
case 50:
dft1024((int16_t*) &lte_eNb_srs->srs_ch_estimates[ind][aa][0],
(int16_t*) lte_eNb_srs->srs_ch_estimates_time[ind][aa],
1);
break;
case 100:
dft2048((int16_t*) &lte_eNb_srs->srs_ch_estimates[ind][aa][0],
(int16_t*) lte_eNb_srs->srs_ch_estimates_time[ind][aa],
1);
break;
}
#ifdef USER_MODE
#ifdef DEBUG_PHY
sprintf(fname,"srs_ch_estimates_time_%d%d.m",ind,aa);
......@@ -156,8 +170,8 @@ int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms,
temp = 0;
for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
Re = ((int16_t*)lte_eNb_srs->srs_ch_estimates_time[ind][aa])[(i<<2)];
Im = ((int16_t*)lte_eNb_srs->srs_ch_estimates_time[ind][aa])[1+(i<<2)];
Re = ((int16_t*)lte_eNb_srs->srs_ch_estimates_time[ind][aa])[(i<<1)];
Im = ((int16_t*)lte_eNb_srs->srs_ch_estimates_time[ind][aa])[1+(i<<1)];
temp += (Re*Re/2) + (Im*Im/2);
}
......
......@@ -752,14 +752,36 @@ int lte_dl_mbsfn_channel_estimation(PHY_VARS_UE *phy_vars_ue,
// do ifft of channel estimate
for (aa=0; aa<phy_vars_ue->lte_frame_parms.nb_antennas_rx*phy_vars_ue->lte_frame_parms.nb_antennas_tx; aa++) {
if (phy_vars_ue->lte_ue_common_vars.dl_ch_estimates[eNB_offset][aa])
fft((short*) &phy_vars_ue->lte_ue_common_vars.dl_ch_estimates[eNB_offset][aa][LTE_CE_OFFSET],
(short*) phy_vars_ue->lte_ue_common_vars.dl_ch_estimates_time[eNB_offset][aa],
phy_vars_ue->lte_frame_parms.twiddle_ifft,
phy_vars_ue->lte_frame_parms.rev,
phy_vars_ue->lte_frame_parms.log2_symbol_size,
phy_vars_ue->lte_frame_parms.log2_symbol_size/2,
0);
if (phy_vars_ue->lte_ue_common_vars.dl_ch_estimates[eNB_offset][aa]) {
switch (phy_vars_ue->lte_frame_parms.N_RB_DL) {
case 6:
idft128((int16_t*) &phy_vars_ue->lte_ue_common_vars.dl_ch_estimates[eNB_offset][aa][LTE_CE_OFFSET],
(int16_t*) phy_vars_ue->lte_ue_common_vars.dl_ch_estimates_time[eNB_offset][aa],
1);
break;
case 25:
idft512((int16_t*) &phy_vars_ue->lte_ue_common_vars.dl_ch_estimates[eNB_offset][aa][LTE_CE_OFFSET],
(int16_t*) phy_vars_ue->lte_ue_common_vars.dl_ch_estimates_time[eNB_offset][aa],
1);
break;
case 50:
idft1024((int16_t*) &phy_vars_ue->lte_ue_common_vars.dl_ch_estimates[eNB_offset][aa][LTE_CE_OFFSET],
(int16_t*) phy_vars_ue->lte_ue_common_vars.dl_ch_estimates_time[eNB_offset][aa],
1);
break;
case 75:
idft1536((int16_t*) &phy_vars_ue->lte_ue_common_vars.dl_ch_estimates[eNB_offset][aa][LTE_CE_OFFSET],
(int16_t*) phy_vars_ue->lte_ue_common_vars.dl_ch_estimates_time[eNB_offset][aa]);
break;
case 100:
idft2048((int16_t*) &phy_vars_ue->lte_ue_common_vars.dl_ch_estimates[eNB_offset][aa][LTE_CE_OFFSET],
(int16_t*) phy_vars_ue->lte_ue_common_vars.dl_ch_estimates_time[eNB_offset][aa],
1);
break;
default:
break;
}
}
}
return(0);
......
......@@ -156,17 +156,46 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
}
}
fft((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
switch (frame_parms->N_RB_DL) {
case 6:
idft128((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
case 25:
idft512((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
case 50:
idft1024((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
case 75:
idft1536((short*)syncF_tmp, /// complex input
(short*)sync_tmp); /// complex output
break;
case 100:
idft2048((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
default:
LOG_E(PHY,"Unsupported N_RB_DL %d\n",frame_parms->N_RB_DL);
break;
}
/*
frame_parms->twiddle_ifft, /// complex twiddle factors
frame_parms->rev, /// bit reversed permutation vector
frame_parms->log2_symbol_size,/// log2(FFT_SIZE)
(frame_parms->log2_symbol_size/2),
0); /// 0 - input is in complex Q1.15 format, 1 - input is in complex redundant Q1.15 format)
*/
for (i=0; i<frame_parms->ofdm_symbol_size; i++)
((int32_t*)primary_synch0_time)[i] = sync_tmp[2*i];
((int32_t*)primary_synch0_time)[i] = sync_tmp[i];
k=frame_parms->ofdm_symbol_size-36;
......@@ -181,16 +210,40 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
}
}
fft((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
frame_parms->twiddle_ifft, /// complex twiddle factors
frame_parms->rev, /// bit reversed permutation vector
frame_parms->log2_symbol_size,/// log2(FFT_SIZE)
frame_parms->log2_symbol_size/2,
0) ; /// 0 - input is in complex Q1.15 format, 1 - input is in complex redundant Q1.15 format)
switch (frame_parms->N_RB_DL) {
case 6:
idft128((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
case 25:
idft512((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
case 50:
idft1024((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
case 75:
idft1536((short*)syncF_tmp, /// complex input
(short*)sync_tmp /// complex output
);
break;
case 100:
idft2048((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
default:
LOG_E(PHY,"Unsupported N_RB_DL %d\n",frame_parms->N_RB_DL);
break;
}
for (i=0; i<frame_parms->ofdm_symbol_size; i++)
((int32_t*)primary_synch1_time)[i] = sync_tmp[2*i];
((int32_t*)primary_synch1_time)[i] = sync_tmp[i];
k=frame_parms->ofdm_symbol_size-36;
......@@ -205,16 +258,40 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
}
}
fft((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
frame_parms->twiddle_ifft, /// complex twiddle factors
frame_parms->rev, /// bit reversed permutation vector
frame_parms->log2_symbol_size,/// log2(FFT_SIZE)
frame_parms->log2_symbol_size/2,
0); /// 0 - input is in complex Q1.15 format, 1 - input is in complex redundant Q1.15 format)
switch (frame_parms->N_RB_DL) {
case 6:
idft128((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
case 25:
idft512((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
case 50:
idft1024((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
case 75:
idft1536((short*)syncF_tmp, /// complex input
(short*)sync_tmp /// complex output
);
break;
case 100:
idft2048((short*)syncF_tmp, /// complex input
(short*)sync_tmp, /// complex output
1);
break;
default:
LOG_E(PHY,"Unsupported N_RB_DL %d\n",frame_parms->N_RB_DL);
break;
}
for (i=0; i<frame_parms->ofdm_symbol_size; i++)
((int32_t*)primary_synch2_time)[i] = sync_tmp[2*i];
((int32_t*)primary_synch2_time)[i] = sync_tmp[i];
......
......@@ -87,7 +87,7 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
while (1) {
//compute frequency-domain representation of 6144-sample chunk
fft6144((int16_t *)rxp,
dft6144((int16_t *)rxp,
sp);
......
This diff is collapsed.
......@@ -42,8 +42,8 @@
#include "LAYER2/MAC/extern.h"
//uint8_t ncs_cell[20][7];
//#define DEBUG_PUCCH_TX
//#define DEBUG_PUCCH_RX
#define DEBUG_PUCCH_TX
#define DEBUG_PUCCH_RX
int16_t cfo_pucch_np[24*7] = {20787,-25330,27244,-18205,31356,-9512,32767,0,31356,9511,27244,18204,20787,25329,
27244,-18205,30272,-12540,32137,-6393,32767,0,32137,6392,30272,12539,27244,18204,
......
......@@ -34,7 +34,7 @@
*/
/**
\fn void PHY_ofdm_mod(int *input,int *output,unsigned char log2fftsize,unsigned char nb_symbols,unsigned short nb_prefix_samples,short *twiddle_ifft,unsigned short *rev,Extension_t etype)
\fn void PHY_ofdm_mod(int *input,int *output,unsigned char log2fftsize,unsigned char nb_symbols,unsigned short nb_prefix_samples,Extension_t etype)
This function performs OFDM modulation with cyclic extension or zero-padding.
@param input The sequence input samples in the frequency-domain. This is a concatenation of the input symbols in SIMD redundant format
......@@ -42,8 +42,6 @@ This function performs OFDM modulation with cyclic extension or zero-padding.
@param log2fftsize Base-2 logarithm of the OFDM symbol size (\f$N_d\f$)
@param nb_symbols The number of OFDM symbols in the block
@param nb_prefix_samples The number of prefix/suffix/zero samples
@param twiddle_ifft Pointer to the ifft twiddle factors
@param rev Pointer to the bit-reversal permutation
@param etype Type of extension (CYCLIC_PREFIX,CYCLIC_SUFFIX,ZEROS)
*/
......@@ -52,8 +50,6 @@ void PHY_ofdm_mod(int *input,
unsigned char log2fftsize,
unsigned char nb_symbols,
unsigned short nb_prefix_samples,
short *twiddle_ifft,
unsigned short *rev,
Extension_t etype
);
......
......@@ -66,8 +66,6 @@ void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRA
frame_parms->log2_symbol_size, // log2_fft_size
1, // number of symbols
frame_parms->nb_prefix_samples0, // number of prefix samples
frame_parms->twiddle_ifft, // IFFT twiddle factors
frame_parms->rev, // bit-reversal permutation
CYCLIC_PREFIX);
#ifdef DEBUG_OFDM_MOD
printf("slot i %d (txdata offset %d)\n",i,OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(i*frame_parms->samples_per_tti>>1));
......@@ -78,8 +76,6 @@ void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRA
frame_parms->log2_symbol_size, // log2_fft_size
(short_offset==1) ? 1 :(frame_parms->symbols_per_tti>>1)-1,//6, // number of symbols
frame_parms->nb_prefix_samples, // number of prefix samples
frame_parms->twiddle_ifft, // IFFT twiddle factors
frame_parms->rev, // bit-reversal permutation
CYCLIC_PREFIX);
......@@ -91,8 +87,6 @@ void PHY_ofdm_mod(int *input, /// pointer to complex input
unsigned char log2fftsize, /// log2(FFT_SIZE)
unsigned char nb_symbols, /// number of OFDM symbols
unsigned short nb_prefix_samples, /// cyclic prefix length
short *twiddle_ifft, /// pointer to precomputed twiddle table
unsigned short *rev, /// pointer to bit-reversal table
Extension_t etype /// type of extension
)
{
......@@ -253,8 +247,6 @@ void do_OFDM_mod(mod_sym_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t
frame_parms->log2_symbol_size, // log2_fft_size
12, // number of symbols
frame_parms->ofdm_symbol_size>>2, // number of prefix samples
frame_parms->twiddle_ifft, // IFFT twiddle factors
frame_parms->rev, // bit-reversal permutation
CYCLIC_PREFIX);
if (frame_parms->Ncp == EXTENDED)
......@@ -263,8 +255,6 @@ void do_OFDM_mod(mod_sym_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t
frame_parms->log2_symbol_size, // log2_fft_size
2, // number of symbols
frame_parms->nb_prefix_samples, // number of prefix samples
frame_parms->twiddle_ifft, // IFFT twiddle factors
frame_parms->rev, // bit-reversal permutation
CYCLIC_PREFIX);
else {
LOG_D(PHY,"Frame %d, subframe %d: Doing PDCCH modulation\n",frame,next_slot>>1);
......@@ -281,8 +271,6 @@ void do_OFDM_mod(mod_sym_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t
frame_parms->log2_symbol_size, // log2_fft_size
6, // number of symbols
frame_parms->nb_prefix_samples, // number of prefix samples
frame_parms->twiddle_ifft, // IFFT twiddle factors
frame_parms->rev, // bit-reversal permutation
CYCLIC_PREFIX);
else {
normal_prefix_mod(&txdataF[aa][slot_offset_F],
......
......@@ -124,18 +124,6 @@ int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue,
SOFFSET) % frame_length_samples],
(int16_t *)&ue_common_vars->rxdataF[aa][frame_parms->ofdm_symbol_size*l],1);
stop_meas(&phy_vars_ue->rx_dft_stats);
/*
fft((short *)&ue_common_vars->rxdata[aa][sample_offset +
nb_prefix_samples0 +
subframe_offset -
SOFFSET],
(short*)&ue_common_vars->rxdataF[aa][2*frame_parms->ofdm_symbol_size*l],
frame_parms->twiddle_fft,
frame_parms->rev,
frame_parms->log2_symbol_size,
frame_parms->log2_symbol_size>>1,
0);
*/
} else {
if ((sample_offset +
(frame_parms->ofdm_symbol_size+nb_prefix_samples0+nb_prefix_samples) +
......@@ -154,26 +142,8 @@ int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue,
SOFFSET) % frame_length_samples],
(int16_t *)&ue_common_vars->rxdataF[aa][frame_parms->ofdm_symbol_size*l],1);
stop_meas(&phy_vars_ue->rx_dft_stats);
/*
fft((short *)&ue_common_vars->rxdata[aa][sample_offset +
(frame_parms->ofdm_symbol_size+nb_prefix_samples0+nb_prefix_samples) +
(frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1) +
subframe_offset-
SOFFSET],
(short*)&ue_common_vars->rxdataF[aa][2*frame_parms->ofdm_symbol_size*l],
frame_parms->twiddle_fft,
frame_parms->rev,
frame_parms->log2_symbol_size,
frame_parms->log2_symbol_size>>1,
0);
*/
}
/*
memcpy(&ue_common_vars->rxdataF2[aa][2*subframe_offset_F+2*frame_parms->ofdm_symbol_size*l],
&ue_common_vars->rxdataF[aa][2*frame_parms->ofdm_symbol_size*l],
2*frame_parms->ofdm_symbol_size*sizeof(int));
*/
}
//if ((l==0) || (l==(4-frame_parms->Ncp))) {
......
......@@ -304,7 +304,7 @@ This function performs optimized fixed-point radix-2 FFT/IFFT.
@param scale Total number of shifts (should be log2size/2 for normalized FFT)
@param input_fmt (0 - input is in complex Q1.15 format, 1 - input is in complex redundant Q1.15 format)
*/
void fft(int16_t *x,
/*void fft(int16_t *x,
int16_t *y,
int16_t *twiddle,
uint16_t *rev,
......@@ -312,30 +312,31 @@ void fft(int16_t *x,
uint8_t scale,
uint8_t input_fmt
);
*/
void ifft1536(int16_t *sigF,int16_t *sig);
void idft1536(int16_t *sigF,int16_t *sig);
void ifft6144(int16_t *sigF,int16_t *sig);
void idft6144(int16_t *sigF,int16_t *sig);
void ifft12288(int16_t *sigF,int16_t *sig);
void idft12288(int16_t *sigF,int16_t *sig);
void ifft18432(int16_t *sigF,int16_t *sig);
void idft18432(int16_t *sigF,int16_t *sig);
void ifft3072(int16_t *sigF,int16_t *sig);
void idft3072(int16_t *sigF,int16_t *sig);
void ifft24576(int16_t *sigF,int16_t *sig);
void idft24576(int16_t *sigF,int16_t *sig);
void fft1536(int16_t *sigF,int16_t *sig);
void dft1536(int16_t *sigF,int16_t *sig);
void fft6144(int16_t *sigF,int16_t *sig);
void dft6144(int16_t *sigF,int16_t *sig);
void fft12288(int16_t *sigF,int16_t *sig);
void dft12288(int16_t *sigF,int16_t *sig);
void fft18432(int16_t *sigF,int16_t *sig);
void dft18432(int16_t *sigF,int16_t *sig);
void fft3072(int16_t *sigF,int16_t *sig);
void dft3072(int16_t *sigF,int16_t *sig);
void fft24576(int16_t *sigF,int16_t *sig);
void dft24576(int16_t *sigF,int16_t *sig);
/*!\fn int rotate_cpx_vector(int16_t *x,int16_t *alpha,int16_t *y,uint32_t N,uint16_t output_shift, uint8_t format)
......@@ -594,12 +595,16 @@ void dft256(int16_t *x,int16_t *y,int scale);
void dft512(int16_t *x,int16_t *y,int scale);
void dft1024(int16_t *x,int16_t *y,int scale);
void dft2048(int16_t *x,int16_t *y,int scale);
void dft4096(int16_t *x,int16_t *y,int scale);
void dft8192(int16_t *x,int16_t *y,int scale);
void idft64(int16_t *x,int16_t *y,int scale);
void idft128(int16_t *x,int16_t *y,int scale);
void idft256(int16_t *x,int16_t *y,int scale);
void idft512(int16_t *x,int16_t *y,int scale);
void idft1024(int16_t *x,int16_t *y,int scale);
void idft2048(int16_t *x,int16_t *y,int scale);
void idft4096(int16_t *x,int16_t *y,int scale);
void idft8192(int16_t *x,int16_t *y,int scale);
/** @} */
......
This diff is collapsed.
k=0;
for i=0:5,
for n=0:(2^i)-1,
twiddleFFT_64(1+(4*k)) = round(16384*cos(2*pi*n/(2^(i+1))));
twiddleIFFT_64(1+(4*k)) = twiddleFFT_64(1+(4*k));
twiddleFFT_64(2+(4*k)) = round(16384*sin(2*pi*n/(2^(i+1))));
twiddleIFFT_64(2+(4*k)) = -twiddleFFT_64(2+(4*k));
twiddleFFT_64(3+(4*k)) = -twiddleFFT_64(2+(4*k));
twiddleIFFT_64(3+(4*k)) = twiddleFFT_64(2+(4*k));
twiddleFFT_64(4+(4*k)) = twiddleFFT_64(1+(4*k));
twiddleIFFT_64(4+(4*k)) = twiddleFFT_64(1+(4*k));
k=k+1;
end
end
[fid, msg] = fopen("twiddle64.h","w","ieee-le");
fprintf(fid,"short twiddle_fft64[63*4] = {");
fprintf(fid,"%d,%d,%d,%d,\n",twiddleFFT_64(1:248));
fprintf(fid,"%d,%d,%d,%d};\n\n",twiddleFFT_64(249:252));
fprintf(fid,"short twiddle_ifft64[63*4] = {");
fprintf(fid,"%d,%d,%d,%d,\n",twiddleIFFT_64(1:248));
fprintf(fid,"%d,%d,%d,%d};\n\n",twiddleIFFT_64(249:252));
fclose(fid);
k=0;
for i=0:6,
for n=0:(2^i)-1,
twiddleFFT_128(1+(4*k)) = round(16384*cos(2*pi*n/(2^(i+1))));
twiddleIFFT_128(1+(4*k)) = twiddleFFT_128(1+(4*k));
twiddleFFT_128(2+(4*k)) = round(16384*sin(2*pi*n/(2^(i+1))));
twiddleIFFT_128(2+(4*k)) = -twiddleFFT_128(2+(4*k));
twiddleFFT_128(3+(4*k)) = -twiddleFFT_128(2+(4*k));
twiddleIFFT_128(3+(4*k)) = twiddleFFT_128(2+(4*k));
twiddleFFT_128(4+(4*k)) = twiddleFFT_128(1+(4*k));
twiddleIFFT_128(4+(4*k)) = twiddleFFT_128(1+(4*k));
k=k+1;
end
end
[fid, msg] = fopen("twiddle128.h","w","ieee-le");
fprintf(fid,"short twiddle_fft128[127*4] = {");
fprintf(fid,"%d,%d,%d,%d,\n",twiddleFFT_128(1:504));
fprintf(fid,"%d,%d,%d,%d};\n\n",twiddleFFT_128(505:508));
fprintf(fid,"short twiddle_ifft128[127*4] = {");
fprintf(fid,"%d,%d,%d,%d,\n",twiddleIFFT_128(1:504));
fprintf(fid,"%d,%d,%d,%d};\n\n",twiddleIFFT_128(505:508));
fclose(fid);
k=0;
for i=0:7,
for n=0:(2^i)-1,
twiddleFFT_256(1+(4*k)) = round(16384*cos(2*pi*n/(2^(i+1))));
twiddleIFFT_256(1+(4*k)) = twiddleFFT_256(1+(4*k));
twiddleFFT_256(2+(4*k)) = round(16384*sin(2*pi*n/(2^(i+1))));
twiddleIFFT_256(2+(4*k)) = -twiddleFFT_256(2+(4*k));
twiddleFFT_256(3+(4*k)) = -twiddleFFT_256(2+(4*k));
twiddleIFFT_256(3+(4*k)) = twiddleFFT_256(2+(4*k));
twiddleFFT_256(4+(4*k)) = twiddleFFT_256(1+(4*k));
twiddleIFFT_256(4+(4*k)) = twiddleFFT_256(1+(4*k));
k=k+1;
end
end
[fid, msg] = fopen("twiddle256.h","w","ieee-le");
fprintf(fid,"short twiddle_fft256[255*4] = {");
fprintf(fid,"%d,%d,%d,%d,\n",twiddleFFT_256(1:1016));
fprintf(fid,"%d,%d,%d,%d};\n\n",twiddleFFT_256(1017:1020));
fprintf(fid,"short twiddle_ifft256[255*4] = {");
fprintf(fid,"%d,%d,%d,%d,\n",twiddleIFFT_256(1:1016));
fprintf(fid,"%d,%d,%d,%d};\n\n",twiddleIFFT_256(1017:1020));
fclose(fid)
k=0;
for i=0:8,
for n=0:(2^i)-1,
twiddleFFT_512(1+(4*k)) = round(16384*cos(2*pi*n/(2^(i+1))));
twiddleIFFT_512(1+(4*k)) = twiddleFFT_512(1+(4*k));
twiddleFFT_512(2+(4*k)) = round(16384*sin(2*pi*n/(2^(i+1))));
twiddleIFFT_512(2+(4*k)) = -twiddleFFT_512(2+(4*k));
twiddleFFT_512(3+(4*k)) = -twiddleFFT_512(2+(4*k));
twiddleIFFT_512(3+(4*k)) = twiddleFFT_512(2+(4*k));
twiddleFFT_512(4+(4*k)) = twiddleFFT_512(1+(4*k));
twiddleIFFT_512(4+(4*k)) = twiddleFFT_512(1+(4*k));
k=k+1;
end
end
[fid, msg] = fopen("twiddle512.h","w","ieee-le");
fprintf(fid,"short twiddle_fft512[511*4] = {");
fprintf(fid,"%d,%d,%d,%d,\n",twiddleFFT_512(1:2040));
fprintf(fid,"%d,%d,%d,%d};\n\n",twiddleFFT_512(2041:2044));
fprintf(fid,"short twiddle_ifft512[511*4] = {");
fprintf(fid,"%d,%d,%d,%d,\n",twiddleIFFT_512(1:2040));
fprintf(fid,"%d,%d,%d,%d};\n\n",twiddleIFFT_512(2041:2044));
fclose(fid)
k=0;
for i=0:9,
for n=0:(2^i)-1,
twiddleFFT_1024(1+(4*k)) = fix(16384*cos(2*pi*n/(2^(i+1))));
twiddleIFFT_1024(1+(4*k)) = twiddleFFT_1024(1+(4*k));
twiddleFFT_1024(2+(4*k)) = fix(16384*sin(2*pi*n/(2^(i+1))));
twiddleIFFT_1024(2+(4*k)) = -twiddleFFT_1024(2+(4*k));
twiddleFFT_1024(3+(4*k)) = -twiddleFFT_1024(2+(4*k));
twiddleIFFT_1024(3+(4*k)) = twiddleFFT_1024(2+(4*k));
twiddleFFT_1024(4+(4*k)) = twiddleFFT_1024(1+(4*k));
twiddleIFFT_1024(4+(4*k)) = twiddleFFT_1024(1+(4*k));
k=k+1;
end
end
[fid, msg] = fopen("twiddle1024.h","w","ieee-le");
fprintf(fid,"short twiddle_fft1024[1023*4] = {");
fprintf(fid,"%d,%d,%d,%d,\n",twiddleFFT_1024(1:4088));
fprintf(fid,"%d,%d,%d,%d};\n\n",twiddleFFT_1024(4089:4092));
fprintf(fid,"short twiddle_ifft1024[1023*4] = {");
fprintf(fid,"%d,%d,%d,%d,\n",twiddleIFFT_1024(1:4088));
fprintf(fid,"%d,%d,%d,%d};\n\n",twiddleIFFT_1024(4089:4092));
%fprintf(fid,"unsigned short rev1024[1024];\n")
fclose(fid)
k=0;
for i=0:10,
for n=0:(2^i)-1,
twiddleFFT_2048(1+(4*k)) = fix(16384*cos(2*pi*n/(2^(i+1))));
twiddleIFFT_2048(1+(4*k)) = twiddleFFT_2048(1+(4*k));
twiddleFFT_2048(2+(4*k)) = fix(16384*sin(2*pi*n/(2^(i+1))));
twiddleIFFT_2048(2+(4*k)) = -twiddleFFT_2048(2+(4*k));
twiddleFFT_2048(3+(4*k)) = -twiddleFFT_2048(2+(4*k));
twiddleIFFT_2048(3+(4*k)) = twiddleFFT_2048(2+(4*k));
twiddleFFT_2048(4+(4*k)) = twiddleFFT_2048(1+(4*k));
twiddleIFFT_2048(4+(4*k)) = twiddleFFT_2048(1+(4*k));
k=k+1;
end
end
[fid, msg] = fopen("twiddle2048.h","w","ieee-le");
fprintf(fid,"short twiddle_fft2048[2047*4] = {");
fprintf(fid,"%d,%d,%d,%d,\n",twiddleFFT_2048(1:8184));
fprintf(fid,"%d,%d,%d,%d};\n\n",twiddleFFT_2048(8185:8188));
fprintf(fid,"short twiddle_ifft2048[2047*4] = {");