Error: A cast between fixpt and floating point type is not supported
이전 댓글 표시
I am trying to convert my matlab code to HDL verilog code by HDL Coder. Fixed-Point Conversion shows no Error,but at the time HDL code Generation it show error that
" ErrorA cast between fixpt and floating point type is not supported, at Function 'cameraman_dwt_code1_fixpt' (#1.874.875), line 21, column 12."
My Fixed-Point Arithmatic code is-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Generated by MATLAB 9.2 and Fixed-Point Designer 5.4 %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%#codegen
function xavg12 = cameraman_dwt_code1_fixpt(xr1)
fm = get_fimath();
[fmo_1,fmo_2,fmo_3,fmo_4] = dwt2(xr1,'db3');
xavg = fi(fmo_1, 0, 14, 5, fm);
xhr = fi(fmo_2, 1, 14, 43, fm);
xvr = fi(fmo_3, 1, 14, 43, fm);
xdig = fi(fmo_4, 0, 14, 83, fm);
x1=fi(xavg(1,1), 0, 14, 5, fm); %#This line creates error at xavg(1,1) section(above mentiond on error- line21,coloumn 12)
xavg12=fi(x1, 0, 14, 5, fm);
end
function fm = get_fimath()
fm = fimath('RoundingMethod', 'Floor',...
'OverflowAction', 'Wrap',...
'ProductMode','FullPrecision',...
'MaxProductWordLength', 128,...
'SumMode','FullPrecision',...
'MaxSumWordLength', 128);
end
####################### My function is->
function xavg12 = cameraman_dwt_code1(xr1)
[xavg,xhr,xvr,xdig] = dwt2(xr1,'db3');
x1=xavg(1,1);
xavg12=x1;
####################### My TestBench code is->
x=158;
xavg11=cameraman_dwt_code1(x);
disp(xavg11);
############# It is actually for an Image processing code but I want to test it only for a single pixel value.
Overall code output is 1.2392 for pixel or input value 158 which is acurate but still I can not solved the Fixed-Point Arithmatic code.
Please Help me.Thank you

댓글 수: 4
Walter Roberson
2019년 12월 21일
That is odd, column 12 appears to be the indexing.
Hmmm, if dwt2 is generating floating point then after indexing xavg(1,1) would be floating point, and perhaps the error is about casting between that floating point and fixed point?
Sandip Paul
2019년 12월 21일
Walter Roberson
2019년 12월 21일
I have not used the Fixed Point toolbox, only read a little about it.
At the moment I am concerned that possibly dwt2() is not being transformed to fixed point.
I wonder if it would help to switch to an integer wavelet? https://www.mathworks.com/help/wavelet/ug/lifting-method-for-constructing-wavelets.html#bs9j3kj
Sandip Paul
2019년 12월 21일
채택된 답변
추가 답변 (2개)
Kiran Kintali
2019년 12월 26일
1 개 추천
Hi Sandip,
Since dwt2 is not supported out of the box, please consider using core MATLAB to HDL features and implement dwt2_fpga.m using first principles. There is lot of material on the web related to this topic. https://tinyurl.com/s8flm5j
The previously mentioned links show you how to write good MATLAB suitable for HDL code generation.
Thanks
Sandip Paul
2019년 12월 23일
편집: Sandip Paul
2019년 12월 23일
0 개 추천
카테고리
도움말 센터 및 File Exchange에서 HDL Coder에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!