# US 2025/0156152 A1 · Performing Constant Modulo Arithmetic

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

- Number: US 2025/0156152 A1
- Document ID: US20250156152A1
- Status: Published application
- Kind: A1
- Application number: 19/022,956
- Filed: 2025-01-15
- Published: 2025-05-15
- Earliest claimed: 2015-05-08
- Assignees: Imagination Technologies Limited
- Applicants: Imagination Technologies Limited
- Inventors: Thomas Rose
- Web page: https://patentgrep.com/patent/US20250156152A1

## CPC

- G06F 7/72: using residue arithmetic
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A binary logic circuit for determining y=x mod (2m−1), where x is an n-bit integer, y is an m-bit integer, and n>m, includes reduction logic configured to reduce x to a sum of a first m-bit integer β and a second m-bit integer γ; and addition logic configured to calculate an addition output represented by the m least significant bits of the following sum right-shifted by m: a first binary value of length 2m, the m most significant bits and the m least significant bits each being the string of bit values represented by β; a second binary value of length 2m, the m most significant bits and the m least significant bits each being the string of bit values represented by γ; and the binary value 1.

## Claims

### Claim 1

A circuit configured to determine y=x mod (2m−1), where x is an n-bit binary number, y is an m-bit binary number, and n>m, the circuit comprising:
addition logic configured to:
receive a first m-bit binary number β and a second m-bit binary number γ,
perform a summation in dependence on the first m-bit binary number β and the second m-bit binary number γ, and
generate an addition output in dependence on the summation;
exception logic configured to form a determination result indicating whether all of the bits of x are 1; and
output logic configured to operate on the addition output in dependence on the determination result received from the exception logic, wherein the output logic is configured to, if the determination result indicates that all of the bits of x are 1, perform a XOR operation of the addition output with the binary value 1.

### Claim 2 (depends on 1)

The circuit as claimed in claim 1, wherein the summation comprises:
a first binary value of length 2m, comprising the bit values of β; and
a second binary value of length 2m, comprising the bit values of γ.

### Claim 3 (depends on 2)

The circuit as claimed in claim 2, wherein the first binary value of length 2m comprises the bit values of β repeated twice and the second binary value of length 2m comprises the bit values of γ repeated twice.

### Claim 4 (depends on 2)

The circuit as claimed in claim 2, wherein the first binary value of length 2m comprises a string of bit values represented by β and the second binary value of length 2m comprises a string of bit values represented by γ.

### Claim 5 (depends on 2)

The circuit as claimed in claim 2, wherein the addition logic comprises an adder configured to calculate a sum of the first and second binary values and the binary value 1.

### Claim 6 (depends on 1)

The circuit as claimed in claim 1, wherein the circuit further comprises reduction logic, and wherein the addition logic is configured to receive the first m-bit binary number β and the second m-bit binary number γ from the reduction logic.

### Claim 7 (depends on 6)

The circuit as claimed in claim 6, wherein the reduction logic is configured to interpret x as a sum of m-bit rows x′, each row representing m consecutive bits of x such that each bit of x contributes to only one row and all of the bits of x are allocated to a row, and the reduction logic is configured to reduce the sum of such m-bit rows x′ in a series of reduction steps so as to generate a sum of the first m-bit binary number β and the second m-bit binary number γ.

### Claim 8 (depends on 7)

The circuit as claimed in claim 7, wherein each reduction step comprises summing a plurality of the m-bit rows of x′ so as to generate a sum of one or more fewer m-bit rows.

### Claim 9 (depends on 7)

The circuit as claimed in claim 7, wherein the reduction logic comprises one or more reduction cells each configured to sum a plurality of the m-bit rows of x′ so as to generate a sum of one or more fewer m-bit rows.

### Claim 10 (depends on 9)

The circuit as claimed in claim 9, wherein the reduction logic comprises a plurality of reduction cells and the plurality of reduction cells are configured to operate in parallel on the rows of x′ at each reduction step.

### Claim 11 (depends on 9)

The circuit as claimed in claim 9, wherein the reduction logic is further configured to iteratively operate the one or more reduction cells over the rows of x′ until two rows remain which represent m-bit binary numbers β and γ.

### Claim 12 (depends on 1)

The circuit as claimed in claim 1, wherein the exception logic is further configured to form a determination result of 1 if all of the bits of x are 1 and a determination result of 0 if not all of the bits of x are 1.

### Claim 13 (depends on 1)

The circuit as claimed in claim 1, wherein the output logic comprises a XOR gate configured to receive the addition output and determination result as its inputs so as to form as its output y for all inputs x.

### Claim 14 (depends on 1)

The circuit as claimed in claim 1, wherein the exception logic comprises a hierarchy of AND gates, the output of the final AND gate being the determination result.

### Claim 15 (depends on 1)

The circuit as claimed in claim 1, wherein the determination result is a binary indication of 1 if all of the input bits of x are 1, and a binary indication of 0 if not all of the input bits of x are 1.

### Claim 16 (depends on 1)

The circuit as claimed in claim 1, wherein the addition logic comprises a compound adder configured to concurrently form a first sum β+γ and a second sum β+γ+1.

### Claim 17 (depends on 1)

The circuit as claimed in claim 1, wherein the addition logic is further configured to provide the m least significant bits of the summation right-shifted by m as the addition output.

### Claim 18 (depends on 1)

The circuit as claimed in claim 1, wherein the addition logic is embodied in fixed function hardware.

### Claim 19

A method of determining y=x mod (2m−1), where x is an n-bit binary number, y is an m-bit binary number, and n>m, the method comprising:
receiving, at addition logic, a first m-bit binary number β and a second m-bit binary number γ; and
performing, at the addition logic, a summation in dependence on the first m-bit binary number β and the second m-bit binary number γ;
generating, at the addition logic, an addition output in dependence on the summation;
forming, at exception logic, a determination result indicating whether all of the bits of x are 1; and
operating, at output logic, on the addition output in dependence on the determination result, wherein, in response to determining that the determination result indicates that all of the bits of x are 1, a XOR operation of the addition output with the binary value 1 is performed.

### Claim 20

A non-transitory computer readable storage medium having stored thereon computer readable instructions that, when processed at a computer system for generating a manifestation of an integrated circuit, cause the computer system to generate a manifestation of a circuit configured to determine y=x mod (2m−1), where x is an n-bit binary number, y is an m-bit binary number, and n>m, the circuit comprising:
addition logic configured to:
receive a first m-bit binary number β and a second m-bit binary number γ,
perform a summation in dependence on the first m-bit binary number β and the second m-bit binary number γ, and
generate an addition output in dependence on the summation;
exception logic configured to form a determination result indicating whether all of the bits of x are 1; and
output logic configured to operate on the addition output in dependence on the determination result received from the exception logic, wherein the output logic is configured to, if the determination result indicates that all of the bits of x are 1, perform a XOR operation of the addition output with the binary value 1.
