Fixed point to float point conversion of 16 point ifft

1 次查看(过去 30 天)
A 16 point ifft Embedded matlab code is to be converted from floating point to fix point for cosimualtion of on FPGA. as is given below in snapshot. Input from Qam16 is -3,-1,0,1,3, real and imaginary.Which i have converted to int16 .Now in Embedded matlab all variables are specified for fixed-point operation using "mathfi" as given in code.But the resultant appearing after is unexpected as highlighted in snapshot.Resultant is only fractional part and very minimum.
Kindly help me solve this issue.
Embedded matlab code is also given below.
function [W,T] = iffxxtt(x,y)
%#eml
X = getfi(.0625,1, 16, 16);
C = getfi(.7071,1, 16, 16);
D = getfi(.9239,1, 16, 16);
E = getfi(.3827,1, 16, 16);
first=getfi([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0],1, 16,16);
ifirst=getfi([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0],1, 16, 16);
first1=getfi([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0],1,16, 16);
ifirst1=getfi([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0],1, 16, 16);
first2=getfi([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0],1, 16, 16);
ifirst2=getfi([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0],1, 16, 16);
first3=getfi([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0],1, 16, 16);
ifirst3=getfi([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0],1, 16, 16);
Ar=getfi([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0],1, 16, 16);
Ai=getfi([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0],1, 16,16);
Ar=x;
Ai=y;
for i=1:8
first(i)=Ar(i)+Ar(i+8);
ifirst(i)=Ai(i)+Ai(i+8);
first(i+8)=Ar(i) - Ar(i+8);
ifirst(i+8)=Ai(i) - Ai(i+8);
end
Ar1=first;
Ai1=ifirst;
for i=1:4
first1(i)=Ar1(i)+Ar1(i+4);
ifirst1(i)=Ai1(i)+Ai1(i+4);
first1(i+4)= Ar1(i)-Ar1(4+i);
ifirst1(i+4)=Ai1(i)-Ai1(4+i);
end
for i=9:12
first1(i)=(Ar1(i)-Ai1(i+4));
ifirst1(i)=(Ai1(i)+Ar1(i+4));
first1(i+4)=(Ai1(4+i) + Ar1(i));
ifirst1(i+4)=(-Ar1(4+i) + Ai1(i));
end
Ar2=first1;
Ai2=ifirst1;
for i=1:2
first2(i)=Ar2(i)+Ar2(i+2);
ifirst2(i)=Ai2(i)+Ai2(i+2);
first2(i+2)= Ar2(i)-Ar2(2+i);
ifirst2(i+2)=Ai2(i)-Ai2(2+i);
first2(i+4)=-(-Ar2(i+4)+Ai2(i+6));
ifirst2(i+4)=Ai2(i+4)+Ar2(i+6);
first2(i+6)=(Ai2(6+i) + Ar2(i+4));
ifirst2(i+6)=-Ar2(6+i) + Ai2(i+4);
end
for i=9:10
first2(i)=Ar2(i)+C*Ar2(i+2)-C*Ai2(i+2);
ifirst2(i)=(Ai2(i)+C*Ar2(i+2)+C*Ai2(i+2));
first2(i+2)=Ar2(i)-C*Ar2(i+2)+C*Ai2(i+2);
ifirst2(i+2)=(Ai2(i)-C*Ar2(i+2)-C*Ai2(i+2));
end
for i=13:14
first2(i)=Ar2(i)-C*Ar2(i+2)-C*Ai2(i+2);
ifirst2(i)=Ai2(i)+C*Ar2(i+2)-C*Ai2(i+2);
first2(i+2)=Ar2(i)+C*Ar2(i+2)+C*Ai2(i+2);
ifirst2(i+2)=Ai2(i)-C*Ar2(i+2)+C*Ai2(i+2);
end
Ar3=first2;
Ai3=ifirst2;
i=1;
first3(i)=Ar3(i)+Ar3(i+1);
ifirst3(i)=Ai3(i)+Ai3(i+1);
first3(i+1)= Ar3(i)-Ar3(1+i);
ifirst3(i+1)=Ai3(i)-Ai3(1+i);
first3(i+2)=-(-Ar3(i+2)+Ai3(i+3));
ifirst3(i+2)=Ai3(i+2)+Ar3(i+3);
first3(i+3)=(Ai3(3+i) + Ar3(i+2));
ifirst3(i+3)=-Ar3(3+i) + Ai3(i+2);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Ar3(i+7)+D*Ai3(i+7);
W = [first3(1);first3(16);first3(8);first3(12);first3(4);first3(14);first3(6);first3(10);first3(2);first3(15);first3(7);first3(11);first3(3);first3(13);first3(5);first3(9);]*X;
T = [ifirst3(1);ifirst3(16);ifirst3(8);ifirst3(12);ifirst3(4);ifirst3(14);ifirst3(6);ifirst3(10);ifirst3(2);ifirst3(15);ifirst3(7);ifirst3(11);ifirst3(3);ifirst3(13);ifirst3(5);ifirst3(9);]*X;
end
function myfi = getfi(input, issigned, wlen, flen)
fm = fimath('RoundMode', 'Nearest', ...
'OverflowMode', 'Saturate', ...
'ProductMode', 'FullPrecision', ...
'MaxProductWordLength', 128, ...
'SumMode', 'FullPrecision', ...
'MaxSumWordLength', 128, ...
'CastBeforeSum', true);
myfi = fi(input, issigned, wlen, flen, 'fimath', fm);
end

回答(1 个)

Kiran Kintali
Kiran Kintali 2020-11-1
See attached example for additional modeling guidelines for MATLAB to HDL.

类别

Help CenterFile Exchange 中查找有关 FPGA, ASIC, and SoC Development 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by