K-CLUSTER RESIDUE NUMBER SYSTEM USING LOOK-UP TABLES WITH REDUCED DATA CAPACITY FOR ADDITION, SUBTRACTION, AND MULTIPLICATION OPERATIONS
20240152330 ยท 2024-05-09
Assignee
Inventors
Cpc classification
International classification
Abstract
A k-cluster residue number system has a processor and a memory. The processor is used to generate an addition and subtraction look-up table and a multiplication look-up table based on periodic behaviors of the modulo to compress the sizes of the addition and subtraction look-up table and the multiplication look-up table. The addition and subtraction look-up table has 2m.sub.i cells for recording values from zero to (m.sub.i?1) in an ascending order twice, wherein m.sub.i is a coprime integer of a modular set of the k-cluster residue number system. The multiplication look-up table has S cells, where
Claims
1. A method for performing addition and subtraction operations in a k-cluster residue number system, the method comprising: generating an addition and subtraction look-up table comprising 2m.sub.i cells for recording values from zero to (m.sub.i?1) in an ascending order twice, wherein m.sub.i is a coprime integer of a modular set of the k-cluster residue number system; storing the addition and subtraction look-up table in a memory of the k-cluster residue number system; retrieving a value recorded in a cell at position Q of the addition and subtraction look-up table when performing an addition operation on two integers A and B, where Q=((A mod m.sub.i)+(B mod m.sub.i)); and retrieving a value recorded in a cell at position R of the addition and subtraction look-up table when subtracting an integer X by an integer Y, where R=(X mod mi)?(Y mod mi)=(X mod mi)+(mi?(Y mod mi))=rx+(mi?ry)=rx+ry, rx is equal to (X mod m.sub.i), ry is equal to (Y mod m.sub.i), and ry is equal to (m.sub.i?(Y mod m.sub.i)).
2. The method of claim 1 further comprising: generating a multiplication look-up table for the coprime integer m.sub.i, wherein the coprime integer m.sub.i is not 2, and the multiplication look-up table is composed of S cells, where
3. The method of claim 2 further comprising: performing a multiplication operation on a multiplicand and a multiplicator using the multiplication look-up table, comprising: determining whether a complement of the multiplicand is greater than or equal to the multiplicator; if it is determined that the complement of the multiplicand is greater than or equal to the multiplicator, perform the following steps: selecting the multiplicand as a column entry and the multiplicator as a row entry, and determining whether the column entry is greater than or equal to the row entry; if it is determined that the column entry is greater than or equal to the row entry, keeping the column entry and the row entry; and if it is determined that the column entry is less than the row entry, interchanging the column entry and the row entry; if it is determined that the complement of the multiplicand is less than the multiplicator, perform the following steps: selecting the complement of the multiplicand as the column entry and a complement of the multiplicator as the row entry, and determining whether the column entry is greater than or equal to the complement of the row entry; if it is determined that the column entry is greater than or equal to the complement of the row entry, keeping the column entry and the row entry; and if it is determined that the column entry is less than the row entry, interchanging the column entry and the row entry; and retrieving a value from the multiplication look-up table as a product of the multiplicand and the multiplicator according to the column entry and the row entry.
4. A method for performing multiplication operations in a k-cluster residue number system, the method comprising: generating a multiplication look-up table for a coprime integer m.sub.i of a modular set of the k-cluster residue number system, wherein the coprime integer m.sub.i is not 2, the multiplication look-up table is composed of S cells,
5. The method of claim 4 further comprises: generating an addition and subtraction look-up table comprising 2m.sub.i cells for recording values from zero to (m.sub.i?1) in an ascending order twice; and storing the addition and subtraction look-up table in the memory of the k-cluster residue number system.
6. The method of claim 5 further comprises: retrieving a value recorded in a cell at position Q of the addition and subtraction look-up table when performing an addition operation on two integers A and B, where Q=((A mod m.sub.i)+(B mod m.sub.i)).
7. The method of claim 5 further comprises: retrieving a value recorded in a cell at position R of the addition and subtraction look-up table when subtracting an integer X by an integer Y, where R=(X mod mi)?(Y mod mi)=(X mod mi)+(mi?(Y mod mi))=rx+(mi?ry)=(rx+ry), rx is equal to (X mod m.sub.i), ry is equal to (Y mod m.sub.i), and ry is equal to (m.sub.i?(Y mod m.sub.i)).
8. A k-cluster residue number system comprising: a processor configured to: generate an addition and subtraction look-up table comprising 2m.sub.i cells for recording values from zero to (m.sub.i?1) in an ascending order twice, wherein m.sub.i is a coprime integer of a modular set of the k-cluster residue number system; retrieve a value recorded in a cell at position Q of the addition and subtraction look-up table when performing an addition operation on two integers A and B, where Q=((A mod m.sub.i)+(B mod m.sub.i)); and retrieve a value recorded in a cell at position R of the addition and subtraction look-up table when subtracting an integer X by an integer Y, where R=(X mod mi)?(Y mod mi)=(X mod mi)+(mi?(Y mod mi))=rx+(mi?ry)=(rx+ry), rx is equal to (X mod m.sub.i), ry is equal to (Y mod m.sub.i), and ry is equal to (m.sub.i?(Y mod m.sub.i)); and a memory coupled to the processor and configured to store the addition and subtraction look-up table.
9. The k-cluster residue number system of claim 8, wherein the processor is further configured to: generate a multiplication look-up table for the coprime integer m.sub.i, wherein the coprime integer m.sub.i is not 2, and the multiplication look-up table is composed of S cells, where
10. The k-cluster residue number system of claim 9, wherein the processor is further configured to: perform a multiplication operation on a multiplicand and a multiplicator using the multiplication look-up table by performing the following steps: determining whether a complement of the multiplicand is greater than or equal to the multiplicator; if it is determined that the complement of the multiplicand is greater than or equal to the multiplicator, perform the following steps: selecting the multiplicand as a column entry and the multiplicator as a row entry, and determining whether the column entry is greater than or equal to the row entry; if it is determined that the column entry is greater than or equal to the row entry, keeping the column entry and the row entry; and if it is determined that the column entry is less than the row entry, interchanging the column entry and the row entry; if it is determined that the complement of the multiplicand is less than the multiplicator, perform the following steps: selecting the complement of the multiplicand as the column entry and a complement of the multiplicator as the row entry, and determining whether the column entry is greater than or equal to the complement of the row entry; if it is determined that the column entry is greater than or equal to the complement of the row entry, keeping the column entry and the row entry; and if it is determined that the column entry is less than the row entry, interchanging the column entry and the row entry; and retrieving a value from the multiplication look-up table as a product of the multiplicand and the multiplicator according to the column entry and the row entry.
11. A k-cluster residue number system, comprising: a processor configured to: generate a multiplication look-up table for a coprime integer m.sub.i of a modular set of the k-cluster residue number system, wherein the coprime integer m.sub.i is not 2, and the multiplication look-up table is composed of S cells,
12. The k-cluster residue number system of claim 11, wherein the processor is further configured to: generate an addition and subtraction look-up table comprising 2m.sub.i cells for recording values from zero to (m.sub.i?1) in an ascending order twice; and store the addition and subtraction look-up table in the memory of the k-cluster residue number system.
13. The k-cluster residue number system of claim 12, wherein the processor is further configured to: retrieve a value recorded in a cell at position Q of the addition and subtraction look-up table when performing an addition operation on two integers A and B, where Q=((A mod m.sub.i)+(B mod m.sub.i)).
14. The k-cluster residue number system of claim 12, wherein the processor is further configured to: retrieve a value recorded in a cell at position R of the addition and subtraction look-up table when subtracting an integer X by an integer Y, where R=(X mod mi)?(Y mod mi)=(X mod mi)+(mi?(Y mod mi))=rx+(mi?ry)=(rx+ry), rx is equal to (X mod m.sub.i), ry is equal to (Y mod m.sub.i), and ry is equal to (m.sub.i?(Y mod m.sub.i)).
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0021]
[0022]
[0023]
[0024]
[0025]
[0026]
[0027]
DETAILED DESCRIPTION
[0028] To represent an n-bit integer and its negative using a k-cluster residue number system (k-RNS), it first defines a modular set of P coprime integers as (m.sub.0, m.sub.1, . . . , m.sub.p) where a dynamic range is generated according to the product of the modular set (m.sub.0, m.sub.1, . . . , m.sub.p). For example, when a modular set of 3 coprime integers is chosen to be (2.sup.n/2?1, 2, 2.sup.n/2+1) , the dynamic range is set to [?(2.sup.n?1), (2.sup.n?2)]. The modular set is not limited to 3 coprime integers.
[0029]
[0030] Processor 4 uses the addition and subtraction look-up table 10 to perform addition operations and subtraction operations.
Z=X+Y (4)
rz=rx+ry (5) [0031] where: [0032] X, Y, and Z are three integers; [0033] rx is equal to (X mod m.sub.i); [0034] ry is equal to (Y mod m.sub.i); [0035] rz is equal to (Z mod m.sub.i); and [0036] m.sub.i is selected from the modular set of the k-cluster residue number system 2.
[0037] In the embodiment, one modulus of the modular set selected by processor 4 is 7. However, the present invention is not limited thereto. The selected modulus could be other coprime integers of the modular set. The addition and subtraction look-up table 10 is composed of 14 (i.e., 2?7) cells 11 for recording values from zero to 6 in an ascending order twice. The addition and subtraction look-up table 10 is a one-dimensional linear array, which is simplified from a traditional two-dimensional addition look-up table A7 for addition operations based on modulus 7. The traditional addition look-up table A7 comprises 49 (i.e., 7?7) cells, more than fourteen cells 11 of the addition and subtraction look-up table 10. Each of the cells 11 is used to store a residue when an addition operation on two remainders rx and ry or two integers X and Y is performed, where rx=(X mod 7) and ry=(Y mod 7). The addition look-up table A7 is transformed to the addition and subtraction look-up table 10 based on the periodic behaviors of the modulo. As shown in
[0038] Similarly, according to the subtraction algorithm, the following equation (6) in the integral domain could be transformed into the following equation (7) in the remainder domain:
Z=X?Y (6)
rz=rx?ry (7)
[0039] Therefore, the addition and subtraction look-up table 10 could be used not only for addition operations but also for subtraction operations since the addition and subtraction look-up table 10 could be obtained by simplifying a traditional subtraction look-up table S7. The traditional subtraction look-up table S7 also comprises 49 (i.e., 7?7) cells, more than fourteen cells 11 of the addition and subtraction look-up table 10. Each of the cells 11 is used to store a residue when the remainder rx is subtracted by the remainder ry. The subtraction look-up table S7 is transformed to the addition and subtraction look-up table 10 based on periodic behaviors of the modulo. As shown in
[0040] In another embodiment of the present invention, when processor 4 subtracts the integer X by the integer Y, processor 4 retrieves the value from the addition and subtraction look-up table 10 according to the complement ry of the remainder ry and the remainder rx (i.e., the minuend). Referring to
TABLE-US-00001 ry 0 1 2 3 4 5 6 ry 0 6 5 4 3 2 1
[0041] Since R=(rx+ry), the start position Ps would be set to be rx of the addition and subtraction look-up table 10, then it is shifted according to the complement ry. For example, when we subtract 5 with 4, rx=5 and ry=4, the table entry becomes=5, the complement of ry=4 is ry=3, it shifts to the right by 3, the value recorded in cell 11 at position 8 is defined as 1, it matches the result of (rx?ry)=1.
[0042] Therefore, the two-dimensional addition look-up table A7 and the two-dimensional subtraction look-up table S7 could be simplified and transformed into the addition and subtraction look-up table 10, which is a one-dimensional linear array. The addition and subtraction look-up table 10 is used by processor 4 when processor 4 performs an addition operation or a subtraction operation when the modulus m.sub.i=7. Since the modulus m.sub.i may be an integer other than 7, processor 4 could generate corresponding addition and subtraction look-up tables for other coprime integers of the modular set.
[0043] In detail, if the k-RNS 2 uses P coprime integers to define its modular set as (m.sub.1, . . . , 2, . . . , m.sub.p), the processor 4 generates a corresponding addition and subtraction look-up table for each coprime integer not equal to 2. If the coprime integer is m.sub.i, its corresponding addition and subtraction look-up table is composed of 2m.sub.i cells 11 for recording values from zero to (m.sub.i?1) in an ascending order twice. When processor 4 performs an addition operation on two integers X and Y, processor 4 retrieves a value recorded in cell 11 at position Q of the addition and subtraction look-up table 10, where Q=((X mod m.sub.i)+(Y mod m.sub.i))=(rx+ry). When processor 4 subtracts the integer X by the integer Y, processor 4 retrieves a value recorded in cell 11 at position R of the addition and subtraction look-up table 10, where R=(X mod mi)?(Y mod mi)=(X mod mi)+(mi?(Y mod mi))=rx+ry, and ry is the complement of the remainder ry (i.e., ry=m.sub.i?ry). According to the subtraction algorithm, the following equation (8) in the integral domain could be transformed into the following equation (9) in the remainder domain:
Z=X?Y (8)
rz=(rx?ry) (9) [0044] where: [0045] X, Y, and Z are three integers; [0046] rx is equal to (X mod m.sub.i); [0047] ry is equal to (Y mod m.sub.i); [0048] rz is equal to (Z mod m.sub.i); and [0049] m.sub.i is selected from the modular set of the k-cluster residue number system 2.
[0050]
[0055] According to equations (2) and (10), the lookup table size is reduced from
to
as compared with the prior art. Moreover, according to the multiplication commutative rule, the order of the multiplicand and multiplicator can be exchanged. Therefore, the products of the temporary multiplication look-up table 60 could be mirrored along a Top-Left and Bottom-Right (TL/BR) diagonal line 62, as shown in
[0056]
[0057]
to
For example, the multiplication look-up table 12 has twelve cells 11 while the temporary multiplication look-up table 60 has thirty-six cells 11. Therefore, the lookup table size for multiplication operations is further reduced. Due to the mirror property and the periodic behaviors of the modulo, the four identical regions 81, 82, 83, and 84 could be simplified as a multiplication look-up table 12, as shown in
[0058] Accordingly, the data amount of the multiplication look-up table 12 could be presented as the following equation (11):
[0063] When processor 4 performs a multiplication operation on the two integers X and Y, processor 4 would perform the procedure shown in
[0064] Step S902: determine whether a complement rx of the multiplicand rx is greater than or equal to the multiplicator ry; if it is determined that the complement rx of the multiplicand rx is greater than or equal to the multiplicator ry, go to Step S904; otherwise, go to Step S914;
[0065] Step S904: select the multiplicand rx as the column entry and the multiplicator ry as the row entry;
[0066] Step S906: determine whether the column entry (rx) is greater than or equal to the row entry (ry); if it is determined that the column entry (rx) is greater than or equal to the row entry (ry), go to Step 908; otherwise, go to Step S910;
[0067] Step 908: keep the column entry and the row entry; go to Step 924
[0068] Step 910: interchange the column entry and the row entry;
[0069] Step 912: ry is selected as the column entry and rx is selected as the row entry; go to Step S924
[0070] Step S914: select the complement rx of rx as the column entry and the complement ry of the multiplicator ry as the row entry;
[0071] Step S916: determine whether the column entry (rx) is greater than or equal to the row entry (ry); if it is determined that the column entry (rx) is greater than or equal to the row entry (ry), go to Step S918; otherwise go to step S920;
[0072] Step S918: keep the column entry (rx) and the row entry (ry); Go to Step S924
[0073] Step S920: interchange the column entry (rx) and row entry (ry);
[0074] Step S922: the complement ry of ry is selected as the column entry and complement rx of rx is selected as the row entry; go to Step 924
[0075] Step 924: Retrieve a value from the multiplication look-up table 12 as a product of the multiplicand and the multiplicator according to the column entry and the row entry.
[0076] Briefly, processor 4 changes the column entry from rx to its RNS complement rx, where rx=(m.sub.i?rx), then processor 4 compares rx with ry (step S902). If rx is less than ry, then both the row and column entries are changed into their residue complement (step S114, where rx=(m.sub.i?rx) and ry=(m.sub.i?ry)), otherwise keeping rx and ry without change (step S904). After that, processor 4 compares the row (rx) and column (ry) entries. If rx is less than ry, then rx and ry are interchanged (rx?ry) for table access.
[0077] For example, when m.sub.i=7, X=10, and Y=19, rx=3, ry=5, rx=7?3=4, ry=7?5=2 According to the above approach, the column entry is rx=4, and the row entry is ry=2. Therefore, when processor 4 performs a multiplication operation on X and Y, processor 4 would retrieve the value recorded in cell 11 at the 4.sup.th column and 2.sup.nd row of the multiplication look-up table 12 as the product of the modulo multiplication. The product of X=10 and Y=19 is 190, where the residue |190|.sub.7=1. It is consistent with the value: 1 stored in 4.sup.th column and 2.sup.rd row. In another example, when m.sub.i=7, X=11, and Y=15, rx=4, ry=1, rx=7?4=3, ry=7?1=6, the column entry is rx=4, and the row entry is ry=1. Therefore, when processor 4 performs a multiplication operation on X and Y (i.e., 11?15), where the residue |165|.sub.7=4, processor 4 would retrieve the value: 4 recorded in cell 11 at the 4.sup.th column and 1.sup.st row of the multiplication look-up table 12 as the product of the multiplication.
[0078] In the k-cluster residue number system 2, since the addition and subtraction look-up table 10 and the multiplication look-up table 12 have compressed size, the required size of the memory 6 for storing look-up tables for addition, subtraction, and multiplication operations could be reduced.
[0079] Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.