ntbchchj 发表于 2010-9-13 19:48:20

求助:SOPC中CPU的硬件浮点单元如何使用

我加了怎么好像没效果,在编软件时要加什么设置么,还是硬件加了就行了?

yuphone 发表于 2010-9-13 21:22:31

我一直想写博文专门论述,无奈最近有点忙。都是大白话,我就不翻译了。

介绍:http://www.altera.com.cn/literature/hb/nios2/n2cpu_nii51002.pdf P5~6
通过自定义指令来实现硬件单精度乘除法,双精度的只能用软件实现。
./bbs_upload/files_33/ourdev_582773V4441T.png

You can add floating-point custom instructions to any Nios II processor core
using the Nios II Processor MegaWizard? interface. The loating-point division
hardware requires more resources than the other instructions. The MegaWizard
interface allows you to omit the floating-point division hardware for cases
in which code running on your hardware design does not make heavy use of
floating-point division. When you omit the floating-point divide instruction,
the Nios II compiler implements floating-point division in software.

All the floating-point custom instructions are single-precision operations.
Double-precision operations are implemented in software. By default, the Nios
II compiler treats floating-point constants as double-precision numbers.
To use the floating-point custom instructions for operations with floating-point
constants, append an “f” to the constant. This tells the compiler to treat
the constant as a single-precision floating-point value, rather than promote
the other variables in your equation to double precision numbers. Table 2–3
shows code examples using constants.
./bbs_upload/files_33/ourdev_582774A05YDV.png


使用:http://www.altera.com.cn/literature/hb/nios2/n2cpu_nii51004.pdf P17~18
默认情况下单精度的除法不打开。

资源消耗:Nios/f开单精度乘法(EP2C8)大约消耗接近6000的LEs;Nios/f开单精度乘除法(EP2C8)大约消耗9000多LEs;而不开单精度乘除法的Nios/f仅需4000左右的LEs。

akuei2 发表于 2010-9-13 21:51:28

( ⊙ o ⊙ )啊!出现了!
怎么换马甲了

ntbchchj 发表于 2010-9-14 10:33:05

回复【1楼】yuphone .COM 缺氧®
-----------------------------------------------------------------------

果然是浮点数精度的问题,我全部搞成单精度就行了。谢谢。。。。
页: [1]
查看完整版本: 求助:SOPC中CPU的硬件浮点单元如何使用