Can I use Simulink fixed-point advisor to translate C code ( with float variable ) to fixed-point code ( only integers ) ??
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
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.
Réponses (1)
Geoff
le 3 Avr 2012
0 votes
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 commentaires
Ramzi Abdelmoula
le 3 Avr 2012
Geoff
le 3 Avr 2012
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?
Geoff
le 3 Avr 2012
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.
Kaustubha Govind
le 6 Avr 2012
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.
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!