NFFT = 1024;

twiddle = zeros(1, NFFT/8);
for mm = 1:1:NFFT/8
    theta = (-2*pi*mm*1/NFFT);
    twiddle(mm) = cos(theta) + (1i*(sin(theta)));
end
twiddle = floor(twiddle*0.99997*2^15);

win = chebwin(NFFT,100);
win = round(reshape(win, 1, []) *0.99998*2^15);

fs = 20.e6;
delt_f = fs/NFFT;
f1 = 10* delt_f;

S = cos(2*pi*f1*[0:NFFT-1]/fs + (rand * 2 *pi)) * (0.25);

S = round(S * 2^11);
S = S .* 2^2;

switch_spt(20);
win_out = win_mex(complex(win),complex(S),'MULTIPLE_COEFF',0);
Stage_0 = rdx4_mex(complex(win), complex(win_out),'WIN_DISABLED','MULTIPLE_COEFF',0,'QUAD_EXT','NO_COMBINED_FFT',0);
Stage_1 = rdx4_mex(twiddle, Stage_0,'WIN_DISABLED','MULTIPLE_COEFF',1,'QUAD_EXT','NO_COMBINED_FFT',0);
Stage_2 = rdx4_mex(twiddle, Stage_1,'WIN_DISABLED','MULTIPLE_COEFF',2,'QUAD_EXT','NO_COMBINED_FFT',0);
Stage_3 = rdx4_mex(twiddle, Stage_2,'WIN_DISABLED','MULTIPLE_COEFF',3,'QUAD_EXT','NO_COMBINED_FFT',0);
Stage_4 = rdx4_mex(twiddle, Stage_3,'WIN_DISABLED','MULTIPLE_COEFF',4,'QUAD_EXT','NO_COMBINED_FFT',0);
