Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
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.

Antworten (1)

Geoff
Geoff am 3 Apr. 2012
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 Kommentare
Geoff
Geoff am 3 Apr. 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
Kaustubha Govind am 6 Apr. 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.

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by