# US 2024/0134607 A1 · Hardware to perform squaring

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0134607 A1
- Document ID: US20240134607A1
- Status: Published application
- Kind: A1
- Application number: 18/240,387
- Filed: 2023-08-31
- Published: 2024-04-25
- Earliest claimed: 2022-08-31
- Applicants: Imagination Technologies Limited
- Inventors: Max Freiburghaus; William Wheeler; Daniel Ley
- Web page: https://patentgrep.com/patent/US20240134607A1

## CPC

- G06F 7/483: Computations with numbers represented by a non-linear combination of denominational numbers, e.g. rational numbers, logarithmic number system or floating-point numbers {(G06F7/4806, G06F7/4824, G06F7/49, G06F7/491, G06F7/544 take precedence)}
- G06F 7/5525: {Roots or inverse roots of single operands}
- G06F 7/405: {binary}
- G06F 7/544: for evaluating functions by calculation {(G06F7/4824 takes precedence)}
- G06F 2207/5523: Calculates a power, e.g. the square, of a number or a function, e.g. polynomials
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Methods of calculating a square of an input number in hardware logic are described. An m-bit number is received and Booth encoding is performed on different groups of three consecutive bits selected from the input to generate an encoded value for each of the groups. For each group, the method comprises forming a truncated string from the input number, generating an updated version of the truncated number and selecting a bit string based on the encoded value, the selected bit string comprising zeros or a left-shifted version of the updated version of the truncated number sign extended to a bit-width of 2m bits. The method further comprises combining the selected bit strings and square and sign bits for each group into an addition array; and summing the bits in the addition array.

## Claims

### Claim 1

A method of calculating a square of an input number in hardware logic, comprising:
receiving an m-bit number, where m is an even integer;
performing Booth encoding on a plurality of different groups of three consecutive bits selected from the m-bit number to generate an encoded value for each of the groups of bits;
for each group of three consecutive bits:
forming a truncated string from the input number;
generating an updated version of the truncated number using the most significant bit of the group of three consecutive bits; and
selecting a bit string based on the encoded value, the selected bit string comprising zeros or a left-shifted version of the updated version of the truncated number sign extended to a bit-width of 2m bits;
combining the selected bit strings for each of the groups and square and sign bits for each group into an addition array, the square bits for a group comprise two bits set based on the encoded value for the group and the sign bit for a group comprises a bit set based on the three consecutive bits in the group; and
summing the bits in the addition array.

### Claim 2 (depends on 1)

The method according to claim 1, further comprising creating a further string by interleaving square and sign bits for each group and wherein combining the selected bit strings for each of the groups and square and sign bits for each group into the addition array comprises:
combining the selected bit strings for each of the groups and the further string into an addition array.

### Claim 3 (depends on 2)

The method according to claim 2, wherein creating a further string by interleaving the square and sign bits comprises:
setting a least significant bit in the further string equal to a least significant bit in the m-bit number;
setting a bit in bit position one in the further string to zero;
setting a bit in bit position two in the further string to a bit value determined by inverting the least significant bit in the m-bit number and combining the inverted bit with a next least significant bit in the m-bit number in an AND logic element;
setting remaining bits in the further string by interleaving sign and square bits in order of increasing value of i used to generate the encoded value.

### Claim 4 (depends on 1)

The method according to claim 1, wherein the input number is the m-bit number and wherein the input number is a signed number.

### Claim 5 (depends on 1)

The method according to claim 1, wherein the input number is an m−1 bit number and wherein the input number is unsigned and wherein the method further comprises:
generating the m-bit number by prepending a leading zero to the input number.

### Claim 6 (depends on 1)

The method according to claim 1, wherein the input number is an m+1 bit number and wherein the input number is signed and wherein the method further comprises:
generating the m-bit number by removing a least significant bit from the input number;
prior to summing the bits in the addition array, generating an extra string by performing a bitwise AND of the input number without the least significant bit with the replicated removed least significant bit and sign extending to a width of the additional array and adding the extra string to addition array;
and subsequent to summing the bits in the addition array, appending a training zero followed by the removed significant bit.

### Claim 7 (depends on 1)

The method according to claim 1, wherein the input number is the m-bit number and wherein the input number is unsigned and wherein the method further comprises, prior to summing the bits in the addition array, generating an additional string by removing a most significant bit from the input number and appending m+1 trailing zeros and adding the extra string to addition array.

### Claim 8 (depends on 1)

The method according to claim 1, further comprising:
deforming the addition array prior to summing the bits.

### Claim 9 (depends on 8)

The method according to claim 8, wherein deforming the addition array comprises:
inverting a sign bit in each of the left shifted and sign extended truncated strings;
replacing the three least significant sign extended bits with ones; and
replacing any more significant sign extended bits with zeros.

### Claim 10 (depends on 1)

The method according to claim 1, wherein performing Booth encoding on a plurality of different groups of three consecutive bits selected from the m-bit number to generate an encoded value for each of the groups of bits comprises:
for each integer value of i from i=imin to i=(m/2)−1:
selecting a group of three bits in positions 2i+1, 2i and 2i−1 in the m-bit number, wherein a bit in position 0 is a least significant bit and a bit in position m−1 is a most significant bit;
generating an encoded value by Booth encoding the selected group of bits.

### Claim 11 (depends on 10)

The method according to claim 10, wherein forming a truncated string from the input number comprises:
based on the value of i used to generate the encoded value, left-truncating the input number to form a truncated string comprising bits in positions 2i−1 to zero.

### Claim 12 (depends on 10)

The method according to claim 10, wherein generating an updated version of the truncated number using the most significant bit of the group of three consecutive bits comprises:
performing a bitwise XOR of the truncated number with a replicated version of the most significant bit of the group of three consecutive bits.

### Claim 13 (depends on 10)

The method according to claim 10, wherein selecting a bit string based on the encoded value comprises:
if the encoded value is ±2, selecting a bit string comprising the truncated string with the most significant bit of the group appended followed by 2i+1 trailing zeros and sign extended to a bit-width of 2m bits;
if the encoded value is ±1, selecting a bit string comprising the truncated string with 2i+1 trailing zeros appended and sign extended to a bit-width of 2m bits; and
otherwise selecting a bit string comprising all zeros.

### Claim 14 (depends on 10)

The method according to claim 10, wherein imin=1 or imin>1.

### Claim 15 (depends on 1)

The method according to claim 1, further comprising:
right-truncating the addition array prior to summing the bits.

### Claim 16 (depends on 15)

The method according to claim 15, wherein right-truncating the addition array comprises:
truncating all bits to the right of a truncation line; and
adding a constant correction term, wherein the constant correction term has a value that is greater than a maximum possible value of the truncated bits.

### Claim 17 (depends on 1)

A method of calculating a sum of squares in hardware logic, the method comprising:
receiving two or more input floating point numbers, each number comprising an exponent and a mantissa;
for each input floating point number, calculating a square of the mantissa of each input number according to the method as set forth in claim 1; and
summing the calculated squares.

### Claim 18 (depends on 17)

The method according to claim 17, further comprising, prior to summing the calculated squares:
aligning the calculated squares based on the exponents of each of the input floating point numbers; and
adding a final correction term, wherein the final correction term is dependent upon the aligning.

### Claim 19 (depends on 17)

The method according to claim 17, wherein each calculated square comprises a pair of bit strings, the pair of bit strings comprising a string of carry bits for the calculated square and a string of save bits for the calculated square.

### Claim 20 (depends on 1)

Hardware logic configured to perform the method as set forth in claim 1.
