问题描述
我想近似使用 e 函数.
I'd like to approximate the e function.
是否可以使用基于多个样条线类型的方法来做到这一点?即在 x 和 x 之间,然后
Is it possible to do so using multiple splines type based approach? i.e between x and x, then
然后
等
这是专用于fpga硬件,而不是通用CPU.因此,我需要自己创建函数.精度问题不那么重要了.此外,我真的负担不起一个以上的乘法电路和/或多个移位/加法器.我还想要比CORDIC函数小的东西,但实际上尺寸至关重要.
This is for dedicated fpga hardware and not a general purpose CPU. As such I need to create the function myself. Accuracy is much less of a concern. Furthermore I can't really afford more than one multiplication circuit and/or multiple shifts/adders. Also I want something much smaller than a CORDIC function, in fact size is critical.
推荐答案
这样的使用公式的策略怎么样
How about a strategy like this that uses the formula
- 预先计算
1/ln(2)
- 将此常数乘以您的参数(1乘)
- 使用二进制移位将2提高到幂的整数部分(假设exp +尾数格式)
- 根据2的幂的余数(可能是第二个乘法)进行调整
- Precalculate
1/ln(2)
- Multiply this constant by your argument (1 multiplication)
- Use binary shifts to raise 2 to the integer portion of the power (assumes exp+mantissa format)
- Adjust based on the fractional power-of-2 remainder (likely a second multiplication)
我意识到这不是一个完整的解决方案,但是它只需要一个乘法就可以解决,剩下的问题可以简化为2的小数次幂,应该在硬件中更容易实现.
I realize this is not a complete solution, but it does only require a single multiplication and reduces the remaining problem to approximating a fractional power of 2, which should be easier to implement in hardware.
此外,如果您的应用程序具有足够的专业性,则可以尝试重新推导将在硬件上运行的所有数字代码,以将它们存储在基数 e 系统中,并实现浮动点硬件也可以在基本 e 中工作.那么根本就不需要转换.
Also, if your application is specialized enough, you could try to re-derive all of the numerical code that will run on your hardware to be in a base-e number system and implement your floating point hardware to work in base e as well. Then no conversion is needed at all.
这篇关于近似e ^ x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!