필터 지우기
필터 지우기

Error: Cast between fixpt and floating point type is not supported

조회 수: 6 (최근 30일)
Tamer
Tamer 2015년 6월 19일
댓글: Walter Roberson 2015년 6월 27일
Hi there,
I'm working at a very long program, and I got the following error. The program successfully passed the fixed point conversion, but still I got the following while I converting it to HDL code.
"Error: Cast between fixpt and floating point type is not supported "
I got this error either if used the following 2 orders.
Matlab M-Code:
x= zeros(1,1000000);
Y=X;
or
Y=fi(double(x),true,16,16);

채택된 답변

Tim McBrayer
Tim McBrayer 2015년 6월 19일
HDL Coder does not support conversion between double/single (IEEE-754) values and any other types. You do not want doubles in your HDL code as they are not synthesizable in general.
The first line could be easily rewritten as (for example: choose your desired data type):
x = int8(zeros(1,1000000));
For your second example, what is the purpose of explicitly casting x to double? If x is not double at that point, there should be no reason to explicitly cast it to double, whether HDL Coder is involved or not.
  댓글 수: 3
Walter Roberson
Walter Roberson 2015년 6월 26일
You should be converting all of that code to use fixed point. All of it.
The amount of space on a chip needed to hold a floating point core to do double precision operations is very high. It can be done, but it should be a very deliberate design decision, and you would probably want to implement it as a custom numeric class so that you could track exactly which floating point operations you needed and leave the rest out. For example if your code doesn't ever use exp() and log() then you would leave those unimplemented so as to not waste space. Part of the custom numeric class would be constructors to convert from fixed point, and an extension of the fixed-point constructor to convert from your custom floating point.
Walter Roberson
Walter Roberson 2015년 6월 27일
Instead of
x = int8(zeros(1,1000000));
You could more directly
x = zeros(1,1000000, 'uint8');
Basically everywhere in your program that you use zeros() or ones() you should explicitly type the result. You might want to build a string that has the type name to make it easier to be consistent.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by