JPH11316544A - Remainder multiplying device - Google Patents

Remainder multiplying device

Info

Publication number
JPH11316544A
JPH11316544A JP5480399A JP5480399A JPH11316544A JP H11316544 A JPH11316544 A JP H11316544A JP 5480399 A JP5480399 A JP 5480399A JP 5480399 A JP5480399 A JP 5480399A JP H11316544 A JPH11316544 A JP H11316544A
Authority
JP
Japan
Prior art keywords
value
bits
remainder
partial
multiplier
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP5480399A
Other languages
Japanese (ja)
Other versions
JP4293665B2 (en
Inventor
Takatoshi Ono
貴敏 小野
Natsume Matsuzaki
なつめ 松崎
Hiroshi Kashiwa
浩 柏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP05480399A priority Critical patent/JP4293665B2/en
Publication of JPH11316544A publication Critical patent/JPH11316544A/en
Application granted granted Critical
Publication of JP4293665B2 publication Critical patent/JP4293665B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To enable a fast operation with a small circuit scale. SOLUTION: Relating to a remainder multiplying device 100 which calculates A*BmodP, a multiplier division part 11 outputs a partial multiplier b(i) obtained by dividing a multiplier B into every 8 bits from the low-order side and a remainder calculation part 12 outputs intermediate number C(i) represented as recursion formulas C(1)=A (A is a multiplicand) and C(i)=C(i-1)*2<8> modP (P is a modulus, 160 bits). Then ROM tables 308 and 309 are stored with remainders corresponding to the high-order part of a carry value C(i-1)*2<8> and a remainder calculation part 12 calculates C(i) by adding a remainder read out of a ROM to the low-order part. A partial product calculation part 13 calculates a partial product C(i)*b(i). An accumulation part 14 accumulates the partial partial product C(i)*b(i). A correction part 15 subtracts an integral multiple of P from the accumulated value of the accumulation part 14 to correct the accumulated value.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、高速かつ小回路規
模の構成により剰余乗算を行う剰余乗算装置に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a modular multiplication device for performing modular multiplication with a high-speed and small-scale circuit configuration.

【0002】[0002]

【従来の技術】近年、通信分野における暗号化技術の発
達に伴って、暗号化の際に利用される各種演算装置の需
要が高まっている。例えば、楕円暗号方式においては剰
余乗算を行うための剰余乗算装置が利用される。ここで
剰余乗算とは、3つの整数a、b及びpにおいて(a*
b)modpの演算を施すことである。ここにおいてa
は被乗数、bは乗数、pは法という。
2. Description of the Related Art In recent years, with the development of encryption technology in the communication field, the demand for various arithmetic devices used for encryption has been increasing. For example, in the elliptic cryptosystem, a modular multiplication device for performing modular multiplication is used. Here, the remainder multiplication means (a *) for three integers a, b, and p.
b) To perform a modp operation. Where a
Is a multiplicand, b is a multiplier, and p is a modulus.

【0003】図17は、従来の剰余乗算装置の構成を示
す。なお、同図の剰余乗算装置1においてa、b、p
は、説明を簡単にするため4ビットで表わされるような
小さい値を用いるものとする。剰余乗算装置1は、積算
出部2、剰余算出部3、制御部4から構成される。積算
出部2は、被乗数レジスタ5(4ビット)、加算器6
(4ビット)、積レジスタ7(9ビット)から構成さ
れ、制御部4の制御によって被乗数aと乗数bとの積a
*bを算出する。
FIG. 17 shows a configuration of a conventional remainder multiplication device. Note that a, b, p
Uses a small value represented by 4 bits for simplicity of explanation. The remainder multiplication device 1 includes a product calculation unit 2, a remainder calculation unit 3, and a control unit 4. The product calculator 2 includes a multiplicand register 5 (4 bits), an adder 6
(4 bits), a product register 7 (9 bits), and the product a of the multiplicand a and the multiplier b is controlled by the control unit 4.
* Calculate b.

【0004】積算出部2に対する制御部4の処理手順を
以下に示す。 ステップ1:初期設定として、被乗数レジスタ5に被乗
数aを保持させ、積レジスタ7(8ビット)の下位4ビ
ットに乗数bを保持させ、積レジスタ7の上位5ビット
に0を保持させる。 ステップ2:積レジスタ7の最下位ビットが0であるか
1であるかを判定し、1と判定した場合には、加算器6
において積レジスタ7の上位5ビットのうち最上位ビッ
トを除く4ビットに保持される値と被乗数レジスタ7に
保持される被乗数aとを加算させ、加算値を積レジスタ
7の上位4ビットに保持させる。
The processing procedure of the control unit 4 for the product calculation unit 2 will be described below. Step 1: As initial settings, the multiplicand register 5 holds the multiplicand a, the lower 4 bits of the product register 7 (8 bits) hold the multiplier b, and the upper 5 bits of the product register 7 hold 0. Step 2: It is determined whether the least significant bit of the product register 7 is 0 or 1, and if it is 1, the adder 6
In the above, the value held in 4 bits except the most significant bit of the upper 5 bits of the product register 7 is added to the multiplicand a held in the multiplicand register 7, and the added value is held in the upper 4 bits of the product register 7 .

【0005】ステップ3:積レジスタ7を右1ビットシ
フトさせる。 ステップ4:ステップ2〜3の処理を4回繰り返す。 以上のようにしてステップ2〜3のループ処理を4回繰
り返すと積レジスタ7には積a*bが保持されることに
なる。剰余算出部3は、法レジスタ8(4ビット)、加
算器9(5ビット)、剰余レジスタ10(13ビット)
から構成され、制御部4の制御によって手書きの筆算と
同等な要領により積a*bの法pによる剰余(a*b)
modpの算出を行う。なお、剰余算出部3により算出
される剰余は符号付きの5ビット値である。
Step 3: The product register 7 is shifted one bit to the right. Step 4: The processing of steps 2-3 is repeated four times. When the loop processing of steps 2 and 3 is repeated four times as described above, the product a * b is held in the product register 7. The remainder calculator 3 includes a modulo register 8 (4 bits), an adder 9 (5 bits), and a remainder register 10 (13 bits).
And the remainder (a * b) of the product a * b by the modulus p in a manner equivalent to handwritten handwriting under the control of the control unit 4.
Modp is calculated. The remainder calculated by the remainder calculation unit 3 is a signed 5-bit value.

【0006】剰余算出部3に対する制御部4の処理手順
を以下に示す。 ステップ5:初期設定として法レジスタ8に法pを保持
させ、剰余レジスタ10の下位8ビットに積レジスタ7
に保持される積a*bを保持させ、上位5ビットに0を
保持させる。 ステップ6:剰余レジスタ10に左1ビットシフトさせ
る。
The processing procedure of the control unit 4 for the remainder calculation unit 3 will be described below. Step 5: The modulo register 8 holds modulo p as an initial setting, and the lower 8 bits of the remainder register 10 store the product register 7
Is held, and 0 is held in the upper 5 bits. Step 6: The remainder register 10 is shifted one bit to the left.

【0007】ステップ7:加算器9において剰余レジス
タ10の上位5ビットに保持される値から法レジスタ8
に保持される法pを減算させ、剰余レジスタ10の上位
5ビットに保持させる。 ステップ8:剰余レジスタ10の上位5ビットの正負を
最上位ビットの値から判定し、負(最上位ビットが1)
と判定した場合は、加算器9において剰余レジスタ10
の上位5ビットと法レジスタ8の法pとを加算させるこ
とによって剰余レジスタ10の値を元に戻す(つまり、
ステップ7において減算される前の値に戻す)。
Step 7: The adder 9 calculates the modulo register 8 from the value held in the upper 5 bits of the remainder register 10.
Is subtracted from the modulo p held in the remainder register 10 and held in the upper 5 bits. Step 8: The sign of the upper 5 bits of the remainder register 10 is determined from the value of the most significant bit, and the result is negative (the most significant bit is 1).
Is determined in the adder 9, the remainder register 10
Is added to the modulo p of the modulo register 8 to restore the value of the remainder register 10 (ie,
Return to the value before being subtracted in step 7).

【0008】ステップ9:ステップ6〜8の処理を8回
繰り返す。 以上のようにしてステップ6〜8のループ処理を8回繰
り返すと、剰余レジスタ10の上位5ビットに剰余(a
*b)modpが保持されることになる。このように剰
余乗算装置1は、積算出部2においては、被乗数aと乗
数bの各ビットとの部分積を、bの下位側から被乗数a
に対応させて算出し、算出される部分積を順次に累算す
ることによって積a*bを算出する。そして剰余算出部
3においては、積算出部2において算出された積a*b
をシフトさせて法pの桁を積a*bの上位桁から下位桁
へと桁を合わせつつa*bから法pを減算することによ
り剰余(a*b)modpを算出する。
Step 9: The processing of steps 6 to 8 is repeated eight times. When the loop processing of steps 6 to 8 is repeated eight times as described above, the remainder (a
* B) modp will be retained. As described above, the remainder multiplication device 1 calculates the partial product of the multiplicand a and each bit of the multiplier b in the product calculation unit 2 from the lower side of b to the multiplicand a.
The product a * b is calculated by sequentially accumulating the calculated partial products. In the remainder calculating unit 3, the product a * b calculated in the product calculating unit 2
To calculate the remainder (a * b) modp by subtracting the modulus p from a * b while adjusting the digit of the modulus p from the upper digit to the lower digit of the product a * b.

【0009】[0009]

【発明が解決しようとする課題】上記従来技術における
剰余乗算装置1においては、a、b、pが4ビットとい
う小さな値であるので、加算器6及び加算器9は4ビッ
トの加算が行えればよく、またループ処理の回数も積算
出部2においては4回、剰余算出部3においては8回と
少ない。それに対して実際の楕円暗号に用いられるa、
b、pは例えば160ビットとかなり大きな値である。
よって従来の剰余乗算装置1を160ビットのa、b、
pを用いた演算に対応させた場合、加算器6及び加算器
9は160ビットの加算を行う必要があり、回路規模が
大きくなるという問題があった。またループ処理の回数
は、積算出部2においては160回、剰余算出部3にお
いては320回繰り返されることとなり、演算時間がか
かるという問題があった。
In the remainder multiplication apparatus 1 of the prior art, since a, b, and p are small values of 4 bits, the adders 6 and 9 can perform 4-bit addition. In addition, the number of times of loop processing is as small as four in the product calculation unit 2 and as small as eight in the remainder calculation unit 3. On the other hand, a used for actual elliptic cryptography,
b and p are considerably large values, for example, 160 bits.
Therefore, the conventional remainder multiplication device 1 is converted into 160-bit a, b,
In the case where the calculation is performed using p, the adder 6 and the adder 9 need to perform 160-bit addition, and there is a problem that the circuit scale becomes large. Further, the number of times of the loop processing is repeated 160 times in the product calculation unit 2 and 320 times in the remainder calculation unit 3, and there is a problem that it takes a long calculation time.

【0010】このようにして従来技術の剰余乗算装置1
をあらゆる値を用いた演算に対応させるとすると、値の
ビット数が大きくなればなるほど、加算器で行われる加
算のビット数が大きくなるので加算器の回路規模が大き
くなり、ループ処理の回数が増えるので演算時間が長く
なるという問題があった。上記剰余乗算装置1の演算時
間の問題を解消する他の従来技術として「UnitedStates
Patent 5,144,574 Modular multiplication method
and the systemfor processing data」に記載の剰余乗
算方法がある。
As described above, the remainder multiplication apparatus 1 according to the prior art
Is assumed to correspond to an operation using all values, the larger the number of bits of the value, the larger the number of bits of addition performed by the adder, so that the circuit size of the adder is increased, and the number of loop processes is There is a problem that the calculation time becomes longer due to the increase. Another conventional technique for solving the problem of the operation time of the remainder multiplication apparatus 1 is “UnitedStates
Patent 5,144,574 Modular multiplication method
and the system for processing data.

【0011】この剰余乗算方法は、乗数bの上位側から
2ビットずつ順次に被乗数aに対応させて、被乗数aと
乗数bの2ビットずつとの部分積を算出し、算出される
度にその部分積から法pの整数倍を減算することによっ
て部分積の法pによる部分剰余を算出し、その部分剰余
を累算することによって(a*b)modpを算出する
方法である。
In this remainder multiplication method, a partial product of a multiplicand a and a 2-bit multiplier b is calculated sequentially in correspondence with the multiplicand a by two bits from the upper side of the multiplier b. This is a method of calculating a partial remainder of the partial product by the modulus p by subtracting an integer multiple of the modulus p from the partial product, and calculating the (a * b) modp by accumulating the partial remainder.

【0012】このような剰余乗算方法を用いた装置にお
いては、剰余乗算装置1が乗数bの1ビットずつを被乗
数aに対応させて部分積を算出していたのに対して、被
乗数aと乗数bの2ビットずつとの部分積を算出するの
で、部分積の算出にかかるループ処理の回数が少なくな
り演算時間が短縮される。このように剰余乗算方法は、
主に、被乗数aと乗数bの2ビットずつとを対応させた
部分積の算出によって演算時間を短縮しようとするもの
である。ただしこの剰余乗算方法においては、部分積を
算出する際に被乗数aに対応させる乗数bのビット数は
たかだか2ビットと少なく、a、b、pが大きな値であ
る場合には、さほど演算時間の短縮の効果は得られな
い。
In an apparatus using such a modular multiplication method, the modular multiplication apparatus 1 calculates a partial product by associating each bit of a multiplier b with a multiplicand a, whereas a multiplicand a and a multiplier Since the partial product of each two bits of b is calculated, the number of loop processes for calculating the partial product is reduced, and the calculation time is reduced. Thus, the remainder multiplication method
Mainly, the calculation time is reduced by calculating a partial product in which the multiplicand a and the two bits of the multiplier b are associated with each other. However, in the remainder multiplication method, when calculating the partial product, the number of bits of the multiplier b corresponding to the multiplicand a is as small as at most 2 bits, and when a, b, and p are large values, the calculation time is significantly reduced. The effect of shortening cannot be obtained.

【0013】上記問題に鑑みて本発明は、回路規模を抑
えながら高速に演算を行う剰余乗算装置を提供すること
を目的とする。
SUMMARY OF THE INVENTION In view of the above problems, an object of the present invention is to provide a modular multiplication device that performs a high-speed operation while suppressing the circuit scale.

【0014】[0014]

【課題を解決するための手段】上記問題を解決するため
本発明の剰余乗算装置は、被乗数aと乗数b(bはkb
ビットのデータ)との積に対して、法p(pはkビット
データ)による剰余と合同な値を次式の累算値として算
出する剰余乗算装置であって、 累算値 = Σ C(i)*b[s*i+s-1:s*i] (ここでΣはi=0〜[[kb/s]]までの累算を示す。 [[k
b/s]]は商kb/sの整数部分であり、iは0から[[k/s]]
までの整数であり、C(i)は漸化式で表わされi=0のときC
(i)=a、i>=1のときC(i)≡(C(i-1)*2s) mod pであり
(≡は両辺の値が法pにおいて合同であることを示
す)) b[s*i+s-1:s*i]は、kビットの乗数bのうち2s*i+s-1
位から2s*iの位までのsビットの部分乗数であり、前記
剰余乗算装置は、m(mはs以上の整数)ビットにより表
現される各値について、その値の2k倍に対する法pに
よる剰余を予め記憶するテーブル手段と、初回(i=0)
では被乗数aを中間数C(0)として出力し、2回目以降
(i>0)では、前回出力された中間数C(i-1)をsビット
桁上げし、桁上げ後の中間数の下位kビットを除く上位
のmビットについての前記剰余をテーブル手段から読み
出し、読み出した剰余と下位kビットとを加算すること
により新たな中間数(i)を算出する中間数算出手段とを
備え、算出された各中間数C(i)と、それに対応する部分
乗数b[s*i+s-1:s*i]との部分積C(i)*b[s*i+s-1:s*i]を
順次累算することによって前記累算値を算出するよう構
成される。
In order to solve the above problem, a modular multiplication apparatus according to the present invention comprises a multiplicand a and a multiplier b (b is kb
A modulo multiplication device for calculating the product of the remainder of the product by the modulus p (p is k-bit data) and the product thereof as the accumulated value of the following equation: accumulated value = ΣC ( i) * b [s * i + s-1: s * i] (where Σ indicates an accumulation from i = 0 to [[kb / s]].
b / s]] is the integer part of the quotient kb / s, and i ranges from 0 to [[k / s]]
C (i) is represented by a recurrence formula, and when i = 0, C (i)
When (i) = a, i> = 1, C (i) ≡ (C (i-1) * 2 s ) mod p (≡ indicates that the values on both sides are congruent in the modulus p)) b [s * i + s-1: s * i] is a partial multiplier of s bits from the order of 2 s * i + s-1 to the order of 2 s * i in the multiplier b of k bits, The remainder multiplication device includes, for each value represented by m (m is an integer equal to or greater than s) bits, a table means for storing in advance a remainder of the value by a modulus p with respect to 2 k times the value, and a first time (i = 0)
Outputs the multiplicand a as an intermediate number C (0). From the second time (i> 0), the intermediate number C (i-1) output last time is carried by s bits, and the intermediate number after carry is output. An intermediate number calculating means for reading the remainder for the upper m bits excluding the lower k bits from the table means, and calculating a new intermediate number (i) by adding the read remainder and the lower k bits; Partial product C (i) * b [s * i + s-1: of each calculated intermediate number C (i) and its corresponding partial multiplier b [s * i + s-1: s * i]: s * i] are sequentially accumulated to calculate the accumulated value.

【0015】また前記中間数算出手段は、中間数を保持
する第1保持手段と、部分乗数b[s*i+s-1:s*i]に対応し
て、第1保持手段に保持された中間数をsビット桁上げ
する桁上げ手段と、桁上げ後の中間数を、桁上げ後の中
間数における下位kビットよりも上位のmビットの部分
である上位データと下位kビットの部分である下位デー
タとに分割する分割手段と、分割手段による上位データ
に対する法pによる剰余を前テーブル手段から読み出す
読み出し手段と、テーブル手段から読み出された剰余
と、分割手段による下位データとを加算することにより
新たな中間数を得る加算手段とを備え、前記第1保持手
段は、加算手段において新たな中間数が得られる度にそ
の保持内容を新たな中間数に更新し、前記初回では被乗
数を中間数として出力し、前記2回目以降では更新後の
新たな中間数を出力するよう構成される。
The intermediate number calculating means is stored in the first storing means in correspondence with the first storing means for storing the intermediate number and the partial multiplier b [s * i + s-1: s * i]. A carry means for carrying the intermediate number by s bits, and converting the carried intermediate number into a higher-order data and a lower k-bit part which are m-bit parts higher than the lower k bits in the carried intermediate number. Dividing means for dividing the data into lower-order data, reading means for reading the remainder of the higher-order data by the modulo p from the preceding table means, and adding the remainder read from the table means and the lower-order data by the dividing means. The first holding means updates the held content to a new intermediate number each time a new intermediate number is obtained by the adding means, and the first multiplicand Output as an intermediate number Wherein arranged to output an intermediate number new updated in second and subsequent.

【0016】また前記剰余乗算装置は、さらに、前記分
割手段、読み出し手段、加算手段を利用することによ
り、前記累算値の法pによる剰余を求める後処理手段を
備える。また、前記テーブル手段は、mビットにより表
現される各値に対応するアドレスが入力され、そのアド
レスが指す記憶領域に当該アドレスに対応するmビット
の値の2k倍に対する法pによる剰余を予め記憶するメ
モリ素子を有する。
The remainder multiplying device further includes a post-processing means for obtaining the remainder of the accumulated value by the modulus p by using the dividing means, the reading means and the adding means. Further, the table means inputs an address corresponding to each value represented by m bits, and stores in a storage area indicated by the address a remainder by a modulus p for 2 k times the value of the m bit corresponding to the address in advance. It has a memory element for storing.

【0017】また前記mビットは下位m1ビットと上位m2
ビット(m=m1+m2)とに分割され、前記mビットにより
表現される各値は、m1ビットにより表現される値とm2ビ
ットにより表現される値との組み合わせに対応し、前記
テーブル手段は、m1ビットにより表現される各値につい
て、その値の2k倍に対する法pによる剰余を予め記憶
する第1部分テーブル手段と、m2ビットにより表現され
る各値について、その値の2k+m1倍に対する法pによる
剰余を予め記憶する第2部分テーブル手段とを備え、前
記加算手段は、第1、第2部分テーブルからの読み出さ
れたそれぞれの剰余と、前記下位データとを加算するこ
とにより新たなっ中間数を得るよう構成される。また前
記mビットは下位側からt(3≦t≦m)個の部分ビットm1、
…、mtに分割され、前記mビットにより表現される各値
は、各mi(iは1からtまで整数)ビットにより表現さ
れる値(t個)を組み合わせたものに対応し、前記テー
ブル手段は、部分ビットmiビットにより表現される各値
について、その値の2k+x倍(ここでx=m1+…+m(i-1)
である)に対する法pによる剰余を予め記憶するt個の
部分テーブル手段Tiを備え、前記加算手段は、t個の
部分テーブル手段Tiからの読み出されたt個の剰余と、
前記下位データとを加算することにより新たな中間数を
得るよう構成される。
The m bits are lower m1 bits and upper m2 bits.
Bits (m = m1 + m2), and each value represented by the m bits corresponds to a combination of a value represented by the m1 bits and a value represented by the m2 bits, and the table means , M1 bits, the first partial table means for storing in advance the remainder of modulo p for 2 k times of the value, and for each value represented by m2 bits, 2 k + m1 Second partial table means for storing in advance a remainder of the double by a modulus p, wherein the adding means adds each of the remainders read from the first and second partial tables to the lower-order data. To obtain a new intermediate number. The m bits are t (3 ≦ t ≦ m) partial bits m1 from the lower side,
.., Mt, and each value represented by the m bits corresponds to a combination of values (t) represented by each mi (i is an integer from 1 to t) bits, and the table means Is 2 k + x times of each value represented by partial bits mi bits (where x = m1 +... + M (i−1)
), And t adding sub-tables Ti in advance to store the remainder of the modulo p with respect to.
It is configured to obtain a new intermediate number by adding the lower order data.

【0018】また前記剰余乗算装置は、さらに累算手段
と補正手段とを備え、前記累算手段は、初期値として0
を保持する第3レジスタと、部分積C(i)*b[s*i+s-1:s*
i]と第3レジスタに保持された累算値とを加算し、加算
結果を新たな累算値として第3レジスタに出力して保持
させる加算器とを備え、前記補正手段は、pの整数倍の
値をもつ補正値を保持する補正値保持手段と、前記第3
レジスタに保持された累算値が所定の値以上であれば、
補正値保持手段に保持された補正値を、前記加算器に減
算させる補正制御手段とを備える。
The remainder multiplying device further includes an accumulating means and a correcting means, wherein the accumulating means has 0 as an initial value.
And a third register holding the partial product C (i) * b [s * i + s-1: s *
i] and the accumulated value held in the third register, and an adder for outputting the addition result as a new accumulated value to the third register and holding the added result. Correction value holding means for holding a correction value having a double value;
If the accumulated value held in the register is equal to or greater than a predetermined value,
And a correction control means for causing the adder to subtract the correction value held by the correction value holding means.

【0019】また前記第3レジスタは符号ビットを有
し、前記補正制御手段は、第3レジスタの累算値が正で
あれば、前記加算器に対して累算値と部分積との加算と
同時に前記補正値を減算させ、前記補正値は、pの整数
倍であってその絶対値が前記部分積の最大値(t+1)(2 s
-1)p以下の値であることを特徴とする。また前記法pは
p=2k−αの関係を満たし、各部分テーブル手段Ti
は、前記剰余をk3ビットのデータとして記憶する、ここ
で、k3はt*2m*αのビット数であり、前記αは、k3がk
より小さくなるように定められた定数であることを特徴
とする。
Further, the third register has a sign bit, and the correction control means, if the accumulated value of the third register is positive, adds the accumulated value and the partial product to the adder. At the same time, the correction value is subtracted, and the correction value is an integer multiple of p, and its absolute value is the maximum value (t + 1) (2 s
-1) It is characterized in that the value is not more than p. The method p satisfies the relationship of p = 2 k -α, and each partial table means Ti
Stores the remainder as k3-bit data, where k3 is the number of bits of t * 2 m * α, and α is k3 = k
It is a constant determined to be smaller.

【0020】また各部分テーブル手段Tiは、miビット
により表現される0から(2mi-1)までの値に対応する2mi
個のエントリを有し、j(jは0から2miまで)番目のエン
トリは、j*2m1++m(i-1) *αを格納していることを特
徴とする。本発明の剰余乗算装置は、被乗数と乗数との
積に対する法p(pはkビットデータ)による剰余と合
同な数を算出する剰余乗算装置であって、乗数をs(s
は2以上の整数)ビットずつに分けて得られるsビット
の部分乗数を下位側から順に出力する出力手段と、各部
分乗数の位に応じて、被乗数を桁上げし、桁上げ後の被
乗数に対して、法pによる剰余と合同な数(以下中間数
と呼ぶ)を算出する第1算出手段と、出力手段により出
力された部分乗数と、当該部分乗数に対応して第1算出
手段により算出された前記中間数との積を部分積として
算出する第2算出手段と、第2算出手段に算出された部
分積を累算する累算手段と、累算手段に累算された累算
値にpの整数倍の値を加減算することにより、累算値を
所定のビット数を越えないように補正する補正手段と、
出力手段により全ての部分乗数が出力されるまで、第1
算出手段による中間数の算出と、第2算出手段による部
分積の算出と、累算手段による累算と、補正手段による
補正とを繰り返し行わせる制御手段とを備え、前記第1
算出手段は、m(mはs以上の整数)ビットにより表現さ
れる各値について、その値の2k倍に対する法pによる
剰余を予め記憶し、制御手段による繰り返しのうち初回
では被乗数を中間数として出力し、2回目以降では、前
回出力された中間数をsビット桁上げし、桁上げ後の中
間数の下位kビットより上位のmビットについてテーブ
ル手段を読み出し、読み出した数と下位kビットとを加
算することにより新たな中間数を算出するよう構成され
る。
Each partial table means Ti has 2 mi corresponding to a value from 0 to (2 mi -1) represented by mi bits.
.. + M (i−1) * α. The j-th entry (j is 0 to 2 mi ) stores j * 2 m1 + ... + M (i−1) * α. The modular multiplication apparatus according to the present invention is a modular multiplication apparatus for calculating a congruent number to a remainder by a modulus p (p is k-bit data) for a product of a multiplicand and a multiplier, wherein the multiplier is s (s
Is an integer of 2 or more). An output means for sequentially outputting s-bit partial multipliers obtained in units of bits from the lower side, and carrying the multiplicand in accordance with the order of each partial multiplier, and adding the multiplicand after the carry On the other hand, a first calculating means for calculating a number (hereinafter referred to as an intermediate number) congruent with the remainder by the modulus p, a partial multiplier outputted by the output means, and a first calculating means corresponding to the partial multiplier by the first calculating means Second calculating means for calculating a product of the intermediate number obtained as a partial product, accumulating means for accumulating the partial product calculated by the second calculating means, and an accumulated value accumulated by the accumulating means Correction means for correcting the accumulated value so as not to exceed a predetermined number of bits by adding or subtracting an integer multiple of p to
Until all partial multipliers are output by the output means, the first
Control means for repeatedly performing the calculation of the intermediate number by the calculation means, the calculation of the partial product by the second calculation means, the accumulation by the accumulation means, and the correction by the correction means;
For each value represented by m (m is an integer equal to or more than s) bits, the calculating means stores in advance the remainder of the value by modulo p for 2 k times the value, and in the first iteration of the control means, calculates the multiplicand as the intermediate number In the second and subsequent times, the intermediate number output last time is carried by s bits, the table means is read out for m bits higher than the lower k bits of the carried intermediate number, and the read number and the lower k bits are read out. Is added to calculate a new intermediate number.

【0021】また前記制御手段は、第1〜第3ステージ
を含むパイプライン処理を制御する、第1ステージでは
出力手段に部分乗数を出力させるとともに第1算出手段
に中間数を出力させ、第2ステージでは第2算出手段に
部分積を算出させ、第3ステージでは累算手段に累算さ
せるともに補正手段に補正させるよう構成される。また
前記出力手段は、最初に乗数を保持し、保持している値
の下位sビットを部分乗数として出力する乗数保持手段
と、乗数保持手段に保持されている値をsビット下位側
にシフトさせ、シフト後の値を乗数保持手段に出力して
保持させるシフト手段とを備える。
The control means controls the pipeline processing including the first to third stages. In the first stage, the output means outputs a partial multiplier and the first calculation means outputs an intermediate number. In the stage, the second calculating means calculates the partial product, and in the third stage, the accumulating means accumulates and the correcting means corrects the partial product. The output means firstly holds the multiplier, and outputs the lower s bits of the held value as a partial multiplier; and shifts the value held by the multiplier holding means to s bits lower. , And a shift means for outputting the shifted value to the multiplier holding means and holding it.

【0022】また前記第2生成手段は、第i(iは1か
ら(s−1)の整数)のシフト手段は、第1算出手段に
より算出された前記中間数をiビット左シフトにより桁
上げする第1から第(s−1)のシフト手段を備え、前
記第1生成手段は、第1算出手段により算出された前記
中間数をsビット左シフトにより桁上げする第sのシフ
ト手段と、前記中間数の1の補数を生成する補数生成手
段と、定数1を出力する定数出力手段とを備え、前記第
2加算手段は、全ビットが1であると判定された場合
に、第sのシフト手段の出力と、補数生成手段に生成さ
れた1の補数と、定数1を選択し、全ビットが1である
と判定されなかった場合に、部分乗数の2 0の位が”
1”であれば前記中間数を選択し、部分乗数の2iの位
が”1”であれば、第iのシフト手段の桁上げ結果を選
択する選択手段と、選択手段の選択結果を加算すること
により前記部分積を算出する加算器とを備える。
Further, the second generation means may generate an i-th (i is 1 or
(S-1) is used as the first calculating means.
Digit of the intermediate number calculated by i-bit left shift
First to (s-1) th shift means for raising
The first generating means calculates the first value calculated by the first calculating means.
An s-th shift to carry the intermediate number by s-bit left shift
Means for generating a one's complement of the intermediate number
And a constant output means for outputting a constant 1;
The two-addition means is provided when all bits are determined to be 1.
The output of the s-th shift means and the output of the complement generation means.
Selected 1's complement and constant 1 and all bits are 1
Is not determined, the partial multiplier of 2 0Is ranked
If 1 ", the intermediate number is selected, and 2 of the partial multiplier is selected.iRank
Is "1", the carry result of the i-th shift means is selected.
Adding the selection means to be selected and the selection result of the selection means
And an adder for calculating the partial product.

【0023】[0023]

【発明の実施の形態】<第1実施形態>以下に本実施形
態における剰余乗算装置ついて図面を用いて説明する。
本実施形態における剰余乗算装置は、楕円曲線暗号の演
算等に用いられる装置で、被乗数A(160ビット)と
乗数B(160ビット)とが入力されると、(式1)に
示す積A*Bの法P(160ビットの素数)による剰余
R(=A*BmodP)又は剰余Rと剰余体上において
同値の値を算出する。ここにおいて法Pは、αを54ビ
ット以下の値とするときP=2160−αを満たす値であ
る。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS <First Embodiment> A remainder multiplication apparatus according to the present embodiment will be described below with reference to the drawings.
The remainder multiplication device according to the present embodiment is a device used for an operation of elliptic curve cryptography or the like. When a multiplicand A (160 bits) and a multiplier B (160 bits) are input, the product A * shown in (Equation 1) is obtained. The remainder R (= A * BmodP) by the modulus P of P (160-bit prime number) or the same value as the remainder R in the remainder field is calculated. Here, the modulus P is a value that satisfies P = 2 160 −α when α is a value of 54 bits or less.

【0024】本剰余乗算装置は、(式1)を変形させた
(式2)に基づいて構成されている。なお、念のため
(式1)から(式2)への変形過程の詳細を発明の実施
の形態の末尾に示す。
The remainder multiplication apparatus is configured based on (formula 2) obtained by modifying (formula 1). Note that details of the transformation process from (Equation 1) to (Equation 2) are shown at the end of the embodiment of the present invention just in case.

【0025】[0025]

【数3】 (Equation 3)

【0026】[0026]

【数4】 (Equation 4)

【0027】<演算式の説明>(式2)においてR1
は、Rと法Pの剰余体において同値の値である。ここで
RとR1とが法Pの剰余体において同値であるとは、R
1とRとの差がPの整数倍であるということを示す。R
1は、i=1からk/sまでの間、C(i)*b(i)
を累算することによって算出される。ここでkは乗数B
のビット数である。sは、乗数Bを数ビットずつの部分
乗数に分割したときの各部分乗数のビット数である。つ
まりk/sは、部分乗数の個数と同じ値である。ここに
おいてkとsとは、kがsで割り切れる関係になるよう
に定められる。
<Explanation of the arithmetic expression>
Is the same value in the remainder field of R and modulo P. Here, R and R1 have the same value in the modulo P
Indicates that the difference between 1 and R is an integer multiple of P. R
1 is C (i) * b (i) from i = 1 to k / s
Is calculated by accumulating. Where k is a multiplier B
Is the number of bits. s is the number of bits of each partial multiplier when the multiplier B is divided into partial multipliers of several bits. That is, k / s is the same value as the number of partial multipliers. Here, k and s are determined such that k is divisible by s.

【0028】b(i)=b[s*i−1:s*i−s)]
は、乗数Bを下位からsビットずつに分割した部分乗数
を示す。i=1のときb(1)=b[s−1:0]、i
=2のときb(2)=b[2s−1:s]、i=3のと
きb(3)=[3s−1:2s]、...となる。ここ
でkビットの乗数Bを2進数表記した場合、bk−1b
k−2...b2b1b0と表わすものとする。またb
[x:y]は、乗数Bの下位からx+1ビット目からy
+1ビット目(ただしx>y)までのビット列を指すも
のとする。よって例えばb[15:8]は、乗数Bの下
位16ビット目から9ビット目までの部分乗数を指し、
2進数表記によりb15b14b13b12b11b1
0b9b8と表わされる。
B (i) = b [s * i-1: s * is)]
Indicates a partial multiplier obtained by dividing the multiplier B into s bits at a time from the lower order. When i = 1, b (1) = b [s−1: 0], i
= 2, b (2) = b [2s−1: s], i = 3, b (3) = [3s−1: 2s],. . . Becomes Here, when the multiplier B of k bits is expressed in a binary number, bk-1b
k-2. . . It shall be represented as b2b1b0. Also b
[X: y] is y from the (x + 1) th bit from the lower order of the multiplier B
It indicates a bit string up to the + 1st bit (where x> y). Therefore, for example, b [15: 8] indicates a partial multiplier from the lower 16th bit to the 9th bit of the multiplier B,
B15b14b13b12b11b1 in binary notation
0b9b8.

【0029】C(i)は、i=1のときC(1)=A
(Aは被乗数)、2<=i<=k/sのときC(i)≡
C(i−1)*2smodPという漸化式で表わされ
る。つまりC(i)は、C(1)=A(被乗数)、C
(2)≡A*2smodP、C(3)≡(A*2smod
P)*2smodP、...というように漸化的に変化す
る。この漸化式において2sは、sビットの部分乗数b
(i)の桁上げに相当する。C(i)は、1つ前の値で
あるC(i−1)をsビット桁上げした値の法Pによる
剰余である。以下、C(i)を以後中間数と呼ぶことと
する。
C (i) is C (1) = A when i = 1
(A is a multiplicand) When 2 <= i <= k / s, C (i) ≡
It is represented by a recurrence formula C (i-1) * 2 s modP. That is, C (i) is C (1) = A (multiplicand), C (i)
(2) ≡A * 2 s modP , C (3) ≡ (A * 2 s mod
P) * 2 s modP,... In this recurrence formula, 2 s is an s-bit partial multiplier b
This corresponds to the carry of (i). C (i) is the remainder of the value obtained by carrying s bits higher than the previous value C (i-1) by modulo P. Hereinafter, C (i) is hereinafter referred to as an intermediate number.

【0030】このように(式2)においてR1は、i=
1〜k/sの間、被乗数Aについて、sビット桁上げし
た値の法Pによる剰余を中間数C(i)として漸化的に
算出し、また乗数Bを下位からsビットずつの部分乗数
b(i)に分割し、それらの部分積C(i)*b(i)
を求めて累算することを繰り返しk/s回行うことによ
って求められる。以下、R1を算出するために演算をk
/s回繰り返すことを繰り返し処理と呼ぶ。 <剰余乗算装置の構成>図1は、本実施形態における剰
余乗算装置100の概略構成を示すブロック図である。
Thus, in (Equation 2), R1 is i =
Between 1 and k / s, for the multiplicand A, the remainder of the value obtained by carrying s bits carried by the modulo P is recursively calculated as the intermediate number C (i), and the multiplier B is a partial multiplier of s bits at a time from the lower order. b (i) and their partial products C (i) * b (i)
Is calculated by repeatedly performing k / s times. Hereinafter, the calculation for calculating R1 is k
Repeating / s times is called a repetition process. <Structure of Remainder Multiplier> FIG. 1 is a block diagram showing a schematic structure of a remainder multiplier 100 according to the present embodiment.

【0031】同図において剰余乗算装置100は、乗数
分割部11、剰余算出部12、部分積算出部13、累算
部14、補正部15、制御部16から構成される。この
剰余乗算装置100は、k=160、s=8としたとき
の(式2)に基づいて構成されている。乗数分割部11
は、8ビットずつの部分乗数b(i)=b[8i−1:
8i−8](i=1,...,19,20)を乗数Bの
下位側から順次出力する。
In FIG. 1, the remainder multiplying device 100 includes a multiplier division unit 11, a remainder calculation unit 12, a partial product calculation unit 13, an accumulation unit 14, a correction unit 15, and a control unit 16. The remainder multiplication device 100 is configured based on (Equation 2) when k = 160 and s = 8. Multiplier division unit 11
Is a partial multiplier b (i) = b [8i-1:
8i-8] (i = 1,..., 19, 20) are sequentially output from the lower side of the multiplier B.

【0032】剰余算出部12は、中間数C(i)(i=
1,...19,20)を漸化的に算出する。つまり剰余
算出部12は、初回(i=1)は被乗数Aを中間数C
(1)として出力する。2回目以降(i=2,
3,...,20)は前回の中間数C(i−1)を8ビ
ット桁上げして、その桁上げ値C(i−1)*28の法
Pによる剰余を中間数C(i)(i=2,3,...,
20)として算出する。より具体的には、剰余算出部1
2は、初回はA、2回目はA*28modP、3回目は
(A*28modP)*28modP、4回目は((A*
8modP)*28modP)*28modP、...
を中間数C(i)として算出する。ここで剰余算出部1
2が算出するC(i)は、桁上げ値C(i−1)*28
と合同な値であって、Pよりも大きい値である場合もあ
る。
The remainder calculator 12 calculates the intermediate number C (i) (i =
1,... 19, 20) are recursively calculated. That is, the remainder calculating unit 12 calculates the multiplicand A for the first time (i = 1)
Output as (1). From the second time (i = 2,
3,. . . , 20) the previous and the intermediate number C (i-1) was increased 8-bit digits, the carry value C (i-1) * 2 8 modulo P to by the remainder of the intermediate number C (i) (i = 2,3, ...,
20). More specifically, the remainder calculation unit 1
2, the first time A, 2 round of A * 2 8 modP, 3 round of (A * 2 8 modP) * 2 8 modP, 4 th is ((A *
2 8 modP) * 2 8 modP) * 2 8 modP,. . .
Is calculated as an intermediate number C (i). Here, the remainder calculation unit 1
C (i) calculated by 2 is a carry value C (i-1) * 28.
It may be a value that is congruent with and is larger than P.

【0033】剰余の算出が高速に行われるようにするた
め剰余算出部12は、ROMテーブル308、ROMテ
ーブル309を有する。これらのROMは、後に詳しく
説明するが、桁上げ値C(i−1)*28から下位16
0ビットを除いた部分、つまり桁上げによって160ビ
ットを越えた部分に対応する法Pによる剰余を予め記憶
する。剰余算出部12は、桁上げ値C(i−1)*28
の160ビットを越える部分について、これらのROM
を参照し、ROMより得られる160ビットを越える部
分に対応する剰余と、桁上げ値C(i−1)*28の下
位160ビットの部分とを加算することにより中間数C
(i)を算出する。
The remainder calculating section 12 has a ROM table 308 and a ROM table 309 so that the calculation of the remainder can be performed at a high speed. These ROM will be described in detail later, but the lower the carry value C (i-1) * 2 8 16
The remainder from the modulus P corresponding to the portion excluding 0 bits, that is, the portion exceeding 160 bits due to carry, is stored in advance. The remainder calculator 12 calculates the carry value C (i−1) * 2 8
Of these ROMs
It refers to the intermediate number C by adding the remainder corresponding to a portion exceeding the 160 bits obtained from the ROM, and the lower 160 bits of the partial carry value C (i-1) * 2 8
(I) is calculated.

【0034】部分積算出部13は、剰余算出部12より
出力される中間数C(i)と乗数分割部11より出力さ
れる部分乗数b(i)との部分積C(i)*b(i)を
出力する。累算部14は、部分積算出部13より出力さ
れる部分積C(i)*b(i)を累算する。
The partial product calculator 13 calculates the partial product C (i) * b () of the intermediate number C (i) output from the remainder calculator 12 and the partial multiplier b (i) output from the multiplier divider 11. Output i). The accumulator 14 accumulates the partial products C (i) * b (i) output from the partial product calculator 13.

【0035】補正部15は、累算部14による累算結果
に応じて累算値にPの整数倍の値を加減算することによ
って累算値を補正し、それによって累算部14における
累算値の桁あふれを防ぐ。制御部16は、剰余算出部1
2、部分積算出部13、累算部14、補正部15におい
てi=1〜20の20回行われる演算の繰り返し処理を
制御する。また制御部16は、剰余算出部12による中
間数の算出と乗数分割部11による部分乗数の算出とを
第1段階、部分積算出部13による部分積の算出を第2
段階、累算部14による累算値の算出と補正部15によ
る累算値の補正とを第3段階としてパイプライン制御を
行う。さらに制御部16は、20回繰り返し動作させた
後、累算部14における最終的な累算値がPより大きい
場合には、その累算値を剰余算出部12に入力して累算
値のPによる剰余を算出させる。
The correcting section 15 corrects the accumulated value by adding or subtracting a value of an integral multiple of P to the accumulated value according to the result of the accumulation by the accumulating section 14, whereby the accumulation in the accumulating section 14 is performed. Prevent value overflow. The control unit 16 controls the remainder calculation unit 1
2. The repetition processing of the calculation performed 20 times i = 1 to 20 in the partial product calculation unit 13, the accumulation unit 14, and the correction unit 15 is controlled. The control unit 16 performs the first step of calculating the intermediate number by the remainder calculation unit 12 and the calculation of the partial multiplier by the multiplier division unit 11, and performs the second step of calculating the partial product by the partial product calculation unit 13 in the second step.
The pipeline control is performed with the calculation of the accumulated value by the accumulator 14 and the correction of the accumulated value by the corrector 15 as the third stage. Further, after the operation is repeated 20 times, if the final accumulated value in the accumulating unit 14 is larger than P, the control unit 16 inputs the accumulated value to the remainder calculating unit 12 and outputs the accumulated value. The remainder from P is calculated.

【0036】図2は、剰余算出部12のより詳細な構成
図を示す。同図において剰余算出部12は、セレクタ3
01、レジスタA302、シフタ303、セレクタ30
4、剰余演算部311から構成される。セレクタ301
は、制御部16の制御により、まず初期設定(i=1)
として外部より入力される被乗数AをレジスタA302
に出力し、初期設定後(2<=i<=20)は剰余演算
部311より入力される中間数C(i)をレジスタA3
02に出力するセレクタである。
FIG. 2 is a more detailed block diagram of the remainder calculator 12. In the figure, the remainder calculation unit 12
01, register A302, shifter 303, selector 30
4. Remainder operation unit 311 Selector 301
Is initially set (i = 1) under the control of the control unit 16.
A multiplicand A input from outside as a register A302
After the initial setting (2 <= i <= 20), the intermediate number C (i) input from the remainder operation unit 311 is stored in the register A3.
02.

【0037】レジスタA302は、161ビットのレジ
スタであり、初期設定(i=1)として外部よりセレク
タ301を介して入力される被乗数A(=C(1))を
保持し、初期設定後(2<=i<=20)は加算器31
0からセレクタ301を介して入力される中間数C
(i)を保持する。レジスタA302は、出力側が部分
積算出部13とシフタ303とに接続されており、制御
部16の指示に応じて保持している中間数を新たに入力
される中間数に更新し、部分積算出部13とシフタ30
3とに出力する。
The register A302 is a 161-bit register. The register A302 holds a multiplicand A (= C (1)) externally input via the selector 301 as an initial setting (i = 1). <= I <= 20) is the adder 31
An intermediate number C input from 0 through the selector 301
Hold (i). The output side of the register A302 is connected to the partial product calculation unit 13 and the shifter 303, and updates the held intermediate number to a newly input intermediate number in accordance with an instruction of the control unit 16, and calculates the partial product. Section 13 and shifter 30
3 and output.

【0038】シフタ303は、入力を8ビット左シフト
する169ビット幅のシフタであり、レジスタA302
より入力される161ビットの中間数C(i−1)を8
ビット左シフトして169ビットの桁上げ値C(i−
1)*28を出力する。このようにシフタ303は、8
ビットの左シフトを行うことによって中間数C(i−
1)に対して8ビットの桁上げを行う。
The shifter 303 is a 169-bit width shifter for shifting the input to the left by 8 bits.
161-bit intermediate number C (i-1) input from
Shift left by 169 bits and carry 169 bits C (i-
1) to the * 2 8. As described above, the shifter 303
By performing a left shift on the bits, the intermediate number C (i−
An 8-bit carry is performed for 1).

【0039】セレクタ304は、繰り返し処理の間、シ
フタ303より入力される桁上げ値C(i−1)*28
を剰余演算部311に出力し、繰り返し処理の後、累算
部14より入力される累算値を剰余演算部311に出力
する。剰余演算部311は、ROMテーブル308、R
OMテーブル309、加算器310から構成され、シフ
タ303よりセレクタ304を介して入力される桁上げ
値C(i−1)*28又は累算部14より入力される累
算値の法Pによる剰余又は合同な値を出力する。この剰
余または合同な値は161ビットである。
The selector 304 carries the carry value C (i-1) * 2 8 inputted from the shifter 303 during the repetitive processing.
Is output to the remainder operation unit 311, and after the repetition processing, the accumulated value input from the accumulation unit 14 is output to the remainder operation unit 311. The remainder operation unit 311 stores the ROM table 308, R
OM table 309 is composed of the adder 310, according to the law P of accumulated values input from the carry input through the selector 304 from the shifter 303 value C (i-1) * 2 8 or accumulator 14 Output remainder or congruent value. This remainder or congruent value is 161 bits.

【0040】また剰余演算部311は、セレクタ304
から入力される169ビットの値の下位160ビットを
加算器310に入力するバス305と、161〜165
ビット目をROMテーブル308に入力するバス306
と、166〜169ビット目をROMテーブル309に
入力するバス307とを備える。これらのバスは、桁上
げ値C(i−1)*28または累算値を下位側から16
0ビットの部分(以下下位部分と呼ぶ)と5ビットの部
分(以下5ビット部分と呼ぶ)と4ビットの部分(以下
4ビット部分と呼ぶ)とに分割してそれぞれ加算器31
0とROMテーブル308とROMテーブル309とに
入力する。
The remainder operation unit 311 includes a selector 304
A bus 305 for inputting the lower 160 bits of the 169-bit value input from the adder 310 to the adder 310;
A bus 306 for inputting a bit into a ROM table 308
And a bus 307 for inputting the 166th to 169th bits to the ROM table 309. These buses, a carry value C (i-1) * 2 8 or accumulated value from the lower side 16
The adder 31 is divided into a 0-bit portion (hereinafter referred to as a lower portion), a 5-bit portion (hereinafter referred to as a 5-bit portion), and a 4-bit portion (hereinafter referred to as a 4-bit portion).
0, ROM table 308, and ROM table 309.

【0041】図3(a)(b)は、ROMテーブル30
9及びROMテーブル308の記憶内容を示す。同図
(b)は、ROMテーブル308の記憶内容を示す。R
OMテーブル308は、5ビットで表現される値(00
000)2〜(11111)2を入力値とし、それら各値
を2160倍した値に対する法Pによる剰余を出力値とし
て対応付けて記憶する。同図(b)においてαは、P=
160−αの関係を満たすことからα=2160modPで
ある。よって同図(b)の出力値0、1*α、2*
α、...31*αは、入力値(5ビット部分)を2160
した値の法Pによる剰余である。ここでαは54ビット
以下の値で入力値は5ビットであるのでROMテーブル
308の出力は最大でも59ビットである。ROMテー
ブル308は、制御部16よりread信号が入力され
たときバス306より入力される5ビット部分に対応す
る剰余を読み出して出力する。
FIGS. 3A and 3B show the ROM table 30.
9 and the contents stored in the ROM table 308. FIG. 3B shows the contents stored in the ROM table 308. R
The OM table 308 stores a value represented by 5 bits (00
000) 2 to (11111) 2 input values and associates and stores them each value as an output value the remainder by modulo P for 2 160 times the value. In FIG. 3B, α is P =
Α = 2 160 modP because the relationship of 2 160 −α is satisfied. Therefore, the output values 0, 1 * α, 2 * in FIG.
alpha, ... 31 * alpha is a remainder by law P of the input value (5 bits portion) 2 160 times the value. Here, since α is a value of 54 bits or less and the input value is 5 bits, the output of the ROM table 308 is at most 59 bits. The ROM table 308 reads and outputs the remainder corresponding to the 5-bit portion input from the bus 306 when the read signal is input from the control unit 16.

【0042】同図(a)は、ROMテーブル309の記
憶内容を示す。ROMテーブル309は、4ビットで表
現される値(0000)2〜(1111)2を入力値と
し、それら各値を2165倍した値に対する法Pによる剰
余を出力値として対応付けて記憶する。ここでα=2
160modPであるので、どう図(a)の出力値0、
*32*α、2*32*α、...15*32*αは入力
値(4ビット)を2165倍した値の法Pによる剰余であ
る。αは54ビット以下の値で、入力値は4ビット、3
2は5ビットであるのでROMテーブル309の出力は
最大でも63ビットである。ROMテーブル309は、
制御部16よりread信号が入力されたときバス30
7より入力される4ビット部分に対応する剰余を読み出
して出力する。
FIG. 9A shows the contents stored in the ROM table 309. ROM table 309, the input value is the value (0000) 2 - (1111) 2 represented by 4 bits, are mapped and stored them each value as an output value the remainder by modulo P for 2 165 times the value. Where α = 2
Since it is 160 modP, the output value 0 in FIG.
* 32 * α, 2 * 32 * α, ... 15 * 32 * α is the remainder by law P values were 2 165 times an input value (4 bits). α is a value of 54 bits or less, and the input value is 4 bits, 3 bits.
Since 2 is 5 bits, the output of the ROM table 309 is at most 63 bits. ROM table 309 is
When a read signal is input from the control unit 16, the bus 30
The remainder corresponding to the 4-bit portion input from 7 is read and output.

【0043】このように剰余演算部311においては桁
上げによって160ビットを越えた部分についてROM
テーブル308、ROMテーブル309を用いて剰余を
求めるので、従来のように減算によって剰余を求める構
成よりも高速になる。また、ROMテーブル308、R
OMテーブル309の2つのROMに分けたことにより
入力値の個数がROMテーブル308は25個、ROM
テーブル309は24個と少なくなる。これによりRO
Mテーブル308、ROMテーブル309は、5ビット
部分、4ビット部分それぞれに対応する入力値の検索が
より速くなり、剰余の算出を高速にしている。
As described above, in the remainder operation unit 311, the portion exceeding 160 bits due to the carry is read from the ROM
Since the remainder is obtained by using the table 308 and the ROM table 309, the processing is faster than the conventional configuration in which the remainder is obtained by subtraction. ROM table 308, R
By dividing into two ROMs of the OM table 309, the number of input values is 25 in the ROM table 308,
Table 309 is reduced 2 4. This allows RO
In the M table 308 and the ROM table 309, the search for the input value corresponding to each of the 5-bit portion and the 4-bit portion is faster, and the calculation of the remainder is faster.

【0044】加算器310は、160ビットの下位部分
とROMテーブル308より出力される5ビット部分の
剰余(59ビット)とROMテーブル309より出力さ
れる4ビット部分の剰余(63ビット)とを加えること
によってC(i−1)*28modP又は合同な値を出
力する。と法Pの剰余体上同値の値を出力する。加算器
310が出力する値は、161ビットである。
The adder 310 adds the lower part of 160 bits, the remainder of the 5-bit part output from the ROM table 308 (59 bits), and the remainder of the 4-bit part output from the ROM table 309 (63 bits). and it outputs the C (i-1) * 2 8 modP or congruent values by. And a modulo P on the remainder field. The value output by the adder 310 is 161 bits.

【0045】図4は、乗数分割部11のより詳細な構成
を示す。同図において乗数分割部11は、シフタ50
3、セレクタ501、レジスタB502から構成され
る。セレクタ501は、制御部16の制御により、初期
設定(i=1)として、外部より入力される乗数Bをレ
ジスタB502へ出力し、初期設定後(2<=i)は、
シフタ503より入力される値をレジスタB502へ出
力する。
FIG. 4 shows a more detailed configuration of the multiplier division unit 11. In the figure, the multiplier division unit 11 includes a shifter 50
3, a selector 501 and a register B502. The selector 501 outputs the multiplier B input from the outside to the register B502 as an initial setting (i = 1) under the control of the control unit 16, and after the initial setting (2 <= i),
The value input from the shifter 503 is output to the register B502.

【0046】レジスタB502は、160ビットのレジ
スタであり、初期設定として外部よりセレクタ501を
介して入力される乗数Bを保持し、初期設定後は、シフ
タ503よりセレクタ501を介して入力される値を保
持する。レジスタB502は、出力側がシフタ503に
接続されており、また下位8ビットの部分が部分積算出
部13に接続されている。乗数分割部11は、制御部1
6の制御により保持している値を、シフタ503よりセ
レクタ501を介して新たに入力される値に更新する。
レジスタB502に保持されている値は、シフタ503
に出力されるとともに下位8ビットが部分積算出部13
へ出力される。
The register B 502 is a 160-bit register and holds a multiplier B input from the outside via the selector 501 as an initial setting. After the initial setting, a value input from the shifter 503 via the selector 501 is set. Hold. The output side of the register B502 is connected to the shifter 503, and the lower 8 bits are connected to the partial product calculation unit 13. The multiplier division unit 11 includes the control unit 1
The value held by the control of No. 6 is updated to a value newly input from the shifter 503 via the selector 501.
The value held in the register B 502 is the shifter 503
And the lower 8 bits are output to the partial product calculation unit 13
Output to

【0047】シフタ503は、レジスタB502より入
力される値を8ビット右シフトして出力する160ビッ
トのシフタである。このような構成によって乗数分割部
11は、乗数Bの下位から8ビットずつの部分乗数b
(i)=b[8i−1:8i−8](i=1,...1
9,20)を順次に部分積算出部13に出力する。
The shifter 503 is a 160-bit shifter that shifts the value input from the register B 502 by 8 bits to the right and outputs it. With such a configuration, the multiplier division unit 11 generates a partial multiplier b of 8 bits at a time from the lower order of the multiplier B.
(I) = b [8i-1: 8i-8] (i = 1,... 1
9, 20) are sequentially output to the partial product calculation unit 13.

【0048】図5は、部分積算出部13のより詳細な構
成を示す。同図において部分積算出部13は、シフタ部
512、セレクタ部513、加算器522、加算器52
3、レジスタCa524、レジスタCb525から構成
される。部分積算出部13における演算を式によって表
わすと(式3)のようになる。
FIG. 5 shows a more detailed configuration of the partial product calculator 13. In the figure, the partial product calculation unit 13 includes a shifter unit 512, a selector unit 513, an adder 522, and an adder 52.
3, a register Ca524 and a register Cb525. The operation in the partial product calculation unit 13 is represented by an expression (Expression 3).

【0049】[0049]

【数5】 (Equation 5)

【0050】なお同式においては便宜上、乗数分割部1
1より入力される部分乗数b(i)の2進表記をbi7
bi6bi5bi4bi3bi2bi1bi0としてい
る。同式に示すように、部分積算出部13は、まず剰余
算出部12より入力される中間数C(i)に対して部分
乗数b(i)の各ビットに応じた0〜7ビットの桁上げ
を行い(同式)、次に桁上げされた各値に部分乗数b
(i)の各ビットを乗じ(同式)、最後にそれらを加
算する(同式、)シフタ部512は、バス504
と、入力される値に対してそれぞれ1〜7ビット左シフ
トを行うシフタ505〜511とを備え、同式に相当
する演算を行う。
In this equation, for convenience, the multiplier division unit 1
The binary notation of the partial multiplier b (i) input from 1 is bi7
bi6bi5bi4bi3bi2bi1bi0. As shown in the equation, the partial product calculation unit 13 first converts the intermediate number C (i) input from the remainder calculation unit 12 into a digit of 0 to 7 bits corresponding to each bit of the partial multiplier b (i). Carry (same expression), and then add a partial multiplier b to each value carried
The shifter 512 multiplies each bit of (i) (same equation) and adds them at the end (same equation).
And shifters 505 to 511 that shift the input values to the left by 1 to 7 bits, respectively, and perform an operation corresponding to the same equation.

【0051】すなわちシフタ部512は、剰余算出部1
2より入力される中間数C(i)を部分乗数b(i)の
各ビットの重みに応じた桁上げを行ってセレクタ部51
3に出力する。シフタ505〜511は、入力されるC
(i)に対してそれぞれ1〜7ビットの左シフトを行う
シフタである。つまりシフタ505〜511は、入力さ
れるC(i)に対して、それぞれC(i)*21〜C
(i)*27を出力する。バス504は、中間数C
(i)をそのままセレクタ部513に出力する。
That is, the shifter unit 512 is
The intermediate unit C (i) input from 2 is carried according to the weight of each bit of the partial multiplier b (i), and the selector unit 51
Output to 3. The shifters 505 to 511 input the C
This shifter shifts left by 1 to 7 bits for (i). That is, the shifters 505 to 511 respectively output C (i) * 2 1 to C
(I) * 2 7 to output. Bus 504 has intermediate number C
(I) is output to the selector unit 513 as it is.

【0052】セレクタ部513は、セレクタ514〜5
21を備え、同式に相当する演算を行う。セレクタ5
14〜521は、それぞれシフタ部512よりC(i)
*2 0〜C(i)*27が入力され、乗数分割部11より
b(i)の各ビットbi0〜bi7が入力される。セレ
クタ514〜521は、それぞれに入力される部分乗数
b(i)の各ビットbi0〜bi7の値に応じて、それ
ぞれに入力されるC(i)*20〜C(i)*27か0か
のどちらかを選択して出力する。すなわちセレクタ51
4〜521は、入力されるbin(n=0,1,...,
7)の値が1の場合はC(i)*2n(n=0,
1,...,7)を出力し、binの値が0の場合は0を
出力する。
The selector section 513 includes selectors 514 to 5
21 and performs an operation corresponding to the same equation. Selector 5
14 to 521 are C (i) from the shifter unit 512 respectively.
* 2 0~ C (i) * 27Is input from the multiplier division unit 11
Each bit bi0 to bi7 of b (i) is input. Sele
514-521 are the partial multipliers respectively input
According to the value of each bit bi0 to bi7 of b (i),
C (i) * 2 input to each0~ C (i) * 27Or 0
Select and output either. That is, the selector 51
4 to 521 are input bins (n = 0, 1,...,
If the value of 7) is 1, C (i) * 2n(N = 0,
1, ..., 7) and outputs 0 when the value of bin is 0
Output.

【0053】加算器522は、に相当する演算を行う
加算器であり、セレクタ514〜517より入力される
4つの値を加算した値(以下部分積aという)をレジス
タCa524へ出力する。加算器523は、に相当す
る演算を行う加算器であり、セレクタ518〜521よ
り入力される4つの値を加算した値(以下部分積bとい
う)をレジスタCb525へ出力する。
The adder 522 performs an operation corresponding to the above, and outputs a value obtained by adding four values input from the selectors 514 to 517 (hereinafter referred to as a partial product a) to the register Ca 524. The adder 523 is an adder that performs an operation corresponding to, and outputs a value obtained by adding four values input from the selectors 518 to 521 (hereinafter, referred to as a partial product b) to the register Cb 525.

【0054】レジスタCa524、レジスタCb525
は、それぞれ部分積a、部分積bを保持し、制御部16
の制御により保持している部分積a、部分積bを新しく
入力された値に更新する。レジスタCa524及びレジ
スタCb525の出力側は、累算部14に接続されてお
り、レジスタCa524及びレジスタCb525は、保
持している部分積a、bを累算部14に出力する。
Register Ca524, Register Cb525
Holds the partial product a and the partial product b, respectively.
Is updated to the newly input value. The output sides of the register Ca 524 and the register Cb 525 are connected to the accumulating unit 14, and the register Ca 524 and the register Cb 525 output the held partial products a and b to the accumulating unit 14.

【0055】この部分積aと部分積bとを加え合わせた
値が部分積C(i)*b(i)に相当する。図6は、累
算部14及び補正部15の詳細な構成を示す。累算部1
4は、加算器601及びレジスタS602から構成され
る。レジスタS602は、累算値を保持する170ビッ
トのレジスタであり、制御部16の制御により、保持し
ている累算値を、加算器601から入力される新しい累
算値に更新する。ここでレジスタS602の最上位ビッ
トは、累算値の正負を表わす符合ビットとなる。
The sum of the partial product a and the partial product b corresponds to the partial product C (i) * b (i). FIG. 6 shows a detailed configuration of the accumulation unit 14 and the correction unit 15. Accumulator 1
4 comprises an adder 601 and a register S602. The register S602 is a 170-bit register that holds the accumulated value, and updates the held accumulated value to a new accumulated value input from the adder 601 under the control of the control unit 16. Here, the most significant bit of the register S602 is a sign bit indicating the sign of the accumulated value.

【0056】加算器601は、レジスタS602に保持
される累算値とレジスタCa524及びレジスタCb5
25に保持される部分積aと部分積bと補正部15より
入力される補正値とを加算してレジスタS602に出力
する。補正部15は、レジスタE603、インバータ6
06、セレクタ604、セレクタ605から構成され
る。
The adder 601 calculates the accumulated value held in the register S602 and the registers Ca524 and Cb5.
The partial product a and the partial product b held in the register 25 and the correction value input from the correction unit 15 are added and output to the register S602. The correction unit 15 includes a register E603, an inverter 6
06, a selector 604, and a selector 605.

【0057】レジスタE603は、部分積a及び部分積
bを合わせた値の最大値となり得る値より大きく、かつ
最も近い値を保持する。インバータ606は、レジスタ
E603に保持される510*Pの反転値(以下、¬5
10*Pと表記する)を出力する。セレクタ604は、
制御部16の制御に従って、0と510*Pと¬510
*Pのうちからいずれかを補正値として選択して加算器
601に供給する。
The register E603 holds a value that is larger than and closest to the maximum value of the combined value of the partial products a and b. Inverter 606 has an inverted value of 510 * P held in register E603 (hereinafter referred to as $ 5
10 * P). The selector 604 is
According to the control of the control unit 16, 0, 510 * P and $ 510
Any one of * P is selected as a correction value and supplied to the adder 601.

【0058】セレクタ605は、制御部16の制御に従
って、0または1を加算器601に供給する。ここで制
御部16は、レジスタS602に保持される累算値の正
負に応じてセレクタ604に補正値を選択させ、またセ
レクタ605に0または1を選択させて加算器601に
供給させる。
The selector 605 supplies 0 or 1 to the adder 601 under the control of the control unit 16. Here, the control unit 16 causes the selector 604 to select a correction value according to the sign of the accumulated value held in the register S602, and causes the selector 605 to select 0 or 1 to supply the selected value to the adder 601.

【0059】詳しくは制御部16は、レジスタS602
の最上位ビットが0であれば、セレクタ604に¬51
0*Pを選択させ、セレクタ605に1を選択させる。
これによってレジスタS602に保持される累算値が正
(最上位ビットが0)である場合には、レジスタE60
3からインバータ606、セレクタ604を介して¬5
10*Pが、またセレクタ605を介して1が加算器6
01に供給される。これのおかげで加算器601の次の
加算においては510*Pが減算されることになり、加
算器601及びレジスタS602における桁あふれが予
防される。
More specifically, the control unit 16 sets the register S602
Is 0 in the selector 604,
0 * P is selected, and the selector 605 selects 1.
As a result, when the accumulated value held in the register S602 is positive (the most significant bit is 0), the register E60
From # 3 via inverter 606 and selector 604 to $ 5
10 * P, and 1 via the selector 605
01 is supplied. Due to this, in the next addition of the adder 601, 510 * P is subtracted, and overflow in the adder 601 and the register S602 is prevented.

【0060】制御部16は、レジスタS602に保持さ
れる累算値が負(最上位ビットが1)である場合には、
セレクタ604に0を選択させ、またセレクタ605に
0を選択させる。また制御部16は、i=1〜20の繰
り返し処理が終わり、レジスタS602の保持する値が
最終的な累算値に更新された場合、その累算値の最上位
ビットが1か0かを判定し、1(負を示す)である場合
には、セレクタ604に510*Pを、セレクタ605
に0を選択させ、加算器601においてレジスタS60
2に保持される累算値に510*Pを加える補正を行わ
せる。これによって制御部16は、最終的な累算値が正
になるよう補正させる。また制御部16は、最終的な累
算値の最上位ビットが0(正を示す)場合には、セレク
タ604に0を、セレクタ605に0を選択させ、累算
値の補正が行われないようにする。 <第2実施形態>以下に第2実施形態における剰余乗算
装置について以下に図面を用いて説明する。
When the accumulated value held in the register S602 is negative (the most significant bit is 1), the control unit 16
The selector 604 selects 0, and the selector 605 selects 0. When the repetition processing of i = 1 to 20 is completed and the value held in the register S602 is updated to the final accumulated value, the control unit 16 determines whether the most significant bit of the accumulated value is 1 or 0. If it is 1 (indicating a negative value), 510 * P is assigned to the selector 604 and the selector 605
At the adder 601 and the register S60
Then, a correction for adding 510 * P to the accumulated value held in 2 is performed. Thereby, the control unit 16 corrects the final accumulated value to be positive. When the most significant bit of the final accumulated value is 0 (indicating a positive value), the control unit 16 causes the selector 604 to select 0 and the selector 605 to select 0, and the accumulated value is not corrected. To do. <Second Embodiment> A remainder multiplication device according to a second embodiment will be described below with reference to the drawings.

【0061】本実施形態における剰余乗算装置は、被乗
数A(160ビット)と乗数B(161ビット)とが入
力されると、積A*Bの法P(160ビット)による剰
余R(=A*BmodP)又は剰余Rと剰余体上におい
て同値の値を算出する。ここにおいて法Pは、αを54
ビット以下の値とするときP=2160−αを満たす値で
ある。
When the multiplicand A (160 bits) and the multiplier B (161 bits) are input, the remainder multiplication device in this embodiment calculates the remainder R (= A *) by the modulus P (160 bits) of the product A * B. BmodP) or the remainder R and the same value on the remainder field are calculated. Here, the modulus P is obtained by setting α to 54
When the value is equal to or smaller than the bit, the value satisfies P = 2 160 −α.

【0062】本実施形態の剰余乗算装置も、第1実施形
態と同様(式2)に基づいて構成されている。ただし第
1実施形態においてはs=8であったのに対して第2実
施形態においてはs=9とする。またk/sの部分は、
実際に計算するとk/s=161/9と割り切れないの
で、本実施形態においてはk/sの部分は18と置き換
えるものとする。
The remainder multiplication device of the present embodiment is also configured based on (Equation 2) in the same manner as in the first embodiment. However, s = 8 in the first embodiment, whereas s = 9 in the second embodiment. The part of k / s is
Since k / s = 161/9 is not divisible when actually calculated, the k / s portion is replaced with 18 in this embodiment.

【0063】図7は、第2実施形態における剰余乗算装
置200の概略構成を示すブロック図である。同図にお
いて剰余乗算装置200は、乗数分割部81、剰余算出
部82、部分積算出部83、累算部84、補正部85、
制御部86から構成される。同図の剰余乗算装置200
において剰余算出部82は、1つしかROMテーブルを
有していない点が剰余算出部12と異なる。また図11
において詳細に説明するが、部分積算出部83は部分積
算出部13に対して、その内部の加算器に入力される入
力数を減らして加算器の回路規模がより小さくなるよう
に構成されている。さらに剰余乗算装置100において
桁挙げ値C(i−1)*28の算出は剰余算出部12が
行っていたが、剰余乗算装置200において桁上げ値C
(i−1)*29の算出は、剰余算出部82ではなく部
分積算出部83が行う。
FIG. 7 is a block diagram showing a schematic configuration of a remainder multiplication device 200 according to the second embodiment. In the figure, the remainder multiplication device 200 includes a multiplier division unit 81, a remainder calculation unit 82, a partial product calculation unit 83, an accumulation unit 84, a correction unit 85,
It comprises a control unit 86. The remainder multiplication device 200 of FIG.
Is different from the remainder calculator 12 in that the remainder calculator 82 has only one ROM table. FIG.
As described in detail below, the partial product calculation unit 83 is configured to reduce the number of inputs to the internal adder to the partial product calculation unit 13 so that the circuit scale of the adder becomes smaller. I have. Although more digits mentioned values C (i-1) * 2 8 calculation of the remainder calculation unit 12 in the modular multiplication device 100 is performing the carry value C in the modular multiplication device 200
Calculation of (i-1) * 2 9, the partial product calculating unit 83 instead of the remainder calculation unit 82 is performed.

【0064】その他、乗数分割部81、累算部84、補
正部85、制御部86は、乗数Bが161ビット、sが
9ビットと第1実施形態とビット数が異なっている点か
ら各構成要素における入出力のビット数やレジスタ等の
ビット数が異なってはいるものの、その点を除けば第1
実施形態と同様の構成である乗数分割部81は、9ビッ
トずつの部分乗数b(i)=b[9i−1:9i−9]
(i=1,...,17,18)を乗数Bの下位側から順
次出力する。
In addition, the multiplier division unit 81, the accumulation unit 84, the correction unit 85, and the control unit 86 are different from the first embodiment in that the multiplier B is 161 bits and s is 9 bits, and the number of bits is different from that of the first embodiment. Although the number of input / output bits and the number of bits of registers and the like in the elements are different, except for that point, the first
The multiplier division unit 81 having the same configuration as that of the embodiment includes a partial multiplier b (i) = b [9i-1: 9i-9] in 9-bit units.
(I = 1,..., 17, 18) are sequentially output from the lower side of the multiplier B.

【0065】剰余算出部82は、中間数C(i)(i=
1,...17,18)を漸化的に算出する。つまり剰余
算出部82は、初回(i=1)は、被乗数Aを中間数C
(i)として出力する。2回目以降(i=2,...1
7,18)は前回の中間数C(i−1)の9ビット桁上
げされた桁上げ値C(i−1)*29の法Pによる剰余
C(i−1)*29modPを中間数C(i)として算
出する。より具体的には、剰余算出部82は、初回は
A、2回目はA*29modP、3回目は(A*29mo
dP)*29modP、4回目は、((A*29mod
P)*29modP)*29modP、...を中間数C
(i)として算出する。ただし、剰余算出部82は、中
間数C(i−1)に対する9ビットの桁上げを行わず、
部分積算出部83において算出される桁上げ値C(i−
1)*29を利用してその法Pによる剰余C(i−1)
*29modPを算出する。
The remainder calculator 82 calculates the intermediate number C (i) (i =
1,... 17, 18) are recursively calculated. In other words, the remainder calculating unit 82 sets the multiplicand A to the intermediate number C for the first time (i = 1).
Output as (i). From the second time (i = 2,... 1)
7, 18) is a 9-bit carry been carry value C (i-1) * 2 9 residue C by law P of (i-1) * 2 9 modP previous intermediate number C (i-1) It is calculated as an intermediate number C (i). More specifically, the remainder calculation unit 82 determines that the first time is A, the second time is A * 2 9 modP, and the third time is (A * 2 9 mod
dP) * 2 9 modP, the fourth time is ((A * 2 9 mod)
P) * 2 9 modP) * 2 9 modP, intermediate number ... C
It is calculated as (i). However, the remainder calculation unit 82 does not carry 9 bits to the intermediate number C (i-1),
Carry value C (i−i) calculated by partial product calculation section 83
1) Remainder C (i-1) by modulo P using * 2 9
* 2 Calculate 9 modP.

【0066】剰余の算出が高速に行われるようにするた
め剰余算出部82は、ROMテーブル904を有する。
ROMテーブル904は、桁上げ値C(i−1)*29
から下位160ビットを除いた部分、つまり桁上げによ
って160ビットを越えた部分に対応する法Pによる剰
余を予め記憶する。剰余算出部82は、桁上げ値C(i
−1)*29の160ビットを越える部分についてRO
Mテーブル904を参照し、当該ROMにより得られる
160ビットを越える部分に対応する剰余と、桁上げ値
C(i−1)*29の下位160ビットの部分とを算出
することにより中間数C(i)を算出する。
The remainder calculating section 82 has a ROM table 904 in order to calculate the remainder at high speed.
The ROM table 904 stores the carry value C (i-1) * 2 9
, The remainder of the modulus P corresponding to the portion excluding the lower 160 bits, that is, the portion exceeding 160 bits due to carry, is stored in advance. The remainder calculator 82 calculates the carry value C (i
-1) * 2 RO for the part exceeding 160 bits of 9
Referring to M table 904, an intermediate number C by calculating the remainder corresponding to a portion exceeding the 160 bits obtained by the ROM, and the lower 160 bits of the partial carry value C (i-1) * 2 9 (I) is calculated.

【0067】部分積算出部83は、剰余算出部82より
出力される中間数C(i)と乗数分割部81より出力さ
れる部分乗数b(i)との部分積C(i)*b(i)を
出力する。また部分積算出部83は、剰余算出部82よ
り出力される中間数C(i−1)の9ビットの桁上げ値
を算出して剰余算出部82に出力する。累算部84は、
部分積算出部83により出力される部分積C(i)*b
(i)を累算する。
The partial product calculation unit 83 calculates the partial product C (i) * b () of the intermediate number C (i) output from the remainder calculation unit 82 and the partial multiplier b (i) output from the multiplier division unit 81. Output i). Further, the partial product calculation unit 83 calculates a 9-bit carry value of the intermediate number C (i−1) output from the remainder calculation unit 82 and outputs the result to the remainder calculation unit 82. The accumulator 84
Partial product C (i) * b output by partial product calculation section 83
(I) is accumulated.

【0068】補正部85は、累算部84による累算結果
に応じて累算値にPの整数倍の値を加減算することによ
って累算値を補正し、それによって累算部84における
累算値の桁あふれを防ぐ。制御部86は、乗数分割部8
1、剰余算出部82、部分積算出部83、累算部84、
補正部85においてi=1〜18の18回行われる演算
の繰り返し処理を制御する。また制御部86は、剰余算
出部82による中間数の算出と乗数分割部81による部
分乗数の算出とを第1段階、部分積算出部83による部
分積の算出を第2段階、累算部84による累算値の算出
と補正部85による累算値の補正とを第3段階としてパ
イプライン制御を行う。制御部86は、18回の繰り返
し動作の後、累算部84における最終的な累算値がPよ
り大きい場合には、その累算値を剰余算出部82に入力
して累算値のPによる剰余を算出させる。
The correcting unit 85 corrects the accumulated value by adding or subtracting an integral multiple of P to the accumulated value according to the result of the accumulation by the accumulating unit 84. Prevent value overflow. The control unit 86 controls the multiplier division unit 8
1, remainder calculation unit 82, partial product calculation unit 83, accumulation unit 84,
The correction unit 85 controls the repetitive processing of the calculation performed 18 times for i = 1 to 18. The control unit 86 performs the first step of calculating the intermediate number by the remainder calculation unit 82 and the calculation of the partial multiplier by the multiplier division unit 81, the second step of calculating the partial product by the partial product calculation unit 83, and the accumulation unit 84. , And the correction of the accumulated value by the correction unit 85 is the third stage, and the pipeline control is performed. If the final accumulated value in accumulator 84 is greater than P after 18 repetitions, control unit 86 inputs the accumulated value to remainder calculator 82 and calculates P of accumulated value. Is calculated.

【0069】図8は、剰余算出部82のより詳細な構成
を示す。同図において剰余算出部82は、セレクタ90
1、レジスタA906、セレクタ902、剰余演算部9
07から構成される。セレクタ901は、制御部86の
制御により、まず初期設定(i=1)として外部より入
力される被乗数AをレジスタA906に出力し、初期設
定後(i=2,...17,18)は剰余演算部907
より入力される中間数C(i)をセレクタ901に出力
するセレクタである。
FIG. 8 shows a more detailed configuration of the remainder calculator 82. In the figure, the remainder calculation unit 82 includes a selector 90
1, register A906, selector 902, remainder operation unit 9
07. Under the control of the control unit 86, the selector 901 first outputs an externally input multiplicand A as an initial setting (i = 1) to the register A 906, and after the initial setting (i = 2,. Remainder operation unit 907
This is a selector that outputs the intermediate number C (i) input thereto to the selector 901.

【0070】レジスタA906は、161ビットのレジ
スタであり、初期設定(i=1)として外部よりセレク
タ901を介して入力される被乗数A(=C(1))を
保持し、初期設定後(i=2,...17,18)は、
加算器905からセレクタ901を介して入力される中
間数C(i)を保持する。レジスタA906は、出力側
が部分積算出部83に接続されており、制御部86の指
示に応じて保持している中間数を新たに入力される中間
数に更新し、部分積算出部83に出力する。レジスタA
906は、最終的には剰余乗算値Rを保持する。
The register A 906 is a 161-bit register, holds the multiplicand A (= C (1)) input from the outside via the selector 901 as the initial setting (i = 1), = 2, ... 17,18)
The intermediate number C (i) input from the adder 905 via the selector 901 is held. The output side of the register A 906 is connected to the partial product calculating unit 83, updates the held intermediate number to a newly input intermediate number in accordance with an instruction from the control unit 86, and outputs the updated intermediate number to the partial product calculating unit 83. I do. Register A
906 finally holds the remainder multiplied value R.

【0071】セレクタ902は、繰り返し処理の間、部
分積算出部83より入力される桁上げ値C(i−1)*
9を剰余演算部907に出力し、繰り返し処理の後、
累算部84より入力される累算値を剰余演算部907に
出力する。剰余演算部907は、ROMテーブル904
と加算器905から構成され、部分積算出部83よりセ
レクタ902を介して入力される170ビットの桁上げ
値C(i−1)*29又は累算部84より入力される1
70ビットの累算値の法Pによる剰余又は合同な値を出
力する。この剰余または合同な値は161ビットであ
る。
During the repetition processing, the selector 902 carries the carry value C (i−1) * input from the partial product calculation unit 83.
2 9 is output to the remainder operation unit 907, and after the repetition processing,
The accumulated value input from the accumulation unit 84 is output to the remainder operation unit 907. The remainder operation unit 907 includes a ROM table 904
And is an adder 905, partial calculating unit 83 from 170 bits input via the selector 902 carry value C (i-1) * 2 9 or 1 input from the accumulator 84
The remainder or congruent value of the 70-bit accumulated value by the modulus P is output. This remainder or congruent value is 161 bits.

【0072】剰余演算部907は、セレクタ902から
入力される170ビットの値の下位160ビットを加算
器905に出力するバス908と、下位160ビットを
除く上位10ビット(161〜170ビット目)をRO
Mテーブル904に出力するバス909とを備える。こ
れらバス908及びバス909は、170ビットの値を
下位160ビット(以下下位部分と呼ぶ)と上位10ビ
ット(以下上位部分と呼ぶ)とに分割して、下位部分と
上位部分とをそれぞれ加算器905とROMテーブル9
04とに入力する。
The remainder operation unit 907 outputs a bus 908 for outputting the lower 160 bits of the 170-bit value input from the selector 902 to the adder 905 and the upper 10 bits (161 to 170 bits) excluding the lower 160 bits. RO
A bus 909 for outputting to the M table 904. These buses 908 and 909 divide the 170-bit value into lower 160 bits (hereinafter referred to as a lower part) and upper 10 bits (hereinafter referred to as an upper part), and add a lower part and an upper part to an adder, respectively. 905 and ROM table 9
04 and input.

【0073】図9は、ROMテーブル904の記憶内容
を示す。同図においてROMテーブル904は、10ビ
ットで表現される各値(0000000000)2
(1111111111)2を入力値とし、それら各値
を2 160倍した値に対する法Pによる剰余を出力値とし
て対応付けて記憶する。ROMテーブル904は、制御
部86よりread信号が入力されたときバス909よ
り入力される上位部分に対応する剰余を読み出して出力
する。
FIG. 9 shows the contents stored in the ROM table 904.
Is shown. Referring to FIG.
Each value expressed as a number (000000000000)Two~
(11111111111)TwoAre input values, and each of those values
2 160The output value is the remainder of modulo P for the multiplied value.
And stored in association with each other. ROM table 904 controls
When the read signal is input from the unit 86, the bus 909
Reads and outputs the remainder corresponding to the upper part input
I do.

【0074】加算器905は、ROMテーブル904よ
り出力される上位部分に対する剰余と下位部分とを加え
ることによって161ビットのC(i−1)*29mo
dP又はそれと合同な値を出力する。このように剰余演
算部907においては9ビットの桁上げによって160
ビットを越えた部分についてROMテーブル904を用
いて剰余を求め、その剰余と下位160ビットとを加算
することによって桁上げ値C(i−1)*2の剰余又は
合同な値を求める。
The adder 905 adds the remainder to the upper part output from the ROM table 904 and the lower part to generate C (i-1) * 2 9 mo of 161 bits.
Output dP or its congruent value. As described above, in the remainder operation unit 907, a carry of 9 bits
The remainder beyond the bits is determined using the ROM table 904, and the remainder and the lower 160 bits are added to determine the remainder or congruent value of the carry value C (i-1) * 2.

【0075】この剰余演算部907の内部の構成を従来
技術における剰余算出部3と似た構成にした場合、剰余
演算部907は従来技術に示したようなループ処理(ス
テップ6〜8)を複数回行わなければならず、剰余の算
出に時間がかかる。これに対して本実施形態の剰余演算
部907は、ROMテーブル904における1回の読出
しと加算器905における1回の加算とを行うだけで剰
余を算出するので従来の構成よりも高速になる。
If the internal configuration of the remainder calculation unit 907 is similar to the configuration of the remainder calculation unit 3 in the prior art, the remainder calculation unit 907 performs a plurality of loop processes (steps 6 to 8) as described in the prior art. And the calculation of the remainder takes time. On the other hand, the remainder operation unit 907 of the present embodiment calculates the remainder only by performing one reading in the ROM table 904 and one addition in the adder 905, and thus is faster than the conventional configuration.

【0076】図10は、乗数分割部81のより詳細な構
成を示す。同図において乗数分割部81は、セレクタ8
01、レジスタB802、シフタ803から構成され
る。セレクタ801は、制御部86の制御により、初期
設定(i=1)として、外部より入力される乗数Bをレ
ジスタB802へ出力し、初期設定後(i=2,...17,1
8)は、シフタ803より入力される値をレジスタB8
02へ出力する。
FIG. 10 shows a more detailed configuration of the multiplier division unit 81. In the figure, the multiplier division unit 81 includes a selector 8
01, a register B 802, and a shifter 803. The selector 801 outputs the multiplier B input from the outside to the register B 802 as the initial setting (i = 1) under the control of the control unit 86, and after the initial setting (i = 2,.
8) stores the value input from the shifter 803 in the register B8.
02 is output.

【0077】レジスタB802は、161ビットのレジ
スタであり、初期設定として外部よりセレクタ801を
介して入力される乗数Bを保持し、初期設定後は、シフ
タ803よりセレクタ801を介して入力される値を保
持する。レジスタB802は、出力側がシフタ803に
接続されており、また下位9ビットの部分が部分積算出
部83に接続されている。レジスタB802は、制御部
16の制御により保持している値を、シフタ803より
セレクタ801を介して新たに入力される値に更新す
る。レジスタB802に保持されている値は、シフタ8
03に出力されるとともに下位9ビットが部分積算出部
83へ出力される。
The register B 802 is a 161-bit register and holds a multiplier B input from the outside via the selector 801 as an initial setting. After the initial setting, a value input from the shifter 803 via the selector 801 is set. Hold. The output side of the register B 802 is connected to the shifter 803, and the lower 9 bits are connected to the partial product calculator 83. The register B 802 updates the value held under the control of the control unit 16 to a value newly input from the shifter 803 via the selector 801. The value held in the register B 802 is the shifter 8
03 and the lower 9 bits are output to the partial product calculator 83.

【0078】シフタ803は、レジスタB802より入
力される値を9ビット右シフトして出力する161ビッ
トのシフタである。このような構成によって剰余算出部
82は、乗数Bの下位から9ビットずつの部分乗数b
(i)=b[9i−1:9i−9](i=1,...1
7,18)を順次に部分積算出部83に出力する。 <部分積算出方法>ここで部分積算出部83の詳細な構
成を説明する前に、部分積算出部83の構成の基礎とな
っている2つの積算出方法について説明する。
The shifter 803 is a 161-bit shifter that shifts the value input from the register B 802 by 9 bits to the right and outputs it. With such a configuration, the remainder calculation unit 82 calculates the partial multiplier b of the lower 9 bits of the multiplier B in units of 9 bits.
(I) = b [9i-1: 9i-9] (i = 1,... 1
7, 18) are sequentially output to the partial product calculation unit 83. <Partial Product Calculation Method> Before describing the detailed configuration of the partial product calculation unit 83, two product calculation methods that are the basis of the configuration of the partial product calculation unit 83 will be described.

【0079】被乗数Xと3ビットの乗数Y(=y2y1
y0)との積は、(式4)のように展開される。
The multiplicand X and the 3-bit multiplier Y (= y2y1
The product with y0) is expanded as in (Equation 4).

【0080】[0080]

【数6】 (Equation 6)

【0081】つまり(式4)において積X*Yは、被乗
数Xと乗数Yの各桁の重み(22,21,20)と各桁の
値(y2,y1,y0)とを乗じて得られる値(X*2
2*y2,X*21*y1,X*20*y0、以下ビット
積と呼ぶ)を加算することにより算出される。具体的に
は例えば、Y=101のとき(式4)はX*Y=X*2
2*y2+X*20*y0であり、X*Yは2つの値(以
下ビット積と呼ぶ)の加算によって算出される。Y=1
10のとき(式4)はX*Y=X*22*y2+X*21
*y1であり、X*Yは2つのビット積の加算によって
算出される。Y=111のとき(式4)はX*Y=X*
2*y2+X*21*y1+X*20*y0であり、X
*Yは3つのビット積の加算によって算出される。
That is, in equation (4), the product X * Y is obtained by multiplying the weight (2 2 , 2 1 , 2 0 ) of each digit of the multiplicand X and the multiplier Y by the value (y2, y1, y0) of each digit. (X * 2
2 * y2, X * 2 1 * y1, X * 2 0 * y0, hereinafter referred to as a bit product). Specifically, for example, when Y = 101 (Equation 4), X * Y = X * 2
2 * y2 + X * 2 0 * y0, and X * Y is calculated by adding two values (hereinafter referred to as a bit product). Y = 1
When 10 (Equation 4) is X * Y = X * 2 2 * y2 + X * 2 1
* Y1, and X * Y is calculated by adding two bit products. When Y = 111 (Equation 4), X * Y = X *
2 2 * y2 + X * 2 1 * y1 + X * 2 0 * y0 and X
* Y is calculated by adding three bit products.

【0082】このように被乗数に対して乗数の各桁の重
みと各桁の値とを乗じて得られるビット積を加算するこ
とにより積を算出する方法を一般算出方法と呼ぶことと
する。第1実施形態における剰余算出部12も、この方
法に基づいて構成されている。ところで111=23
1である。よってY=111のとき積X*Yは、被乗数
Xに111を乗じる代わりに23−1を乗じることによ
っても算出することができる。被乗数Xと23−1と積
は次のように展開される。
The method of calculating the product by adding the bit product obtained by multiplying the multiplicand by the weight of each digit of the multiplier and the value of each digit is referred to as a general calculation method. The remainder calculation unit 12 in the first embodiment is also configured based on this method. By the way, 111 = 2 3
It is one. Therefore, when Y = 111, the product X * Y can also be calculated by multiplying the multiplicand X by 2 3 -1 instead of multiplying by 111. The product of the multiplicand X and 2 3 -1 is expanded as follows.

【0083】[0083]

【数7】 (Equation 7)

【0084】つまり(式5)においてY=111のとき
積X*Yは、被乗数Xに23を乗じた値から被乗数Xを
減算することにより算出される。またY’=11100
0のとき、Y’=Y*23であるから積X*Y’は被乗
数Xに111000を乗じる代わりに26−23を乗じる
ことによっても算出することができる。
That is, when Y = 111 in (Equation 5), the product X * Y is calculated by subtracting the multiplicand X from the value obtained by multiplying the multiplicand X by 2 3 . Also, Y ′ = 11100
When 0, Y '= Y * 2 3 a is because the product X * Y' can also be calculated by multiplying the 2 6-2 3 instead of multiplying the 111000 to the multiplicand X.

【0085】以上により乗数において2pの位(下位か
らp+1ビット目)から2q(下位からq+1ビット目)
の位(ただしp>q)が全て1であるとき、その部分にお
ける積は被乗数に2p+1を乗じた値(以下被減数ともい
う)から被乗数に2q(以下減数ともいう)を乗じた値
を減ずることによって算出することができる。この方法
を特別算出方法と呼ぶこととする。
[0085] 2 p's place in the multiplier by more than (p + 1 bit from the low-order) from 2 q (q + 1 bit from the low-order)
When all places (where p> q) are 1, the product in that part is obtained by multiplying the multiplicand by 2 p + 1 (hereinafter also referred to as the divisor ) and multiplying the multiplicand by 2 q (hereinafter also referred to as the decrement). It can be calculated by subtracting the value. This method is called a special calculation method.

【0086】ところで加算器においてsとtとの減算値
s−tは、sとtの反転値(1の補数)と定数1との加
算に置きかえられて算出される。よって乗数において2
pの位(下位からp+1ビット目)から2q(下位からq+
1ビット目)の位(ただしp>q)が全て1である場合、
その部分について特別算出方法によって積を算出すると
すれば、加算器は被乗数の2p+1倍と被乗数の2q倍の反
転値(以下単に反転値ともいう)と定数1との加算を行
うだけでよい。しかも定数1の加算は加算器の下位ビッ
トのキャリーインを利用して実現することができる。つ
まり特別算出方法によって積を算出する場合、加算器は
2つの加算とキャリーインとを行うだけでよい。
In the adder, the subtraction value st of s and t is calculated by replacing the inverted value of s and t (1's complement) with the constant 1. Therefore, the multiplier is 2
p of the place from 2 q (lower from (p + 1 bit from the low-order) q +
When the order of the first bit) (where p> q) is all 1,
Assuming that the product is to be calculated for that part by a special calculation method, the adder simply adds a constant 1 and an inverted value (hereinafter simply referred to as an inverted value) of 2 p + 1 times the multiplicand and 2 q times the multiplicand. Is fine. Moreover, the addition of the constant 1 can be realized by using the carry-in of the lower bit of the adder. That is, when calculating the product by the special calculation method, the adder only needs to perform two additions and carry-in.

【0087】これに対してnビットの乗数の全ビットが
1である場合、一般算出方法によって積を算出するとす
れば、加算器はn個のビット積の加算を行う必要があ
る。以上のことから乗数中1が3以上連続して並ぶ場
合、その部分については、一般算出方法によるよりも特
別算出方法によって積を算出するほうが加算器における
加算の数を減らすことができるので、加算器の規模の縮
小と加算量の負荷軽減とを実現できる。部分積算出部8
3は、上記2つの方法に基づいて部分積C(i)*b
(i)を算出するよう構成される。
On the other hand, when all bits of the n-bit multiplier are 1, if the product is calculated by the general calculation method, the adder needs to add n bit products. From the above, when three or more 1s in the multiplier are consecutively arranged, the number of additions in the adder can be reduced by calculating the product by the special calculation method rather than by the general calculation method. It is possible to reduce the size of the container and reduce the load on the amount of addition. Partial product calculator 8
3 is a partial product C (i) * b based on the above two methods.
(I) is calculated.

【0088】部分積算出部83は、部分乗数b(i)の
ビット列において1が連続している部分に特別算出方法
を適用し、それ以外の部分については一般算出方法を適
用する。より具体的には、部分積算出部83は、9ビッ
トの部分乗数b(i)が111111111である場合
と、部分乗数b(i)の上位6ビット又は下位6ビット
が111111である場合と、上位3ビット又は中位3
ビット又は下位3ビットが111である場合にその部分
について特別算出方法を適用し、それ以外は一般算出方
法を適用する。
The partial product calculation unit 83 applies a special calculation method to a part where 1s are continuous in the bit string of the partial multiplier b (i), and applies a general calculation method to the other parts. More specifically, the partial product calculation unit 83 calculates a case where the 9-bit partial multiplier b (i) is 111111111, a case where the upper 6 bits or lower 6 bits of the partial multiplier b (i) is 111111, Upper 3 bits or middle 3
If the bit or the lower three bits are 111, the special calculation method is applied to that part, and otherwise the general calculation method is applied.

【0089】例えば、部分乗数b(i)が111111
011である場合、部分積算出部83は、上位6ビット
の111111の部分に特別算出方法を適用し、下位3
ビットの010の部分に一般算出方法を適用して積C
(i)*b(i)する。ただしこのとき、上位6ビット
の111111は、下位から3ビット桁上げされた値
(23倍した値)であるので、部分積算出部83は、特
別算出方法を適用する際には上位6ビットの部分に対し
て23の桁上げを行わなければならない。
For example, if the partial multiplier b (i) is 111111
In the case of 011, the partial product calculation unit 83 applies the special calculation method to the upper 6 bits 111111,
Applying the general calculation method to the bit 010, the product C
(I) * b (i). However this time, the upper 6 bits 111111 are the 3-bit carry value from the lower (2 3 times the value), partial product calculating section 83, the upper 6 bits when applying a special calculation method It must be performed 2 3 of carry for the part.

【0090】具体的には(式6)のように展開される。Specifically, it is expanded as shown in (Equation 6).

【0091】[0091]

【数8】 (Equation 8)

【0092】(式6)に示すように上位6ビットの11
1111については特別算出方法の適用と23の桁上げ
とにより同式のように展開される。すなわち部分積算
出部83は、中間数C(i)を9ビット桁上げした値と
中間数C(i)を3ビット桁上げした値と定数1との加
算によって上位6ビットの111111の部分における
積を算出する。また下位3ビットの011については一
般算出方法の適用により同式のように展開される。す
なわち部分積算出部83は、下位3ビットの011の値
に応じて、中間数C(i)を1ビット桁上げした値と中
間数C(i)との加算によって下位3ビットの011の
部分における積を算出する。
As shown in (Equation 6), the upper 6 bits 11
It is expanded as in the equation by the application of a special calculation method and the 2 3 carry about 1111. That is, the partial product calculation unit 83 adds the value obtained by carrying the intermediate number C (i) by 9 bits, the value obtained by carrying the intermediate number C (i) by 3 bits, and the constant 1 to the upper 6 bits 111111. Calculate the product. The lower three bits 011 are developed as in the same equation by applying the general calculation method. That is, the partial product calculation unit 83 adds the value obtained by raising the intermediate number C (i) by one bit and the intermediate number C (i) in accordance with the value of 011 of the lower 3 bits to obtain the 011 part of the lower 3 bits. Is calculated.

【0093】図11は、部分積算出部83のより詳細な
構成を示す。同図において部分積算出部83は、シフタ
部51、選択部52、OR回路513、加算器A70
1、加算器B702、レジスタCa844、レジスタC
b845から構成される。シフタ部51は、バス830
とシフタ831〜839とを有する。バス830は、入
力される161ビットの中間数C(i)をそのまま選択
部52へ出力する。シフタ831〜839は、それぞれ
入力される中間数C(i)を左に1〜9ビットシフトさ
せることにより中間数C(i)を1〜9ビット桁上げし
てC(i)*2、C(i)*22、C(i)*23、C
(i)*24、C(i)*25、C(i)*26、C
(i)*27、C(i)*28、C(i)*29を生成し
て選択部52に出力する。またシフタ839は、中間数
C(i)を左に9ビットシフトさせて選択部52に出力
すると同時に、その値を桁上げ値C(i−1)*29
して剰余算出部82に出力する。
FIG. 11 shows a more detailed configuration of the partial product calculator 83. In the figure, the partial product calculation unit 83 includes a shifter unit 51, a selection unit 52, an OR circuit 513, and an adder A70.
1, adder B702, register Ca844, register C
b845. The shifter unit 51 includes a bus 830
And shifters 831 to 839. The bus 830 outputs the input 161-bit intermediate number C (i) to the selection unit 52 as it is. The shifters 831 to 839 shift the input intermediate number C (i) to the left by 1 to 9 bits, thereby raising the intermediate number C (i) by 1 to 9 bits, and C (i) * 2, C (i) * 2 2, C (i) * 2 3, C
(I) * 24 , C (i) * 25 , C (i) * 26 , C
(I) * 27 , C (i) * 28 , and C (i) * 29 are generated and output to the selection unit 52. The shifter 839 outputs an intermediate number C (i) and simultaneously outputs to the selection unit 52 by 9-bit shift to the left, the remainder calculation unit 82 that value as the carry value C (i-1) * 2 9 .

【0094】シフタ部51において、バス830とシフ
タ831〜838の出力、すなわちC(i)、C(i)
*21C、...、C(i)*28は一般算出方法による
算出の際のビット積の候補となる値である。シフタ83
3、836、839の出力、すなわちC(i)*23
C(i−1)*26、C(i−1)*29は、特別算出方
法による算出の際の被減数の候補となる値である。また
バス830、シフタ833、836の出力、すなわちC
(i)、C(i)*23、C(i−1)*26は、特別算
出方法による算出の際、減数の候補となる値である。以
下これらの候補となる値を候補値と呼ぶこととする。
In shifter section 51, outputs of bus 830 and shifters 831 to 838, ie, C (i) and C (i)
* 2 1 C,. . . , C (i) * 2 8 is a candidate to become the value of the bit product during calculation by the general calculation method. Shifter 83
3, 836, 839, ie C (i) * 2 3 ,
C (i-1) * 2 6, C (i-1) * 2 9 is a candidate to become the value of the minuend during calculation by special calculation method. The outputs of the bus 830 and the shifters 833 and 836, that is, C
(I), C (i) * 23 , and C (i-1) * 26 are values that are candidates for the reduction in the calculation by the special calculation method. Hereinafter, these candidate values will be referred to as candidate values.

【0095】選択部52は、シフタ部51より0〜9ビ
ット桁上げされた値と乗数分割部81からの部分乗数b
(i)とが入力されると、9ビットの部分乗数b(i)
が111111111であるか否か、部分乗数b(i)
の上位6ビット又は下位6ビットが111111である
か否か、上位3ビット又は中位3ビット又は下位3ビッ
トが111であるか否かを判定する。次に選択部52
は、その判定に応じてシフタ部51から入力される候補
値のうちのいくつかを選択する。より詳しくは、選択部
52は、肯定的に判定された部分については、候補値の
中からその部分に対応する被減数と減数とを選択する。
選択部52は、否定的に判定された部分については、候
補値の中からその部分に対応するビット積を選択する。
選択部52は、選択された候補値のうち、被減数とビッ
ト積についてはそのまま加算器A701又は加算器B7
02に出力する。選択部52は、選択された候補値のう
ち、減数については、その値を反転させた反転値と定数
1とを生成して、生成した値を加算器A701又は加算
器B702に出力する。
The selector 52 has a value obtained by carrying 0 to 9 bits from the shifter 51 and a partial multiplier b from the multiplier divider 81.
When (i) is input, a 9-bit partial multiplier b (i)
Is 111111111 or not, the partial multiplier b (i)
It is determined whether the upper 6 bits or lower 6 bits are 111111, and whether the upper 3 bits, middle 3 bits or lower 3 bits are 111. Next, the selection unit 52
Selects some of the candidate values input from the shifter unit 51 according to the determination. More specifically, the selection unit 52 selects a minuend and a subtrahend corresponding to the part, from the candidate values, for the part determined to be positive.
The selection unit 52 selects a bit product corresponding to the part from the candidate values for the part determined to be negative.
The selecting unit 52 determines whether the minuend and the bit product among the selected candidate values are the adder A701 or the adder B7.
02 is output. The selection unit 52 generates an inverted value obtained by inverting the value of the subtraction value among the selected candidate values and a constant 1, and outputs the generated value to the adder A 701 or the adder B 702.

【0096】選択部52は、演算値選択器840、84
1、842を備える。図12は、演算値選択器840、
841、842の詳細な構成を示す。演算値選択器84
0は、インバータ1301、セレクタ1302、130
3、制御回路1304を備える。また演算値選択器84
0は、入力端子S、Z、I0、I1、I2、I3、出力
端子F、O0、O1を備える。
The selection section 52 has operation value selectors 840 and 84.
1, 842. FIG. 12 shows an operation value selector 840,
The detailed configuration of 841 and 842 is shown. Calculation value selector 84
0 is an inverter 1301, selectors 1302, 130
3. A control circuit 1304 is provided. The operation value selector 84
0 has input terminals S, Z, I0, I1, I2, I3 and output terminals F, O0, O1.

【0097】インバータ1301は、入力端子I0より
候補値C(i)が減数として入力されると、その減数を
反転させた反転値をセレクタ1303に出力する。セレ
クタ1303は、インバータ1301より入力端子¬I
0を介して候補値C(i)の反転値が、入力端子Zより
0が、入力端子I0より候補値C(i)が、入力端子I
1より候補値C(i)*21が入力されると、制御回路
1304の入出力論理に従ってこれらの入力端子のうち
から1つを選択し、選択した入力端子より入力される値
を出力端子O0より出力する。
When the candidate value C (i) is input as a subtraction from the input terminal I0, the inverter 1301 outputs an inverted value obtained by inverting the subtraction to the selector 1303. Selector 1303 receives input terminal #I from inverter 1301.
0, the inverted value of the candidate value C (i) is 0 from the input terminal Z, and the candidate value C (i) from the input terminal I0 is the input terminal I
When the candidate value C (i) * 2 1 is input from 1, one of these input terminals is selected according to the input / output logic of the control circuit 1304, and the value input from the selected input terminal is output to the output terminal. Output from O0.

【0098】セレクタ1302は、入力端子Zより0
が、入力端子I1より候補値C(i)*21が、入力端
子I2より候補値C(i)*22が、入力端子I3より
候補値C(i)*23が入力されると、制御回路130
4の入出力論理に従ってこれらの入力端子のうちから1
つを選択し、選択した入力端子より入力される値を出力
端子O1より出力する。
The selector 1302 receives 0 from the input terminal Z.
But if the candidate value C from the input terminal I1 (i) * 2 1 is the candidate value C (i) * 2 2 from the input terminal I2, the input terminal I3 candidate value C (i) * 2 3 is input , Control circuit 130
4 of these input terminals according to the input / output logic of 4.
One is selected, and the value input from the selected input terminal is output from the output terminal O1.

【0099】制御回路1304は、入力端子Sより部分
乗数b(i)が入力されると、図13(c)に示す入出
力論理に基づいてセレクタ1302及び1303に入力
端子の1つを選択させて、その入力端子から入力される
値を出力端子O1、O0より出力させる。また制御回路
1304は、セレクタ1303に入力端子¬I0を選択
させたとき、出力端子Fより1を出力する。それ以外の
とき、制御回路1304は、出力端子Fより0を出力す
る。
When the partial multiplier b (i) is input from the input terminal S, the control circuit 1304 causes the selectors 1302 and 1303 to select one of the input terminals based on the input / output logic shown in FIG. Then, the value input from the input terminal is output from the output terminals O1 and O0. When the selector 1303 selects the input terminal # I0, the control circuit 1304 outputs 1 from the output terminal F. Otherwise, the control circuit 1304 outputs 0 from the output terminal F.

【0100】図13(c)は、制御回路1304に入力
される部分乗数b(i)と入出力論理を示す。同図
(c)の1列目は、入力端子Sより入力される部分乗数
b(i)を示す。“−”は、1か0かの任意の値を示
し、“###”は、“111”以外の任意の値を示す。
2列目は、セレクタ1302に選択させる入力端子を示
す。3列目は、セレクタ1303に選択させる入力端子
を示す。4列目は、制御回路1304が出力端子Fより
出力する値で、1のとき定数1を示す。
FIG. 13C shows the partial multiplier b (i) input to the control circuit 1304 and the input / output logic. The first column in FIG. 9C shows the partial multiplier b (i) input from the input terminal S. “−” Indicates an arbitrary value of 1 or 0, and “####” indicates an arbitrary value other than “111”.
The second column shows input terminals to be selected by the selector 1302. The third column shows input terminals to be selected by the selector 1303. The fourth column indicates a value output from the output terminal F by the control circuit 1304, and indicates a constant 1 when the value is 1.

【0101】例えば、制御回路1304は、部分乗数b
(i)の下位6ビットすべてが1であると判定した場合
は、出力端子O1より0を、出力端子O0よりC(i)
の反転値を出力させ、出力端子Fより定数1を出力す
る。下位6ビットすべてが1であると判定しなかった場
合であって、下位3ビットすべてが1であると判定した
場合は、制御回路1304は、出力端子O1よりC
(i)*23を出力させ、出力端子O0よりC(i)を
出力させ、出力端子Fより定数1を選択する。その他の
場合、制御回路1304は、部分乗数b(i)の下位3
ビットの値に応じて出力端子O1、O0よりC(i)*
2、C(i)*21、C(i)、0のうちのいずれか2
つの値を出力させる。
For example, the control circuit 1304 calculates the partial multiplier b
If it is determined that all the lower 6 bits of (i) are 1, 0 is output from the output terminal O1 and C (i) is output from the output terminal O0.
And outputs a constant 1 from an output terminal F. If it is not determined that all of the lower 6 bits are 1 and if it is determined that all of the lower 3 bits are 1, the control circuit 1304 outputs a C signal from the output terminal O1.
(I) Output * 2 3 , output C (i) from the output terminal O0, and select a constant 1 from the output terminal F. In other cases, the control circuit 1304 determines the lower three bits of the partial multiplier b (i).
C (i) * from output terminals O1 and O0 according to the bit value
Any one of 2 2 , C (i) * 2 1 , C (i), 0
Output two values.

【0102】演算値選択器841は、インバータ130
1、セレクタ1302、1303、制御回路1305を
備える。また演算値選択器841は、入力端子S、Z、
I0、I1、I2、I3、出力端子F、O0、O1を備
える。演算値選択器841は、演算値選択器840に対
して制御回路1304の代わりに制御回路1305を備
える点が異なっている。制御回路1305は、入力端子
Sより部分乗数b(i)が入力されると、図13(b)
に示す入出力論理に基づいてセレクタ1302及び13
03に入力端子の1つを選択させて、その入力端子から
入力される値を出力端子O1、O0より出力させる。そ
の他の構成要素は、演算値選択器840と同様であるの
で説明を省略する。
The operation value selector 841 is connected to the inverter 130
1, a selector 1302, 1303, and a control circuit 1305. The operation value selector 841 has input terminals S, Z,
It has I0, I1, I2, I3 and output terminals F, O0, O1. The operation value selector 841 is different from the operation value selector 840 in that a control circuit 1305 is provided instead of the control circuit 1304. When the partial multiplier b (i) is input from the input terminal S to the control circuit 1305, FIG.
Selectors 1302 and 13 based on the input / output logic
03 is made to select one of the input terminals, and the value input from the input terminal is output from the output terminals O1 and O0. The other components are the same as those of the operation value selector 840, and a description thereof will be omitted.

【0103】演算値選択器842は、インバータ130
1、セレクタ1302、1303、制御回路1306を
備える。また演算値選択器842は、入力端子S、Z、
I0、I1、I2、I3、出力端子F、O0、O1を備
える。演算値選択器842は、演算値選択器840に対
して制御回路1304の代わりに制御回路1306を備
える点が異なっている。制御回路1306は、入力端子
Sより部分乗数b(i)が入力されると、図13(a)
に示す入出力論理に基づいてセレクタ1302及び13
03に入力端子の1つを選択させて、その入力端子から
入力される値を出力端子O1、O0より出力させる。そ
の他の構成要素は、演算値選択器840と同様であるの
で説明を省略する。
The operation value selector 842 is connected to the inverter 130
1, a selector 1302, 1303, and a control circuit 1306. The operation value selector 842 includes input terminals S, Z,
It has I0, I1, I2, I3 and output terminals F, O0, O1. The operation value selector 842 differs from the operation value selector 840 in that a control circuit 1306 is provided instead of the control circuit 1304. When the partial multiplier b (i) is input from the input terminal S, the control circuit 1306 enters the state shown in FIG.
Selectors 1302 and 13 based on the input / output logic
03 is made to select one of the input terminals, and the value input from the input terminal is output from the output terminals O1 and O0. The other components are the same as those of the operation value selector 840, and a description thereof will be omitted.

【0104】OR回路513は、演算値選択器840及
び841それぞれの出力端子Fの出力値の論理和をと
る。図13(b)(c)からわかるように、演算値選択
器840及び841において、出力端子Fの一方の出力
が定数1であるときは必ず他方の出力は0である。よっ
てOR回路513は、論理和をとることによって2つの
値を1つにまとめ、これにより選択器52の出力数を減
らしている。
The OR circuit 513 ORs the output values of the output terminals F of the operation value selectors 840 and 841. As can be seen from FIGS. 13B and 13C, in the operation value selectors 840 and 841, when one output of the output terminal F is a constant 1, the other output is always 0. Therefore, the OR circuit 513 combines the two values into one by taking a logical sum, thereby reducing the number of outputs of the selector 52.

【0105】加算器A701は、演算値選択器842の
出力端子O1、O0、Fの出力値と演算値選択器841
の出力端子O1の出力値とを加算して、結果の部分積c
をレジスタCa844に出力する。加算器B702は、
演算値選択器841の出力端子O0の出力値と演算値選
択器840の出力端子O1、O0の出力値とOR回路5
13の出力値とを加算しての出力値とを加算して、結果
の部分積dをレジスタCa845に出力する。
The adder A 701 is connected to the output values of the output terminals O 1, O 0, F of the operation value selector 842 and the operation value selector 841.
And the output value of the output terminal O1 is added to obtain a partial product c
Is output to the register Ca844. The adder B702 is
The output value of output terminal O0 of operation value selector 841, the output values of output terminals O1, O0 of operation value selector 840, and OR circuit 5
13 and the output value obtained by adding the 13 output values, and the resultant partial product d is output to the register Ca845.

【0106】ここにおいて部分積cと部分積dとを加え
合わせた値が部分積C(i)*b(i)である。レジス
タCa844レジスタCb845は、それぞれ部分積c
及び部分積dを保持し、制御部86の制御により保持し
ている部分積c及び部分積dを新しく入力される値に更
新する。レジスタCa844レジスタCb845の出力
側は、累算部84に接続されており、レジスタCa84
4レジスタCb845は、保持している部分積c及び部
分積dを累算部84に出力する。
Here, a value obtained by adding the partial product c and the partial product d is a partial product C (i) * b (i). The register Ca844 and the register Cb845 each have a partial product c
And the partial product d and the partial product c and the partial product d stored under the control of the control unit 86 are updated to newly input values. The output side of the register Ca844 and the register Cb845 is connected to the accumulator 84, and the register Ca84
The four register Cb845 outputs the held partial products c and d to the accumulator 84.

【0107】図14は、累算部84及び補正部85のよ
り詳細な構成を示す。同図において累算部84は、加算
器705及びレジスタS707から構成される。レジス
タS707は、累算値を保持する171ビットのレジス
タであり、制御部86の制御により、保持している累算
値を、セレクタ706から入力される新しい累算値に更
新する。ここでレジスタS707の最上位ビットは、累
算値の正負を表わす符号ビットとなる。
FIG. 14 shows a more detailed configuration of the accumulating section 84 and the correcting section 85. In the figure, the accumulator 84 includes an adder 705 and a register S707. The register S707 is a 171-bit register that holds the accumulated value, and updates the held accumulated value to a new accumulated value input from the selector 706 under the control of the control unit 86. Here, the most significant bit of the register S707 is a sign bit representing the sign of the accumulated value.

【0108】加算器705は、レジスタS707に保持
される累算値とレジスタCa844及びレジスタCb8
45に保持される部分積cと部分積dと補正部85より
入力される補正値とを加算してレジスタS707に出力
する。補正部85は、レジスタE703、インバータ7
08、セレクタ704、セレクタ706から構成され
る。
The adder 705 calculates the accumulated value held in the register S707 and the registers Ca844 and Cb8.
The partial product c and the partial product d held in 45 and the correction value input from the correction unit 85 are added and output to the register S707. The correction unit 85 includes a register E703 and an inverter 7
08, a selector 704, and a selector 706.

【0109】レジスタE703は、部分積c及び部分積
dを合わせた値の最大値と成り得る値より大きく、かつ
最も近い値を保持する。具体的にはレジスタE703
は、122*Pを保持する。インバータ708は、レジ
スタE703に保持される1022*Pの反転値(以
下、¬1022*Pと表記する)を出力する。
The register E703 holds a value that is larger than and closest to the maximum value of the sum of the partial products c and d. Specifically, the register E703
Holds 122 * P. Inverter 708 outputs an inverted value of 1022 * P held in register E703 (hereinafter, referred to as # 1022 * P).

【0110】セレクタ704は、制御部86の制御に従
って、0と1022*Pと¬1022*Pのうちからい
ずれかを補正値として選択してセレクタ706に供給す
る。セレクタ706は、制御部86の制御に従って、0
または1をセレクタ706に供給する。ここで制御部8
6は、レジスタS707に保持される累算値の正負に応
じてセレクタ704に補正値を選択させ、またセレクタ
706に0または1を選択させて加算器705に供給さ
せる。
The selector 704 selects one of 0, 1022 * P and $ 1022 * P as a correction value and supplies it to the selector 706 under the control of the control unit 86. The selector 706 outputs 0 according to the control of the control unit 86.
Alternatively, 1 is supplied to the selector 706. Here, the control unit 8
6 causes the selector 704 to select a correction value according to the sign of the accumulated value held in the register S707, and causes the selector 706 to select 0 or 1 to supply it to the adder 705.

【0111】詳しくは制御部86は、レジスタS707
の最上位ビットが0であれば、セレクタ704に¬10
22*Pを選択させ、セレクタ706に1を選択させ
る。これによってレジスタS707に保持される累算値
が正(最上位ビットが0)である場合には、レジスタE
703からインバータ708、セレクタ704を介して
¬1022*Pが、またセレクタ706を介して1が加
算器705に供給される。これのおかげで加算器705
の次の加算においては1022*Pが減算されることに
なり、加算器705及びレジスタS707における桁あ
ふれが予防される。
More specifically, the control unit 86 sets the register S707
Is 0, the selector 704 supplies $ 10
22 * P, and the selector 706 selects 1. As a result, if the accumulated value held in the register S707 is positive (the most significant bit is 0), the register E
From 703, # 1022 * P is supplied to the adder 705 via the inverter 708 and the selector 704, and 1 is supplied via the selector 706. Thanks to this adder 705
In the next addition, 1022 * P is subtracted, and overflow in the adder 705 and the register S707 is prevented.

【0112】制御部86は、レジスタS707に保持さ
れる累算値が負(最上位ビットが1)である場合には、
セレクタ704に0を選択させ、またセレクタ706に
0を選択させる。また制御部86は、i=1〜18の繰
り返し処理が終わり、レジスタS707の保持する値が
最終的な累算値に更新された場合、その累算値の最上位
ビットが1か0かを判定し、1(負を示す)である場合
には、セレクタ704に1022*Pを、セレクタ70
6に0を選択させ、加算器705においてレジスタS7
07に保持される累算値に1022*Pを加えるという
補正を行わせる。これによって制御部86は、最終的な
累算値が正になるよう補正させる。また制御部86は、
最終的な累算値の最上位ビットが0(正を示す)の場合
には、セレクタ704に0を、セレクタ706に0を選
択させ、累算値の補正が行われないようにする。
When the accumulated value held in the register S707 is negative (the most significant bit is 1), the control unit 86
The selector 704 selects 0, and the selector 706 selects 0. When the repetition processing of i = 1 to 18 is completed and the value held in the register S707 is updated to the final accumulated value, the control unit 86 determines whether the most significant bit of the accumulated value is 1 or 0. If it is 1 (indicating a negative value), 1022 * P is assigned to the selector 704 and the selector 70
6 is set to 0, and the adder 705 selects the register S7
Correction of adding 1022 * P to the accumulated value held in 07 is performed. Thereby, the control unit 86 corrects the final accumulated value to be positive. Also, the control unit 86
When the most significant bit of the final accumulated value is 0 (indicating a positive value), the selector 704 selects 0 and the selector 706 selects 0, so that the accumulated value is not corrected.

【0113】なお部分積算出部83は、図15のように
構成してもよい。同図は、図11に対して、シフタ84
7及びシフタ846を備える点と、演算値選択器84
0、841、842の代わりに演算値選択器850、8
51、852を備える点が異なっている。シフタ847
は、部分乗数b(i)を右に3ビットシフトして出力す
る。
The partial product calculating section 83 may be configured as shown in FIG. This figure is different from FIG.
7 and the shifter 846, and the operation value selector 84
Operation value selectors 850, 8 instead of 0, 841, 842
51 and 852 are different. Shifter 847
Outputs the partial multiplier b (i) shifted right by 3 bits.

【0114】シフタ846は、部分乗数b(i)を左に
3ビットシフトして出力する。図16は、演算値選択器
850、851、852に共通の制御回路の入出力論理
を示す。このように図16に示す部分積算出部83は、
シフタ847及びシフタ846を備えることによって、
右に3ビットシフトさせた部分乗数b(i)と、部分乗
数b(i)そのものと、左に3ビットシフトさせた部分
乗数b(i)とを選択器52に入力させる。こうするこ
とにより演算値選択器850、851、852は、同じ
入出力論理を適用することができる。また演算値選択器
850、851、852がいずれも同じ入出力論理を適
用できるので、制御回路を1つにしても良い。
Shifter 846 shifts partial multiplier b (i) to the left by 3 bits and outputs the result. FIG. 16 shows the input / output logic of the control circuit common to the operation value selectors 850, 851, and 852. Thus, the partial product calculation unit 83 shown in FIG.
By providing the shifters 847 and 846,
The selector 52 inputs the partial multiplier b (i) shifted right by 3 bits, the partial multiplier b (i) itself, and the partial multiplier b (i) shifted left by 3 bits. In this way, the operation value selectors 850, 851, and 852 can apply the same input / output logic. Further, since the same input / output logic can be applied to all of the operation value selectors 850, 851, and 852, a single control circuit may be used.

【0115】また実施形態1において剰余算出部12が
有するROMテーブルは2つ、実施形態2において剰余算
出部82が有するROMテーブルは1つであったが、3つ
以上のROMテーブルを備えるようにしてもよい。 <式の展開>実施形態1における(式1)から(式2)
の変形過程を以下に示しておく。
Although the remainder calculation unit 12 has two ROM tables in the first embodiment and the remainder calculation unit 82 has one ROM table in the second embodiment, three or more ROM tables may be provided. You may. <Expansion of Equation> From (Equation 1) to (Equation 2) in the first embodiment.
The deformation process of is described below.

【0116】[0116]

【数9】 (Equation 9)

【0117】[0117]

【発明の効果】本発明の剰余乗算装置は、被乗数aと乗
数b(bはkbビットのデータ)との積に対して、法p
(pはkビットデータ)による剰余と合同な値を次式の
累算値として算出する剰余乗算装置であって、 累算値 = Σ C(i)*b[s*i+s-1:s*i] (ここでΣはi=0〜[[kb/s]]までの累算を示す。[[kb
/s]]は商kb/sの整数部分であり、iは0から[[k/s]]ま
での整数であり、C(i)は漸化式で表わされi=0のときC
(i)=a、i>=1のときC(i)≡(C(i-1)*2s) mod pであり
(≡は両辺の値が法pにおいて合同であることを示
す)) b[s*i+s-1:s*i]は、kビットの乗数bのうち2s*i+s-1
位から2s*iの位までのsビットの部分乗数であり、前記
剰余乗算装置は、m(mはs以上の整数)ビットにより表
現される各値について、その値の2k倍に対する法pに
よる剰余を予め記憶するテーブル手段と、初回(i=0)
では被乗数aを中間数C(0)として出力し、2回目以降
(i>0)では、前回出力された中間数C(i-1)をsビット
桁上げし、桁上げ後の中間数の下位kビットを除く上位
のmビットについての前記剰余をテーブル手段から読み
出し、読み出した剰余と下位kビットとを加算すること
により新たな中間数(i)を算出する中間数算出手段とを
備え、算出された各中間数C(i)と、それに対応する部分
乗数b[s*i+s-1:s*i]との部分積C(i)*b[s*i+s-1:s*i]を
順次累算することによって前記累算値を算出するよう構
成される。
The remainder multiplication apparatus according to the present invention employs a modulo p for a product of a multiplicand a and a multiplier b (b is kb-bit data).
A remainder multiplication device that calculates a value congruent with a remainder (where p is k-bit data) as an accumulated value of the following equation: accumulated value = ΣC (i) * b [s * i + s-1: s * i] (where Σ indicates the accumulation from i = 0 to [[kb / s]]. [[kb
/ s]] is the integer part of the quotient kb / s, i is an integer from 0 to [[k / s]], and C (i) is represented by a recurrence formula and C when i = 0
When (i) = a, i> = 1, C (i) ≡ (C (i-1) * 2 s ) mod p (≡ indicates that the values on both sides are congruent in the modulus p)) b [s * i + s-1: s * i] is a partial multiplier of s bits from the order of 2 s * i + s-1 to the order of 2 s * i in the multiplier b of k bits, The remainder multiplication device includes, for each value represented by m (m is an integer equal to or greater than s) bits, a table means for storing in advance a remainder of the value by a modulus p with respect to 2 k times the value, and a first time (i = 0)
Outputs the multiplicand a as an intermediate number C (0). From the second time (i> 0), the intermediate number C (i-1) output last time is carried by s bits, and the intermediate number after carry is output. An intermediate number calculating means for reading the remainder for the upper m bits excluding the lower k bits from the table means, and calculating a new intermediate number (i) by adding the read remainder and the lower k bits; Partial product C (i) * b [s * i + s-1: of each calculated intermediate number C (i) and its corresponding partial multiplier b [s * i + s-1: s * i]: s * i] are sequentially accumulated to calculate the accumulated value.

【0118】この構成によれば、テーブル手段はmビッ
トにより表現される各値、つまり0から2m−1に相当
する各値について、それらの値の2K倍に対する法pに
よる剰余を予め記憶する。中間数算出手段は、i>=1
のとき、まず桁上げ後の中間数の下位kビットを除く上
位mビットについての剰余、つまり上位mビットの2k
倍に対する法pによる剰余をテーブル手段から読み出
す。次に中間数算出手段は、テーブル手段より読み出し
た剰余と下位kビットとを加算することにより桁上げ後
の中間数の法pによる剰余又は合同な値を算出する。
According to this configuration, the table means previously stores, for each value represented by m bits, that is, each value corresponding to 0 to 2 m −1, the remainder by modulo p of 2 K times those values. I do. The intermediate number calculating means calculates i> = 1
, First, the remainder of the upper m bits excluding the lower k bits of the intermediate number after the carry, that is, 2 k of the upper m bits
The remainder of the double by the modulus p is read from the table means. Next, the intermediate number calculating means calculates the remainder or congruent value of the intermediate number after carry by the modulus p by adding the remainder read from the table means and the lower k bits.

【0119】ここで桁上げ後の中間数の下位kビット
は、法pによる剰余そのものの値であるか、又は法pに
よる剰余と合同な値である。この合同な値は、剰余より
大きくかつ剰余により近い値である。よって桁上げ後の
中間数について法pによる剰余又は合同な値であって剰
余により近い値を得るには、中間数算出手段は、上位m
ビットについて剰余を得て、これと下位kビットとを加
え合わせればよい。中間数算出手段は、上位mビットの
剰余をテーブル手段から読み出すことによって、桁上げ
後の中間数の法pによる剰余又は合同な値をより短時間
で算出する。
Here, the lower k bits of the intermediate number after the carry are the value of the remainder itself according to the modulus p or a value congruent with the remainder according to the modulus p. This congruent value is a value larger than the remainder and closer to the remainder. Therefore, in order to obtain a remainder or a congruent value according to the modulus p with respect to the intermediate number after the carry, which is closer to the remainder, the intermediate number calculating means must calculate the upper m
What is necessary is to obtain the remainder for the bits and add this to the lower k bits. The intermediate number calculation means calculates the remainder or congruent value of the intermediate number after carry by the modulus p in a shorter time by reading the remainder of the upper m bits from the table means.

【0120】仮に、従来技術の剰余乗算装置1の剰余算
出部3における剰余算出の手順と同様な手順を用いて桁
上げ後の中間数の法pによる剰余を求めるとすれば、中
間数算出部は、ステップ6〜8のループ処理を複数回繰
り返さなければならない。より詳しくは、このループ処
理の回数は、桁上げ後の中間数のビット数に相当する。
これに対し本発明における中間数算出部は、テーブル部
の1回の読み出しと、1回の加算によって桁上げ後の中
間数の法pによる剰余又は合同な値を算出することがで
き高速な剰余演算を実現できる。
If it is assumed that the remainder is obtained by the modulo p of the intermediate number after carry using the same procedure as that of the remainder calculation in the remainder calculation unit 3 of the remainder multiplication apparatus 1 of the prior art, the intermediate number calculation unit Must repeat the loop processing of steps 6 to 8 a plurality of times. More specifically, the number of times of this loop processing corresponds to the number of bits of the intermediate number after carry.
On the other hand, the intermediate number calculating unit according to the present invention can calculate the remainder or the congruent value of the intermediate number after carry by a single reading and one addition of the table unit, and can calculate the remainder at high speed. Calculation can be realized.

【0121】また中間数算出手段は、漸化的に前回の中
間数を桁上げした値の剰余を中間数として算出し、これ
によって中間数算出手段は、算出する中間数のビット数
の増大を防止している。この防止により、中間数を用い
て算出される部分積のビット数の増大を防止する。この
結果、部分積の累算においてはビット数の抑えられた部
分積を用いて加算を行えばよいので、加算器の回路規模
を抑えることができる。
Further, the intermediate number calculating means calculates the remainder of the value obtained by carrying the previous intermediate number recursively as an intermediate number, whereby the intermediate number calculating means determines the increase in the number of bits of the calculated intermediate number. Preventing. This prevention prevents the number of bits of the partial product calculated using the intermediate number from increasing. As a result, in the accumulation of the partial products, the addition may be performed using the partial products in which the number of bits is suppressed, so that the circuit scale of the adder can be reduced.

【0122】また前記中間数算出手段は、中間数を保持
する第1保持手段と、部分乗数b[s*i+s-1:s*i]に対応し
て、第1保持手段に保持された中間数をsビット桁上げ
する桁上げ手段と、桁上げ後の中間数を、桁上げ後の中
間数における下位kビットよりも上位のmビットの部分
である上位データと下位kビットの部分である下位デー
タとに分割する分割手段と、分割手段による上位データ
に対する法pによる剰余を前テーブル手段から読み出す
読み出し手段と、テーブル手段から読み出された剰余
と、分割手段による下位データとを加算することにより
新たな中間数を得る加算手段とを備え、前記第1保持手
段は、加算手段において新たな中間数が得られる度にそ
の保持内容を新たな中間数に更新し、前記初回では被乗
数を中間数として出力し、前記2回目以降では更新後の
新たな中間数を出力するよう構成される。
The intermediate number calculating means is held in the first holding means for holding the intermediate number and the first holding means corresponding to the partial multiplier b [s * i + s-1: s * i]. A carry means for carrying the intermediate number by s bits, and converting the carried intermediate number into a higher-order data and a lower k-bit part which are m-bit parts higher than the lower k bits in the carried intermediate number. Dividing means for dividing the data into lower-order data, reading means for reading the remainder of the higher-order data by the modulo p from the preceding table means, and adding the remainder read from the table means and the lower-order data by the dividing means. The first holding means updates the held content to a new intermediate number each time a new intermediate number is obtained by the adding means, and the first multiplicand Output as an intermediate number Wherein arranged to output an intermediate number new updated in second and subsequent.

【0123】この構成によれば、中間数算出手段内部の
各構成要素は、汎用のハードウェア素子を用いて簡単に
構成することができる。つまり第1保持手段はレジス
タ、桁上げ手段はシフタ、分割手段は前記シフタの上位
mビット部分と下位kビット部分に接続されたmビット
のバスとkビットのバス、加算手段は加算器を用いて構
成でき、これらの構成要素によって中間数算出手段は、
中間数C(i)を漸化的に算出する。
According to this configuration, each component in the intermediate number calculation means can be easily configured using a general-purpose hardware element. That is, the first holding means is a register, the carry means is a shifter, the dividing means is an m-bit bus and a k-bit bus connected to the upper m-bit part and the lower k-bit part of the shifter, and the adder means is an adder. With these components, the intermediate number calculating means
An intermediate number C (i) is recursively calculated.

【0124】また前記剰余乗算装置は、さらに、前記分
割手段、読み出し手段、加算手段を利用することによ
り、前記累算値の法pによる剰余を求める後処理手段を
備える。この構成によれば、後処理手段が最後の累算値
の法pによる剰余を求めることにより、最後の累算値を
pよりも小さい値にすることができる。
The remainder multiplying device further includes post-processing means for obtaining the remainder of the accumulated value by the modulus p by using the dividing means, the reading means, and the adding means. According to this configuration, the post-processing means obtains the remainder of the last accumulated value by the modulus p, thereby making the last accumulated value smaller than p.

【0125】また前記テーブル手段は、mビットにより
表現される各値に対応するアドレスが入力され、そのア
ドレスが指す記憶領域に当該アドレスに対応するmビッ
トの値の2k倍に対する法pによる剰余を予め記憶する
メモリ素子を有する。この構成によれば、テーブル手段
はメモリ素子1個で実現することができる。メモリ素子
は、mビットにより表現される各値、つまり10進数の
0から2m−1に相当する各値について、その2k倍の法
pによる剰余を予め記憶する。これら剰余の記憶領域を
指し示すアドレスは、各値と同じ値である。メモリ素子
は、読み出し手段から上位mビットが入力されると、そ
の値をアドレスとして、そのアドレスが示す記憶領域の
剰余が読み出し手段によって読み出される。これによっ
て中間数算出手段は、メモリ素子からの1回の読出しを
行うだけで、上位mビットに対応する剰余を短時間で得
ることができる。
The table means inputs an address corresponding to each value represented by m bits, and stores, in a storage area indicated by the address, a remainder by modulo p with respect to 2 k times the value of the m bit corresponding to the address. Is stored in advance. According to this configuration, the table means can be realized by one memory element. The memory element previously stores a remainder of 2 k times modulo p for each value represented by m bits, that is, each value corresponding to a decimal number from 0 to 2 m -1. The addresses pointing to these surplus storage areas have the same value as each value. When the upper m bits are input from the reading means to the memory element, the value is used as an address, and the remainder of the storage area indicated by the address is read by the reading means. Thus, the intermediate number calculating means can obtain the remainder corresponding to the upper m bits in a short time only by performing one reading from the memory element.

【0126】また前記mビットは下位m1ビットと上位m2
ビット(m=m1+m2)とに分割され、前記mビットにより
表現される各値は、m1ビットにより表現される値とm2ビ
ットにより表現される値との組み合わせに対応し、前記
テーブル手段は、m1ビットにより表現される各値につい
て、その値の2k倍に対する法pによる剰余を予め記憶
する第1部分テーブル手段と、m2ビットにより表現され
る各値について、その値の2k+m1倍に対する法pによる
剰余を予め記憶する第2部分テーブル手段とを備え、前
記加算手段は、第1、第2部分テーブルからの読み出さ
れたそれぞれの剰余と、前記下位データとを加算するこ
とにより新たなっ中間数を得るよう構成される。
The m bits are the lower m1 bits and the upper m2 bits.
Bits (m = m1 + m2), and each value represented by the m bits corresponds to a combination of a value represented by the m1 bits and a value represented by the m2 bits, and the table means , M1 bits, the first partial table means for storing in advance the remainder of modulo p for 2 k times of the value, and for each value represented by m2 bits, 2 k + m1 Second partial table means for storing in advance a remainder of the double by a modulus p, wherein the adding means adds each of the remainders read from the first and second partial tables to the lower-order data. To obtain a new intermediate number.

【0127】この構成によれば、テーブル手段は、mビ
ットのうち上位側のm1ビットに対応する第1部分テー
ブル手段と、下位側のm2ビットに対応する第2部分テ
ーブル手段とを有する。第1部分テーブル手段は、上位
側m1ビットに対応する剰余を2m1個記憶し、第2部分
テーブル手段は、下位側m2ビットに対応する剰余を2
m2個記憶する。この個数からわかるように、第1及び第
2部分テーブル手段とを合わせた剰余の記憶個数は、メ
モリ素子1個の場合に比べて、さらに少なくなる。これ
によりテーブル手段は、記憶容量の小さい2つのメモリ
素子によって構成することができる。
According to this configuration, the table means has the first partial table means corresponding to the upper m1 bit of the m bits and the second partial table means corresponding to the lower m2 bits. The first partial table means stores 2 m1 remainders corresponding to the upper m1 bits, and the second partial table means stores the remainder corresponding to the lower m2 bits as 2 bits.
Remember m2 . As can be seen from this number, the storage number of the remainder combined with the first and second partial table means is even smaller than in the case of one memory element. Thus, the table means can be constituted by two memory elements having a small storage capacity.

【0128】また前記mビットは下位側からt(3≦t≦m)
個の部分ビットm1、…、mtに分割され、前記mビットに
より表現される各値は、各mi(iは1からtまで整数)
ビットにより表現される値(t個)を組み合わせたもの
に対応し、前記テーブル手段は、部分ビットmiビットに
より表現される各値について、その値の2k+x倍(ここ
でx=m1+…+m(i-1)である)に対する法pによる剰余を
予め記憶するt個の部分テーブル手段Tiを備え、前記
加算手段は、t個の部分テーブル手段Tiからの読み出さ
れたt個の剰余と、前記下位データとを加算することに
より新たな中間数を得るよう構成される。
The m bits are t (3 ≦ t ≦ m) from the lower side.
, Mt, and each value represented by the m bits is each mi (i is an integer from 1 to t).
Corresponding to a combination of the values (t) represented by bits, the table means calculates, for each value represented by the partial bit mi bits, 2 k + x times the value (where x = m1 +...). + M (i-1)), and t partial table means Ti for preliminarily storing the remainder of the modulus p with respect to the modulo p. And the lower order data are added to obtain a new intermediate number.

【0129】このようにテーブル手段は、mビットを分
割したt個の部分ビットの各値に対応するt個の部分テ
ーブル手段Tiを有する。このようにテーブル手段は、複
数の部分テーブル手段Tiを有することにより各部分テー
ブル手段Tiにおける剰余の記憶個数を少なくしている。
前記剰余乗算装置は、さらに累算手段と補正手段とを備
え、前記累算手段は、初期値として0を保持する第3レ
ジスタと、部分積C(i)*b[s*i+s-1:s*i]と第3レジスタ
に保持された累算値とを加算し、加算結果を新たな累算
値として第3レジスタに出力して保持させる加算器とを
備え、前記補正手段は、pの整数倍の値をもつ補正値を
保持する補正値保持手段と、前記第3レジスタに保持さ
れた累算値が所定の値以上であれば、補正値保持手段に
保持された補正値を、前記加算器に減算させる補正制御
手段とを備える。
As described above, the table means has t partial table means Ti corresponding to respective values of t partial bits obtained by dividing m bits. Thus, the table means has a plurality of partial table means Ti, thereby reducing the number of surplus storage in each partial table means Ti.
The remainder multiplying device further includes accumulating means and correcting means, wherein the accumulating means includes a third register for holding 0 as an initial value, and a partial product C (i) * b [s * i + s- 1: s * i] and the accumulated value held in the third register, and the adder outputs the addition result as a new accumulated value to the third register and holds the sum. , A correction value holding means for holding a correction value having an integer multiple of p, and a correction value held by the correction value holding means if the accumulated value held in the third register is equal to or larger than a predetermined value. And correction control means for causing the adder to subtract

【0130】この構成によれば補正制御手段は、累算値
が所定の値以上であれば、加算器に累算値から補正値を
減算させるので、第3レジスタにおける桁あふれが防止
される。また前記第3レジスタは符号ビットを有し、前
記補正制御手段は、第3レジスタの累算値が正であれ
ば、前記加算器に対して累算値と部分積との加算と同時
に前記補正値を減算させ、前記補正値は、pの整数倍で
あってその絶対値が前記部分積の最大値(t+1)(2 s -1)p
以下の値であることを特徴とする。
According to this configuration, the correction control means causes the adder to subtract the correction value from the accumulated value if the accumulated value is equal to or greater than the predetermined value, thereby preventing overflow in the third register. The third register has a sign bit, and the correction control means, if the accumulated value of the third register is positive, adds the accumulated value and the partial product to the adder simultaneously with the correction. The correction value is an integer multiple of p, and its absolute value is the maximum value of the partial product (t + 1) (2 s -1) p
It is characterized by the following values.

【0131】この構成によれば、補正制御手段は第3レ
ジスタに保持される累算値の符号ビットが1(累算値が
正を示す)であるとき、加算器に累算値から補正値を減
算させるので、第3レジスタにおける桁あふれが防止さ
れる。また補正値は、pの整数倍であって前記部分積の
最大値(t+1)(2s-1)p以下の値であるので、累算値の最終
的な値がpより小さい値か又はpに近い値にする。
According to this configuration, when the sign bit of the accumulated value held in the third register is 1 (the accumulated value indicates a positive value), the correction control means outputs the correction value from the accumulated value to the adder. , The overflow of the third register is prevented. Further, since the correction value is an integer multiple of p and is equal to or less than the maximum value (t + 1) (2s-1) p of the partial product, it is determined whether the final value of the accumulated value is smaller than p. Or a value close to p is set.

【0132】また前記法pはp=2k−αの関係を満た
し、各部分テーブル手段Tiは、前記剰余をk3ビットの
データとして記憶する、ここで、k3はt*2m*αのビット
数であり、前記αは、k3がkより小さくなるように定め
られた定数であることを特徴とする。この構成によれば
p=2k−αの関係を満たし、αはk3がkより小さくな
るように上限を定められた定数である。これらによって
部分テーブル手段Tiに記憶される剰余はk3ビットまで
に制限することができ、部分テーブルからの出力ビット
数を少なくすることができる。部分テーブル手段Tiから
出力される剰余のビット数がk3ビット以下であるの
で、それに合わせて加算部のビット幅も制限することが
できる。
The modulus p satisfies the relationship of p = 2 k -α, and each partial table means Ti stores the remainder as k3 bit data, where k3 is a bit of t * 2 m * α. Wherein α is a constant determined such that k3 is smaller than k. According to this configuration, the relationship of p = 2 k -α is satisfied, and α is a constant whose upper limit is determined so that k3 is smaller than k. Thus, the remainder stored in the partial table means Ti can be limited to k3 bits, and the number of output bits from the partial table can be reduced. Since the number of bits of the remainder output from the partial table means Ti is equal to or less than k3 bits, the bit width of the adder can be limited accordingly.

【0133】また各部分テーブル手段Tiは、miビット
により表現される0から(2mi-1)までの値に対応する2mi
個のエントリを有し、j(jは0から2miまで)番目のエン
トリは、j*2m1++m(i-1) *αを格納していることを特
徴とする。この構成において、部分テーブル手段Tiは、
記憶するエントリの個数を2mi−1と制限することがで
き、部分テーブルの規模を小さくすることができる。
Each partial table means Ti stores 2 mi corresponding to a value from 0 to (2 mi -1) represented by mi bits.
.. + M (i−1) * α. The j-th entry (j is 0 to 2 mi ) stores j * 2 m1 + ... + M (i−1) * α. In this configuration, the partial table means Ti
The number of entries to be stored can be limited to 2 mi -1 and the size of the partial table can be reduced.

【0134】また、αが仮にuビットであるとすると、
j番目のエントリであるj*2m1++ m(i-1)*αのビット
数は、最大でもjのビット数にm1+m2+...+m
(i−1)とuビットとを加え合わせた値に制限するこ
とができる。部分テーブル手段Tiより出力される剰余を
加算する加算手段は、ビット幅を制限することができ
る。
If α is u bits,
The number of bits of the j-th entry j * 2 m1 + ... + m (i-1) * α is m1 + m2 +.
It is possible to limit the value to the sum of (i-1) and u bits. The adding means for adding the remainder output from the partial table means Ti can limit the bit width.

【0135】本発明の剰余乗算装置は、被乗数と乗数と
の積に対する法p(pはkビットデータ)による剰余と
合同な数を算出する剰余乗算装置であって、乗数をs
(sは2以上の整数)ビットずつに分けて得られるsビ
ットの部分乗数を下位側から順に出力する出力手段と、
各部分乗数の位に応じて、被乗数を桁上げし、桁上げ後
の被乗数に対して、法pによる剰余と合同な数(以下中
間数と呼ぶ)を算出する第1算出手段と、出力手段によ
り出力された部分乗数と、当該部分乗数に対応して第1
算出手段により算出された前記中間数との積を部分積と
して算出する第2算出手段と、第2算出手段に算出され
た部分積を累算する累算手段と、累算手段に累算された
累算値にpの整数倍の値を加減算することにより、累算
値を所定のビット数を越えないように補正する補正手段
と、出力手段により全ての部分乗数が出力されるまで、
第1算出手段による中間数の算出と、第2算出手段によ
る部分積の算出と、累算手段による累算と、補正手段に
よる補正とを繰り返し行わせる制御手段とを備え、前記
第1算出手段は、m(mはs以上の整数)ビットにより表
現される各値について、その値の2k倍に対する法pに
よる剰余を予め記憶し、制御手段による繰り返しのうち
初回では被乗数を中間数として出力し、2回目以降で
は、前回出力された中間数をsビット桁上げし、桁上げ
後の中間数の下位kビットより上位のmビットについて
テーブル手段を読み出し、読み出した数と下位kビット
とを加算することにより新たな中間数を算出するよう構
成される。
The remainder multiplication apparatus according to the present invention is a remainder multiplication apparatus for calculating a number congruent with a remainder by a modulus p (p is k-bit data) for a product of a multiplicand and a multiplier.
(S is an integer of 2 or more) output means for sequentially outputting, from the lower side, a partial multiplier of s bits obtained in units of bits;
First calculating means for carrying the multiplicand in accordance with the order of each partial multiplier, and calculating a number (hereinafter referred to as an intermediate number) which is the same as the remainder of the multiplicand after the carry by the modulus p; And the first multiplier corresponding to the partial multiplier
Second calculating means for calculating the product of the intermediate number calculated by the calculating means as a partial product, accumulating means for accumulating the partial product calculated by the second calculating means, and accumulating in the accumulating means. Adding and subtracting an integral multiple of p to the accumulated value to correct the accumulated value so that the accumulated value does not exceed a predetermined number of bits; and until all partial multipliers are output by the output unit.
Control means for repeatedly performing the calculation of the intermediate number by the first calculating means, the calculation of the partial product by the second calculating means, the accumulation by the accumulating means, and the correction by the correcting means; Is stored in advance for each value represented by m (m is an integer of s or more) bits, modulo p for 2 k times of the value, and outputs the multiplicand as an intermediate number at the first time of repetition by the control means. In the second and subsequent times, the previously output intermediate number is carried by s bits, the table means is read out for m bits higher than the lower k bits of the carried intermediate number, and the read number and the lower k bits are compared. It is configured to calculate a new intermediate number by adding.

【0136】この構成によれば第1算出手段は、制御手
段により繰り返しのうち2回目以降では、sビット桁上
げされた桁上げ後の中間数の下位kビットを除く上位も
mビットについてテーブル手段より対応する剰余を読出
し、その剰余と下位kビットとを加算することにより、
桁上げ後の中間数の法pによる剰余又は合同な値を中間
数として算出する。これによって第1算出手段は、剰余
の算出を高速に行う。
According to this configuration, in the second and subsequent iterations of the repetition by the control means, the first calculating means sets the table means for the upper m bits excluding the lower k bits of the intermediate number after s bit carry. By reading the corresponding remainder and adding the remainder and the lower k bits,
The remainder or congruent value of the intermediate number after carry by the modulus p is calculated as the intermediate number. As a result, the first calculating means calculates the remainder at high speed.

【0137】また第2算出手段は、sビットの部分乗数
毎に部分乗数と中間数との部分積を算出する。このよう
に複数桁の部分乗数ずつ部分積を算出するので、部分乗
数の個数分だけ部分積の算出を行えばよく、第2算出手
段における繰り返しの回数が減り、従来技術の積算出部
2に比べて高速になる。また前記制御手段は、第1〜第
3ステージを含むパイプライン処理を制御する、第1ス
テージでは出力手段に部分乗数を出力させるとともに第
1算出手段に中間数を出力させ、第2ステージでは第2
算出手段に部分積を算出させ、第3ステージでは累算手
段に累算させるともに補正手段に補正させるよう構成さ
れる。
The second calculating means calculates a partial product of the partial multiplier and the intermediate number for each s-bit partial multiplier. Since the partial product is calculated for each of the partial multipliers of a plurality of digits in this way, the calculation of the partial product may be performed by the number of the partial multipliers, and the number of repetitions in the second calculating means is reduced. Faster than compared. The control means controls the pipeline processing including the first to third stages. In the first stage, the output means outputs a partial multiplier and the first calculation means outputs an intermediate number. 2
The calculation means is configured to calculate the partial product, and in the third stage, the accumulation is performed by the accumulation means and the correction is performed by the correction means.

【0138】この構成によれば剰余乗算装置は、パイプ
ライン処理を行うので、各構成要素における処理が効率
良く行われ、演算の処理速度がより高速になる。また前
記出力手段は、最初に乗数を保持し、保持している値の
下位sビットを部分乗数として出力する乗数保持手段
と、乗数保持手段に保持されている値をsビット下位側
にシフトさせ、シフト後の値を乗数保持手段に出力して
保持させるシフト手段とを備える。
According to this configuration, since the remainder multiplication apparatus performs the pipeline processing, the processing in each component is efficiently performed, and the processing speed of the operation is further increased. The output means firstly holds the multiplier, and outputs the lower s bits of the held value as a partial multiplier; and shifts the value held by the multiplier holding means to s bits lower. , And a shift means for outputting the shifted value to the multiplier holding means and holding it.

【0139】この構成によれば、出力手段は、乗数を保
持するレジスタと、保持された乗数をsビット下位側に
シフトさせるシフタによって簡単に構成することができ
る。また前記第2生成手段は、第i(iは1から(s−
1)の整数)のシフト手段は、第1算出手段により算出
された前記中間数をiビット左シフトにより桁上げする
第1から第(s−1)のシフト手段を備え、前記第1生
成手段は、第1算出手段により算出された前記中間数を
sビット左シフトにより桁上げする第sのシフト手段
と、前記中間数の1の補数を生成する補数生成手段と、
定数1を出力する定数出力手段とを備え、前記第2加算
手段は、全ビットが1であると判定された場合に、第s
のシフト手段の出力と、補数生成手段に生成された1の
補数と、定数1を選択し、全ビットが1であると判定さ
れなかった場合に、部分乗数の2 0の位が”1”であれ
ば前記中間数を選択し、部分乗数の2iの位が”1”で
あれば、第iのシフト手段の桁上げ結果を選択する選択
手段と、選択手段の選択結果を加算することにより前記
部分積を算出する加算器とを備える。
According to this configuration, the output means stores the multiplier.
Register and the held multiplier to lower s bits
Can be easily configured by shifting shifters
You. Further, the second generation means may generate the ith (i is 1 to (s−
The shift means of 1) is calculated by the first calculating means.
Carry the intermediate number by i-bit left shift
First to (s-1) th shift means, wherein the first
Generating means for calculating the intermediate number calculated by the first calculating means.
s-th shift means for carrying by s-bit left shift
And complement generation means for generating a one's complement of the intermediate number;
Constant output means for outputting a constant 1;
The means is configured to, when all bits are determined to be 1 to be s-th,
And the output of the one generated by the complement generation means.
Complement and constant 1 are selected and all bits are determined to be 1.
Otherwise, the partial multiplier of 2 0Is "1"
If the intermediate number is selected, the partial multiplier 2iIs "1"
If there is, select to select the carry result of the i-th shift means
Means, by adding the selection result of the selection means,
An adder for calculating a partial product.

【0140】この構成によれば、第1から第(s−1)
のシフト手段は、1〜(s−1)ビット左シフトを行う
シフタによって実現される。第sのシフト手段は、sビ
ット左シフトを行うシフタによって実現される。補数生
成手段は、インバータにより実現される。このように第
1生成手段及び第2生成手段は、汎用的なハードウェア
素子によって構成することができる。これらの構成要素
は、加算手段に加算させるべき候補の値を前もって生成
する。選択手段は、部分乗数の値に応じて候補の値から
加算手段に加算させるべき値を選択する。加算手段は、
選択された候補の値を加算することによって部分積を算
出する。このような構成によって第2算出手段は、複数
桁の中間数と部分乗数との部分積を高速に算出すること
ができる。
According to this configuration, the first to (s-1) th
Is realized by a shifter that shifts left by 1 to (s-1) bits. The s-th shift means is realized by a shifter that performs s-bit left shift. The complement generation means is realized by an inverter. As described above, the first generation unit and the second generation unit can be configured by general-purpose hardware elements. These components generate in advance the values of the candidates to be added by the adding means. The selecting means selects a value to be added to the adding means from the candidate values according to the value of the partial multiplier. The addition means
A partial product is calculated by adding the values of the selected candidates. With such a configuration, the second calculating unit can calculate the partial product of the intermediate number and the partial multiplier of a plurality of digits at high speed.

【図面の簡単な説明】[Brief description of the drawings]

【図1】第1実施形態における剰余乗算装置100の概
略構成を示すブロック図である。
FIG. 1 is a block diagram illustrating a schematic configuration of a remainder multiplication device 100 according to a first embodiment.

【図2】剰余算出部12のより詳細な構成図を示す。FIG. 2 shows a more detailed configuration diagram of a remainder calculation unit 12.

【図3】(a)ROMテーブル309の記憶内容を示
す。 (b)ROMテーブル308の記憶内容を示す。
FIG. 3A shows the storage contents of a ROM table 309. (B) Shows the storage contents of the ROM table 308.

【図4】乗数分割部11のより詳細な構成を示す。FIG. 4 shows a more detailed configuration of the multiplier division unit 11;

【図5】部分積算出部13のより詳細な構成を示す。FIG. 5 shows a more detailed configuration of a partial product calculator 13;

【図6】累算部14及び補正部15の詳細な構成を示
す。
FIG. 6 shows a detailed configuration of an accumulation unit 14 and a correction unit 15.

【図7】第2実施形態における剰余乗算装置200の概
略構成を示すブロック図である。
FIG. 7 is a block diagram illustrating a schematic configuration of a remainder multiplication device 200 according to a second embodiment.

【図8】剰余算出部82のより詳細な構成を示す。FIG. 8 shows a more detailed configuration of a remainder calculator 82.

【図9】ROMテーブル904の記憶内容を示す。FIG. 9 shows storage contents of a ROM table 904.

【図10】乗数分割部81のより詳細な構成を示す。FIG. 10 shows a more detailed configuration of a multiplier division unit 81.

【図11】部分積算出部83のより詳細な構成を示す。FIG. 11 shows a more detailed configuration of a partial product calculator 83.

【図12】演算値選択器840、841、842の詳細
な構成を示す。
FIG. 12 shows a detailed configuration of operation value selectors 840, 841, and 842.

【図13】(a)は、制御回路1306に入力される部
分乗数b(i)と制御回路1306の入出力論理との対
応を示す。(b)は、制御回路1305に入力される部
分乗数b(i)と制御回路1305の入出力論理との対
応を示す。(c)は、制御回路1304に入力される部
分乗数b(i)と制御回路1304の入出力論理との対
応を示す。
13A shows the correspondence between the partial multiplier b (i) input to the control circuit 1306 and the input / output logic of the control circuit 1306. FIG. (B) shows the correspondence between the partial multiplier b (i) input to the control circuit 1305 and the input / output logic of the control circuit 1305. (C) shows the correspondence between the partial multiplier b (i) input to the control circuit 1304 and the input / output logic of the control circuit 1304.

【図14】累算部84及び補正部85のより詳細な構成
を示す。
FIG. 14 shows a more detailed configuration of an accumulation unit 84 and a correction unit 85.

【図15】部分積算出部83は、図15のように構成し
てもよい。
FIG. 15 may be configured as shown in FIG.

【図16】演算値選択器850、851、852に共通
の制御回路の入出力論理を示す。
FIG. 16 shows input / output logic of a control circuit common to operation value selectors 850, 851, and 852.

【図17】従来の剰余乗算装置の構成を示す。FIG. 17 shows a configuration of a conventional remainder multiplication device.

【符号の説明】[Explanation of symbols]

100 剰余乗算装置 11 乗数分割部 12 剰余算出部 13 部分積算出部 14 累算部 15 補正部 16 制御部 308 ROMテーブル 309 ROMテーブル 301 セレクタ 302 レジスタA 303 シフタ 304 セレクタ 310 加算器 311 剰余演算部 REFERENCE SIGNS LIST 100 remainder multiplication unit 11 multiplier division unit 12 remainder calculation unit 13 partial product calculation unit 14 accumulation unit 15 correction unit 16 control unit 308 ROM table 309 ROM table 301 selector 302 register A 303 shifter 304 selector 310 adder 311 remainder calculation unit

Claims (31)

【特許請求の範囲】[Claims] 【請求項1】 被乗数aと乗数b(bはkbビットのデ
ータ)との積に対して、法p(pはkビットデータ)に
よる剰余と合同な値を次式の累算値として算出する剰余
乗算装置であって、 【数1】 ここで[[kb/s]]は商kb/sの整数部分であり、 iは0から[[k/s]]までの整数であり、 C(i)は漸化式で表わされi=0のときC(i)=a、i>=1のときC
(i)≡(C(i-1)*2s) modpであり(≡は両辺の値が法pに
おいて合同であることを示す)、 b[s*i+s-1:s*i]は、kビットの乗数bのうち2s*i+s-1
位から2s*iの位までのsビットの部分乗数であり、 前記剰余乗算装置は、 m(mはs以上の整数)ビットにより表現される各値につ
いて、その値の2k倍に対する法pによる剰余を予め記
憶するテーブル手段と、 初回(i=0)では被乗数aを中間数C(0)として出力し、 2回目以降(i>0)では、前回出力された中間数C(i-1)
をsビット桁上げし、桁上げ後の中間数の下位kビット
を除く上位のmビットについての前記剰余をテーブル手
段から読み出し、読み出した剰余と下位kビットとを加
算することにより新たな中間数(i)を算出する中間数算
出手段とを備え、 算出された各中間数C(i)と、それに対応する部分乗数b
[s*i+s-1:s*i]との部分積C(i)*b[s*i+s-1:s*i]を順次累
算することによって前記累算値を算出することを特徴と
する剰余乗算装置。
For a product of a multiplicand a and a multiplier b (b is kb-bit data), a value congruent with a remainder by a modulus p (p is k-bit data) is calculated as an accumulated value of the following equation. A modular multiplication device, comprising: Here, [[kb / s]] is an integer part of the quotient kb / s, i is an integer from 0 to [[k / s]], and C (i) is represented by a recurrence formula and i = 0 when C (i) = a, when i> = 1 C
(i) ≡ (C (i-1) * 2 s ) modp (≡ indicates that the values on both sides are congruent in the modulus p), and b [s * i + s-1: s * i] Is a partial multiplier of s bits from the order of 2 s * i + s−1 to the order of 2 s * i in the multiplier b of k bits, and the remainder multiplication device is m (m is an integer equal to or more than s) ) For each value represented by bits, table means for storing in advance the remainder of the value by 2 k times the modulus p, and in the first time (i = 0), output the multiplicand a as the intermediate number C (0), After the first time (i> 0), the intermediate number C (i-1) previously output
Is carried out by s bits, and the remainder of the upper m bits excluding the lower k bits of the carried intermediate number is read from the table means, and the read remainder and the lower k bits are added to obtain a new intermediate number. (i) is calculated, and the calculated intermediate numbers C (i) and the corresponding partial multipliers b are provided.
The cumulative value is calculated by sequentially accumulating the partial product C (i) * b [s * i + s-1: s * i] with [s * i + s-1: s * i] A residue multiplication device characterized by the above-mentioned.
【請求項2】 前記中間数算出手段は、 中間数を保持する第1保持手段と、 部分乗数b[s*i+s-1:s*i]に対応して、第1保持手段に保
持された中間数をsビット桁上げする桁上げ手段と、 桁上げ後の中間数を、桁上げ後の中間数における下位k
ビットよりも上位のmビットの部分である上位データと
下位kビットの部分である下位データとに分割する分割
手段と、 分割手段による上位データに対する法pによる剰余を前
テーブル手段から読み出す読み出し手段と、 テーブル手段から読み出された剰余と、分割手段による
下位データとを加算することにより新たな中間数を得る
加算手段とを備え、 前記第1保持手段は、加算手段において新たな中間数が
得られる度にその保持内容を新たな中間数に更新し、前
記初回では被乗数を中間数として出力し、前記2回目以
降では更新後の新たな中間数を出力することを特徴とす
る請求項1記載の剰余乗算装置。
2. The intermediate number calculating means includes: a first holding means for holding an intermediate number; and a first holding means corresponding to a partial multiplier b [s * i + s-1: s * i]. A carry means for carrying the carried intermediate number by s bits, and converting the carried intermediate number into a lower k in the carried intermediate number.
Dividing means for dividing the data into higher-order data, which is an m-bit part higher than bits, and lower-order data, which is a lower-order k-bit part; Adding means for obtaining a new intermediate number by adding the remainder read from the table means and lower-order data obtained by the dividing means, wherein the first holding means obtains a new intermediate number in the adding means. 2. The method according to claim 1, further comprising: updating the held content to a new intermediate number each time, outputting the multiplicand as an intermediate number at the first time, and outputting a new intermediate number after the update at the second time and thereafter. Multiplication unit.
【請求項3】 前記剰余乗算装置は、さらに、 前記分割手段、読み出し手段、加算手段を利用すること
により、前記累算値の法pによる剰余を求める後処理手
段を備えることを特徴とする請求項2記載の剰余乗算装
置。
3. The remainder multiplication apparatus further includes a post-processing unit that obtains a remainder of the accumulated value by a modulus p by using the dividing unit, the reading unit, and the adding unit. Item 3. The modular multiplication device according to Item 2.
【請求項4】 前記テーブル手段は、 mビットにより表現される各値に対応するアドレスが入
力され、そのアドレスが指す記憶領域に当該アドレスに
対応するmビットの値の2k倍に対する法pによる剰余
を予め記憶するメモリ素子を有することを特徴とする請
求項2及び3記載の剰余乗算装置。
4. The table means receives an address corresponding to each value represented by m bits, and stores the address in a storage area indicated by the address by a modulus p for 2 k times the value of the m bit corresponding to the address. 4. The remainder multiplication apparatus according to claim 2, further comprising a memory element for storing the remainder in advance.
【請求項5】 前記mビットは下位m1ビットと上位m2ビ
ット(m=m1+m2)とに分割され、 前記mビットにより表現される各値は、m1ビットにより
表現される値とm2ビットにより表現される値との組み合
わせに対応し、 前記テーブル手段は、 m1ビットにより表現される各値について、その値の2k
倍に対する法pによる剰余を予め記憶する第1部分テー
ブル手段と、 m2ビットにより表現される各値について、その値の2
k+m1倍に対する法pによる剰余を予め記憶する第2部分
テーブル手段とを備え、 前記加算手段は、第1、第2部分テーブルからの読み出
されたそれぞれの剰余と、前記下位データとを加算する
ことにより新たなっ中間数を得ることを特徴とする請求
項2及び3記載の剰余乗算装置。
5. The m bits are divided into lower m1 bits and upper m2 bits (m = m1 + m2), and each value represented by m bits is represented by a value represented by m1 bits and m2 bits. corresponding to a combination of the value represented, the table means, for each value represented by m1 bits, 2 k of the value
First partial table means for storing beforehand the remainder of the modulo p, and for each value represented by m2 bits, 2
second partial table means for storing in advance the remainder of the modulus p for k + m1 times, wherein the adding means calculates each remainder read from the first and second partial tables and the lower data. 4. The remainder multiplication device according to claim 2, wherein a new intermediate number is obtained by adding the remainder.
【請求項6】 前記mビットは下位側からt(3≦t≦m)個
の部分ビットm1、…、mtに分割され、 前記mビットにより表現される各値は、各mi(iは1か
らtまで整数)ビットにより表現される値(t個)を組
み合わせたものに対応し、 前記テーブル手段は、 部分ビットmiビットにより表現される各値について、そ
の値の2k+x倍(ここでx=m1+…+m(i-1)である)に対
する法pによる剰余を予め記憶するt個の部分テーブル
手段Tiを備え、 前記加算手段は、t個の部分テーブル手段Tiからの読み
出されたt個の剰余と、前記下位データとを加算するこ
とにより新たな中間数を得ることを特徴とする請求項2
及び3記載の剰余乗算装置。
6. The m bits are divided into t (3 ≦ t ≦ m) partial bits m1,..., Mt from the lower side, and each value represented by the m bits is mi (i is 1). Table means, for each value represented by the partial bit mi bits, 2 k + x times (here, , X = m1 +... + M (i-1)). The t partial table means Ti for preliminarily storing the remainder of the modulus p with respect to the modulo p, and the adding means is read from the t partial table means Ti. 3. A new intermediate number is obtained by adding the t remainders and the lower order data.
And the modular multiplication device according to 3.
【請求項7】前記mビットは下位側からt(2≦t≦m)個の
部分ビットm1、…、mtに分割され、 前記テーブル手段は、 xが次式で表わされるとき、各部分テーブル手段Ti
は、部分ビットmiビットにより表現される各値につい
て、その値の2k+x倍に対する法pによる剰余を予め記
憶するt個の部分テーブル手段Ti(iは1からtの整
数)を備え、 ここでxは次式によって表わされるものとする 【数2】 前記加算手段は、t個の部分テーブル手段Tiから読み
出されたt個の剰余と前記下位データとを加算すること
により新たな中間数を得ることを特徴とする請求項2及
び3記載の剰余乗算装置。
7. The m bits are divided into t (2 ≦ t ≦ m) partial bits m1,..., Mt from the lower side, and the table means: when x is represented by the following equation, Means Ti
Is provided with t partial table means Ti (i is an integer from 1 to t) for storing in advance for each value represented by the partial bit mi bits the remainder of the value by 2 k + x times the modulus p. Here, x is represented by the following equation. 4. The remainder according to claim 2, wherein the addition means obtains a new intermediate number by adding the t remainders read from the t partial table means Ti and the lower order data. Multiplication device.
【請求項8】 各部分テーブル手段Tiは、前記剰余を
kビットのデータとして記憶することを特徴とする請求
項7記載の剰余乗算装置。
8. The remainder multiplication device according to claim 7, wherein each partial table means Ti stores the remainder as k-bit data.
【請求項9】 前記剰余乗算装置は、さらに累算手段と
補正手段とを備え、 前記累算手段は、 初期値として0を保持する第3レジスタと、 部分積C(i)*b[s*i+s-1:s*i]と第3レジスタに保持され
た累算値とを加算し、 加算結果を新たな累算値として第3レジスタに出力して
保持させる加算器とを備え、 前記補正手段は、 pの整数倍の値をもつ補正値を保持する補正値保持手段
と、 前記第3レジスタに保持された累算値が所定の値以上で
あれば、補正値保持手段に保持された補正値を、前記加
算器に減算させる補正制御手段とを備えることを特徴と
する請求項8記載の剰余乗算装置。
9. The remainder multiplication device further includes accumulating means and correcting means, wherein the accumulating means includes a third register for holding 0 as an initial value, and a partial product C (i) * b [s * i + s-1: s * i] and the accumulated value held in the third register, and the adder outputs the addition result as a new accumulated value to the third register and holds the sum. The correction means includes: a correction value holding means for holding a correction value having an integer multiple of p; and a correction value holding means if the accumulated value held in the third register is a predetermined value or more. 9. The remainder multiplication apparatus according to claim 8, further comprising: a correction control unit that causes the adder to subtract the held correction value.
【請求項10】 前記第3レジスタは符号ビットを有
し、 前記補正制御手段は、第3レジスタの累算値が正であれ
ば、前記加算器に対して累算値と部分積との加算と同時
に前記補正値を減算させ、 前記補正値は、pの整数倍であってその絶対値が前記部
分積の最大値(t+1)(2 s -1)p以下の値であることを特徴
とする請求項9記載の剰余乗算装置。
10. The third register has a sign bit.
The correction control means may determine whether the accumulated value of the third register is positive.
If the addition of the accumulated value and the partial product is
Is subtracted from the correction value, and the correction value is an integral multiple of p and its absolute value is
The maximum value of the product (t + 1) (2 s -1) is characterized by a value less than or equal to p
The remainder multiplication device according to claim 9, wherein
【請求項11】 前記法pはp=2k−αの関係を満た
し、 各部分テーブル手段Tiは、前記剰余をk3ビットのデー
タとして記憶する、 ここで、k3はt*2m*αのビット数であり、 前記αは、k3がkより小さくなるように定められた定数
であることを特徴とする請求項7記載の剰余乗算装置。
11. The modulus p satisfies the relationship p = 2 k −α, and each partial table means Ti stores the remainder as k3 bit data, where k3 is t * 2 m * α The modular multiplication apparatus according to claim 7, wherein the number of bits is a, and α is a constant determined so that k3 is smaller than k.
【請求項12】 各部分テーブル手段Tiは、miビット
により表現される0から(2mi-1)までの値に対応する2mi
個のエントリを有し、 j(jは0から2miまで)番目のエントリは、j*2m1+
+m(i-1) *αを格納していることを特徴とする請求項1
1記載の剰余乗算装置。
12. Each partial table means Ti has 2 mi corresponding to a value from 0 to (2 mi -1) represented by mi bits.
J entries (j is from 0 to 2 mi ), and the j-th entry is j * 2 m1 + .
2. The method according to claim 1, wherein + m (i-1) * α is stored.
2. The modular multiplication device according to 1.
【請求項13】 前記剰余乗算装置は、さらに累算手段
と補正手段とを備え、 前記累算手段は、 初期値として0を保持する第3レジスタと、 部分積C(i)*b[s*i+s-1:s*i]と第3レジスタに保持され
た累算値とを加算し、 加算結果を新たな累算値として第3レジスタに出力して
保持させる加算器とを備え、 前記補正手段は、 pの整数倍の値をもつ補正値を保持する補正値保持手段
と、 前記第3レジスタに保持された累算値が所定の値以上で
あれば、補正値保持手段に保持された補正値を、前記加
算器に減算させる補正制御手段と、 を備えることを特徴とする請求項12記載の剰余乗算装
置。
13. The remainder multiplication device further includes accumulating means and correcting means, wherein the accumulating means includes a third register for holding 0 as an initial value, and a partial product C (i) * b [s * i + s-1: s * i] and the accumulated value held in the third register, and the adder outputs the addition result as a new accumulated value to the third register and holds the sum. The correction means includes: a correction value holding means for holding a correction value having an integer multiple of p; and a correction value holding means if the accumulated value held in the third register is a predetermined value or more. The remainder multiplication apparatus according to claim 12, further comprising: a correction control unit configured to cause the adder to subtract the held correction value.
【請求項14】 前記第3レジスタは符号ビットを有
し、 前記補正制御手段は、第3レジスタの累算値が正であれ
ば、前記加算器に対して累算値と部分積との加算と同時
に前記補正値を減算させ、 前記補正値は、pの整数倍であって前記部分積の最大値
(2s+1-2)p以下の値であることを特徴とする請求項13
記載の剰余乗算装置。
14. The third register has a sign bit, and the correction control means adds the accumulated value and the partial product to the adder if the accumulated value of the third register is positive. At the same time, the correction value is subtracted. The correction value is an integral multiple of p and is the maximum value of the partial product.
14. A value not more than (2 s + 1 -2) p.
A modular multiplication device as described.
【請求項15】 被乗数と乗数との積に対する法p(p
はkビットデータ)による剰余と合同な数を算出する剰
余乗算装置において、 乗数をs(sは2以上の整数)ビットずつに分けて得ら
れるsビットの部分乗数を下位側から順に出力する出力
手段と、 各部分乗数の位に応じて、被乗数を桁上げし、桁上げ後
の被乗数に対して、法pによる剰余と合同な数(以下中
間数と呼ぶ)を算出する第1算出手段と、 出力手段により出力された部分乗数と、当該部分乗数に
対応して第1算出手段により算出された前記中間数との
積を部分積として算出する第2算出手段と、 第2算出手段に算出された部分積を累算する累算手段
と、 累算手段に累算された累算値にpの整数倍の値を加減算
することにより、累算値を所定のビット数を越えないよ
うに補正する補正手段と、 出力手段により全ての部分乗数が出力されるまで、第1
算出手段による中間数の算出と、第2算出手段による部
分積の算出と、累算手段による累算と、補正手段による
補正とを繰り返し行わせる制御手段とを備え、 前記第1算出手段は、m(mはs以上の整数)ビットによ
り表現される各値について、その値の2k倍に対する法
pによる剰余を予め記憶し、 制御手段による繰り返しのうち初回では被乗数を中間数
として出力し、2回目以降では、前回出力された中間数
をsビット桁上げし、桁上げ後の中間数の下位kビット
より上位のmビットについてテーブル手段を読み出し、
読み出した数と下位kビットとを加算することにより新
たな中間数を算出することを特徴とする剰余乗算装置。
15. The modulo p (p) for the product of the multiplicand and the multiplier
Is a remainder multiplication device that calculates a congruent number with a remainder by k-bit data. An output that outputs a partial multiplier of s bits obtained by dividing the multiplier into s (s is an integer of 2 or more) bits in order from the lower side. A first calculating means for carrying the multiplicand in accordance with the order of each partial multiplier, and calculating, for the multiplicand after the carry, a number (hereinafter referred to as an intermediate number) which is the same as the remainder of the modulus p A second calculating means for calculating, as a partial product, a product of the partial multiplier output by the output means and the intermediate number calculated by the first calculating means corresponding to the partial multiplier; Accumulating means for accumulating the calculated partial product, and adding or subtracting an integral multiple of p to the accumulated value accumulated in the accumulating means so that the accumulated value does not exceed a predetermined number of bits. Correction means to correct and all partial multipliers by output means Until the force, the first
Control means for repeatedly performing the calculation of the intermediate number by the calculating means, the calculation of the partial product by the second calculating means, the accumulation by the accumulating means, and the correction by the correcting means, wherein the first calculating means comprises: For each value represented by m (m is an integer equal to or greater than s) bits, the remainder of modulo p for 2 k times the value is stored in advance, and the multiplicand is output as an intermediate number in the first iteration of the control means, In the second and subsequent times, the intermediate number output last time is carried up by s bits, and the table means is read out for m bits higher than the lower k bits of the carried intermediate number,
A remainder multiplication apparatus for calculating a new intermediate number by adding the read number and the lower k bits.
【請求項16】 前記第1算出手段は、 被乗数を保持する第1保持手段と、 出力手段から2回目以降に出力される部分乗数に対応し
て、第1保持手段に保持された中間数をsビット桁上げ
する桁上げ手段と、 桁上げ後の中間数を桁上げ後の中間数における下位kビ
ットよりも上位のmビットの部分である上位データと下
位kビットの部分である下位データとに分割する分割手
段と、 分割手段による上位データに対する法pによる剰余を前
記テーブル手段から読み出す読み出し手段と、 テーブル手段から読み出された剰余と、分割手段による
下位データとを加算することにより新たな中間数を得る
加算手段と、 を備え、 前記第1保持手段は、前記加算手段により新たな中間数
が得られる度にその保持内容を新たな中間数に更新し、
前記初回では被乗数を中間数として出力し、前記2回目
以降では更新後の新たな中間数を出力し、 前記第2算出手段は、第1保持手段の保持内容を中間数
として前記部分積を算出することを特徴とする請求項15
記載の剰余乗算装置。
16. The first calculating means includes: a first holding means for holding a multiplicand; and an intermediate number held by the first holding means corresponding to a partial multiplier output from the output means for the second time and thereafter. carry means for carrying s bits; and upper data which is an m-bit part higher than the lower k bits in the intermediate number after the carry and a lower data which is a part of the lower k bits. Dividing means, reading means for reading the remainder of the higher-order data with respect to the higher-order data by the dividing means from the table means, and adding the remainder read from the table means and the lower-order data by the dividing means to form a new data. Adding means for obtaining an intermediate number, wherein the first holding means updates the held content to a new intermediate number each time a new intermediate number is obtained by the adding means,
In the first time, the multiplicand is output as an intermediate number, and in the second and subsequent times, an updated new intermediate number is output. The second calculating means calculates the partial product using the content held in the first holding means as an intermediate number. Claim 15
A modular multiplication device as described.
【請求項17】 前記制御手段は、第1〜第3ステージ
を含むパイプライン処理を制御する、第1ステージでは
出力手段に部分乗数を出力させるとともに第1算出手段
に中間数を出力させ、第2ステージでは第2算出手段に
部分積を算出させ、第3ステージでは累算手段に累算さ
せるともに補正手段に補正させることを特徴とする請求
項16記載の剰余乗算装置。
17. The control means controls pipeline processing including first to third stages. In the first stage, the output means outputs a partial multiplier and the first calculation means outputs an intermediate number. 17. The remainder multiplication apparatus according to claim 16, wherein in the second stage, the second calculating means calculates a partial product, and in the third stage, the accumulating means accumulates the partial product and the correcting means corrects the partial product.
【請求項18】 前記出力手段は、 最初に乗数を保持し、保持している値の下位sビットを
部分乗数として出力する乗数保持手段と、 乗数保持手段に保持されている値をsビット下位側にシ
フトさせ、シフト後の値を乗数保持手段に出力して保持
させるシフト手段とを備えることを特徴とする請求項17
記載の剰余乗算装置。
18. A multiplier holding means for first holding a multiplier and outputting the lower s bits of the held value as a partial multiplier, and a s bit lower value for the value held in the multiplier holding means. 18. A shift means for shifting the value to the side and outputting and holding the shifted value to the multiplier holding means.
A modular multiplication device as described.
【請求項19】 前記第2算出手段は、 第1保持手段に保持された中間数と乗数保持手段から出
力された部分乗数とから前記部分積を算出する乗算手段
と、 乗算手段に算出された部分積を保持する第2保持手段と
を備えることを特徴とする請求項18記載の剰余乗算装
置。
19. The multiplying means for calculating the partial product from the intermediate number held in the first holding means and the partial multiplier output from the multiplier holding means, and the second calculating means calculates the partial product. 19. The modular multiplication apparatus according to claim 18, further comprising: a second holding unit that holds a partial product.
【請求項20】 前記累算手段は、 前記累算値を保持する第3保持手段と、 第2保持手段に保持された部分積と、第3保持手段に保
持された累算値とを加算する加算器とを備え、 前記第3保持手段は加算結果を新たな累算値として保持
することを特徴とする請求項19記載の剰余乗算装置。
20. The accumulating means adds a third holding means for holding the accumulated value, a partial product held in the second holding means, and the accumulated value held in the third holding means. 20. The remainder multiplication apparatus according to claim 19, further comprising an adder that performs the addition, wherein the third holding unit holds the addition result as a new accumulated value.
【請求項21】 前記補正手段は、 pの整数倍の値をもつ補正値を保持する補正値保持手段
と、 前記第3保持手段に保持された累算値の有効ビット数が
所定のビット数以上になったとき、補正値保持手段に保
持された補正値を、部分積と累算値の加算と同時に前記
加算器に加減算させる補正制御手段とを備えることを特
徴とする請求項20記載の剰余乗算装置。
21. A correction value holding means for holding a correction value having an integer multiple of p, a correction value holding means for holding a correction value having an integral multiple of p, wherein the effective bit number of the accumulated value held by the third holding means is a predetermined bit number. 21.The correction device according to claim 20, further comprising: a correction control unit that adds / subtracts the correction value held by the correction value holding unit to the adder at the same time as the addition of the partial product and the accumulated value. Remainder multiplier.
【請求項22】 前記制御部は、第1保持手段及び乗数
保持手段を第1から第2ステージへのパイプラインラッ
チとし、第2保持手段を第2から第3ステージへのパイ
プラインラッチとしてパイプライン処理を制御すること
を特徴とする請求項21記載の剰余乗算装置。
22. The control unit, wherein the first holding means and the multiplier holding means are pipeline latches from a first stage to a second stage, and the second holding means is pipeline pipeline latches from a second stage to a third stage. 22. The remainder multiplication device according to claim 21, wherein the remainder multiplication device controls line processing.
【請求項23】 前記テーブル手段は、 mビットにより表現される各値に対応するアドレスが入
力され、そのアドレスが指す記憶領域に当該アドレスに
対応するmビットの値の2k倍に対する法pによる剰余
を予め記憶するメモリ素子を有することを特徴とする請
求項17記載の剰余乗算装置。
23. The table means, wherein an address corresponding to each value represented by m bits is input, and a modulo p for 2 k times the value of the m bit corresponding to the address is stored in a storage area indicated by the address. 18. The remainder multiplication device according to claim 17, further comprising a memory element that stores a remainder in advance.
【請求項24】 前記mビットは下位m1ビットと上位m2
ビット(m=m1+m2)とに分割され、 前記mビットにより表現される各値は、m1ビットにより
表現される値とm2ビットにより表現される値との組み合
わせに対応し、 前記テーブル手段は、 m1ビットにより表現される各値について、その値の2k
倍に対する法pによる剰余を予め記憶する第1部分テー
ブル手段と、 m2ビットにより表現される各値について、その値の2
k+m1倍に対する法pによる剰余を予め記憶する第2部分
テーブル手段とを備え、 前記加算手段は、第1、第2部分テーブルからの読み出
されたそれぞれの剰余と、前記下位データとを加算する
ことを特徴とする請求項17記載の剰余乗算装置。
24. The m bits include lower m1 bits and upper m2 bits.
Bits (m = m1 + m2), and each value represented by the m bits corresponds to a combination of a value represented by the m1 bits and a value represented by the m2 bits. , M1 bits, for each value 2 k
First partial table means for storing beforehand the remainder of the modulo p, and for each value represented by m2 bits, 2
second partial table means for storing in advance the remainder of the modulus p for k + m1 times, wherein the adding means calculates each remainder read from the first and second partial tables and the lower data. 18. The remainder multiplication device according to claim 17, wherein the addition is performed.
【請求項25】 前記mビットは下位側からt(3≦t≦m)
個の部分ビットm1、…、mtに分割され、 前記mビットにより表現される各値は、各mi(iは1か
らtまで整数)ビットにより表現される値(t個)を組
み合わせたものに対応し、 前記テーブル手段は、 部分ビットmiビットにより表現される各値について、そ
の値の2k+x倍(ここでx=m1+…+m(i-1))に対する法
pによる剰余を予め記憶するt個の部分テーブル手段T
iを備え、 前記加算手段は、t個の部分テーブル手段Tiからの読み
出されたt個の剰余と、前記下位データとを加算するこ
とを特徴とする請求項17記載の剰余乗算装置。
25. The m bits are t (3 ≦ t ≦ m) from the lower side.
, Mt, and each value represented by the m bits is a combination of values (t) represented by each mi (i is an integer from 1 to t) bits. Correspondingly, the table means previously stores, for each value represented by the partial bit mi bits, the remainder of 2 k + x times (here, x = m1 +... + M (i-1)) by the modulus p. T partial table means T
18. The remainder multiplication apparatus according to claim 17, further comprising: i, wherein the addition means adds the t remainders read from the t partial table means Ti and the lower order data.
【請求項26】 前記第2算出手段は、 出力手段から出力されたsビットの部分乗数の全ビット
が1であるか否かを判定する判定手段と、 第1算出手段により算出された前記中間数を2のs乗倍
した値と、当該被乗数の負の値とを生成する第1生成手
段と、 部分乗数の各ビットについて、部分乗数におけるビット
重みと前記中間数との積を生成する、この積は中間数を
ビット重みだけ桁上げした数である第2生成手段と、 全ビットが1であると判定された場合、第1生成手段に
生成された各値を加算し、全ビットが1であると判定さ
れなかった場合、第2生成手段に生成された積のうち、
部分乗数中の”1”のビットに対応するものを加算する
第2加算手段とを備えることを特徴とする請求項16記載
の剰余乗算装置。
26. The second calculating means determines whether or not all bits of the partial multiplier of s bits output from the output means are 1, and the intermediate calculated by the first calculating means. First generating means for generating a value obtained by multiplying the number by the s power of 2 and a negative value of the multiplicand; generating, for each bit of the partial multiplier, a product of a bit weight in the partial multiplier and the intermediate number; This product is obtained by adding the second generation means, which is a number obtained by carrying the intermediate number by the bit weight, and each value generated by the first generation means when it is determined that all the bits are 1, so that all the bits are obtained. If it is not determined to be 1, among the products generated by the second generation means,
17. The modular multiplication apparatus according to claim 16, further comprising second adding means for adding a bit corresponding to a bit of "1" in the partial multiplier.
【請求項27】 前記第2生成手段は、 第i(iは1から(s−1)の整数)のシフト手段は、
第1算出手段により算出された前記中間数をiビット左
シフトにより桁上げする第1から第(s−1)のシフト
手段を備え、 前記第1生成手段は、 第1算出手段により算出された前記中間数をsビット左
シフトにより桁上げする第sのシフト手段と、 前記中間数の1の補数を生成する補数生成手段と、 定数1を出力する定数出力手段とを備え、 前記第2加算手段は、 全ビットが1であると判定された場合に、第sのシフト
手段の出力と、補数生成手段に生成された1の補数と、
定数1を選択し、全ビットが1であると判定されなかっ
た場合に、部分乗数の20の位が”1”であれば前記中
間数を選択し、部分乗数の2iの位が”1”であれば、
第iのシフト手段の桁上げ結果を選択する選択手段と、 選択手段の選択結果を加算することにより前記部分積を
算出する加算器とを備えることを特徴とする請求項26記
載の剰余乗算装置。
27. The i-th (i is an integer from 1 to (s−1)) shift means,
First to (s-1) th shift means for carrying the intermediate number calculated by the first calculation means by i-bit left shift; and wherein the first generation means is calculated by the first calculation means. S-th shift means for carrying the intermediate number by s-bit left shift; complement generation means for generating a one's complement of the intermediate number; constant output means for outputting a constant 1; The means includes: when all bits are determined to be 1, the output of the s-th shift means, the one's complement generated by the complement generation means,
Select constant 1, when all the bits are not determined to be 1, if the 2 zero-position of the partial multiplier "1" to select the intermediate speed, the position of 2 i of portions multiplier " 1 "
27. The modular multiplication apparatus according to claim 26, further comprising: a selection unit that selects a carry result of the i-th shift unit; and an adder that calculates the partial product by adding the selection result of the selection unit. .
【請求項28】 前記sは3の倍数(3n)ビットであ
り、 前記部分乗数は、3ビットずつ区切ったn個の3ビット
データsn,…,s1で表され、 前記第2算出手段は、 第j(jは1からnの整数)の判定手段は、前記3ビッ
トデータsjが"111"であるか否かを判定する第1から
第nの判定手段と、 第jの判定手段により"111"であると判定された場合
に、前記中間数に”1000”と3ビットデータsjの位
3(j-1)とを乗じた値と、被乗数の負の値に3ビットデ
ータsjの位23(j-1)を乗じた値とを生成する第1から第
nの特別生成手段と、 第jの判定手段により"111"でないと判定された場合
には、3ビットデータsjの各ビットについて、当該ビッ
トの論理値と、sビット部分乗数における各ビットの重
みと、前記中間数との積を生成する第1から第nの一般
生成手段と、 "111"であると判定されたsjに対応する特別生成手段
により生成された値と、"111"でないと判定されたsj
に対応する一般生成手段により生成された積とを加算す
る加算手段とを備えることを特徴とする請求項16記載の
剰余乗算装置。
28. The s is a multiple of 3 (3n) bits, and the partial multiplier is represented by n pieces of 3-bit data sn,..., S1 divided by 3 bits. The j-th (j is an integer from 1 to n) determining means determines whether the 3-bit data sj is "111" by the first to n-th determining means and the j-th determining means. If it is determined to be 111 ", the value obtained by multiplying the intermediate number by" 1000 "and the order 2 3 (j-1) of the 3-bit data sj, and the negative value of the multiplicand by the 3-bit data sj The first to n-th special generation means for generating a value multiplied by the order 2 3 (j-1) and the j- th determination means, when it is determined that the value is not "111", the 3-bit data sj of For each bit, a first value for generating a product of the logical value of the bit, the weight of each bit in the s-bit partial multiplier, and the intermediate number And the value generated by the special generation unit corresponding to the n-th general generation unit, the sj determined to be “111”, and the sj determined to be not “111”.
17. The remainder multiplication device according to claim 16, further comprising: an addition unit that adds the product generated by the general generation unit corresponding to (i).
【請求項29】 前記第2算出手段は、 第i(iは1からsの整数)のシフト手段は、前記中間
数をiビット左シフトにより桁上げする第1から第sの
シフト手段を備え、 前記第1の一般生成手段は、第1及び第2シフト手段に
よるシフト結果を利用し、 前記第1を除く第jの一般生成手段は、第(3j−
3)、第(3j−2)、第(3j−1)のシフト手段に
よるシフト結果を利用し、 前記第jの特別生成手段は、第(3j)のシフト手段に
よるシフト結果を利用し、 第jの特別生成手段と第(j+1)の一般生成手段と
は、第(3j)のシフト手段を共用することを特徴とす
る請求項28記載の剰余乗算装置。
29. The second calculating means, wherein the i-th (i is an integer of 1 to s) shifting means includes first to s-th shifting means for carrying the intermediate number by i-bit left shift. The first general generation unit uses the shift result of the first and second shift units, and the j-th general generation unit except the first uses the (3j-
3) using the shift result by the (3j-2) th and (3j-1) th shift means; the jth special generation means using the shift result by the (3j) th shift means; 29. The modular multiplication apparatus according to claim 28, wherein the j special generation unit and the (j + 1) th general generation unit share the (3j) th shift unit.
【請求項30】 前記第jの特別生成手段は、 前記中間数又は第(3j−3)のシフト手段によるシフ
ト結果の1の補数を生成する補数生成手段と、 定数1を出力する定数出力手段とを備え、 前記加算手段は、 sjが”111”であると判定された場合に、第(3
j)のシフト手段の出力と、第jの特別生成手段中の補
数生成手段により生成された1の補数と、第jの特別生
成手段中の定数出力手段により出力された定数1とを選
択し、 s1が”111”であると判定されなかった場合に、中
間数と第(3j−2)、第(3j−1)のシフト手段の
出力とを選択し、 s1を除くsjが”111”であると判定されなかった
場合に、第(3j−3)、第(3j−2)、第(3j−
3)のシフト手段の出力を選択する選択手段と、 選択手段の選択結果を加算することにより前記部分積を
算出する加算器とを備えることを特徴とする請求項29記
載の剰余乗算装置。
30. The j-th special generation means, a complement generation means for generating the one's complement of the intermediate number or the result of the shift by the (3j-3) th shift means, and a constant output means for outputting a constant 1. The addition means includes: when sj is determined to be "111",
j) the output of the shift means, the one's complement generated by the complement generation means in the j-th special generation means, and the constant 1 output by the constant output means in the j-th special generation means. If s1 is not determined to be "111", the intermediate number and the outputs of the (3j-2) th and (3j-1) th shift means are selected, and sj excluding s1 is "111". Are not determined, the (3j-3) th, (3j-2) th, (3j-
30. The modular multiplication apparatus according to claim 29, further comprising: a selection unit that selects an output of the shift unit of 3); and an adder that calculates the partial product by adding a selection result of the selection unit.
【請求項31】 前記分割手段、読み出し手段、加算手
段を利用することにより、補正手段に補正された最後の
累算値の法pによる剰余を求める後処理手段を備えるこ
とを特徴とする請求項16記載の剰余乗算装置。
31. A post-processing unit for obtaining a remainder of the corrected last accumulated value by a modulus p by using the dividing unit, the reading unit, and the adding unit. 16. The modular multiplication device according to claim 16.
JP05480399A 1998-03-02 1999-03-02 Remainder multiplier Expired - Fee Related JP4293665B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP05480399A JP4293665B2 (en) 1998-03-02 1999-03-02 Remainder multiplier

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
JP4915298 1998-03-02
JP10-49152 1998-03-02
JP05480399A JP4293665B2 (en) 1998-03-02 1999-03-02 Remainder multiplier

Publications (2)

Publication Number Publication Date
JPH11316544A true JPH11316544A (en) 1999-11-16
JP4293665B2 JP4293665B2 (en) 2009-07-08

Family

ID=26389512

Family Applications (1)

Application Number Title Priority Date Filing Date
JP05480399A Expired - Fee Related JP4293665B2 (en) 1998-03-02 1999-03-02 Remainder multiplier

Country Status (1)

Country Link
JP (1) JP4293665B2 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU2003252789B2 (en) * 1999-09-29 2006-02-23 Hitachi, Ltd. Processing apparatus, program, or system of secret information
JP2010091913A (en) * 2008-10-10 2010-04-22 Renesas Technology Corp Data processing device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU2003252789B2 (en) * 1999-09-29 2006-02-23 Hitachi, Ltd. Processing apparatus, program, or system of secret information
JP2010091913A (en) * 2008-10-10 2010-04-22 Renesas Technology Corp Data processing device

Also Published As

Publication number Publication date
JP4293665B2 (en) 2009-07-08

Similar Documents

Publication Publication Date Title
US20060010190A1 (en) Modular arithmetic apparatus and method selecting a base in the residue number system
US6366940B1 (en) High-speed modular multiplication apparatus achieved in small circuit
US4807175A (en) Booth&#39;s multiplier
JPH05216627A (en) Multiplier and multiplying method
JPH05210484A (en) Bit series division method and device
JP3551113B2 (en) Divider
US6769006B2 (en) Method and apparatus for calculating a reciprocal
US10635397B2 (en) System and method for long addition and long multiplication in associative memory
JP4293665B2 (en) Remainder multiplier
US7296049B2 (en) Fast multiplication circuits
JP3660075B2 (en) Dividing device
JP2000503146A (en) Modular arithmetic coprocessor with integer division circuit
EP1573510A2 (en) Multiplier with look up tables
JP4177125B2 (en) Arithmetic device and arithmetic method of arithmetic device
JPH0326114A (en) Multiplication remainder computing element
CN111615700A (en) Arithmetic circuit
JPH11237973A (en) Multiplier
JPH11282351A (en) Inverse element computing method in security technique, computing device using the method and recording medium recording program for executing the method
JP3197186B2 (en) Multiplication device using semiconductor memory
JP3875183B2 (en) Arithmetic unit
JP3261600B2 (en) Remainder multiplier
JPS6155691B2 (en)
CN112732219A (en) Multiplication circuit and method in SSD (solid State disk) master control chip
JPH11203110A (en) Divider
JP2803442B2 (en) Square root device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20051130

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20090310

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20090407

FPAY Renewal fee payment (prs date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120417

Year of fee payment: 3

R150 Certificate of patent (=grant) or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees