如何转换浮点C code到固定点? [英] How do I convert a floating point C code to fixed point?

查看:234
本文介绍了如何转换浮点C code到固定点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C code,它使用双打。我希望能够运行在一个DSP( TMS320 )在code。但在DSP不支持双打中,仅定点数。什么是对code转换成定点的最好方法?是否有定点数一个很好的C库(作为整数实现)?


解决方案

TI提供了一个名为IQMATH定点库:

<一个href=\"http://focus.ti.com/lit/sw/sprc990/sprc990.pdf\">http://focus.ti.com/lit/sw/sprc990/sprc990.pdf

转换涉及分析当前code - 你需要知道的范围内它可以容纳什么precision它需要每一个变量,。然后你就可以决定哪种类型将其保存英寸IQMath显从Q30提供各类与一系列+/- 2和0.0000000001一个precision到Q1与一系列〜+/- 1万,并拥有precision 0.5。

有关可可能溢出变量的范围内操作,你需要增加检查溢出,并决定如何处理它 - 在最大,店内有不同规模的针呢,引发错误,等等。

实在是没有办法转换为固定点而没有真正的获得过程的数据流的深刻理解。

I have a C code which uses doubles. I want to be able to run the code on a DSP (TMS320). But the DSP doesn't support doubles, only fixed-point numbers. What is the best way to convert the code into fixed-point? Is there a good C library for fixed-point numbers (implemented as integers)?

解决方案

TI provides a fixed-point library called "IQmath":

http://focus.ti.com/lit/sw/sprc990/sprc990.pdf

Converting involves analyzing your current code - for each variable you need to know what range it can hold, and what precision it needs. Then you can decide which type to store it in. IQMath provides types from q30 with a range of +/-2 and a precision of 0.0000000001 to q1 with a range of ~+/- 1 million and a precision of 0.5.

For operations which can possibly overflow the range of the variables, you need to add checks for overflow, and decide how to handle it - pin it at max, store with a different scale, raise an error, etc.

There is really no way to convert to fixed point without really gaining a deep understanding of the dataflow of your process.

这篇关于如何转换浮点C code到固定点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆