Can I use Simulink fixed-point advisor to translate C code ( with float variable ) to fixed-point code ( only integers ) ??

Hi everyone,
I have a program written in C code that uses Floats and I'm asked to import it on a fixed-point ARM9 board without simulating (software simulation) the floating-point part, so I have to rewrite it using only integers, I was wondering if Simulink fixed-point advisor can help me with that process? if not is there a tool that does the conversion automatically?
And thanks in advance.

Respuestas (1)

Are you supposed to use MatLab for this? Fixed-point in C is not hard. You just exploit bit-shifting, which is built into the language. There ought to be a ton of information on the web about fixed-point operations in C. What arithmetic operations do you need to perform?

4 comentarios

I'm not supposed to use Matlab, but if it helps me convert the C code which is pretty complex and long ( voice recognition related).
And what I'm exactly looking for is an automatic tool or software that does that, at least semi-automatic because it will take me forever to do it manually,
And Thanks again
Oh, I thought you meant you had a C program that used floating point and you wanted to convert it into a C program using fixed point that would then be compiled for the target architecture. What language are you trying to convert it to?
If you have a C++ compiler for your architecture, have a look at this class:
http://www.codeproject.com/Articles/37636/Fixed-Point-Class
You could probably do a global replace-all on 'float' using that class, and the operator overloading should take care of the rest. It would be a start anyway. There are probably many other classes people have written to do this if you don't like Boost.
Just as a clarification, the Simulink Fixed-Point Advisor only helps you convert Simulink models with floating-point types into fixed-point types. In particular, it helps you pick the right word-length and scaling so as to not compromise the accuracy of your algorithm. It cannot work directly with C-code - your algorithm has to be implemented with Simulink blocks.

La pregunta está cerrada.

Preguntada:

el 3 de Abr. de 2012

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by