Tuesday, November 24, 2026SubscribeMastheadAbout
Cali ReporterCalifornia · National · West Coast · Good News

Advertisement

Technology

IEEE VHDL Floating-Point Package Contains Rounding Errors

The IEEE 1076-2008 and 1076-2019 VHDL floating-point package has been found to contain rounding errors in several operations, according to a detailed audit. These errors affect multiple functions and formats, including…

Portrait of Benjamin Boyce
Artificial Intelligence & Technology · November 23, 2026
Share

AI-generated editorial illustration from an imagined camera angle.
AI-generated editorial illustration from an imagined camera angle. Source image: github.com.

The IEEE 1076 float package, as implemented in GHDL and NVC, exhibits rounding errors in several operations, including square root and multiply-accumulate (mac). For instance, the sqrt(2.0) function returns a value that is one unit in the last place too low in double precision by default. This issue arises because the package uses a fixed number of Newton steps and lacks a sticky bit, leading to inaccuracies in the rounding process. The testbench and reference code provided in the IEEE's repository show that 1,271,619 out of 8,692,326 calls in a 7-bit format are not correctly rounded. These errors are consistent across multiple implementations, including GHDL and NVC, which produce identical result files when running the same test vectors. [1]

The mac operation also demonstrates significant errors, with 2,671 out of 10,000 calls in float32 format returning incorrect results in the round_nearest style. The package's implementation of the mac function truncates the product to the width of one operand before adding the third operand, leading to inaccuracies in cases where the product and third operand have the same exponent and unlike signs. For example, mac(-6.0, -1.0, -5.0) returns -15.0 instead of the correct value of 1.0. These errors are further compounded in resize operations, where converting from float64 to float32 results in incorrect infinity or zero values for certain powers of two, such as 2^-512, which returns 1.0 instead of the correct value. [1]

The package's implementation also suffers from issues in division and reciprocal operations. For example, the reciprocal of 2^127 in single precision returns infinity instead of the correct value. Similarly, the divide operation in float32 format has 27 out of 10,000 calls returning incorrect results in the round_nearest style. These errors are attributed to the lack of a sticky bit in the division function, which leads to incorrect rounding of exact ties. The IEEE's testbench and reference code demonstrate that these issues are consistent across multiple implementations and are not limited to specific tools or versions of the package. [1]

The IEEE 1076 float package, specifically the ieee.float_pkg, is implemented in VHDL as defined by IEEE Std 1076-2008 and 1076-2019. The package is sourced from the IEEE's official repository, located at ieee/float_generic_pkg-body.vhdl on the release branch of opensource.ieee.org/vasg/Packages, with a revision number of 1220 and a file size of 5,712 lines. The same file is mirrored in the IEEE P1076 working group's develop branch on gitlab.com/IEEE-P1076/Packages. Both GHDL and NVC use the unchanged version of this file in their implementations. The package is used for floating-point arithmetic in VHDL and includes functions such as sqrt, mac, resize, and others. The source file is part of the IEEE's effort to standardize floating-point operations in hardware description languages, and it is widely adopted by simulators like GHDL and NVC. [1]

Advertisement

The package's implementation has documented limits and scope. For instance, the sqrt function in the float_pkg has been found to return one unit in the last place too low in double precision by default. This issue was identified through extensive testing using a testbench and reference implementation provided in the folder of the source. The testing involved 8,692,326 calls for a 7-bit format (3 exponent bits, 3 fraction bits) and found 1,271,619 incorrect results. The testing was conducted using GHDL and NVC, which produced identical result files for common test sets, confirming the consistency of the errors across different simulators. The package's limitations are further evident in functions like mac, which returns incorrect results for certain inputs, such as mac(-6, -1, -5) returning -15 instead of 1. These issues highlight the need for a patch to the package to ensure correct rounding and precision in floating-point operations. [1]

The package's testing and verification procedures are well-documented. For example, the exact.py script is used as a reference to compare the results of the package's functions with the expected exact results. The testing involved 10,000 calls per operation, format, and rounding style, focusing on operands that challenge arithmetic, such as denormal operands and results, both ends of the exponent range, and fractions that round up into the next binade. The results are summarized in tables that show the number of incorrect results for each function and rounding style. For example, in float32, the add function had 0 incorrect results in 10,000 calls with round_nearest, but 304 incorrect results with round_zero. Similar data is provided for float64 and other formats, showing the extent of the errors in different rounding styles and operations. These tests were conducted using GHDL and NVC, ensuring that the results are consistent across different simulators. [1]

The package's implementation includes several functions that have been identified as problematic. For example, the resize function in the package has been found to return incorrect results for certain inputs. For instance, converting 2^-512 double to single returns 1.0, and the reciprocal of 2^127 in single returns infinity. These issues are further compounded by the fact that resize from float64 to float32 returns +infinity for every power of two from 2^-1074 to 2^-1024 and stops the simulator from 2^-662 to 2^-639. The resize function's behavior is particularly problematic in the context of denormal numbers and when resizing to narrower formats, where the exponent is cut to two bits more than the target's width, leading to incorrect results. These issues have been documented in the source and are addressed in the patch provided. [1]

The patch for the IEEE 1076 float package, float_generic_pkg-body.patch, is applied to the IEEE file and modifies the package body only, with 33 hunks of changes. The patch addresses several issues, including the incorrect rounding in functions such as sqrt, mac, and resize. The patch modifies the normalize function to decide between zero, denormal, normal, and infinity based on the exponent at its full width, ensuring that the correct number is returned according to the rounding style. The divide and reciprocal functions are also modified to take the sticky bit from the remainder of the division, ensuring that the correct rounding is applied. The sqrt function is modified to take the integer square root of the significand one bit per step, with the remainder as the sticky bit. These changes ensure that the package's functions produce the correct results for a wide range of inputs and rounding styles. [1]

Advertisement

Sources

HN (Official)

Prepared with AI assistance from the cited sources.

The Cali Reporter newsletter

The stories worth your time.

California, the country, and what comes next. Join our free newsletter for reporting that keeps you informed.

By joining, you agree to receive the Cali Reporter newsletter. Unsubscribe at any time. Privacy policy.

More in Technology

  • Modern Web Guidance 1.0 and Browser Compatibility

    Modern Web Guidance 1.0, announced by Chrome for Developers on November 10, introduces browser compatibility data to assist coding agents in building web features. The initiative emphasizes the importance of fallback…

  • Apache mod_http2 Vulnerability Detection with Nmap

    A new Nmap scripting module has been developed to detect the Apache mod_http2 vulnerability (CVE-2026-119618), addressing the challenges of identifying affected systems accurately.

  • Securing Remote Vendor Access in Industrial Networks

    Best practices for managing remote vendor access in operational technology (OT) networks emphasize controlled access points, multifactor authentication, and time-bound sessions to reduce cybersecurity risks.

Advertisement