How to use extended word length and fraction in HDLFFT?

Hi
When I extend word and fraction length by using sfi(ddc_out,50,30) from sfi(ddc_out,32,24).
But I've got the below error messages during run the below code
[Yf(loop),validOut(loop)] = HDLFFT8(complex(y_fixed(i)),(loop <= N));
What am I supposed to do to resolve this problem?
close all
N = 8;
y_fixed = sfi(ddc_out,50,30);
Yf = zeros(1,3*N);
validOut = false(1,3*N);
for loop = 1:1:3*N
if (mod(loop, N) == 0)
i = N;
else
i = mod(loop, N);
end
[Yf(loop),validOut(loop)] = HDLFFT8(complex(y_fixed(i)),(loop <= N));
end
%%code
function [yOut,validOut] = HDLFFT8(yIn,validIn)
%HDLFFT8
% Processes one sample of FFT data using the dsp.HDLFFT System object(TM)
% yIn is a fixed-point scalar or column vector.
% validIn is a logical scalar value.
% You can generate HDL code from this function.
persistent fft8;
if isempty(fft8)
fft8 = dsp.HDLFFT('FFTLength',8);
end
[yOut,validOut] = fft8(yIn,validIn);
end
*Error using dsp.HDLFFT/parenReference
Changing the data type on input 1 is not allowed without first calling the release() method.
Error in HDLFFT8 (line 12)
[yOut,validOut] = fft8(yIn,validIn);
Error in AD9467_Cal_171219 (line 151)
[Yf(loop),validOut(loop)] = HDLFFT8(complex(y_fixed(i)),(loop <= N));
>>

Antworten (1)

Satish,
I am not able to reproduce the error. Here is my code.
close all
N = 8;
ddc_out = randi([0 1],8,1);
y_fixed = sfi(ddc_out,50,30);
Yf = zeros(1,3*N);
validOut = false(1,3*N);
for loop = 1:1:3*N
if (mod(loop, N) == 0)
i = N;
else
i = mod(loop, N);
end
[Yf(loop),validOut(loop)] = HDLFFT8(complex(y_fixed(i)),(loop <= N));
end
disp('Output of FFT: ');
Yf(validOut)
HDLFFT8.m:
function [yOut,validOut] = HDLFFT8(yIn,validIn)
%HDLFFT8
% Processes one sample of FFT data using the dsp.HDLFFT System object(TM)
% yIn is a fixed-point scalar or column vector.
% validIn is a logical scalar value.
% You can generate HDL code from this function.
persistent fft8;
if isempty(fft8)
fft8 = dsp.HDLFFT('FFTLength',8);
end
[yOut,validOut] = fft8(complex(yIn),validIn);
end
Bharath

3 Kommentare

Dear Bharath,
Would you please help me how to get the verification values correctly?
I've succeeded with as your recommends, I came across all zero value as the below. but when I use hdlcoder with HDLFFT8.m .
ans =
1×0 empty double row vector
close all
clear
clc
N = 8;
ddc_out = [43.1071670298783 + 6.93920051078942i,196.370439792336 + 72.8360842474480i,45.0743298749615 + 68.5707875747732i,-253.063222261192 + 131.949254363931i,3287.75721314405 + 496.424894456540i,10796.7475951656 + 4062.11599418717i,7668.00136364171 + 7105.42396362013i,5142.92229218845 + 9422.14012629434i];
y_fixed = sfi(ddc_out,50,30);
Yf = zeros(1,3*N);
validOut = false(1,3*N);
ddcout = zeros(1,3*N);
for loop = 1:1:3*N
if (mod(loop, N) == 0)
i = N;
else
i = mod(loop, N);
end
[Yf(loop),validOut(loop)] = HDLFFT8(complex(y_fixed(i)),(loop <= N));
disp('test1 : Output of FFT: ');
Yf(loop)
end
disp('test2 : Output of FFT: ');
Yf(validOut)
By the way, you can simplify
if (mod(loop, N) == 0)
i = N;
else
i = mod(loop, N);
end
as
i = mod(loop-1, N) + 1;
Since you are already using fixed-point types, in Step 1 of Fixed point conversion, I suggest that you skip the conversion and use the datatypes as is.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by