Hardware efficient rounding
AssigneeImagination Technologies Limited
InventorsRostam King, Simon Fenney
Life of this patent
Estimating the term…
Abstract
A binary logic circuit and method for rounding an unsigned normalised n-bit binary number to an m-bit binary number. A correction value of length of n bits and a pre-truncation value of length of n bits are determined. The correction value is determined by shifting the n-bit number by m bits. The pre-truncation value is determined based on at least the n-bit number, the correction value, a value for the most significant bit (MSB) of the n-bit number, and a rounding value having a ‘1’ at the n−mth bit position and a ‘0’ at all other bits. The rounded m-bit number is then obtained by truncating the n−m least significant bits (LSB) of the pre-truncation value.
Claims20
A computer-implemented method of rounding an unsigned normalised n-bit number to an m-bit number, the method comprising:
- receiving the n-bit number in a binary format;
- determining a correction value having a bit length of n bits, wherein determining the correction value comprises shifting the n-bit number by m bits;
- determining a pre-truncation value having a bit length of n bits based on at least the n-bit number, the correction value, a value for the most significant bit (MSB) of the n-bit number, and a rounding value having a ‘1’ at the n−mth bit position and a ‘0’ at all other bits;
- and
- obtaining the rounded m-bit number by truncating the n−m least significant bits (LSB) of the pre-truncation value.
A binary logic circuit for rounding an unsigned normalised n-bit number to an m-bit number, the binary logic circuit comprising:
- an input configured to receive the n-bit number;
- correction value logic configured to generate a correction value having a bit length of n bits, the logic comprising a shifter for shifting the n-bit number by m bits;
- MSB value logic configured to determine the MSB value of the n-bit number;
- pre-truncation value logic configured to determine a pre-truncation value having a bit length of n bits based on at least the n-bit number, the correction value, the MSB value of the received number, and a rounding value having a ‘1’ at the n−mth bit position and a ‘0’ at all other bits;
- truncation logic configured to truncate the pre-truncation value by discarding the n−m LSB bits to obtain a rounded m-bit number;
- and
- an output configured to output the rounded m-bit number.
Dependencies are inferred from the claim text.