Error: Cast between fixpt and floating point type is not supported
5 views (last 30 days)
Show older comments
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);
0 Comments
Accepted Answer
Tim McBrayer
on 19 Jun 2015
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 Comments
Walter Roberson
on 26 Jun 2015
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
on 27 Jun 2015
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.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!