Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
Ramzi Abdelmoula
Ramzi Abdelmoula 2012 年 4 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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.

回答 (1 件)

Geoff
Geoff 2012 年 4 月 3 日
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 件のコメント
Geoff
Geoff 2012 年 4 月 3 日
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 2012 年 4 月 6 日
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.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by