Info
This question is closed. Reopen it to edit or answer.
Can I use Simulink fixed-point advisor to translate C code ( with float variable ) to fixed-point code ( only integers ) ??
1 view (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Geoff
on 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 Comments
Geoff
on 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
on 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.
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!