IEEE Std 1076 标准中的 ieee.float_pkg 浮点数包被发现在算术精度上存在严重缺陷,该问题同时影响 IEEE Std 1076-2008 和 1076-2019 版本 1。在 GHDL 和 NVC 等主流仿真器中运行测试显示,该包的 sqrt、mac、divide 等多个核心函数在处理非规格化数、舍入模式及特定操作时产生大量错误结果或导致仿真器崩溃 1。具体错误案例显示,sqrt(2.0) 在 float64 格式下返回的十六进制值为 3FF6A09E667F3BCC,而正确值应为 3FF6A09E667F3BCD;另一例中,mac(-6.0, -1.0, -5.0) 的计算结果为 -15.0,与正确值 1.0 不符 1。
此次技术分析揭示了显著的错误频率:在 float32 模式下,859,771 次调用中有 81,068 次出错;而在 float64 模式下,857,234 次调用中有 86,081 次出现错误 1。部分操作如将小数值调整至窄格式(resize)时,还会引发模拟器停止运行,例如 GHDL 在第 358 行因索引越界而崩溃 1。经分析,根本原因涉及 normalize 函数的指数截断逻辑错误、除法/倒数缺乏正确的粘性位处理、平方根牛顿迭代法步数不足以及 MAC 指令未执行融合乘加导致的中间舍入错误等 1。
作者已提供详细的补丁方案以解决上述问题,经验证应用 float_generic_pkg-body.patch 后,数百万次测试调用的错误率降为 0 1。2026年11月13日,相关报告已正式提交给 IEEE P1076 工作组(Issue #388)以及 GHDL(#3486)、NVC(#1758)和 FPHDL(#4)等项目 1。
A technical analysis has identified critical arithmetic precision defects within the floating-point package of the IEEE VHDL standard, specifically affecting ieee.float_pkg in versions Std 1076-2008 and 1076-2019 1. Testing conducted using mainstream simulators such as GHDL and NVC revealed that core functions including sqrt, mac, and divide produce erroneous results or cause simulator crashes when handling denormalized numbers, specific rounding modes, and particular operations 1. A notable example demonstrates that calculating the square root of 2.0 in float64 format returns an incorrect hexadecimal value (3FF6A09E667F3BCC) instead of the correct result (3FF6A09E667F3BCD), while a multiply-add operation with inputs -6.0, -1.0, and -5.0 yields -15.0 rather than the expected 1.0 1.
The error rates observed during extensive testing are significant, with 81,068 failures out of 859,771 calls in float32 and 86,081 errors out of 857,234 calls in float64 1. Some operations, such as resizing small values to narrower formats, trigger index-out-of-bounds errors that halt simulation processes; for instance, GHDL encountered a crash at line 358 due to this logic failure 1. The underlying causes were traced to several implementation flaws, including exponential truncation errors in the normalize function, missing sticky bit handling in division and reciprocal calculations, insufficient iterations in the Newton-Raphson method for square roots, and the lack of fused multiply-add execution in MAC instructions which leads to intermediate rounding errors 1.
To address these issues, the author developed and verified a patch file named float_generic_pkg-body.patch, which reduced the error rate to zero across millions of test calls 1. On November 13, 2026, reports detailing these bugs and solutions were formally submitted to the IEEE P1076 Working Group (Issue #388), as well as open-source projects GHDL (#3486), NVC (#1758), and FPHDL (#4) 1.
评论
还没有评论,欢迎留下第一条。