JP2002175180A - Reciprocal operation method and reciprocal operation device, and computer-readable recording medium with reciprocal operation program recorded thereon - Google Patents

Reciprocal operation method and reciprocal operation device, and computer-readable recording medium with reciprocal operation program recorded thereon

Info

Publication number
JP2002175180A
JP2002175180A JP2000372115A JP2000372115A JP2002175180A JP 2002175180 A JP2002175180 A JP 2002175180A JP 2000372115 A JP2000372115 A JP 2000372115A JP 2000372115 A JP2000372115 A JP 2000372115A JP 2002175180 A JP2002175180 A JP 2002175180A
Authority
JP
Japan
Prior art keywords
value
flag
register
updating
reciprocal
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.)
Pending
Application number
JP2000372115A
Other languages
Japanese (ja)
Inventor
Takatoshi Ono
貴敏 小野
Natsume Matsuzaki
なつめ 松崎
Yasuo Okumura
康男 奥村
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 JP2000372115A priority Critical patent/JP2002175180A/en
Publication of JP2002175180A publication Critical patent/JP2002175180A/en
Pending legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To provide a reciprocal operation method suitable for shortening the time taken for an operation and reducing the circuit scale, a reciprocal operation device and a recording medium with reciprocal operation program recorded thereon. SOLUTION: This device is provided with 5 registers Ua, Ub, Va, Vb and W, 2 adders, a 1-bit arithmetic right shifter and a selector group. By repeating parallel update for the 5 registers Ua, Ub, Va, Vb and W, a reciprocal is calculated.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明は、バイナリユークリ
ッド互除法に基づく逆数演算方法、逆数演算装置に関す
る。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a reciprocal operation method and a reciprocal operation device based on a binary Euclidean algorithm.

【0002】[0002]

【従来の技術】従来、素数pを法とし、剰余体上におけ
る逆数を算出する一方法として、バイナリユークリッド
互除法(Binary extended gcd algorithm)がある。例
えば、文献Handbook of Applied Cryptography(by A.
Menezes, P. van Oorschot, and S. Vanstone, CRC Pre
ss, 1996)のp.608にバイナリユークリッド互除法(Bin
ary extended gcd algorithm)が記載されている。な
お、バイナリユークリッド互除法は、1962年に、R.
SilverとJ. Tersianにより考案された。
2. Description of the Related Art Conventionally, a binary Euclidean algorithm (Binary extended gcd algorithm) is known as a method for calculating a reciprocal number on a remainder field using a prime number p as a modulus. For example, the reference Handbook of Applied Cryptography (by A.
Menezes, P. van Oorschot, and S. Vanstone, CRC Pre
ss, 1996), p.608, Binary Euclidean Algorithm (Bin
ary extended gcd algorithm). The Binary Euclidean algorithm was introduced in 1962 by R.
Invented by Silver and J. Tersian.

【0003】図28は、前記文献に記されているアルゴ
リズムを示す図である。同図にみられるように、前記文
献に記されたアルゴリズム(バイナリユークリッド互除
法)2800は、二つの正の整数x,yを入力した結
果、ax+by=vの関係を満たす、整数a,b,vを
算出する。ここで、v=gcd(x,y)であり、gc
d(x,y)とは、xとyとの最大公約数を意味する。
FIG. 28 is a diagram showing an algorithm described in the above document. As can be seen from the figure, the algorithm (binary Euclidean algorithm) 2800 described in the above-mentioned document receives two positive integers x and y, and as a result, integers a, b, and satisfies the relationship of ax + by = v. Calculate v. Here, v = gcd (x, y), and gc
d (x, y) means the greatest common divisor of x and y.

【0004】そして、アルゴリズム2800は、変数
u,v,A,B,C,Dを初期化する処理2801、変
数u,A,Bを2で割り更新する処理2802、変数
v,C,Dを2で割り更新する処理2803、変数u,
vの大小関係に基づいて、各変数を更新する処理280
4、変数uの値に基づく処理2805から構成される。
図29乃至図30に、一例として、アルゴリズム280
0に基づく逆数演算方法のフローチャートを示す。な
お、前記文献において、逆数(gcd(x,y)=1)
を算出する際に、図28に示したアルゴリズムにおける
変数A,Cの値を演算する必要性がないことが示されて
いる。これにより、フローチャートでは、AとCとの演
算は省略されている。また、v=1により、変数gの計
算も省略されている。
The algorithm 2800 includes a process 2801 for initializing the variables u, v, A, B, C and D, a process 2802 for dividing and updating the variables u, A, B by 2 and a process 2802 for updating the variables v, C and D. The process 2803 of updating by dividing by 2, the variable u,
Processing 280 for updating each variable based on the magnitude relation of v
4. Processing 2805 based on the value of the variable u.
FIGS. 29 and 30 show an algorithm 280 as an example.
4 shows a flowchart of a reciprocal operation method based on 0. Note that, in the above document, the reciprocal (gcd (x, y) = 1)
It is shown that there is no need to calculate the values of the variables A and C in the algorithm shown in FIG. Thus, the calculation of A and C is omitted in the flowchart. Also, the calculation of the variable g is omitted because v = 1.

【0005】図29にみられるように、アルゴリズム2
800に基づく逆数演算方法(以下、逆数演算方法28
00と呼称)は、まず、変数x,yに、二つの正の整数
を入力し(ステップS2901)、変数x,yとも偶数
である間(ステップS2902)、xにx/2、yにy
/2を代入する(ステップS2903)。そして、uに
x、vにy、Bに0、Dに1を代入し、変数u,v,
B,Dを初期化する(ステップS2904)。
[0005] As shown in FIG.
800 (hereinafter, reciprocal operation method 28)
First, two positive integers are input to variables x and y (step S2901), and while x and y are even numbers (step S2902), x is x / 2 and y is y.
/ 2 is substituted (step S2903). Then, x is substituted into u, y is substituted into v, 0 is substituted into B, 1 is substituted into D, and variables u, v,
B and D are initialized (step S2904).

【0006】次に、図30にみられるように、処理28
02に進み、変数uが偶数であるかを判定し、判定の結
果、uが奇数であるならば、処理2803に進み、uが
偶数であるならば、以下の処理を施す(ステップS30
01)。変数uにu/2を代入する(ステップS300
2)。そして、Bが偶数であるかを判定する(ステップ
S3003)。判定の結果、Bが偶数であるならば、変
数BにB/2を代入し(ステップS3004)、Bが奇
数であるならば、変数Bに(B−x)/2を代入する
(ステップS3005)。以上、ステップS3001に
戻り処理を繰返す。
Next, as shown in FIG.
02, it is determined whether or not the variable u is an even number. If the result of the determination is that u is an odd number, the processing proceeds to step 2803. If u is an even number, the following processing is performed (step S30).
01). Substitute u / 2 for the variable u (step S300)
2). Then, it is determined whether B is an even number (step S3003). As a result of the determination, if B is an even number, B / 2 is substituted for the variable B (step S3004), and if B is an odd number, (B−x) / 2 is substituted for the variable B (step S3005). ). As described above, the process returns to step S3001 and is repeated.

【0007】処理2803は、変数vが偶数であるかを
判定し、判定の結果、vが奇数であるならば、処理28
04に進み、vが偶数であるならば、以下の処理を施す
(ステップS3011)。変数vにv/2を代入する
(ステップS3012)。そして、Dが偶数であるかを
判定する(ステップS3013)。判定の結果、Dが偶
数であるならば、変数DにD/2を代入し(ステップS
3014)、Dが奇数であるならば、変数Dに(D−
x)/2を代入する(ステップS3015)。以上、ス
テップS3011に戻り処理を繰返す。
A process 2803 determines whether or not the variable v is an even number. If the result of the determination is that the variable v is an odd number, the process 2803
Proceeding to 04, if v is an even number, the following processing is performed (step S3011). Substitute v / 2 for the variable v (step S3012). Then, it is determined whether D is an even number (step S3013). If the result of the determination is that D is an even number, D / 2 is substituted for the variable D (step S
3014), if D is odd, the variable D is set to (D−
x) / 2 is substituted (step S3015). As described above, the process returns to step S3011 to repeat the process.

【0008】処理2804は、変数u,vの大小関係を
判定し(ステップS3021)、判定の結果、uがvよ
り大きければ、変数uにu−v、変数BにB−Dを代入
し(ステップS3022,S3023)、uがvより小
さければ,変数vにv−u、変数DにD−Bを代入する
(ステップS3024,S3025)。そして、図29
にみられるように、処理2805に進み、条件(u=
0)が成立するかを判定する(ステップS2911)。
判定の結果、条件(u=0)が成立する迄、処理280
2(ステップS3001)又は処理2803(ステップ
S3011)に戻り、処理を繰返し、条件(u=0)が
成立すると、変数bにDを代入し(ステップS291
2)、変数bの値を出力し、処理を終了する(ステップ
S2913)。
In step 2804, the magnitude relationship between the variables u and v is determined (step S3021). If the result of the determination is that u is greater than v, uv is substituted for the variable u and BD is substituted for the variable B (step S3021). If u is smaller than v, vu is substituted for the variable v and DB is substituted for the variable D (steps S3024 and S3025). And FIG.
As can be seen from FIG.
0) is determined (step S2911).
Processing 280 until the condition (u = 0) is satisfied as a result of the determination.
2 (step S3001) or processing 2803 (step S3011), the processing is repeated, and when the condition (u = 0) is satisfied, D is substituted for the variable b (step S291).
2) The value of the variable b is output, and the process ends (step S2913).

【0009】(補足事項)ここで、図29乃至図30の
フローチャートについて補足する。 (補足−1)処理2802と処理2803とは、処理の
対象とする変数が異なるだけで、処理としては同じであ
る。 (補足−2)演算処理としては、減算処理(f(x,
y)=x−y)とシフト処理(g(z)=z/2)のみ
で構成される。なお、減算処理の代わりに、加算処理
(f(x,y)=x+(−y))としてもよい。
(Supplementary Items) Here, the flowcharts of FIGS. 29 and 30 will be supplemented. (Supplement-1) The processing 2802 and the processing 2803 are the same as the processing except that the variables to be processed are different. (Supplement-2) As the arithmetic processing, a subtraction processing (f (x,
y) = xy) and shift processing (g (z) = z / 2) only. Note that, instead of the subtraction processing, an addition processing (f (x, y) = x + (− y)) may be performed.

【0010】(補足−3)処理2802において、変数
u,Bはそれぞれ独立であり、処理2803において、
変数v,Dはそれぞれ独立である。同様に、処理280
4においても、変数u,Bはそれぞれ独立であり、変数
v,Dはそれぞれ独立である。これにより、ステップS
3002とS3004またはS3005とを並列に処理
し、変数u,Bを並列に更新することが可能である。同
様に、ステップS3012とS3014またはS301
5とを並列に処理し、変数v,Dを並列に更新すること
が可能である。また、ステップS3022,S302
3、またはステップS3024,S3025を並列に処
理し、変数u,B、または変数v,Dを並列に更新する
ことも可能である。
(Supplement-3) In step 2802, variables u and B are independent of each other.
The variables v and D are independent of each other. Similarly, processing 280
Also in 4, the variables u and B are independent, and the variables v and D are independent. Thereby, step S
It is possible to process 3002 and S3004 or S3005 in parallel, and update variables u and B in parallel. Similarly, steps S3012 and S3014 or S301
5 can be processed in parallel, and variables v and D can be updated in parallel. Steps S3022 and S302
3 or Steps S3024 and S3025 can be processed in parallel to update variables u and B or v and D in parallel.

【0011】そして、前記(補足−1)乃至(補足−
3)をも考慮すると、アルゴリズム2800に基づく逆
数演算装置として、逐次処理装置と並列処理装置の二種
類が考えられる。ここで、逐次処理装置とは、1つの減
算器または1つの加算器と1つの1ビット算術右シフト
器とを備え、変数u,v,B,Dを逐次に処理する逆数
演算装置を指す。並列処理装置とは、2つの減算器また
は2つの加算器と2つの1ビット算術右シフト器とを備
え、前記(補足−3)に基づいて、変数u,v,B,D
を並列に処理する逆数演算装置を指す。
The above (Supplement-1) to (Supplement-
In consideration of 3), two types of reciprocal operation devices based on the algorithm 2800 can be considered: a sequential processing device and a parallel processing device. Here, the sequential processing device refers to a reciprocal operation device that includes one subtractor or one adder and one 1-bit arithmetic right shifter and sequentially processes variables u, v, B, and D. The parallel processing device includes two subtracters or two adders and two 1-bit arithmetic right shifters, and based on (Supplement-3), variables u, v, B, D
Are processed in parallel.

【0012】[0012]

【発明が解決しようとする課題】しかしながら、逐次処
理装置は、並列処理装置に比べ、回路規模が小さい代わ
りに、変数u,v,B,Dを逐次に処理することによ
り、演算に費やす時間が長くなる。一方、並列処理装置
は、逐次処理装置に比べ、演算に費やす時間が短くなる
代わりに、2つの減算器または2つの加算器と2つの1
ビット算術右シフト器とを備えることにより、回路規模
が大きくなるという問題がある。
However, the sequential processing device has a smaller circuit scale than the parallel processing device, but instead of processing the variables u, v, B, and D sequentially, the time spent for the operation is reduced. become longer. On the other hand, the parallel processing device requires two subtractors or two adders and two 1
The provision of the bit arithmetic right shifter has a problem that the circuit scale is increased.

【0013】本発明は上記の問題に鑑みてなされたもの
であり、演算に費やす時間を短く、かつ回路規模を小さ
くするのに適した逆数演算方法と、前記逆数演算方法に
基づいて装置化した逆数演算装置と、前記逆数演算方法
をプログラムとして記録したコンピュータ読み取り可能
な記録媒体とを提供することを目的とする。
SUMMARY OF THE INVENTION The present invention has been made in view of the above problems, and has a reciprocal operation method suitable for reducing the time required for the operation and reducing the circuit scale, and an apparatus based on the reciprocal operation method. It is an object of the present invention to provide a reciprocal operation device and a computer-readable recording medium in which the reciprocal operation method is recorded as a program.

【0014】[0014]

【課題を解決するための手段】上記問題を解決するた
め、本発明の逆数演算方法は、あらかじめ定められた正
の素数pを法とした剰余体上で、整数Aの逆数を求める
逆数演算方法であって、5つの中間値保持レジスタU
a,Ub,Va,Vb,Wを、Ua=A,Ub=2,V
a=−p,Vb=0,W=A−pに初期化する初期化ス
テップと、次の(a)乃至(e)を並列に実行する更新ステッ
プと、(a)Uaの値を第1の値に更新すること、第1の
値は(a1)Ub、または(a2)(Ub/2 mod p)で
あり、(b)Ubの値を、(b1)W、または(b2)Uaに更新
すること、(c)Vaの値を第2の値に更新すること、第
2の値は(c1)(Vb/2 modp)、または(c2)Vb
であり、(d)Vbの値を、(d1)W、または(d2)Vaに更
新すること、(e)Wの値を、第1の値と第2の値とを加
算した値に更新すること、Ubの値が0でないとき、更
新ステップを再度実行し、0のとき、Uaの値を整数A
に対する逆数として出力する出力ステップとを有し、前
記更新ステップは、前記(a1)と(c1)の組、(a2)と(c2)の
組を選択し、(b)(d)について、(b1)と(d1)の組み以外の
組を選択し、5つの中間値保持レジスタを並列に更新す
る。
In order to solve the above-mentioned problem, a reciprocal operation method according to the present invention comprises a reciprocal operation method for obtaining a reciprocal of an integer A on a modulo modulo a predetermined positive prime p. And the five intermediate value holding registers U
a, Ub, Va, Vb, W, Ua = A, Ub = 2, V
an initialization step of initializing a = -p, Vb = 0, W = A-p, an update step of executing the following (a) to (e) in parallel, and (a) first setting the value of Ua The first value is (a1) Ub or (a2) (Ub / 2 mod p), and the value of (b) Ub is changed to (b1) W or (b2) Ua. Updating, (c) updating the value of Va to a second value, the second value being (c1) (Vb / 2 modp), or (c2) Vb
And (d) updating the value of Vb to (d1) W or (d2) Va, and updating the value of (e) W to a value obtained by adding the first value and the second value. That is, when the value of Ub is not 0, the updating step is executed again.
And an output step of outputting as a reciprocal to the updating step, wherein the updating step selects the pair of (a1) and (c1) and the pair of (a2) and (c2), and for (b) and (d), A set other than the set of b1) and (d1) is selected, and the five intermediate value holding registers are updated in parallel.

【0015】さらに、前記更新ステップは、状態を示す
4つのフラグF1乃至F4を管理し、前記(a1)または(a
2)、(b1)または(b2)、(c1)または(c2)、(d1)または(d2)
のそれぞれ一方をフラグF1乃至F4が示す値に応じて
選択する。さらに、前記初期化ステップは、4つのフラ
グF1,F2,F3,F4を、F1=0,F2=Ua
[0](Uaの最下位ビットの値),F3=0,F4=
W[s](Wの符号ビットの値)に初期化し、前記更新
ステップは、次の(f)乃至(i)を並列に実行し、(f)フラ
グF1の値を反転すること、(g)フラグF2の値を、フ
ラグF1の値が1かつフラグF3の値が0の場合には、
(g1)第1の値の最下位ビットの値に更新し、フラグF1
の値が1かつフラグF3の値が1の場合には、(g2)第2
の値の最下位ビットの値に更新し、それ以外の場合に
は、(g3)更新しないこと、(h)フラグF3の値を、フラ
グF1の値が0かつフラグF2の値が1の場合には、(h
1)F4の値に更新し、それ以外の場合には、(h2)更新し
ないこと、(i)フラグF4の値を、フラグF1の値が1
の場合には、(i1)第1の値と第2の値とを加算した値の
符号ビットの値に更新し、フラグF1の値が0の場合に
は、(i2)更新しないこと、とする。
Further, the updating step manages four flags F1 to F4 indicating a state, and
2), (b1) or (b2), (c1) or (c2), (d1) or (d2)
Are selected according to the values indicated by the flags F1 to F4. Further, in the initialization step, the four flags F1, F2, F3, and F4 are set as follows: F1 = 0, F2 = Ua
[0] (the value of the least significant bit of Ua), F3 = 0, F4 =
W [s] (the value of the sign bit of W), the updating step executes the following (f) to (i) in parallel, and (f) inverts the value of the flag F1, (g) ) When the value of the flag F2 is 1 and the value of the flag F3 is 0,
(g1) Update to the value of the least significant bit of the first value, and
Is 1 and the value of the flag F3 is 1, the (g2) second
Is updated to the value of the least significant bit of the value of (a), otherwise (g3) is not updated, (h) the value of the flag F3 is 0, and the value of the flag F1 is 0 and the value of the flag F2 is 1. Contains (h
1) Update to the value of F4, otherwise (h2) Do not update, (i) Change the value of flag F4 to 1
In the case of (i1), update to the value of the sign bit of the value obtained by adding the first value and the second value, and if the value of the flag F1 is 0, (i2) do not update. I do.

【0016】さらに、前記更新ステップは、前記(a)に
おいて、フラグF3の値が1の場合には、(a1)を選択
し、フラグF3の値が0の場合には、(a2)を選択し、前
記(b)において、フラグF2の値が1かつフラグF4の値
が0の場合には、(b1)を選択し、それ以外の場合には、
(b2)を選択し、前記(c)において、フラグF3の値が1
の場合には、(c1)を選択し、フラグF3の値が0の場合
には、(c2)を選択し、前記(d)において、フラグF2の値
が1かつフラグF4の値が1の場合には、(d1)を選択
し、それ以外の場合には、(d2)を選択する。
Further, in the updating step, in (a), when the value of the flag F3 is 1, (a1) is selected, and when the value of the flag F3 is 0, (a2) is selected. Then, in (b), if the value of the flag F2 is 1 and the value of the flag F4 is 0, (b1) is selected; otherwise,
(b2) is selected, and in (c), the value of the flag F3 is set to 1
In the case of (c), (c1) is selected, and when the value of the flag F3 is 0, (c2) is selected. In (d), the value of the flag F2 is 1 and the value of the flag F4 is 1 In this case, select (d1). Otherwise, select (d2).

【0017】さらに、前記初期化ステップは、整数Aを
素数p未満になるまで繰返しpの値で減算し、減算結果
をもって中間値保持レジスタUa,Wを初期化するとし
てもよい。さらに、前記更新ステップは、前記(a2)(U
b/2 mod p)として、Ubが偶数の場合には、
Ubを1ビット右算術シフトし、Ubが奇数の場合に
は、Ubにpの値を加算又は減算し、1ビット右算術シ
フトし、前記(c1)(Vb/2mod p)として、Vb
が偶数の場合には、Vbを1ビット右算術シフトし、V
bが奇数の場合には、Vbにpの値を加算又は減算し、
1ビット右算術シフトするとしてもよい。
Further, in the initialization step, the integer A may be repeatedly subtracted by the value of p until the integer A becomes less than the prime number p, and the intermediate value holding registers Ua and W may be initialized based on the subtraction result. Further, the updating step includes the step (a2) (U
b / 2 mod p), when Ub is an even number,
If Ub is arithmetically shifted right by one bit, and if Ub is an odd number, the value of p is added or subtracted to Ub, arithmetically shifted right by one bit, and Vb is calculated as (c1) (Vb / 2 mod p).
Is an even number, Vb is arithmetically shifted right by one bit,
If b is odd, add or subtract the value of p to Vb,
Arithmetic shift by one bit right may be performed.

【0018】さらに、nは、1以上かつ2n-1<p<2n
の関係式を満す正の整数であり、前記更新ステップは、
前記(a2)として、Ubが奇数の場合において、Ubが2
n-1以下ならば、Ubにpの値を加算し、Ubが2n-1
上ならば、Ubにpの値を減算し、前記(c1)として、V
bが奇数の場合において、Vbが2n-1以下ならば、V
bにpの値を加算し、Vbが2n-1以上ならば、Vbに
pの値を減算するとしてもよい。
Further, n is 1 or more and 2 n-1 <p <2 n
Is a positive integer that satisfies the relationship of
As (a2), when Ub is an odd number, Ub is 2
If n-1 or less, adds the value of p in Ub, if Ub is 2 n-1 or more, the value of p by subtracting the Ub, as the (c1), V
When b is an odd number and Vb is 2 n-1 or less, V
The value of p may be added to b, and the value of p may be subtracted from Vb if Vb is 2 n-1 or more.

【0019】上記問題を解決するため、本発明の逆数演
算装置は、あらかじめ定められた正の素数pを法とした
剰余体上で、整数Aの逆数を求める逆数演算装置であっ
て、初期値として整数A,2,−p,0,A−pをそれ
ぞれ保持する中間値レジスタUa,Ub,Va,Vb,
Wと、中間値レジスタUb及びVbの一方の値を選択す
る第1セレクタと、第1セレクタの選択結果を剰余体上
で2で割る除算部と、中間値レジスタUb及び除算部の
除算結果の一方を選択し、中間値レジスタUaに出力す
る第2セレクタと、中間値レジスタVb及び除算部の除
算結果の一方を選択し、中間値レジスタVaに出力する
第3セレクタと、第2セレクタの選択結果と第3セレク
タの選択結果とを加算し、中間値レジスタWに出力する
加算器と、中間値レジスタUa及び加算結果の一方を選
択し、中間値レジスタUbに出力する第4セレクタと、
中間値レジスタVa及び加算結果の一方を選択し、中間
値レジスタVbに出力する第5セレクタと、中間値レジ
スタUbの値が0になるまで、第1乃至第5セレクタの
選択を制御するとともに、中間値レジスタUa,Ub,
Va,Vb,Wの同時更新を繰返し行い、中間値レジス
タUbの値が0になったとき、中間値レジスタUaの値
を整数Aの逆数として出力する制御部とを備える。
In order to solve the above problem, a reciprocal operation device of the present invention is a reciprocal operation device for obtaining a reciprocal of an integer A on a modulo modulo a predetermined positive prime p. , Intermediate values registers Ua, Ub, Va, Vb, which hold integers A, 2, -p, 0, Ap, respectively.
W, a first selector for selecting one of the intermediate value registers Ub and Vb, a division unit for dividing the selection result of the first selector by 2 on the remainder field, and a division result for the intermediate value register Ub and the division unit. A second selector for selecting one and outputting the result to the intermediate value register Ua; a third selector for selecting one of the intermediate value register Vb and the division result of the division unit and outputting the result to the intermediate value register Va; An adder that adds the result and the selection result of the third selector and outputs the result to the intermediate value register W, a fourth selector that selects one of the intermediate value register Ua and the addition result and outputs the result to the intermediate value register Ub,
A fifth selector that selects one of the intermediate value register Va and the addition result and outputs the selected result to the intermediate value register Vb, and controls selection of the first to fifth selectors until the value of the intermediate value register Ub becomes 0, The intermediate value registers Ua, Ub,
A control unit that repeatedly updates Va, Vb, and W repeatedly and outputs the value of the intermediate value register Ua as the reciprocal of the integer A when the value of the intermediate value register Ub becomes 0.

【0020】さらに、前記制御部は、状態を示すための
4つのフラグF1乃至F4を保持するフラグ部と、4つ
のフラグの値に応じて第1乃至第5セレクタの選択を制
御するセレクタ制御部と、中間値レジスタUbの値が0
になるまで、4つのフラグF1乃至F4を同時に更新す
るととも、5つの中間値レジスタUa,Ub,Va,V
b,Wを更新させる更新部とを備える。
Further, the control section includes a flag section for holding four flags F1 to F4 for indicating states, and a selector control section for controlling selection of the first to fifth selectors according to the values of the four flags. And the value of the intermediate value register Ub is 0
, The four flags F1 to F4 are updated simultaneously, and the five intermediate value registers Ua, Ub, Va, V
b, an updating unit for updating W.

【0021】さらに、前記除算部は、第1セレクタの選
択結果が奇数である場合に素数pを加減算する加算器
と、加算器による加算結果を1ビット右算術シフトする
1ビット右算術シフト器とを備える。
Further, the division unit includes an adder for adding and subtracting a prime number p when the selection result of the first selector is an odd number, and a 1-bit right arithmetic shifter for right-arithmically shifting the addition result by the adder. Is provided.

【0022】[0022]

【発明の実施の形態】(実施の形態1)本発明の実施の
形態1における逆数演算方法は、nビットの素数pを法
とする剰余体上で正の整数Aの逆数を算出する逆数演算
方法であり、例えば図8及び図9に示すようなハードウ
ェアにおいて実行される。このハードウェアは、5つの
中間値Ua,Ub,Va,Vb,Wを保持する5つの中
間値保持レジスタと、2つの加算器と1ビット算術右シ
フト器と、複数のセレクタと、状態を示すフラグF1乃
至F4を保持する複数のフリップフロップとを備える。
ここで、nは160ビット、各中間値保持レジスタは最
上位ビットを符号ビットとする162ビットのレジスタ
であるものとする。
(Embodiment 1) A reciprocal operation method according to Embodiment 1 of the present invention calculates an inverse of a positive integer A on a remainder field modulo an n-bit prime p. The method is executed in hardware as shown in FIGS. 8 and 9, for example. This hardware shows five intermediate value holding registers for holding five intermediate values Ua, Ub, Va, Vb, and W, two adders, a 1-bit arithmetic right shifter, a plurality of selectors, and states. A plurality of flip-flops that hold flags F1 to F4.
Here, it is assumed that n is 160 bits, and each intermediate value holding register is a 162 bit register with the most significant bit as a sign bit.

【0023】(逆数演算方法の構成)図1乃至図3は、
実施の形態1における逆数演算方法を示すフローチャー
トである。図1にみられるように、フローチャート10
0(以下、逆数演算方法100と呼称)は、逆数演算を
行う演算数Aの入力を受け付け(ステップS101)、
UaにA、Ubに2、Vaに−p、Vbに0、WにA−
pを代入し、変数Ua,Ub,Va,Vb,Wを初期化
する(ステップS102)。そして、F1に0、F2に
Ua[0]、F3に0、F4にW[s]、F5にUb
[0]を代入し、フラグF1乃至F5を初期化する(ス
テップS103)。ここで、Ua[0]とは、変数Ua
の0ビット(最下位ビット)の値を指し、W[s]と
は、変数Wの符号ビット(変数の正負を示すビット)の
値を指す。変数Uaのkビット目の値を示すときには、
Ua[k]と記す。なお、変数Ub,Va,Vb,Wに
ついても同様である。
(Configuration of Reciprocal Calculation Method) FIGS.
5 is a flowchart illustrating a reciprocal operation method according to the first embodiment. As can be seen in FIG.
0 (hereinafter, referred to as a reciprocal operation method 100) receives an input of an operation number A for performing a reciprocal operation (step S101);
A for Ua, 2 for Ub, -p for Va, 0 for Vb, A- for W
Substitute p and initialize variables Ua, Ub, Va, Vb, and W (step S102). Then, F1 is 0, Fa is Ua [0], F3 is 0, F4 is W [s], and F5 is Ub.
[0] is substituted, and the flags F1 to F5 are initialized (step S103). Here, Ua [0] is a variable Ua
And W [s] indicates the value of the sign bit of the variable W (the bit indicating the sign of the variable). When indicating the value of the k-th bit of the variable Ua,
Ua [k]. Note that the same applies to the variables Ub, Va, Vb, and W.

【0024】次に、変数Ua,Ub,Va,Vbを並行
して更新する(ステップS111乃至S114)。 (変数Uaの更新処理)図2にみられるように、ステッ
プS111は、フラグF3,F5の値を判定する(ステ
ップS201,S202)。そして、判定の結果に基づ
いて、変数Uaを、フラグF3の値が1の場合には、U
bに、フラグF3の値が0かつフラグF5の値が0の場
合には、Ub/2に、フラグF3の値が0かつフラグF
5の値が1の場合(Ubが奇数の場合)には、(Ub−
p)/2に更新する(ステップS211乃至S21
3)。
Next, the variables Ua, Ub, Va, Vb are updated in parallel (steps S111 to S114). (Process of Updating Variable Ua) As shown in FIG. 2, step S111 determines the values of the flags F3 and F5 (steps S201 and S202). Then, based on the result of the determination, if the value of the flag F3 is 1, the variable Ua is set to U
If the value of the flag F3 is 0 and the value of the flag F5 is 0, the value of the flag F3 is 0 and the value of the flag F3 is set to Ub / 2.
When the value of 5 is 1 (when Ub is an odd number), (Ub−
p) / 2 (steps S211 to S21)
3).

【0025】(変数Ubの更新処理)ステップS112
は、フラグF2,F4の値を判定する(ステップS22
1)。そして、判定の結果に基づいて、変数Ubを、フ
ラグF2の値が1かつフラグF4の値が0の場合には、
Wに、それ以外の場合には、Uaに更新する(ステップ
S231,S232)。
(Update of Variable Ub) Step S112
Determines the values of the flags F2 and F4 (step S22).
1). Then, based on the result of the determination, when the value of the flag F2 is 1 and the value of the flag F4 is 0,
W is updated to Ua in other cases (steps S231 and S232).

【0026】(変数Vaの更新処理)ステップS113
は、フラグF3,F5の値を判定する(ステップS24
1,S242)。そして、判定の結果に基づいて、変数
Vaを、フラグF3の値が0の場合には、Vbに、フラ
グF3の値が1かつフラグF5の値が0の場合には、V
b/2に、フラグF3の値が1かつフラグF5の値が1
の場合(Vbが奇数の場合)には、(Vb+p)/2に
更新する(ステップS251乃至S253)。
(Update of Variable Va) Step S113
Determines the values of the flags F3 and F5 (step S24).
1, S242). Based on the result of the determination, the variable Va is set to Vb when the value of the flag F3 is 0, and to Vb when the value of the flag F3 is 1 and the value of the flag F5 is 0.
b / 2, the value of the flag F3 is 1 and the value of the flag F5 is 1
(Vb is an odd number), it is updated to (Vb + p) / 2 (steps S251 to S253).

【0027】(変数Vbの更新処理)ステップS114
は、フラグF2,F4の値を判定する(ステップS26
1)。そして、判定の結果に基づいて、変数Vbを、フ
ラグF2の値が1かつフラグF4の値が1の場合には、
Wに、それ以外の場合には、Vaに更新する(ステップ
S271,S272)。
(Update of Variable Vb) Step S114
Determines the values of the flags F2 and F4 (step S26).
1). Then, based on the result of the determination, when the value of the flag F2 is 1 and the value of the flag F4 is 1,
W is updated to Va in other cases (steps S271 and S272).

【0028】(変数Wの更新処理)そして、図1にみら
れるように、変数Ua,Vaを加算し、変数Wを更新す
る(ステップS115)。次に、並行して、フラグF1
乃至F4を更新する(ステップS121乃至S12
4)。
(Update process of variable W) Then, as shown in FIG. 1, the variables Ua and Va are added to update the variable W (step S115). Next, in parallel, the flag F1
To F4 (Steps S121 to S12)
4).

【0029】(フラグF1の更新処理)図3にみられる
ように、ステップS121は、フラグF1を、1なら
0、0なら1に値を反転し更新する(ステップS30
1)。 (フラグF2の更新処理)ステップS122は、フラグ
F1,F3の値を判定する(ステップS311)。そし
て、判定の結果に基づいて、フラグF2を、フラグF1
の値が1かつフラグF3の値が0の場合には、Ua
[0]に、フラグF1の値が1かつフラグF3の値が1
の場合には、Va[0]に更新し(ステップS321,
S322)、それ以外の場合には、更新しない。
(Update of Flag F1) As shown in FIG. 3, in step S121, the flag F1 is updated by inverting the value of the flag F1 to 0 if it is 1 and 1 if it is 0 (step S30).
1). (Update processing of flag F2) In step S122, the values of the flags F1 and F3 are determined (step S311). Then, based on the result of the determination, the flag F2 is changed to the flag F1.
Is 1 and the value of the flag F3 is 0, Ua
In [0], the value of the flag F1 is 1 and the value of the flag F3 is 1
Is updated to Va [0] (Step S321,
S322) Otherwise, it is not updated.

【0030】(フラグF3の更新処理)ステップS12
3は、フラグF1,F2の値を判定する(ステップS3
31)。そして、判定の結果に基づいて、フラグF3
を、フラグF1の値が0かつフラグF2の値が1の場合
には、フラグF4の値に更新し(ステップS341)、
それ以外の場合には、更新しない。
(Update of Flag F3) Step S12
3 judges the values of the flags F1 and F2 (step S3
31). Then, based on the result of the determination, the flag F3
Is updated to the value of the flag F4 when the value of the flag F1 is 0 and the value of the flag F2 is 1 (step S341),
Otherwise, do not update.

【0031】(フラグF4の更新処理)ステップS12
4は、フラグF1の値を判定する(ステップS35
1)。そして、判定の結果に基づいて、フラグF4を、
フラグF1の値が1の場合には、W[s](符号ビット
の値)に更新し(ステップS361)、フラグF1の値
が0の場合には、更新しない。
(Update of Flag F4) Step S12
4 judges the value of the flag F1 (Step S35)
1). Then, the flag F4 is set based on the result of the determination.
When the value of the flag F1 is 1, it is updated to W [s] (the value of the sign bit) (step S361), and when the value of the flag F1 is 0, it is not updated.

【0032】(フラグF5の更新処理)そして、図1に
みられるように、フラグF3の値に基づいて、フラグF
5を、フラグF3の値が1の場合には、Vb[0]に、
フラグF3の値が0の場合には、Ub[0]に更新する
(ステップS125)。なお、”式1?式2:式3”
は、三項演算子を意味し、式1の真偽を判定し、真(0
以外)の場合には、式2の値をとり、偽(0)の場合に
は、式3の値をとるものとする。
(Update of Flag F5) As shown in FIG. 1, the flag F5 is updated based on the value of the flag F3.
5 to Vb [0] when the value of the flag F3 is 1,
If the value of the flag F3 is 0, it is updated to Ub [0] (step S125). In addition, “Expression 1? Expression 2: Expression 3”
Means a ternary operator, determines whether the expression 1 is true or false, and sets true (0
In the case of (other than), the value of Expression 2 is taken, and in the case of false (0), the value of Expression 3 is taken.

【0033】次に、条件(Ub=0)が成立するかを判
定する(ステップS131)。判定の結果、条件(Ub
=0)が成立しない場合には、ステップS111乃至S
114に戻り、処理を繰返し、条件(Ub=0)が成立
する場合には、演算数Aの逆数として変数Uaの値を出
力し、処理を終了する(ステップS132)。 (補足事項−A)ここで、逆数演算方法100について
補足する。
Next, it is determined whether the condition (Ub = 0) is satisfied (step S131). As a result of the judgment, the condition (Ub
= 0) is not satisfied, the processing in steps S111 to S111
Returning to 114, the process is repeated, and if the condition (Ub = 0) is satisfied, the value of the variable Ua is output as the reciprocal of the operation number A, and the process ends (step S132). (Supplementary Information-A) Here, the reciprocal operation method 100 will be supplemented.

【0034】(補足−A1)フラグF1乃至F5は、0
または1のいずれかの値をとり、フラグF1乃至F5の
値の組み合わせにより、変数Ua,Ub,Va,Vb,
Wの更新処理を制御する。 (補足−A2)ステップS111乃至S114におい
て、変数Ua、Vaを並行して更新する際に、2で除算
(1ビット算術右シフト処理)される変数が、フラグF
3により、1つに制御される。すなわち、図2中のS2
12(又はS213)における”Ua←Ub/2(又は
Ua←(Ub−p)/2)”と、S252(又はS25
3)における”Va←Vb/2(又はVa←(Vb−p)
/2)”とはいずれか一方が択一的に実行される。これ
により加算器及び1ビット算術右シフト器をS111と
S113とで兼用することができる。
(Supplement-A1) Flags F1 to F5 are set to 0
Or one of the values 1, and by combining the values of the flags F1 to F5, the variables Ua, Ub, Va, Vb,
W update processing is controlled. (Supplement-A2) In steps S111 to S114, when the variables Ua and Va are updated in parallel, the variable to be divided by two (1-bit arithmetic right shift processing) is set to the flag F
3 controls one. That is, S2 in FIG.
12 (or S213), “Ua ← Ub / 2 (or Ua ← (Ub−p) / 2)” and S252 (or S25).
3) “Va ← Vb / 2 (or Va ← (Vb−p)
/ 2) "is executed alternatively. As a result, the adder and the 1-bit arithmetic right shifter can be shared by S111 and S113.

【0035】(補足−A3)変数Ua,Ub,Va,V
bの更新処理(ステップS111乃至S114)から条
件判定処理(ステップS131)までの処理を1ループ
とする。例えば、3ループといえば、変数Ua,Ub,
Va,Vbの更新処理(ステップS111乃至S11
4)から条件判定処理(ステップS131)までの処理
を3回実行することを指す。
(Supplement-A3) Variables Ua, Ub, Va, V
The process from the update process (b) (steps S111 to S114) to the condition determination process (step S131) is defined as one loop. For example, speaking of three loops, variables Ua, Ub,
Update processing of Va and Vb (Steps S111 to S11
This refers to executing the processing from 4) to the condition determination processing (step S131) three times.

【0036】(変数Ua,Ub,Va,Vb,Wについ
て)次に、逆数演算方法100における変数Ua,U
b,Va,Vb,Wを、従来の技術に記した逆数演算方
法2800に対応させて説明する。図4は、変数Ua,
Ub,Va,Vb,Wと変数u,v,B,Dとの対応関
係を示すテーブルである。
(Regarding Variables Ua, Ub, Va, Vb, W) Next, the variables Ua, U
b, Va, Vb, and W will be described in association with the reciprocal operation method 2800 described in the related art. FIG. 4 shows the variables Ua,
9 is a table showing the correspondence between Ub, Va, Vb, W and variables u, v, B, D.

【0037】同図にみられるように、逆数演算方法28
00に基づけば、フラグF1の値が0の場合には、変数
Uaはvを、変数UbはDを、変数Vaは−uを、変数
Vbは−Bを、変数Wはv−uに対応する。フラグF1
の値が1の場合には、変数UaはDを、変数Ubはv
を、変数Vaは−Bを、変数Vbは−uを、変数WはD
−Bに対応する。
As can be seen from FIG.
Based on 00, when the value of the flag F1 is 0, the variable Ua corresponds to v, the variable Ub corresponds to D, the variable Va corresponds to -u, the variable Vb corresponds to -B, and the variable W corresponds to v-u. I do. Flag F1
Is 1, the variable Ua is D, and the variable Ub is v
, The variable Va is -B, the variable Vb is -u, and the variable W is D
Corresponds to -B.

【0038】(フラグF1乃至F5について)次に、逆
数演算方法100におけるフラグF1乃至F5を、従来
の技術に記した逆数演算方法2800に対応させて説明
する。図5は、フラグF1乃至F5が更新される処理
を、逆数演算方法2800の処理に対応付けたテーブル
である。
(Flags F1 to F5) Next, the flags F1 to F5 in the reciprocal operation method 100 will be described in association with the reciprocal operation method 2800 described in the conventional art. FIG. 5 is a table in which the processing of updating the flags F1 to F5 is associated with the processing of the reciprocal operation method 2800.

【0039】同図にみられるように、逆数演算方法28
00に対応付ければ、フラグF1は、処理2802にお
いては、変数uまたはBのどちらを更新するかを示し、
処理2803においては、変数vまたはDのどちらを更
新するかを示し、ステップS3002,S3004,S
3005,S3012,S3014,S3015,S3
022,S3023,S3024,S3025のいずれ
かの処理を実行した際に更新される。
As can be seen from FIG.
If it is associated with 00, the flag F1 indicates in the process 2802 which of the variables u or B is to be updated,
Processing 2803 indicates which of the variables v or D is to be updated.
3005, S3012, S3014, S3015, S3
It is updated when any one of the processes S022, S3023, S3024, and S3025 is executed.

【0040】フラグF2は、処理2804を実行するか
実行しないかを示し、ステップS3002,S301
2,S3023,S3025のいずれかの処理を実行し
た際に更新される。フラグF3は、処理2802または
処理2803のどちらを実行するかを示し、ステップS
3022,S3024のいずれかの処理を実行した際に
更新される。
The flag F2 indicates whether or not to execute the processing 2804.
2, S3023 and S3025 are updated when any of the processes is executed. The flag F3 indicates which of the processing 2802 and the processing 2803 is to be executed,
It is updated when any of the processes of 3022 and S3024 is executed.

【0041】フラグF4は,処理2804における変数
uまたはvのどちらを更新するかを示し、ステップS3
002,S3012,S3023,S3025のいずれ
かの処理を実行した際に更新される。フラグF5は、更
新する変数が偶数であるか奇数であるかを示し、ステッ
プS3002,S3004,S3005,S3012,
S3014,S3015,S3022,S3023,S
3024,S3025のいずれかの処理を実行した際に
更新される。
The flag F4 indicates which of the variables u or v in the processing 2804 is to be updated.
It is updated when any of the processes of 002, S3012, S3023, and S3025 is executed. The flag F5 indicates whether the variable to be updated is an even number or an odd number. Steps S3002, S3004, S3005, S3012
S3014, S3015, S3022, S3023, S
It is updated when any one of the processes 3024 and S3025 is executed.

【0042】以上、テーブル500に基づいて、逆数演
算方法100における各フラグの更新タイミングが決定
される。図6は、逆数演算方法2800に対応付けて、
フラグF1乃至F5により実行される処理のテーブルで
ある。なお、テーブル600は、行に逆数演算方法10
0における各フラグとし、列に逆数演算方法2800に
おける処理とし、”○”は実行する処理(処理可)、”
×”は実行しない処理(処理不可)、”−”は実行して
もしなくてもどちらでもよい処理とする。
As described above, the update timing of each flag in the reciprocal operation method 100 is determined based on the table 500. FIG. 6 corresponds to the reciprocal operation method 2800,
It is a table of a process performed by flags F1 to F5. In the table 600, the reciprocal operation method 10
Each flag is set to 0, the column is processed in the reciprocal operation method 2800, and “○” indicates a process to be executed (processable), “
“×” indicates that the processing is not executed (processing is impossible), and “−” indicates that the processing may or may not be executed.

【0043】同図にみられるように、フラグF1の値が
0の場合には、ステップS3004,S3005,S3
014,S3015,S3022,S3024を処理可
とし、ステップS3002,S3012,S3023,
S3025を処理不可とする。フラグF1の値が1の場
合には、ステップS3002,S3012,S302
3,S3025を処理可とし、ステップS3004,S
3005,S3014,S3015,S3022,S3
024を処理不可とする。
As can be seen from the figure, when the value of the flag F1 is 0, steps S3004, S3005, S3
014, S3015, S3022, and S3024 are allowed to be processed, and steps S3002, S3012, S3023,
S3025 is set to processing impossible. If the value of the flag F1 is 1, steps S3002, S3012, S302
Steps S3004 and S3025
3005, S3014, S3015, S3022, S3
024 cannot be processed.

【0044】フラグF2の値が0の場合には、ステップ
S3022乃至S3025を処理不可とする。フラグF
2の値が1の場合には、ステップS3022乃至S30
25を処理可とする。フラグF3の値が0の場合には、
ステップS3012,S3014,S3015を処理可
とし、ステップS3002,S3004,S3005を
処理不可とする。フラグF3の値が1の場合には、ステ
ップS3002,S3004,S3005を処理可と
し、ステップS3012,S3014,S3015を処
理不可とする。
If the value of the flag F2 is 0, steps S3022 to S3025 cannot be processed. Flag F
If the value of 2 is 1, steps S3022 to S30
25 can be processed. When the value of the flag F3 is 0,
Steps S3012, S3014, and S3015 are allowed to be processed, and steps S3002, S3004, and S3005 are disabled. If the value of the flag F3 is 1, steps S3002, S3004, and S3005 are allowed to be processed, and steps S3012, S3014, and S3015 are disabled.

【0045】フラグF4の値が0の場合には、ステップ
S3024,S3025を処理可とし、ステップS30
22,S3023を処理不可とする。フラグF4の値が
1の場合には、ステップS3022,S3023を処理
可とし、ステップS3024,S3025を処理不可と
する。フラグF5の値が0の場合には、ステップS30
02,S3004,S3012,S3014を処理可と
し、ステップS3005,S3015を処理不可とす
る。フラグF5の値が1の場合には、ステップS300
5,S3015を処理可とし、ステップS3002,S
3004,S3012,S3014を処理不可とする。
If the value of the flag F4 is 0, steps S3024 and S3025 are permitted to be processed, and step S30
22 and S3023 cannot be processed. If the value of the flag F4 is 1, steps S3022 and S3023 are allowed to be processed, and steps S3024 and S3025 are disabled. If the value of the flag F5 is 0, step S30
02, S3004, S3012, and S3014 can be processed, and steps S3005 and S3015 cannot be processed. If the value of the flag F5 is 1, step S300
5, S3015 can be processed, and steps S3002, S3015
Steps 3004, S3012, and S3014 are disabled.

【0046】図7は、テーブル600に基づいて、フラ
グF1乃至F5の値の組み合わせにより実行される処理
を示したテーブルである。なお、テーブル700は、行
に逆数演算方法2800における処理とし、列に逆数演
算方法100におけるフラグF1乃至F5の値の組み合
わせとし、”○”は実行する処理(処理可)、”×”は
実行しない処理(処理不可)とする。
FIG. 7 is a table showing processing executed based on a combination of the values of the flags F1 to F5 based on the table 600. In the table 700, the row is a process in the reciprocal operation method 2800, and the column is a combination of the values of the flags F1 to F5 in the reciprocal operation method 100. No processing (processing not possible).

【0047】同図にみられるように、例えば,フラグF
1乃至F5の値の組み合わせ{F1,F2,F3,F
4,F5}={0,0,0,0,0}の場合には、ステ
ップS3014が実行される。{F1,F2,F3,F
4,F5}={0,1,0,1,0}の場合には、ステ
ップS3014,S3022とが実行される。なお、変
数u,v,B,Dは、夫々が独立した変数であり、同時
に更新することが可能である。即ち、フラグF1乃至F
5の値の組み合わせによっては、ステップS3002,
S3012のいずれかにより、変数u,vのいずれかが
更新される一方で、並行して、ステップS3023,S
3025のいずれかにより、変数B,Dのいずれかが更
新される。同様に、ステップS3004(またはS30
05),S3014(またはS3015)のいずれかに
より変数B,Dが更新される一方で、並行してステップ
S3022,S3024のいずれかにより、変数u,v
のいずれかが更新される。
As can be seen from FIG.
Combination of values of 1 to F5 {F1, F2, F3, F
When 4, F5} = {0,0,0,0,0}, step S3014 is executed. {F1, F2, F3, F
When 4, F5} = {0,1,0,1,0}, steps S3014 and S3022 are executed. The variables u, v, B, and D are independent variables, and can be updated at the same time. That is, the flags F1 to F
Depending on the combination of the values of step 5, step S3002,
While any of the variables u and v is updated by any of S3012, in parallel, steps S3023 and S30
3025, any of the variables B and D is updated. Similarly, step S3004 (or S30)
05) and S3014 (or S3015), while the variables B and D are updated, and in parallel, the variables u and v are updated by one of steps S3022 and S3024.
Is updated.

【0048】以上、テーブル700に基づいて、変数U
a,Ub,Va,Vb,Wの更新処理が制御される。 (逆数演算方法100における初期値)次に、逆数演算
方法100における初期値について説明する。テーブル
400と、ステップS2904とに基づけば、変数U
a,Ub,Va,Vb,Wの初期値としては{Ua,U
b,Va,Vb,W}={A,1,−p,0,A−p}
が考えられる。ここで、x=p,y=Aとする。
As described above, based on the table 700, the variable U
The update processing of a, Ub, Va, Vb, and W is controlled. (Initial Value in Reciprocal Operation Method 100) Next, an initial value in the reciprocal operation method 100 will be described. Based on the table 400 and step S2904, the variable U
The initial values of a, Ub, Va, Vb, and W are {Ua, U
b, Va, Vb, W} = {A, 1, −p, 0, Ap}
Can be considered. Here, x = p and y = A.

【0049】しかしながら、以下の考察に基づいて、逆
数演算方法100における変数Ua,Ub,Va,V
b,WとフラグF1乃至F5との初期値を決める。逆数
演算方法2800において、演算数Aが奇数の場合に
は、ステップS3022,S3024のどちらかが実行
される。一方、テーブル700によれば、ステップS3
022,S3024を単独に実行するフラグF1乃至F
5の値の組み合わせが存在しないことが示されている。
即ち、逆数演算方法100において、演算数Aが奇数の
場合には、ステップS3022,S3024は単独に実
行されず、必ず、ステップS3004,S3005,S
3014,S3015のいずれかの処理と組をなす。
However, based on the following considerations, the variables Ua, Ub, Va, V
b, W and initial values of the flags F1 to F5 are determined. In the reciprocal operation method 2800, when the operation number A is an odd number, one of steps S3022 and S3024 is executed. On the other hand, according to the table 700, step S3
022, flags F1 to F for executing S3024 independently
It is shown that there is no combination of values of 5.
That is, in the reciprocal operation method 100, when the operation number A is an odd number, steps S3022 and S3024 are not executed independently, and steps S3004, S3005, and S
A pair is formed with any of the processes 3014 and S3015.

【0050】また、ステップS3004,S3005を
制御するフラグの値の組み合わせのうち、フラグF2,
F5は、変数Va,Vbの偶奇性に基づいている。一
方、ステップS3014,S3015を制御するフラグ
の値の組み合わせのうち、フラグF2,F5は、変数U
a,Ubの偶奇性に基づいている。これにより、ステッ
プS3004,S3005は、演算数Aの偶奇性に依存
しない処理であり、初期値に施される処理の対象から外
される。結果、初期値に施される処理として、ステップ
S3014とS3015とが挙げられる。
Further, among the combinations of the values of the flags for controlling steps S3004 and S3005, the flag F2
F5 is based on the evenness of the variables Va and Vb. On the other hand, among the combinations of the values of the flags that control steps S3014 and S3015, the flags F2 and F5
a, Ub. As a result, steps S3004 and S3005 are processes that do not depend on the evenness of the operation number A, and are excluded from the processes to be performed on the initial values. As a result, steps S3014 and S3015 are given as processing performed on the initial values.

【0051】以上、ステップS3014,S3015の
どちらかを実行するフラグF1乃至F5の値の組み合わ
せを、逆数演算方法100におけるフラグF1乃至F5
の初期値とする。さらに、ステップS3014,S30
15のどちらかを実行した後の変数Ua,Ub,Va,
Vb,Wの値が、{Ua,Ub,Va,Vb,W}=
{A,1,−p,0,A−p}となる変数Ua,Ub,
Va,Vb,Wの値を、逆数演算方法100における変
数Ua,Ub,Va,Vb,Wの初期値とする。
As described above, the combination of the values of the flags F1 to F5 for executing any one of steps S3014 and S3015 is determined by using the flags F1 to F5 in the reciprocal operation method 100.
The initial value of. Further, steps S3014 and S30
15, the variables Ua, Ub, Va,
When the values of Vb and W are {Ua, Ub, Va, Vb, W} =
Variables Ua, Ub, which become {A, 1, −p, 0, Ap}
The values of Va, Vb, and W are set as initial values of the variables Ua, Ub, Va, Vb, and W in the reciprocal operation method 100.

【0052】具体的には、テーブル700によれば、ス
テップS3014を実行するフラグF1乃至F5の値の
組み合わせ{F1,F2,F3,F4,F5}={0,
0,0,0,0}(演算数Aが偶数かつA>pの場
合)、または{0,1,0,0,0}(演算数Aが奇数
かつA>pの場合)、または{0,0,0,1,0}
(演算数Aが偶数かつA<pの場合)、または{0,
1,0,1,0}(演算数Aが奇数かつA<pの場合)
のいずれかが初期値となる。ステップS3015につい
ても同様である。
Specifically, according to the table 700, the combination of the values of the flags F1 to F5 for executing the step S3014 {F1, F2, F3, F4, F5} = {0,
0,0,0,0} (when the operation number A is even and A> p), or {0,1,0,0,0} (when the operation number A is odd and A> p), or { 0,0,0,1,0}
(If the operand A is even and A <p), or {0,
1,0,1,0} (when the operation number A is odd and A <p)
Is the initial value. The same applies to step S3015.

【0053】また、{Ua,Ub,Va,Vb,W}=
{A,1,−p,0,A−p}から逆算すると、{U
a,Ub,Va,Vb,W}={A,2,−p,0,A
−p}(ステップS3014の場合)または{Ua,U
b,Va,Vb,W}={A,2+p,−p,0,A−
p}(ステップS3015の場合)が初期値となる。な
お、逆数演算方法2800において、演算数Aが偶数の
場合には、ステップS3012が実行される。一方、テ
ーブル700によれば、ステップS3012を単独に実
行するフラグF1乃至F5の値の組み合わせは存在す
る。即ち、逆数演算方法100において、演算数Aが偶
数の場合には、ステップS3012を単独に実行し、逆
数演算方法2800と同様に振舞う。
Also, {Ua, Ub, Va, Vb, W} =
Back calculation from {A, 1, −p, 0, Ap} gives {U
a, Ub, Va, Vb, W} = {A, 2, -p, 0, A
−p} (in the case of step S3014) or {Ua, U
b, Va, Vb, W} = {A, 2 + p, -p, 0, A-
p} (in the case of step S3015) is the initial value. In the reciprocal operation method 2800, when the operation number A is an even number, step S3012 is executed. On the other hand, according to the table 700, there is a combination of the values of the flags F1 to F5 for executing the step S3012 independently. That is, in the reciprocal operation method 100, when the operation number A is an even number, step S3012 is executed independently, and the behavior is the same as that of the reciprocal operation method 2800.

【0054】(逆数演算装置の構成)以上のように構成
された逆数演算方法100に基づいて装置化した逆数演
算装置の構成を説明する。図8は、逆数演算方法100
に基づいて装置化した逆数演算装置のブロック図を示し
ている。
(Configuration of Reciprocal Arithmetic Apparatus) The configuration of the reciprocal arithmetic apparatus implemented as the above based on the reciprocal arithmetic method 100 will be described. FIG. 8 shows a reciprocal operation method 100.
FIG. 2 is a block diagram of a reciprocal operation device implemented as a device based on FIG.

【0055】同図にみられるように、逆数演算装置80
0は、初期値設定部801、補正値記憶部802、演算
部803、制御部804、出力部805から構成され
る。初期値設定部801は、演算数Aの入力を受け、補
正値記憶部802から素数pの値を読み込む。そして、
変数Ua,Ub,Va,Vb,WとフラグF1乃至F5
との初期値を設定し、変数Ua,Ub,Va,Vb,W
の初期値を演算部803に転送し、フラグF1乃至F5
の初期値を制御部804に転送する。
As can be seen from FIG.
0 includes an initial value setting unit 801, a correction value storage unit 802, a calculation unit 803, a control unit 804, and an output unit 805. The initial value setting unit 801 receives the operation number A and reads the value of the prime number p from the correction value storage unit 802. And
Variables Ua, Ub, Va, Vb, W and flags F1 to F5
And the variables Ua, Ub, Va, Vb, W
Is transferred to the arithmetic unit 803, and the flags F1 to F5
Is transferred to the control unit 804.

【0056】補正値記憶部802は、素数pの値を記憶
し、初期値設定部801に転送する。また、素数pの値
を元に、演算部803において補正する際に用いられる
補正値(p,−p,0)を転送する。素数pは160ビ
ットとする。演算部803は、初期値設定部801から
変数Ua,Ub,Va,Vb,Wの初期値を受け取る。
そして、制御部804からフラグF1乃至F5の値を受
け、変数Ua,Ub,Va,Vb,Wの値を更新し、変
数Ua,Ubの値を出力部805に転送する。さらに、
変数Ua,Ub,Va,Vbの最下位ビットの値と変数
Wの符号ビットの値とを制御部804に転送する。ま
た、補正値記憶部802から補正値(p,−p,0)を
受け取る。
The correction value storage unit 802 stores the value of the prime number p and transfers it to the initial value setting unit 801. Further, based on the value of the prime number p, a correction value (p, -p, 0) used for correction in the calculation unit 803 is transferred. The prime number p is 160 bits. The calculation unit 803 receives the initial values of the variables Ua, Ub, Va, Vb, and W from the initial value setting unit 801.
Then, it receives the values of the flags F1 to F5 from the control unit 804, updates the values of the variables Ua, Ub, Va, Vb, W, and transfers the values of the variables Ua, Ub to the output unit 805. further,
The value of the least significant bit of the variables Ua, Ub, Va, Vb and the value of the sign bit of the variable W are transferred to the control unit 804. Also, the correction value (p, -p, 0) is received from the correction value storage unit 802.

【0057】制御部804は、初期値設定部801から
フラグF1乃至F5の初期値を受け取る。そして、演算
部803から変数Ua,Ub,Va,Vbの最下位ビッ
トの値と変数Wの符号ビットの値とを受け、フラグF1
乃至F5の値を更新し、演算部803に転送する。出力
部805は、演算部803から変数Ua,Ubの値を受
け、解析する。解析の結果、条件(Ub=0)が成立す
ると変数Uaの値を演算数Aの逆数として出力する。
The control unit 804 receives the initial values of the flags F1 to F5 from the initial value setting unit 801. Then, the value of the least significant bit of the variables Ua, Ub, Va, Vb and the value of the sign bit of the variable W are received from the arithmetic unit 803, and the flag F1
Update the values of F5 through F5 and transfer them to the calculation unit 803. The output unit 805 receives and analyzes the values of the variables Ua and Ub from the calculation unit 803. As a result of the analysis, when the condition (Ub = 0) is satisfied, the value of the variable Ua is output as the reciprocal of the operation number A.

【0058】図9は、演算部803と制御部804との
詳細なブロック図である。なお、ブロック図の説明にお
いて、セレクタなど、複数の入力線を備える場合には、
左側の入力線を入力(L)、中側の入力線を入力
(C)、右側の入力線を入力(R)として入力線(入力
値)を区別する。 (演算部803の構成)図9(a)にみられるように、
演算部803は、レジスタ901乃至905、セレクタ
911乃至916、加算器921,922、1ビット算
術右シフト器931から構成される。
FIG. 9 is a detailed block diagram of the arithmetic unit 803 and the control unit 804. In the description of the block diagram, when a plurality of input lines such as a selector are provided,
Input lines (input values) are distinguished by inputting a left input line (L), inputting a middle input line (C), and inputting a right input line (R). (Configuration of the arithmetic unit 803) As shown in FIG.
The operation unit 803 includes registers 901 to 905, selectors 911 to 916, adders 921 and 922, and a 1-bit arithmetic right shifter 931.

【0059】レジスタ901乃至905は、レジスタ9
01に変数Uaの値、レジスタ902に変数Ubの値、
レジスタ903に変数Vaの値、レジスタ904に変数
Vbの値、レジスタ905に変数Wの値が入力されるレ
ジスタである。また、レジスタ901,902に入力さ
れた値は、出力部805に転送される。各レジスタのビ
ット数は最上位ビットを符号ビットとする162ビット
であるものとする。
The registers 901 to 905 are the registers 9
01 is the value of the variable Ua, the register 902 is the value of the variable Ub,
The register 903 receives the value of the variable Va, the register 904 receives the value of the variable Vb, and the register 905 receives the value of the variable W. The values input to the registers 901 and 902 are transferred to the output unit 805. It is assumed that the number of bits in each register is 162 bits with the most significant bit as a sign bit.

【0060】セレクタ911乃至916は、制御入力と
して入力される値またはその値の組み合わせにより、入
力値(入力線)を選択し、出力する。加算器921,9
22は、入力(L)と入力(R)との入力値を加算し、
出力する。1ビット算術右シフト器931は、入力値を
1ビット算術右シフトし、出力する。各加算器および各
セレクタのビット数も各レジスタと同様に162ビット
であるものとする。
The selectors 911 to 916 select and output an input value (input line) according to a value input as a control input or a combination of the values. Adders 921, 9
22 adds the input values of the input (L) and the input (R),
Output. 1-bit arithmetic right shifter 931 shifts the input value by 1-bit arithmetic right and outputs the result. The number of bits of each adder and each selector is 162 bits as in each register.

【0061】(制御部804の構成)図9(b)にみら
れるように、制御部804は、フリップフロップ941
乃至945、セレクタ951乃至954、NOTゲート
961から構成される。フリップフロップ941乃至9
45は、フリップフロップ941にフラグF1の値、フ
リップフロップ942にフラグF2の値、フリップフロ
ップ943にフラグF3の値、フリップフロップ944
にフラグF4の値、フリップフロップ945にフラグF
5の値が入力されるフリップフロップである。そして、
フリップフロップ941乃至945に入力された値は、
各セレクタの制御入力として出力される。
(Configuration of Control Unit 804) As shown in FIG. 9B, the control unit 804 includes a flip-flop 941
To 945, selectors 951 to 954, and a NOT gate 961. Flip-flops 941 to 9
45 is the value of the flag F1 in the flip-flop 941, the value of the flag F2 in the flip-flop 942, the value of the flag F3 in the flip-flop 943, and the flip-flop 944.
To the value of the flag F4, and the flip-flop 945 to the flag F
This is a flip-flop to which a value of 5 is input. And
The value input to the flip-flops 941 to 945 is
It is output as a control input of each selector.

【0062】セレクタ951乃至954は、制御入力と
して入力される値または値の組み合わせにより、データ
入力を選択し、出力する。NOTゲート961は、0の
値が入力されると、1の値を出力し、1の値が入力され
ると、0の値を出力する。 (補足事項−B)ここで、演算部803と制御部804
とについて補足する。
The selectors 951 to 954 select and output a data input according to a value or a combination of values input as a control input. The NOT gate 961 outputs a value of 1 when a value of 0 is input, and outputs a value of 0 when a value of 1 is input. (Supplementary item-B) Here, the arithmetic unit 803 and the control unit 804
And supplement.

【0063】(補足−B1)レジスタ901乃至905
は、初期値設定部801により、レジスタ901に演算
数A、レジスタ902に2、レジスタ903に−p、レ
ジスタ904に0、レジスタ905にA−pが初期値と
して設定される。 (補足−B2)フリップフロップ941乃至945は、
初期値設定部801により、フリップフロップ941に
0、フリップフロップ942にレジスタ901の最下位
ビットの値、フリップフロップ943に0、フリップフ
ロップ944にレジスタ905の符号ビットの値、フリ
ップフロップ945にレジスタ902の最下位ビットの
値が初期値として設定される。
(Supplement-B1) Registers 901 to 905
The initial value setting unit 801 sets an initial value of the operation number A in the register 901, 2 in the register 902, −p in the register 903, 0 in the register 904, and Ap in the register 905. (Supplement-B2) The flip-flops 941 to 945 are
The initial value setting unit 801 sets the flip-flop 941 to 0, the flip-flop 942 to the value of the least significant bit of the register 901, the flip-flop 943 to 0, the flip-flop 944 to the sign bit value of the register 905, and the flip-flop 945 to the register 902. Is set as the initial value.

【0064】(補足−B3)制御入力として、セレクタ
911,912,915には、フリップフロップ943
の出力値が入力される。セレクタ913,916には、
フリップフロップ942,944の出力値が入力され
る。セレクタ914には、フリップフロップ943,9
45の出力値が入力される。セレクタ951には、フリ
ップフロップ941,943の出力値が入力される。セ
レクタ952には、フリップフロップ942の出力値が
入力される。セレクタ953には、フリップフロップ9
41の出力値が入力される。セレクタ954には、フリ
ップフロップ943の入力値が入力される。
(Supplement-B3) The selectors 911, 912, and 915 receive flip-flops 943 as control inputs.
Is input. The selectors 913 and 916 include:
Output values of the flip-flops 942 and 944 are input. The selector 914 includes flip-flops 943, 9
Forty-five output values are input. The output values of the flip-flops 941 and 943 are input to the selector 951. The output value of the flip-flop 942 is input to the selector 952. The selector 953 has a flip-flop 9
41 output values are input. The input value of the flip-flop 943 is input to the selector 954.

【0065】(補足−B4)フリップフロップ941の
値が、0から1または1から0に反転する周期を1サイ
クルとし、1サイクルに要する時間を1クロックとす
る。 (各セレクタの入力選択)図10は、各セレクタの入力
選択を示すテーブルである。なお、各テーブルの説明に
おいて、フリップフロップ941乃至945を略して、
F1乃至F5と表記する。
(Supplement-B4) A cycle in which the value of the flip-flop 941 is inverted from 0 to 1 or 1 to 0 is defined as one cycle, and the time required for one cycle is defined as one clock. (Input Selection of Each Selector) FIG. 10 is a table showing input selection of each selector. In the description of each table, the flip-flops 941 to 945 are omitted, and
Notated as F1 to F5.

【0066】図10(a)にみられるように、セレクタ
911は、F3の値が0の場合には、入力(L)を選択
し、F3の値が1の場合には、入力(R)を選択する。
図10(b)にみられるように、セレクタ912は、F
3の値が0の場合には、入力(R)を選択し、F3の値
が1の場合には、入力(L)を選択する。図10(c)
にみられるように、セレクタ913は、F2の値が1か
つF4の値が0の場合には、入力(R)を選択し、それ
以外の場合には、入力(L)を選択する。
As shown in FIG. 10A, the selector 911 selects the input (L) when the value of F3 is 0, and selects the input (R) when the value of F3 is 1. Select
As shown in FIG. 10B, the selector 912 outputs
When the value of 3 is 0, the input (R) is selected, and when the value of F3 is 1, the input (L) is selected. FIG. 10 (c)
As shown in the above, the selector 913 selects the input (R) when the value of F2 is 1 and the value of F4 is 0, and otherwise selects the input (L).

【0067】図10(d)にみられるように、セレクタ
914は、F5の値が0の場合には、入力(R)を選択
し、F3の値が0かつF5の値が1の場合には、入力
(L)を選択し、F3の値が1かつF5の値が1の場合
には、入力(C)を選択する。なお、入力(R)が選択
された場合には、補正されないことを意味する。図10
(e)にみられるように、セレクタ915は、F3の値
が0の場合には、入力(R)を選択し、F3の値が1の
場合には、入力(L)を選択する。
As shown in FIG. 10D, the selector 914 selects the input (R) when the value of F5 is 0, and selects the input (R) when the value of F3 is 0 and the value of F5 is 1. Selects the input (L), and selects the input (C) when the value of F3 is 1 and the value of F5 is 1. When the input (R) is selected, it means that the correction is not performed. FIG.
As shown in (e), the selector 915 selects the input (R) when the value of F3 is 0, and selects the input (L) when the value of F3 is 1.

【0068】図10(f)にみられるように、セレクタ
916は、F2の値が1かつF4の値が1の場合には、
入力(L)を選択し、それ以外の場合には、入力(R)
を選択する。図10(g)にみられるように、セレクタ
951は、F1の値が0の場合には、入力(R)を選択
し、F1の値が1かつF3の値が0の場合には、入力
(C)を選択し、F1の値が1かつF3の値が1の場合
には、入力(L)を選択する。
As can be seen from FIG. 10 (f), when the value of F2 is 1 and the value of F4 is 1,
Select input (L), otherwise input (R)
Select As shown in FIG. 10G, the selector 951 selects the input (R) when the value of F1 is 0, and selects the input (R) when the value of F1 is 1 and the value of F3 is 0. If (C) is selected and the value of F1 is 1 and the value of F3 is 1, the input (L) is selected.

【0069】図10(h)にみられるように、セレクタ
952は、F2の値が0の場合には、入力(R)を選択
し、F2の値が1の場合には、入力(L)を選択する。
図10(i)にみられるように、セレクタ953は、F
1の値が0の場合には、入力(R)を選択し、F1の値
が1の場合には、入力(L)を選択する。図10(j)
にみられるように、セレクタ954は、F3の値が0の
場合には、入力(L)を選択し、F3の値が1の場合に
は、入力(R)を選択する。
As can be seen from FIG. 10 (h), the selector 952 selects the input (R) when the value of F2 is 0, and selects the input (L) when the value of F2 is 1. Select
As shown in FIG. 10 (i), the selector 953
When the value of 1 is 0, the input (R) is selected, and when the value of F1 is 1, the input (L) is selected. FIG. 10 (j)
, The selector 954 selects the input (L) when the value of F3 is 0, and selects the input (R) when the value of F3 is 1.

【0070】(逆数演算装置800と逆数演算方法10
0との対応関係)次に、図8、図9に示した逆数演算装
置800と図1に示した逆数演算方法100との対応関
係を説明する。図11は、逆数演算装置800の各構成
部と逆数演算方法100における各処理との対応関係を
示すテーブルである。
(Reciprocal operation device 800 and reciprocal operation method 10
Next, the correspondence between the reciprocal operation device 800 shown in FIGS. 8 and 9 and the reciprocal operation method 100 shown in FIG. 1 will be described. FIG. 11 is a table showing the correspondence between each component of the reciprocal operation device 800 and each process in the reciprocal operation method 100.

【0071】同図にみられるように、初期値設定部80
1は、演算数Aの入力を受け付け、変数Ua,Ub,V
a,Vb,WとフラグF1乃至F5を初期化する処理
(ステップS101乃至S103)に対応する。演算部
803は、変数Ua,Ub,Va,Vb,Wを更新する
処理(ステップS111乃至S115)に対応する。図
1では、S111乃至S114を並列に実行した後にS
115を実行しているが、演算部801はS111乃至
S114とS115とを並列に実行する。即ち、S11
5におけるW=Ua+Vaを算出するため、レジスタ9
01(Ua)とレジスタ902(Va)の出力データで
はなく入力データを先取りして加算器911が加算する
ように構成されている。これにより5つのレジスタ90
1,902,903,904,905は同じクロックタ
イミングで同時に更新することができる。
As can be seen from FIG.
1 accepts an input of the operation number A and outputs the variables Ua, Ub, V
a, Vb, W and the processing of initializing the flags F1 to F5 (steps S101 to S103). The calculation unit 803 corresponds to the process of updating the variables Ua, Ub, Va, Vb, and W (Steps S111 to S115). In FIG. 1, after executing S111 to S114 in parallel, S
Although step S115 is executed, the calculation unit 801 executes steps S111 to S114 and S115 in parallel. That is, S11
5 to calculate W = Ua + Va.
01 (Ua) and the input data, not the output data of the register 902 (Va), are pre-fetched and the adder 911 is configured to add them. This allows five registers 90
1, 902, 903, 904, and 905 can be updated simultaneously at the same clock timing.

【0072】制御部804は、フラグF1乃至F5を更
新する処理(ステップS121乃至S125)に対応す
る。図1ではS121乃至S124を並列に実行した後
にS125の判定を行なっているが、制御部804はS
121乃至S124とS125とを並列に1クロックで
実行する。加えて、演算部803における前記変数の更
新(S111乃至S115)と、制御部804における
フラグの更新(S121乃至S125)とは、同じクロ
ックタイミングで同時に実行される。その結果、逆数演
算装置800は、S111乃至S131までの1ループ
を1クロックで実行する。
The control unit 804 corresponds to the processing for updating the flags F1 to F5 (steps S121 to S125). In FIG. 1, the determination in S125 is performed after S121 to S124 are executed in parallel, but the control unit 804 determines
Steps 121 to S124 and S125 are executed in parallel with one clock. In addition, the update of the variables (S111 to S115) in the arithmetic unit 803 and the update of the flags (S121 to S125) in the control unit 804 are simultaneously executed at the same clock timing. As a result, the reciprocal operation device 800 executes one loop from S111 to S131 with one clock.

【0073】出力部805は、逆数を出力する処理(ス
テップS131,S132)に対応する。レジスタ90
1乃至905は、変数Ua,Ub,Va,Vb,Wに対
応する。セレクタ911は、変数UbまたはVbのどち
らをシフト演算するかを判定する処理(ステップS20
1,S241)に対応する。
The output unit 805 corresponds to the process of outputting the reciprocal (steps S131 and S132). Register 90
1 to 905 correspond to variables Ua, Ub, Va, Vb, and W. The selector 911 determines which of the variables Ub and Vb is to be shifted (step S20).
1, S241).

【0074】セレクタ912は、シフト演算した結果を
変数Uaに代入するかを判定する処理(ステップS20
1)に対応する。セレクタ913は、変数Wを変数Ub
に代入するかを判定する処理(ステップS221)に対
応する。セレクタ914は、素数pを加算し補正する
か、減算し補正するか、それとも補正処理を実施しない
かを判定する処理(ステップS202,S242)に対
応する。
The selector 912 determines whether to assign the result of the shift operation to the variable Ua (step S20).
This corresponds to 1). The selector 913 sets the variable W to the variable Ub
(Step S221). The selector 914 corresponds to a process (steps S202 and S242) of determining whether the prime number p is added and corrected, subtracted and corrected, or whether the correction process is not performed.

【0075】セレクタ915は、シフト演算した結果を
変数Vaに代入するかを判定する処理(ステップS24
1)に対応する。セレクタ916は、変数Wを変数Vb
に代入するかを判定する処理(ステップS261)に対
応する。加算器921は、逆数演算方法100におい
て、変数UbまたはVbの値に素数pの値を加算または
減算し補正する処理(ステップS213,S253)に
対応する。
The selector 915 determines whether to assign the result of the shift operation to the variable Va (step S24).
This corresponds to 1). The selector 916 sets the variable W to the variable Vb.
(Step S261). The adder 921 corresponds to the process of adding or subtracting the value of the prime number p to or from the value of the variable Ub or Vb in the reciprocal operation method 100 and correcting the value (steps S213 and S253).

【0076】加算器922は、変数UaとVaとの値を
加算する処理(ステップS115)に対応する。1ビッ
ト算術右シフト器931は、変数UbまたはVbをシフ
ト演算する処理(ステップS212,S213,S25
2,S253)に対応する。フリップフロップ941乃
至945は、フラグF1乃至F5に対応する。
The adder 922 corresponds to the process of adding the values of the variables Ua and Va (step S115). The 1-bit arithmetic right shifter 931 performs a shift operation on the variable Ub or Vb (steps S212, S213, and S25).
2, S253). The flip-flops 941 to 945 correspond to the flags F1 to F5.

【0077】セレクタ951は、フラグF2の値を更新
するかを判定する処理(ステップS311)に対応す
る。セレクタ952は、フラグF3の値を更新するかを
判定する処理(ステップS331)に対応する。セレク
タ953は、フラグF4の値を更新するかを判定する処
理(ステップS351)に対応する。
The selector 951 corresponds to the processing for determining whether to update the value of the flag F2 (step S311). The selector 952 corresponds to the process of determining whether to update the value of the flag F3 (Step S331). The selector 953 corresponds to the process of determining whether to update the value of the flag F4 (Step S351).

【0078】セレクタ954は、フラグF5の値を更新
するかを判定する処理(ステップS125における三項
演算子)に対応する。NOTゲート961は、フラグF
1の値を更新する処理(ステップS301)に対応す
る。 (ステップS111乃至S115と、ステップS121
乃至S125とに該当する回路)図12乃至図16は、
ステップS111乃至S115とステップ121乃至S
125とに該当する回路のブロック図を示している。な
お、演算部803と制御部804とは破線で示し、当該
処理に該当する回路を実線で示す。
The selector 954 corresponds to the process of determining whether to update the value of the flag F5 (the ternary operator in step S125). NOT gate 961 has a flag F
This corresponds to the process of updating the value of 1 (step S301). (Steps S111 to S115 and step S121
12 to FIG. 16 are circuits corresponding to
Steps S111 to S115 and steps 121 to S
125 shows a block diagram of a circuit corresponding to 125. The arithmetic unit 803 and the control unit 804 are indicated by broken lines, and circuits corresponding to the processing are indicated by solid lines.

【0079】図12(a)にみられるように、ステップ
S111に該当する回路は、レジスタ901,902、
セレクタ911,912,914、加算器921、1ビ
ット算術右シフト器931とから構成される。セレクタ
912の入力線(L)は、レジスタ902の出力線に接
続され、セレクタ912の入力線(R)は、1ビット算
術右シフト器931の出力線に接続され、セレクタ91
2の出力線は、レジスタ901の入力線に接続される。
そして、セレクタ912の切り替えにより、レジスタ9
02の値をシフト演算した値、及びレジスタ902の値
のいずれかが選択され、レジスタ901に転送される。
As shown in FIG. 12A, the circuit corresponding to step S111 includes registers 901 and 902,
It comprises selectors 911, 912, 914, an adder 921 and a 1-bit arithmetic right shifter 931. The input line (L) of the selector 912 is connected to the output line of the register 902, and the input line (R) of the selector 912 is connected to the output line of the 1-bit arithmetic right shifter 931.
The output line 2 is connected to the input line of the register 901.
Then, by switching the selector 912, the register 9
Either the value obtained by shifting the value of 02 and the value of the register 902 are selected and transferred to the register 901.

【0080】図12(b)にみられるように、ステップ
S121に該当する回路は、フリップフロップ941、
NOTゲート961とから構成される。NOTゲート9
61の入力線は、フリップフロップ941の出力線に接
続され、NOTゲート961の出力線は、フリップフロ
ップ941の入力線に接続される。そして、NOTゲー
ト961により、0なら1、1なら0に、フリップフロ
ップ941の値が反転され、フリップフロップ941に
転送される。
As shown in FIG. 12B, the circuit corresponding to step S121 includes a flip-flop 941,
And a NOT gate 961. NOT gate 9
The input line 61 is connected to the output line of the flip-flop 941, and the output line of the NOT gate 961 is connected to the input line of the flip-flop 941. Then, the value of the flip-flop 941 is inverted to 1 if 0 and 0 if 1 by the NOT gate 961 and transferred to the flip-flop 941.

【0081】図13(a)にみられるように、ステップ
S112に該当する回路は、レジスタ901,902,
905、セレクタ913とから構成される。セレクタ9
13の入力線(L)は、レジスタ901の出力線に接続
され、セレクタ913の入力線(R)は、レジスタ90
5の出力線に接続され、セレクタ913の出力線は、レ
ジスタ902の入力線に接続される。そして、セレクタ
913の切り替えにより、レジスタ901の値、及びレ
ジスタ905の値のいずれかが選択され、レジスタ90
2に転送される。
As shown in FIG. 13A, the circuit corresponding to step S112 includes registers 901, 902,
905 and a selector 913. Selector 9
13 is connected to the output line of the register 901, and the input line (R) of the selector 913 is connected to the register 90.
5, and the output line of the selector 913 is connected to the input line of the register 902. Then, by switching the selector 913, one of the value of the register 901 and the value of the register 905 is selected, and
2

【0082】図13(b)にみられるように、ステップ
S122に該当する回路は、フリップフロップ942、
セレクタ951とから構成される。セレクタ951の入
力線(L)は、レジスタ903の入力線の最下位ビット
の線から別途分岐した線に接続され、セレクタ951の
入力線(C)は、レジスタ901の入力線の最下位ビッ
トの線から別途分岐した線に接続され、セレクタ951
の入力線(R)は、フリップフロップ942の出力線に
接続され、セレクタ951の出力線は、フリップフロッ
プ942の入力線に接続される。そして、セレクタ95
1の切り替えにより、レジスタ903の最下位ビットの
値、レジスタ901の最下位ビットの値、及びフリップ
フロップ942の値のいずれかが選択され、フリップフ
ロップ942に転送される。
As shown in FIG. 13B, the circuit corresponding to step S122 includes a flip-flop 942,
And a selector 951. The input line (L) of the selector 951 is connected to a line separately branched from the least significant bit line of the input line of the register 903, and the input line (C) of the selector 951 is connected to the least significant bit of the input line of the register 901. The selector 951 is connected to a line separately branched from the line.
Is connected to the output line of the flip-flop 942, and the output line of the selector 951 is connected to the input line of the flip-flop 942. And the selector 95
By switching 1, one of the value of the least significant bit of the register 903, the value of the least significant bit of the register 901 and the value of the flip-flop 942 is selected and transferred to the flip-flop 942.

【0083】図14(a)にみられるように、ステップ
S113に該当する回路は、レジスタ903,904、
セレクタ911,915,914、加算器921、1ビ
ット算術右シフト器931とから構成される。セレクタ
915の入力線(R)は、レジスタ904の出力線に接
続され、セレクタ915の入力線(L)は、1ビット算
術右シフト器931の出力線に接続され、セレクタ91
5の出力線は、レジスタ903の入力線に接続される。
そして、セレクタ915の切り替えにより、レジスタ9
04の値をシフト演算した値、及びレジスタ904の値
のいずれかが選択され、レジスタ903に転送される。
As shown in FIG. 14A, the circuit corresponding to step S113 includes registers 903, 904,
It comprises selectors 911, 915, 914, an adder 921, and a 1-bit arithmetic right shifter 931. The input line (R) of the selector 915 is connected to the output line of the register 904, and the input line (L) of the selector 915 is connected to the output line of the 1-bit arithmetic right shifter 931.
The output line of No. 5 is connected to the input line of the register 903.
Then, by switching the selector 915, the register 9
One of the value obtained by shifting the value of the value 04 and the value of the register 904 is selected and transferred to the register 903.

【0084】図14(b)にみられるように、ステップ
S123に該当する回路は、フリップフロップ943,
944、セレクタ952とから構成される。セレクタ9
52の入力線(L)は、フリップフロップ944の出力
線に接続され、セレクタ952の入力線(R)は、フリ
ップフロップ943の出力線に接続され、セレクタ95
2の出力線は、フリップフロップ943の入力線に接続
される。そして、セレクタ952の切り替えにより、フ
リップフロップ944の値、及びフリップフロップ94
3の値のいずれかが選択され、フリップフロップ943
に転送される。
As shown in FIG. 14B, the circuit corresponding to step S123 includes a flip-flop 943,
944 and a selector 952. Selector 9
The input line (L) of 52 is connected to the output line of the flip-flop 944, the input line (R) of the selector 952 is connected to the output line of the flip-flop 943, and the selector 95
The output line 2 is connected to the input line of the flip-flop 943. By switching the selector 952, the value of the flip-flop 944 and the flip-flop 94
3 is selected and flip-flop 943 is selected.
Is forwarded to

【0085】図15(a)にみられるように、ステップ
S114に該当する回路は、レジスタ903,904,
905、セレクタ916とから構成される。セレクタ9
16の入力線(L)は、レジスタ905の出力線に接続
され、セレクタ916の入力線(R)は、レジスタ90
3の出力線に接続され、セレクタ916の出力線は、レ
ジスタ904の入力線に接続される。そして、セレクタ
916の切り替えにより、レジスタ905の値、及びレ
ジスタ903の値のいずれかが選択され、レジスタ90
4に転送される。
As shown in FIG. 15A, the circuit corresponding to step S114 includes registers 903, 904,
905 and a selector 916. Selector 9
The input line (L) of the selector 916 is connected to the output line of the register 905, and the input line (R) of the selector 916 is connected to the register 90.
3, and the output line of the selector 916 is connected to the input line of the register 904. Then, by switching of the selector 916, one of the value of the register 905 and the value of the register 903 is selected, and
4 is transferred.

【0086】図15(b)にみられるように、ステップ
S124に該当する回路は、フリップフロップ944、
セレクタ953とから構成される。セレクタ953の入
力線(L)は、レジスタ905の入力線の符号ビットの
線から別途分岐した線に接続され、セレクタ953の入
力線(R)は、フリップフロップ944の出力線に接続
され、セレクタ953の出力線はフリップフロップ94
4の入力線に接続される。そして、セレクタ953によ
り、レジスタ905の符号ビットの値、及びフリップフ
ロップ944の値のいずれかが選択され、フリップフロ
ップ944に転送される。
As shown in FIG. 15B, the circuit corresponding to step S124 includes a flip-flop 944,
And a selector 953. The input line (L) of the selector 953 is connected to a line separately branched from the sign bit line of the input line of the register 905, and the input line (R) of the selector 953 is connected to the output line of the flip-flop 944. The output line of 953 is a flip-flop 94
4 input lines. Then, the selector 953 selects one of the value of the sign bit of the register 905 and the value of the flip-flop 944, and is transferred to the flip-flop 944.

【0087】図16(a)にみられるように、ステップ
S115に該当する回路は、レジスタ901,903,
905、加算器922とから構成される。加算器922
の入力線(L)は、レジスタ901の入力線から分岐し
た線に接続され、加算器922の入力線(R)は、レジ
スタ903の入力線から分岐した線に接続され、加算器
922の出力線は、レジスタ905の入力線に接続され
る。そして、加算器922により、レジスタ901の入
力値と、レジスタ903の入力値とが加算され、レジス
タ905に転送される。
As shown in FIG. 16A, the circuit corresponding to step S115 includes registers 901, 903,
905 and an adder 922. Adder 922
Is connected to the line branched from the input line of the register 901, the input line (R) of the adder 922 is connected to the line branched from the input line of the register 903, and the output of the adder 922. The line is connected to the input line of the register 905. Then, the adder 922 adds the input value of the register 901 and the input value of the register 903 and transfers the result to the register 905.

【0088】図16(b)にみられるように、ステップ
S125を実行する回路は、フリップフロップ945、
セレクタ954とから構成される。セレクタ954の入
力線(L)は、レジスタ902の入力線から分岐した最
下位ビットの線に接続され、セレクタ954の入力線
(R)は、レジスタ904の入力線から分岐した最下位
ビットの線に接続され、セレクタ954の出力線は、フ
リップフロップ945の入力線に接続される。そして、
セレクタ954により、レジスタ902の最下位ビット
の値、及びレジスタ904の最下位ビットの値のいずれ
かが選択され、フリップフロップ945に転送される。
As shown in FIG. 16B, the circuit for executing step S125 includes a flip-flop 945,
And a selector 954. The input line (L) of the selector 954 is connected to the least significant bit line branched from the input line of the register 902, and the input line (R) of the selector 954 is connected to the least significant bit line branched from the input line of the register 904. , And the output line of the selector 954 is connected to the input line of the flip-flop 945. And
Either the value of the least significant bit of the register 902 or the value of the least significant bit of the register 904 is selected by the selector 954 and transferred to the flip-flop 945.

【0089】(補足事項−C)ここで、逆数演算装置8
00と逆数演算方法100との対応関係について補足す
る。 (補足−C1)逆数演算方法100における”1ルー
プ”が、逆数演算装置800における”1サイクル”で
ある。
(Supplementary Information-C) Here, the reciprocal arithmetic unit 8
The correspondence between 00 and the reciprocal operation method 100 will be supplemented. (Supplement-C1) “1 loop” in the reciprocal operation method 100 is “1 cycle” in the reciprocal operation device 800.

【0090】(補足−C2)逆数演算装置800におい
て、シフト演算されるレジスタが、セレクタ911によ
り、1つに制御される。これは、逆数演算方法100に
おける、(補足−A5)に対応する。 (補足−C3)装置化にあたって(補足−C2)によ
り、ステップS212,S213,S252,S253
における加算演算とシフト演算とを、加算器921と1
ビット算術右シフト器931とで共有した。
(Supplement-C2) In the reciprocal arithmetic unit 800, the selector 911 controls one register to be shifted. This corresponds to (supplement-A5) in the reciprocal operation method 100. (Supplement-C3) When the apparatus is implemented (Supplement-C2), steps S212, S213, S252, and S253 are performed.
In the adders 921 and 1
Shared with bit arithmetic right shifter 931.

【0091】(補足−C4)セレクタ954の制御入力
は、フリップフラップ943の入力線から分岐した線か
ら入力される。 (補足−C5)セレクタ914の入力線は、全て、補正
値記憶部802に接続される、セレクタ914の出力線
は、加算器931の入力(R)に接続される。そして、
セレクタ914により、補正値(p,−p,0)のいず
れかが選択され、加算器931に転送される。
(Supplement-C4) The control input of the selector 954 is input from a line branched from the input line of the flip flap 943. (Supplement-C5) All input lines of the selector 914 are connected to the correction value storage unit 802. Output lines of the selector 914 are connected to the input (R) of the adder 931. And
One of the correction values (p, -p, 0) is selected by the selector 914 and transferred to the adder 931.

【0092】(装置化にあたっての補足事項)ここで、
逆数演算方法100の装置化にあたって補足する。逆数
演算方法100において、ステップS111乃至S11
4(変数Ua,Ub,Va,Vbの更新処理)を並行し
て実行した後に、ステップS115(変数Wの更新処
理)を実行すると記した。ここで、ステップS115
は、”変数Uaと変数Vaとの加算結果を変数Wに代入
する処理”であるから、”変数Uaを格納するレジスタ
の出力データと変数Vaを格納するレジスタの出力デー
タとを加算器により加算し、加算結果をレジスタWに格
納する構成”(実装A)とすることもできるし、図9の
ように”変数Uaが入力されているレジスタの入力デー
タと変数Vaが入力されているレジスタの入力データと
を加算し、加算結果をレジスタWに格納する構成”(実
装B)とすることもできる。
(Supplementary Items for Deviceization) Here,
Supplementary explanation will be given for the implementation of the reciprocal operation method 100. In the reciprocal operation method 100, steps S111 to S11
4 (update of variables Ua, Ub, Va, Vb) is executed in parallel, and then step S115 (update of variable W) is executed. Here, step S115
Is a process of assigning the result of addition of the variable Ua and the variable Va to the variable W. Therefore, "the output data of the register storing the variable Ua and the output data of the register storing the variable Va are added by the adder. Then, the configuration in which the addition result is stored in the register W may be "implemented A", or as shown in FIG. 9, "the input data of the register to which the variable Ua is input and the input data of the register to which the variable Va is input. A configuration of adding the input data and storing the addition result in the register W (B).

【0093】言い換えると、逆数演算方法100の装置
化にあたって、(実装A)を採用するか、(実装B)を
採用するかにより、回路の構成が異なる。例えば、(実
装A)を採用した逆数演算装置は、変数Ua,Vaに対
応するレジスタの”出力値”に対して加算処理を施し、
変数Ua,Ub,Va,Vbに対応するレジスタの更新
処理と、変数Wに対応するレジスタの更新処理を”逐次
に”実行する。一方、(実装B)を採用した逆数演算装
置は、変数Ua,Vaに対応するレジスタの”入力値”
に対して加算処理を施し、変数Ua,Ub,Va,V
b,Wの更新処理を”並列に”実行することが可能であ
る。これにより、(実装A)を採用した場合に比べ、
(実装B)を採用した場合は、変数Ua,Ub,Va,
Vb,Wの更新処理を同じクロックタイミングで実行で
き、より高速にすることができる。そして、逆数演算装
置800は、(実装B)に基づいて、逆数演算方法10
0を装置化した。
In other words, in implementing the reciprocal operation method 100, the circuit configuration differs depending on whether (mounting A) or (mounting B) is used. For example, a reciprocal operation device employing (implementation A) performs an addition process on an “output value” of a register corresponding to variables Ua and Va,
The updating process of the registers corresponding to the variables Ua, Ub, Va, and Vb and the updating process of the register corresponding to the variable W are executed “sequentially”. On the other hand, the reciprocal operation device adopting (implementation B) uses the "input value" of the register corresponding to the variables Ua and Va.
To the variables Ua, Ub, Va, V
It is possible to execute the update processing of b and W “in parallel”. As a result, compared to the case where (Mounting A) is adopted,
When (Implementation B) is adopted, the variables Ua, Ub, Va,
The update processing of Vb and W can be executed at the same clock timing, and the speed can be further increased. Then, the reciprocal operation device 800 executes the reciprocal operation method 10 based on (Implementation B).
0 was instrumented.

【0094】(レジスタ転送)図17は、一例として、
{F1,F2,F3,F4,F5}={1,1,0,
0,0}の場合における、演算部803と制御部804
との1サイクル内のレジスタ転送の概略図を示してい
る。なお、演算部803と制御部804とは破線で示
し、レジスタのデータの流れを実線で示している。
(Register Transfer) FIG. 17 shows, as an example,
{F1, F2, F3, F4, F5} = {1, 1, 0,
Operation unit 803 and control unit 804 in the case of 0,0}
FIG. 3 shows a schematic diagram of register transfer in one cycle. The arithmetic unit 803 and the control unit 804 are indicated by broken lines, and the data flow of the register is indicated by solid lines.

【0095】同図にみられるように、レジスタ902か
ら出力した値は、セレクタ911、加算器921、1ビ
ット算術右シフト器931、セレクタ912を経由し、
レジスタ901に転送される。なお、加算器921によ
り、”0”が加算され、1ビット算術右シフト器931
により、1ビット算術右シフトされる。レジスタ905
から出力した値は、セレクタ913を経由し、レジスタ
902に転送される。
As shown in the figure, the value output from the register 902 passes through a selector 911, an adder 921, a 1-bit arithmetic right shifter 931 and a selector 912.
The data is transferred to the register 901. Note that “0” is added by the adder 921, and the 1-bit arithmetic right shifter 931 is added.
Shifts right by one bit arithmetically. Register 905
Are transferred to the register 902 via the selector 913.

【0096】レジスタ904から出力した値は、セレク
タ915を経由し、レジスタ903に転送される。レジ
スタ903から出力した値は、セレクタ916を経由
し、レジスタ904に転送される。さらに、レジスタ9
02,904とから出力した値は、レジスタ901,9
03とは別に、加算器922を経由し、レジスタ905
に転送される。なお、加算器922により、レジスタ9
02,904とから出力した値が加算される。
The value output from the register 904 is transferred to the register 903 via the selector 915. The value output from the register 903 is transferred to the register 904 via the selector 916. In addition, register 9
02, 904 are stored in registers 901, 9
03, and via the adder 922, the register 905
Is forwarded to The register 9 is added by the adder 922.
02, 904 are added.

【0097】また、レジスタ905に入力される値の符
号ビットの値は、レジスタ905とは別に、セレクタ9
53を経由し、フリップフロップ944にも転送され
る。フリップフロップ944から出力した値は、セレク
タ952を経由し、フリップフロップ943に転送され
る。レジスタ901に入力される値の最下位ビットの値
は、レジスタ901とは別に、セレクタ951を経由
し、フリップフロップ942にも転送される。
The value of the sign bit of the value input to the register 905 is set separately from the register 905 by the selector 9.
The data is also transferred to the flip-flop 944 via 53. The value output from the flip-flop 944 is transferred to the flip-flop 943 via the selector 952. The value of the least significant bit of the value input to the register 901 is transferred to the flip-flop 942 via the selector 951 separately from the register 901.

【0098】フリップフロップ941から出力した値
は、NOTゲート961を経由し、フリップフロップ9
41に転送される。レジスタ902に入力される値の最
下位ビットの値は、レジスタ902とは別に、セレクタ
954を経由し、フリップフロップ945にも転送され
る。さらに、フリップフロップ943に入力される値
は、フリップフロップ943とは別に、セレクタ954
の制御入力としても入力される。
The value output from the flip-flop 941 passes through a NOT gate 961 and the flip-flop 9
41. The value of the least significant bit of the value input to the register 902 is also transferred to the flip-flop 945 via the selector 954 separately from the register 902. Further, the value input to the flip-flop 943 is different from the value input to the flip-flop 943 by the selector 954.
Is also input as a control input.

【0099】そして、逆数演算装置800は、1サイク
ルで、レジスタ901乃至905と、フリップフロップ
941乃至945とを並行して更新する。 (逆数演算方法100、及び逆数演算装置800の動
作)以上のように構成された逆数演算方法100、及び
逆数演算装置800の動作を説明する。
Then, the reciprocal arithmetic unit 800 updates the registers 901 to 905 and the flip-flops 941 to 945 in one cycle in parallel. (Operations of Reciprocal Operation Method 100 and Reciprocal Operation Device 800) Operations of the reciprocal operation method 100 and the reciprocal operation device 800 configured as described above will be described.

【0100】図18は、一例として、演算数Aを271
とした場合における、逆数演算方法100、及び逆数演
算装置800による演算結果を示している。図18
(a)にみられるように、テーブルは、コラム1801
にループ数(サイクル数)、コラム1802に変数Ua
(レジスタ901)の値、コラム1803に変数Ub
(レジスタ902)の値、コラム1804に変数Va
(レジスタ903)の値、コラム1805に変数Vb
(レジスタ904)の値、コラム1806に変数W(レ
ジスタ905)の値、コラム1807にフラグF1(フ
リップフロップ941)の値、コラム1808にフラグ
F2(フリップフロップ942)の値、コラム1809
にフラグF3(フリップフロップ943)の値、コラム
1810にフラグF4(フリップフロップ944)の
値、コラム1811にフラグF5(フリップフロップ9
45)の値を示している。
FIG. 18 shows an example in which the number of operations A is 271
In this case, the calculation results by the reciprocal calculation method 100 and the reciprocal calculation device 800 are shown. FIG.
As can be seen in (a), the table has columns 1801
Is the number of loops (number of cycles), and column 1802 is the variable Ua
(Register 901) value, variable Ub in column 1803
(Register 902), variable Va in column 1804
(Register 903), variable Vb in column 1805
(Register 904), the value of variable W (register 905) in column 1806, the value of flag F1 (flip-flop 941) in column 1807, the value of flag F2 (flip-flop 942) in column 1808, column 1809
The value of the flag F3 (flip-flop 943), the value of the flag F4 (flip-flop 944) in the column 1810, and the flag F5 (flip-flop 9) in the column 1811.
45).

【0101】図18(b)にみられるように、タイミン
グチャートは、横軸に時間(クロック数)、縦軸に、上
から順に、CLK(クロック)、フラグF1(フリップ
フロップ941)、フラグF2(フリップフロップ94
2)、フラグF3(フリップフロップ943)、フラグ
F4(フリップフロップ944)、及びフラグF5(フ
リップフロップ945)を示している。
As can be seen from FIG. 18B, the horizontal axis indicates time (the number of clocks), and the vertical axis indicates CLK (clock), flag F1 (flip-flop 941), and flag F2 in order from the top. (Flip-flop 94
2), a flag F3 (flip-flop 943), a flag F4 (flip-flop 944), and a flag F5 (flip-flop 945).

【0102】例えば、逆数演算方法100によると、1
3ループ目の結果から、テーブル400により、14ル
ープ目における変数Ua,Ub,Va,Vb,Wが、
{Ua,Ub,Va,Vb,W}={D,v,−B,−
u,D−B}に対応する。さらに、テーブル700によ
り、14ループ目の処理が、ステップS3012(v←
v/2)に決定されることが示される。そして、14ル
ープ目に、{Ua,Ub,Va,Vb,W}={33,
−281,−7,24,26},{F1,F2,F3,
F4,F5}={0,1,0,0,1}が算出される。
For example, according to the reciprocal operation method 100, 1
From the results of the third loop, according to the table 400, the variables Ua, Ub, Va, Vb, and W in the fourteenth loop are
{Ua, Ub, Va, Vb, W} = {D, v, -B,-
u, D-B}. Further, according to the table 700, the processing of the fourteenth loop is performed in step S3012 (v ←
v / 2). Then, in the fourteenth loop, {Ua, Ub, Va, Vb, W} = {33,
−281, −7, 24, 26}, {F1, F2, F3,
F4, F5} = {0, 1, 0, 0, 1} is calculated.

【0103】同じく、14ループ目の結果から、テーブ
ル400により、15ループ目における変数Ua,U
b,Va,Vb,Wが、{Ua,Ub,Va,Vb,
W}={v,D,−u,−B,v−u}に対応する。さ
らに、テーブル700により、15ループ目の処理が、
ステップS3015(D←(D−x)/2),S302
4(v←v−u)に決定されることが示される。そし
て、15ループ目に、{Ua,Ub,Va,Vb,W}
={−332,26,24,−7,−308},{F
1,F2,F3,F4,F5}={1,1,0,0,
0}が算出される。
Similarly, from the result of the 14th loop, the variables Ua and U
b, Va, Vb, W are {Ua, Ub, Va, Vb,
W} = {v, D, -u, -B, vu}. Further, according to the table 700, the processing of the fifteenth loop is
Step S3015 (D ← (Dx) / 2), S302
4 (v ← v−u). Then, in the fifteenth loop, {Ua, Ub, Va, Vb, W}
= {333,26,24, -7, -308},} F
1, F2, F3, F4, F5} = {1,1,0,0,
0 ° is calculated.

【0104】以上、逆数演算方法100は、25ループ
目に、271の逆数として106を出力する。なお、逆
数演算装置800についても同様に、25サイクル目
に、271の逆数として106を出力し、図18に示す
演算結果と同じ結果を導く。 (その他)なお、演算数Aが素数p未満になるまで繰返
しpの値で減算し、減算結果をもって変数Ua,Wを初
期化するとしてもよい。
As described above, the reciprocal operation method 100 outputs 106 as the reciprocal of 271 in the 25th loop. Note that the reciprocal operation device 800 similarly outputs 106 as the reciprocal of 271 in the 25th cycle, leading to the same result as the operation result shown in FIG. (Others) Note that it is also possible to repeatedly subtract the value of p until the operation number A becomes less than the prime number p, and initialize the variables Ua and W with the subtraction result.

【0105】なお、本実施の形態における逆数演算方法
100は、並列処理可能なコンピュータ等のハードウェ
ア上で、逆数演算方法100を記述した逆数演算プログ
ラムを実行することによりなし得る。そして、この逆数
演算プログラムを、光学記録媒体(例えば、CD−RO
Mなど)、磁気記録媒体(例えば、ハードディスクな
ど)、光磁気記録媒体(例えば、MOなど)、半導体メ
モリ(例えば、ROMなど)等のコンピュータ読み取り
可能な記録媒体に記録しておくことにより、他のコンピ
ュータにおいても実行することが可能となる。また、ネ
ットワークにより接続されているコンピュータ等の一般
のハードウェア上に設けられたハードディスク等のコン
ピュータ読み取り可能な記録媒体に記録しておくことに
より、ネットワーク等の伝送路を経由して読み取った他
のコンピュータにおいても実行することが可能となる。
The reciprocal operation method 100 according to the present embodiment can be performed by executing a reciprocal operation program describing the reciprocal operation method 100 on hardware such as a computer capable of performing parallel processing. Then, the reciprocal operation program is stored in an optical recording medium (for example, CD-RO).
M), a magnetic recording medium (for example, a hard disk), a magneto-optical recording medium (for example, an MO), a semiconductor memory (for example, a ROM), and the like. It can also be executed on a computer. In addition, by recording on a computer-readable recording medium such as a hard disk provided on general hardware such as a computer connected by a network, other data read via a transmission path such as a network can be used. It can also be executed on a computer.

【0106】(実施の形態2)以下、実施の形態1にお
ける逆数演算方法100、及び逆数演算装置800を説
明する際に示した図1乃至図18と同じ点は、図中にお
いて同じ符号を付して説明を省略し、異なる点を中心に
実施の形態2を説明する。 (逆数演算方法100と異なる構成)図19乃至図20
は、実施の形態2における逆数演算方法を示すフローチ
ャートである。
(Embodiment 2) Hereinafter, the same points as those in FIGS. 1 to 18 shown in describing the reciprocal operation method 100 and the reciprocal operation device 800 in Embodiment 1 are denoted by the same reference numerals in the drawings. The second embodiment will be described focusing on the differences. (Configuration Different from Reciprocal Calculation Method 100) FIGS. 19 and 20
9 is a flowchart illustrating a reciprocal operation method according to Embodiment 2.

【0107】図19にみられるように、逆数演算方法1
900は、図1に示した逆数演算方法100と比べて、
フラグF5を備えていない点が異なる。これにより、フ
ラグF5の更新処理(ステップS125)を備えない。
これにより、初期化するフラグが5つから4つになる
(ステップS1903)。
As shown in FIG. 19, reciprocal operation method 1
900 is different from the reciprocal operation method 100 shown in FIG.
The difference is that the flag F5 is not provided. Thus, the updating process of the flag F5 (step S125) is not provided.
As a result, the number of flags to be initialized is changed from five to four (step S1903).

【0108】次に、並行して、変数Ua,Ub,Va,
Vbを更新する(ステップS1911,S112,S1
913,S114)。 (変数Uaの更新処理)図20にみられるように、ステ
ップS1911は、ステップS111と比べて、フラグ
F5の値を判定するのではなく、変数Ubが偶数である
か奇数であるか、2n-1以下かを判定する(ステップS
2002,S2003)。そして、判定の結果に基づい
て、変数Uaを、変数Ubが偶数(Ub[0]=0)の
場合には、Ub/2に、変数Ubが奇数(Ub[0]=
1)、かつ2n-1以下の場合には、(Ub+p)/2
に、変数Ubが奇数(Ub[0]=1)、かつ2n-1
上の場合には、(Ub−p)/2に更新する(ステップ
S2012乃至S2014)点が異なる。
Next, in parallel, the variables Ua, Ub, Va,
Vb is updated (steps S1911, S112, S1
913, S114). As seen in (variable update processing Ua) Figure 20, step S1911 is compared with the step S111, instead of determining the value of the flag F5, or variable Ub is even or odd, 2 n determines -1 or less (step S
2002, S2003). Then, based on the result of the determination, the variable Ua is set to Ub / 2 when the variable Ub is an even number (Ub [0] = 0), and the variable Ub is set to an odd number (Ub [0] =
1) and when it is 2 n-1 or less, (Ub + p) / 2
If the variable Ub is an odd number (Ub [0] = 1) and equal to or greater than 2 n−1 , it is updated to (Ub−p) / 2 (steps S2012 to S2014).

【0109】(変数Vaの更新処理)ステップS191
3は、ステップS113と比べて、フラグF5の値を判
定するのではなく、変数Vbが偶数であるか奇数である
か、2n-1以下かを判定する(ステップS2042,S
2043)。そして、判定の結果に基づいて、変数Va
を、変数Vbが偶数(Vb[0]=0)の場合には、V
b/2に、変数Vbが奇数(Vb[0]=1)、かつ2
n-1以下の場合には、(Vb+p)/2に、変数Vbが
奇数(Vb[0]=1)、かつ2n-1以上の場合には、
(Vb−p)/2に更新する(ステップS2052乃至
S2054)点が異なる。
(Update of Variable Va) Step S191
3 does not determine the value of the flag F5 as compared with step S113, but determines whether the variable Vb is an even number, an odd number, or 2 n-1 or less (steps S2042, S204).
2043). Then, based on the result of the determination, the variable Va
When the variable Vb is an even number (Vb [0] = 0),
The variable Vb is an odd number (Vb [0] = 1) and 2
When the variable Vb is an odd number (Vb [0] = 1) and 2n-1 or more,
(Vb-p) / 2 (steps S2052 to S2054).

【0110】以上、逆数演算方法1900において、逆
数演算方法100におけるフラグF5に係わる各判定処
理は、フラグF5ではなく、シフト演算される変数が偶
数であるか奇数であるかの判定処理と、2n-1以下かの
判定処理に置き換わる。 (補足事項−D)ここで、逆数演算方法1900につい
て補足する。
As described above, in the reciprocal operation method 1900, the respective determination processes related to the flag F5 in the reciprocal operation method 100 are not the flag F5 but the determination process of determining whether the variable to be shifted is an even number or an odd number. It is replaced by the judgment processing of whether it is n-1 or less. (Supplementary Item-D) Here, the reciprocal operation method 1900 will be supplemented.

【0111】(補足−D1)nは、1以上かつ2n-1
p<2nの関係式を満たす正の整数である。 (補足−D2)法pの下では、f(x)=(x+p)/
2,g(x)=(x−p)/2,(x∈Zp)は、f
(x)=g(x)+pにより、f(x)≡g(x),
(mod p)である。即ち、素数pを加算し補正する
処理と減算し補正する処理とは、法pの下においては同
義である。
(Supplement -D1) n is 1 or more and 2 n-1 <
It is a positive integer satisfying the relational expression of p <2 n . (Supplement-D2) Under the method p, f (x) = (x + p) /
2, g (x) = (x−p) / 2, (x∈Z p ) is f
According to (x) = g (x) + p, f (x) ≡g (x),
(Mod p). That is, the process of adding and correcting the prime number p and the process of subtracting and correcting it are synonymous under the modulus p.

【0112】(補足−D3)限られた桁数で計算する際
には、オーバーフローが起こりうることがある。そこ
で、素数pによる補正処理を行う際には、オーバーフロ
ーを考慮して、ステップS2003,S2043を設け
た。これにより、例えば、ステップS2003におい
て、Ub<2n-1から、Ub+p<2n+2n-1<2n+1
示されることにより、変数Ubは、符号を表すビットを
除いて、n+1ビット以内で計算することが示される。
変数Vbにおいても同様である。
(Supplement-D3) When calculating with a limited number of digits, overflow may occur. Therefore, when performing the correction process using the prime number p, steps S2003 and S2043 are provided in consideration of overflow. Accordingly, for example, in step S2003, Ub + p <2 n +2 n-1 <2 n + 1 is indicated from Ub <2 n−1 , and the variable Ub has n + 1 bits excluding the bit representing the sign. It is shown to calculate within.
The same applies to the variable Vb.

【0113】(補足−D4)加算によるビットの繰り上
がりと、符号を表すビットと、(補足−D3)とを考慮
して、変数Ua,Ub,Va,Vbを、n+2ビットと
する。 (テーブル600と異なる点)図21は、逆数演算方法
2800に対応付けて、フラグF1乃至F4により実行
される処理のテーブルである。なお、テーブル2100
は、行に逆数演算方法1900における各フラグとし、
列に逆数演算方法2800における処理とし、”○”は
実行する処理(処理可)、”△”は条件付で実行する処
理(条件付で処理可)、”×”は実行しない処理(処理
不可)、”−”は実行してもしなくてもどちらでもよい
処理とする。
(Supplement -D4) Variables Ua, Ub, Va, Vb are set to n + 2 bits in consideration of the carry of the bit by the addition, the bit representing the sign, and (Supplement -D3). (Differences from Table 600) FIG. 21 is a table of processing executed by the flags F1 to F4 in association with the reciprocal operation method 2800. The table 2100
Represents each flag in the reciprocal operation method 1900 in a row,
The column is a process in the reciprocal operation method 2800, where “○” indicates a process to be executed (processable), “△” indicates a process to be executed conditionally (processable with a condition), and “×” indicates a process not to be executed (process not possible). ) And "-" are processing that may or may not be performed.

【0114】同図にみられるように、テーブル2100
は、テーブル600と比べて、フラグF1の値が0の場
合には、ステップS3004,S3005,S301
4,S3015,S3022,S3024を条件付で処
理可とする点が異なる。ここで、”条件付きで処理可”
とは、処理を施す変数に対して、別途、変数が偶数であ
るか奇数であるかを判定する処理(例えば、逆数演算方
法1900におけるステップS2002,S2042な
ど)を設け、その判定結果に基づいて、”処理可”また
は”処理不可”のいずれかを決定する。
As can be seen from FIG.
When the value of the flag F1 is 0 as compared with the table 600, steps S3004, S3005, S301
4, S3015, S3022, and S3024 are processable conditionally. Here, "Processable with conditions"
Means that a process (for example, steps S2002 and S2042 in the reciprocal operation method 1900) for separately determining whether a variable is an even number or an odd number is provided for a variable to be processed, and based on the determination result. , "Processing possible" or "processing not possible".

【0115】なお、処理を施す変数が偶数ならば、ステ
ップS3004,S3014は、”処理可”であり、ス
テップS3005,S3015は、”処理不可”であ
る。処理を施す変数が奇数ならば、ステップS300
5,S3015は、”処理可”であり、ステップS30
04,S3014は、”処理不可”である。図22は、
テーブル2100に基づいて、フラグF1乃至F4の値
の組み合わせにより実行される処理を示したテーブルで
ある。なお、テーブル2200は、行に逆数演算方法2
800における処理とし、列に逆数演算方法1900に
おけるフラグF1乃至F4の値の組み合わせとし、”
○”は実行する処理(処理可)、”△”は条件付で実行
する処理(条件付きで処理可)、”×”は実行しない処
理(処理不可)とする。
If the variable to be processed is an even number, steps S3004 and S3014 are "processing possible", and steps S3005 and S3015 are "processing not possible". If the variable to be processed is an odd number, step S300
5, S3015 is "processable", and step S30
04 and S3014 are "processing not possible". FIG.
21 is a table showing processing executed based on a combination of values of flags F1 to F4 based on a table 2100. In the table 2200, the reciprocal operation method 2
800, and the column is a combination of the values of the flags F1 to F4 in the reciprocal operation method 1900.
“” ”Indicates a process to be executed (processable),“ △ ”indicates a process to be executed conditionally (processable with a condition), and“ × ”indicates a process not executed (process not possible).

【0116】同図にみられるように、例えば、フラグF
1乃至F4の値の組み合わせ{F1,F2,F3,F
4}={0,0,0,0}の場合には、ステップS30
14,S3015が条件付きで実行される。なお、処理
を施す変数が偶数ならば、ステップS3014が実行さ
れ、処理を施す変数が奇数ならば、ステップS3015
が実行され、変数が偶数であるか奇数であるかにより、
択一的に処理が選択される。
As can be seen from FIG.
Combination of values of 1 to F4 {F1, F2, F3, F
If 4} = {0,0,0,0}, step S30
14, S3015 is executed conditionally. If the variable to be processed is an even number, step S3014 is executed. If the variable to be processed is an odd number, step S3015 is executed.
Is executed, and depending on whether the variable is even or odd,
Alternatively, the processing is selected.

【0117】また、フラグの組み合わせ{F1,F2,
F3,F4}={0,1,0,1}の場合には、処理を
施す変数が偶数ならば、ステップS3014が実行さ
れ、奇数ならば、ステップS3015が実行される。ま
た、ステップS3022も同時に実行される。以上、テ
ーブル2200に基づいて、変数Ua,Ub,Va,V
b,Wに対して実行される演算処理が決定される。
Further, the combination of flags {F1, F2,
When F3, F4} = {0, 1, 0, 1}, if the variable to be processed is an even number, step S3014 is executed, and if it is an odd number, step S3015 is executed. Step S3022 is also executed at the same time. As described above, based on the table 2200, the variables Ua, Ub, Va, V
Calculation processing to be performed on b and W is determined.

【0118】(逆数演算装置800と異なる構成)以上
のように構成された逆数演算方法1900に基づいて、
装置化した逆数演算装置を説明する。図23は、逆数演
算方法1900に基づいて装置化した逆数演算装置のブ
ロック図を示している。
(Configuration Different from Reciprocal Operation Device 800) Based on the reciprocal operation method 1900 configured as described above,
A reciprocal operation device that has been implemented will be described. FIG. 23 is a block diagram of a reciprocal operation device implemented based on the reciprocal operation method 1900.

【0119】同図にみられるように、逆数演算装置23
00は、逆数演算装置800と比べて、初期値設定部8
01の代わりに、初期値設定部2301を備え、演算部
803の代わりに、演算部2303を備え、制御部80
4の代わりに、制御部2304を備える点が異なる。初
期値設定部2301は、初期値設定部801と比べて、
フラグF1乃至F4との初期値を設定し、フラグF1乃
至F4の初期値を制御部2304に転送する点が異な
る。
As can be seen from FIG.
00 is different from the reciprocal arithmetic unit 800 in that the initial value setting unit 8
01, an initial value setting unit 2301 is provided, and instead of the calculation unit 803, a calculation unit 2303 is provided.
4 in that a control unit 2304 is provided instead of 4. The initial value setting unit 2301 is different from the initial value setting unit 801 in that
The difference is that the initial values of the flags F1 to F4 are set and the initial values of the flags F1 to F4 are transferred to the control unit 2304.

【0120】演算部2303は、演算部803と比べ
て、制御部2304からフラグF1乃至F4の値を受け
る。さらに、変数Uaの最下位ビットの値と変数Vaの
最下位ビットの値と変数Wの符号ビットの値とを制御部
2304に転送し、変数Ub,Vbとの最下位ビットの
値を転送しない点が異なる。制御部2304は、制御部
804と比べて、初期値設定部2301からフラグF1
乃至F4の初期値を受け取る。そして、演算部2303
から変数Ua,Vaとの最下位ビットの値と、変数Wの
符号ビットの値とを受け、フラグF1乃至F4の値を更
新し、演算部2303に転送する。
The operation unit 2303 receives the values of the flags F1 to F4 from the control unit 2304 as compared with the operation unit 803. Further, the value of the least significant bit of the variable Ua, the value of the least significant bit of the variable Va, and the value of the sign bit of the variable W are transferred to the control unit 2304, and the value of the least significant bit of the variables Ub, Vb is not transferred. The points are different. The control unit 2304 is different from the control unit 804 in that the initial value setting unit 2301
Through F4. Then, the calculation unit 2303
Receive the values of the least significant bits of the variables Ua and Va and the value of the sign bit of the variable W, update the values of the flags F1 to F4, and transfer them to the arithmetic unit 2303.

【0121】図24は、演算部2303と制御部230
4との詳細なブロック図である。なお、回路構成図の説
明において、セレクタなど、複数の入力線を備える場合
には、左側の入力線を入力(L)、中側の入力線を入力
(C)、右側の入力線を入力(R)として入力線(入力
値)を区別する。 (演算部803と異なる構成)図24(a)にみられる
ように、演算部2303は、演算部803と比べて、セ
レクタ914の代わりに、セレクタ2414を備える点
が異なる。
FIG. 24 shows the operation section 2303 and the control section 230.
4 is a detailed block diagram of FIG. In the description of the circuit configuration diagram, when a plurality of input lines such as a selector are provided, the left input line is input (L), the middle input line is input (C), and the right input line is input ( An input line (input value) is distinguished as R). (Configuration Different from Operation Unit 803) As shown in FIG. 24A, the operation unit 2303 differs from the operation unit 803 in that a selector 2414 is provided instead of the selector 914.

【0122】なお、制御入力として、セレクタ2414
には、セレクタ911の出力値のn−1ビット目の値と
最下位ビットの値とが入力される。図24(b)にみら
れるように、制御部2304は、制御部804と比べ
て、フリップフロップ945とセレクタ954を備えな
い点が異なる。図25は、セレクタ2414の入力選択
を示すテーブルである。なお、テーブルの説明におい
て、セレクタ911の出力値のn−1ビット目の値と最
下位ビットの値とを、[n−1]と[0]と略して、表
記する。
The selector 2414 is used as a control input.
, The value of the (n−1) th bit of the output value of the selector 911 and the value of the least significant bit are input. As shown in FIG. 24B, the control unit 2304 is different from the control unit 804 in that the control unit 2304 does not include the flip-flop 945 and the selector 954. FIG. 25 is a table showing the input selection of the selector 2414. In the description of the table, the value of the (n-1) th bit and the value of the least significant bit of the output value of the selector 911 are abbreviated as [n-1] and [0].

【0123】図25にみられるように、セレクタ241
4は、[0]の値が0の場合には、入力(R)を選択
し、[n−1]の値が0かつ[0]の値が1の場合に
は、入力(C)を選択し、[n−1]の値が1かつ
[0]の値が1の場合には、入力(L)を選択する。 (レジスタ転送)図26は、一例として、{F1,F
2,F3,F4}={1,1,0,0}の場合におけ
る、演算部2303と制御部2304との1サイクル内
のレジスタ転送の概略図を示している。なお、演算部2
303と制御部2304とは破線で示し、レジスタのデ
ータの流れを実線で示している。
As shown in FIG. 25, the selector 241
4 selects the input (R) when the value of [0] is 0, and selects the input (C) when the value of [n-1] is 0 and the value of [0] is 1 If the value of [n-1] is 1 and the value of [0] is 1, the input (L) is selected. (Register transfer) FIG. 26 shows, as an example, $ F1, F
2, a schematic diagram of register transfer in one cycle between the arithmetic unit 2303 and the control unit 2304 when 2, F3, F4} = {1, 1, 0, 0}. The operation unit 2
303 and the control unit 2304 are indicated by broken lines, and the data flow of the register is indicated by solid lines.

【0124】同図にみられるように、レジスタ902か
ら出力した値は、セレクタ911、加算器921、1ビ
ット算術右シフト器931、セレクタ912を経由し、
レジスタ901に転送される。なお、ここでは、レジス
タ902から出力した値を偶数とし、加算器921によ
り、”0”が加算され、1ビット算術右シフト器931
により、1ビット算術右シフトされる。
As shown in the figure, the value output from the register 902 passes through a selector 911, an adder 921, a 1-bit arithmetic right shifter 931 and a selector 912.
The data is transferred to the register 901. Here, the value output from the register 902 is set to an even number, and “0” is added by the adder 921, and the 1-bit arithmetic right shifter 931
Shifts right by one bit arithmetically.

【0125】レジスタ905から出力した値は、セレク
タ913を経由し、レジスタ902に転送される。レジ
スタ904から出力した値は、セレクタ915を経由
し、レジスタ903に転送される。レジスタ903から
出力した値は、セレクタ916を経由し、レジスタ90
4に転送される。
The value output from the register 905 is transferred to the register 902 via the selector 913. The value output from the register 904 is transferred to the register 903 via the selector 915. The value output from the register 903 passes through the selector 916,
4 is transferred.

【0126】さらに、レジスタ902,904とから出
力した値は、レジスタ901,903とは別に、加算器
922を経由し、レジスタ905に転送される。なお、
加算器922により、レジスタ902,904とから出
力した値が加算される。また、レジスタ905に入力さ
れる値の符号ビットの値は、レジスタ905とは別に、
セレクタ953を経由し、フリップフロップ944にも
転送される。
Further, the values output from the registers 902 and 904 are transferred to the register 905 via the adder 922 separately from the registers 901 and 903. In addition,
The values output from the registers 902 and 904 are added by the adder 922. The value of the sign bit of the value input to the register 905 is different from that of the register 905.
The data is also transferred to the flip-flop 944 via the selector 953.

【0127】フリップフロップ944から出力した値
は、セレクタ952を経由し、フリップフロップ943
に転送される。レジスタ901に入力される値の最下位
ビットの値は、レジスタ901とは別に、セレクタ95
1を経由し、フリップフロップ942にも転送される。
フリップフロップ941から出力した値は、NOTゲー
ト961を経由し、フリップフロップ941に転送され
る。
The value output from the flip-flop 944 passes through the selector 952 and
Is forwarded to The value of the least significant bit of the value input to the register 901 is determined separately from the register 901 by the selector 95.
1 and also transferred to the flip-flop 942.
The value output from the flip-flop 941 is transferred to the flip-flop 941 via the NOT gate 961.

【0128】さらに、セレクタ911の出力値のn−1
ビット目の値と最下位ビットの値とは、セレクタ241
4の制御入力として入力される。そして、逆数演算装置
2300は、1サイクルで、レジスタ901乃至905
と、フリップフロップ941乃至944とを並行して更
新する。 (逆数演算方法1900、及び逆数演算装置2300の
動作)以上のように構成された逆数演算方法1900、
及び逆数演算装置2300の動作を説明する。
Further, the output value of the selector 911 is n-1
The value of the bit and the value of the least significant bit are
4 is input as a control input. Then, the reciprocal operation unit 2300 performs one cycle by using the registers 901 to 905.
And the flip-flops 941 to 944 are updated in parallel. (Operation of reciprocal operation method 1900 and reciprocal operation device 2300) The reciprocal operation method 1900 configured as described above,
And the operation of the reciprocal operation device 2300 will be described.

【0129】図27は、一例として、演算数Aを271
とした場合における、逆数演算方法1900、及び逆数
演算装置2300による演算結果を示している。図27
(a)にみられるように、テーブルは、コラム2701
にループ数(サイクル数)、コラム2702に変数Ua
(レジスタ901)の値、コラム2703に変数Ub
(レジスタ902)の値、コラム2704に変数Va
(レジスタ903)の値、コラム2705に変数Vb
(レジスタ904)の値、コラム2706に変数W(レ
ジスタ905)の値、コラム2707にフラグF1(フ
リップフロップ941)の値、コラム2708にフラグ
F2(フリップフロップ942)の値、コラム2709
にフラグF3(フリップフロップ943)の値、コラム
2710にフラグF4(フリップフロップ944)の値
を示している。
FIG. 27 shows an example in which the number of operations A is 271.
In this case, the calculation results by the reciprocal calculation method 1900 and the reciprocal calculation device 2300 are shown. FIG.
As can be seen in (a), the table has column 2701
Is the number of loops (number of cycles), and column 2702 is the variable Ua
(Register 901) value, column 2703 contains variable Ub
(Register 902) value, variable Va in column 2704
(Register 903) value, variable Vb in column 2705
(Register 904), the value of variable W (register 905) in column 2706, the value of flag F1 (flip-flop 941) in column 2707, the value of flag F2 (flip-flop 942) in column 2708, column 2709
Shows the value of the flag F3 (flip-flop 943), and the column 2710 shows the value of the flag F4 (flip-flop 944).

【0130】図27(b)にみられるように、タイミン
グチャートは、横軸に時間(クロック数)、縦軸に、上
から順に、CLK(クロック)、フラグF1(フリップ
フロップ941)、フラグF2(フリップフロップ94
2)、フラグF3(フリップフロップ943)、及びフ
ラグF4(フリップフロップ944)を示している。例
えば、逆数演算方法1900によると、13ループ目の
結果から、テーブル400により、14ループ目におけ
る変数Ua,Ub,Va,Vb,Wが、{Ua,Ub,
Va,Vb,W}={D,v,−B,−u,D−B}に
対応する。さらに、テーブル2200により、14ルー
プ目の処理が、ステップS3012(v←v/2)に決
定されることが示される。そして、14ループ目に、
{Ua,Ub,Va,Vb,W}={33,102,−
7,24,26},{F1,F2,F3,F4}=
{0,1,0,0}が算出される。
As can be seen from FIG. 27B, the horizontal axis indicates time (the number of clocks), and the vertical axis indicates CLK (clock), flag F1 (flip-flop 941), and flag F2 in order from the top. (Flip-flop 94
2), a flag F3 (flip-flop 943), and a flag F4 (flip-flop 944). For example, according to the reciprocal operation method 1900, the variables Ua, Ub, Va, Vb, and W in the fourteenth loop are represented by {Ua, Ub,
Va, Vb, W} = {D, v, -B, -u, DB}. Further, the table 2200 indicates that the processing of the fourteenth loop is determined in step S3012 (v ← v / 2). And on the 14th loop,
{Ua, Ub, Va, Vb, W} = {33, 102, −
7, 24, 26}, {F1, F2, F3, F4} =
{0,1,0,0} is calculated.

【0131】同じく、14ループ目の結果から、テーブ
ル400により、15ループ目における変数Ua,U
b,Va,Vb,Wが、{Ua,Ub,Va,Vb,
W}={v,D,−u,−B,v−u}に対応する。さ
らに、テーブル2200により、15ループ目の処理
が、条件付でステップS3014(D←D/2),S3
015(D←(D−x)/2)と、ステップS3024
(v←v−u)になる。しかし、更新する変数(変数D
に対応する変数Ub)が偶数により、ステップS301
4(D←D/2),S3024(v←v−u)に決定さ
れることが示される。そして、15ループ目に、{U
a,Ub,Va,Vb,W}={51,26,24,−
7,75},{F4,F3,F2,F1}={0,0,
1,1}が算出される。
Similarly, based on the result of the 14th loop, the variables Ua, U
b, Va, Vb, W are {Ua, Ub, Va, Vb,
W} = {v, D, -u, -B, vu}. Further, according to the table 2200, the processing in the fifteenth loop is conditionally performed in steps S3014 (D ← D / 2), S3
015 (D ← (D−x) / 2) and step S 3024
(V ← v−u). However, the variable to be updated (variable D
In step S301, the variable Ub) corresponding to
4 (D ← D / 2) and S3024 (v ← v−u). Then, on the fifteenth loop, $ U
a, Ub, Va, Vb, W} = {51, 26, 24, −
7,75}, {F4, F3, F2, F1} = {0,0,
1,1} is calculated.

【0132】以上、逆数演算方法100は、25ループ
目に、271の逆数として106を出力する。なお、逆
数演算装置2300についても同様に、25サイクル目
に、271の逆数として106を出力し、図27に示す
演算結果と同じ結果を導く。
As described above, the reciprocal operation method 100 outputs 106 as the reciprocal of 271 in the 25th loop. Note that the reciprocal arithmetic unit 2300 similarly outputs 106 as the reciprocal of 271 in the 25th cycle, leading to the same result as the calculation result shown in FIG.

【0133】[0133]

【発明の効果】本発明の逆数演算方法は、あらかじめ定
められた正の素数pを法とした剰余体上で、整数Aの逆
数を求める逆数演算方法であって、5つの中間値保持レ
ジスタUa,Ub,Va,Vb,Wを、Ua=A,Ub
=2,Va=−p,Vb=0,W=A−pに初期化する
初期化ステップと、次の(a)乃至(e)を並列に実行する更
新ステップと、(a)Uaの値を第1の値に更新するこ
と、第1の値は(a1)Ub、または(a2)(Ub/2 mo
d p)であり、(b)Ubの値を、(b1)W、または(b2)
Uaに更新すること、(c)Vaの値を第2の値に更新す
ること、第2の値は(c1)(Vb/2 modp)、また
は(c2)Vbであり、(d)Vbの値を、(d1)W、または(d
2)Vaに更新すること、(e)Wの値を、第1の値と第2
の値とを加算した値に更新すること、Ubの値が0でな
いとき、更新ステップを再度実行し、0のとき、Uaの
値を整数Aに対する逆数として出力する出力ステップと
を有し、前記更新ステップは、前記(a1)と(c1)の組、(a
2)と(c2)の組を選択し、(b)(d)について、(b1)と(d1)の
組み以外の組を選択し、5つの中間値保持レジスタを並
列に更新する。
The reciprocal operation method according to the present invention is a reciprocal operation method for obtaining the reciprocal of an integer A on a modulo modulo a predetermined positive prime number p, and comprises five intermediate value holding registers Ua. , Ub, Va, Vb, W, Ua = A, Ub
= 2, Va = −p, Vb = 0, W = A−p, an update step of executing the following (a) to (e) in parallel, and (a) the value of Ua Is updated to a first value, and the first value is (a1) Ub or (a2) (Ub / 2 mo
d p), and (b) the value of Ub is calculated as (b1) W or (b2)
Uc, (c) updating the value of Va to a second value, and the second value is (c1) (Vb / 2 modp) or (c2) Vb, and (d) Value is (d1) W or (d
2) updating to Va, and (e) changing the value of W to the first value and the second value.
And updating the value of Ub as a reciprocal to the integer A when the value of Ub is not 0, and executing the updating step again when the value of Ub is not 0. The updating step is a combination of (a1) and (c1), (a
A pair of (2) and (c2) is selected, and for (b) and (d), a pair other than the pair of (b1) and (d1) is selected, and the five intermediate value holding registers are updated in parallel.

【0134】この構成によって本発明の逆数演算方法
は、装置化した際には、逐次的に行っていた処理の一部
を並列化し、5つの中間値保持レジスタを並列に更新す
ることが可能となり、逐次処理装置に比べ、演算に費や
す時間を短くするという効果がある。また、変数Ua,
Vaを並行して更新する際に、(a2)と(c1)の組が選択さ
れないことにより、2で除算(1ビット算術右シフト処
理)される変数が、変数Ub,Vbの中から択一的に選
択され、1つの1ビット算術右シフト器で兼用すること
が可能となり、並列処理装置に比べ、回路規模を小さく
するという効果がある。
With this configuration, the reciprocal operation method of the present invention, when implemented as a device, makes it possible to parallelize part of the processing that has been performed sequentially and update the five intermediate value holding registers in parallel. This has the effect of shortening the time spent for computation as compared with the sequential processing device. Also, the variables Ua,
When updating Va in parallel, since the pair of (a2) and (c1) is not selected, the variable to be divided by 2 (1-bit arithmetic right shift processing) is selected from the variables Ub and Vb. And it can be shared by one 1-bit arithmetic right shifter, which has the effect of reducing the circuit scale as compared with a parallel processing device.

【0135】本発明の逆数演算方法は、さらに、前記更
新ステップは、状態を示す4つのフラグF1乃至F4を
管理し、前記(a1)または(a2)、(b1)または(b2)、(c1)ま
たは(c2)、(d1)または(d2)のそれぞれ一方をフラグF1
乃至F4が示す値に応じて選択する。さらに、前記初期
化ステップは、4つのフラグF1,F2,F3,F4
を、F1=0,F2=Ua[0](Uaの最下位ビット
の値),F3=0,F4=W[s](Wの符号ビットの
値)に初期化し、前記更新ステップは、次の(f)乃至(i)
を並列に実行し、(f)フラグF1の値を反転すること、
(g)フラグF2の値を、フラグF1の値が1かつフラグ
F3の値が0の場合には、(g1)第1の値の最下位ビット
の値に更新し、フラグF1の値が1かつフラグF3の値
が1の場合には、(g2)第2の値の最下位ビットの値に更
新し、それ以外の場合には、(g3)更新しないこと、(h)
フラグF3の値を、フラグF1の値が0かつフラグF2
の値が1の場合には、(h1)F4の値に更新し、それ以外
の場合には、(h2)更新しないこと、(i)フラグF4の値
を、フラグF1の値が1の場合には、(i1)第1の値と第
2の値とを加算した値の符号ビットの値に更新し、フラ
グF1の値が0の場合には、(i2)更新しないこと、とす
る。
In the reciprocal operation method according to the present invention, further, in the updating step, four flags F1 to F4 indicating states are managed, and (a1) or (a2), (b1) or (b2), (c1 ) Or (c2), (d1) or (d2) is set to the flag F1.
Selection is made according to the values indicated by F4. Further, the initialization step includes four flags F1, F2, F3, F4
Are initialized to F1 = 0, F2 = Ua [0] (the value of the least significant bit of Ua), and F3 = 0, F4 = W [s] (the value of the sign bit of W). (F) to (i)
(F) inverting the value of the flag F1;
(g) When the value of the flag F1 is 1 and the value of the flag F3 is 0, the value of the flag F2 is updated to (g1) the value of the least significant bit of the first value, and the value of the flag F1 becomes 1 And if the value of the flag F3 is 1, (g2) update to the value of the least significant bit of the second value; otherwise, (g3) do not update, (h)
If the value of the flag F3 is 0 and the value of the flag F2
Is updated to the value of (h1) F4 when the value of the flag is 1; otherwise, (h2) is not updated. (I) When the value of the flag F4 is 1, the value of the flag F1 is 1. In (2), it is assumed that (i1) the value of the sign bit of the value obtained by adding the first value and the second value is updated, and (i2) is not updated when the value of the flag F1 is 0.

【0136】さらに、前記更新ステップは、前記(a)に
おいて、フラグF3の値が1の場合には、(a1)を選択
し、フラグF3の値が0の場合には、(a2)を選択し、前
記(b)において、フラグF2の値が1かつフラグF4の値
が0の場合には、(b1)を選択し、それ以外の場合には、
(b2)を選択し、前記(c)において、フラグF3の値が1
の場合には、(c1)を選択し、フラグF3の値が0の場合
には、(c2)を選択し、前記(d)において、フラグF2の値
が1かつフラグF4の値が1の場合には、(d1)を選択
し、それ以外の場合には、(d2)を選択する。
Further, in the updating step, in (a), when the value of the flag F3 is 1, (a1) is selected, and when the value of the flag F3 is 0, (a2) is selected. Then, in (b), if the value of the flag F2 is 1 and the value of the flag F4 is 0, (b1) is selected; otherwise,
(b2) is selected, and in (c), the value of the flag F3 is set to 1
In the case of (c), (c1) is selected, and when the value of the flag F3 is 0, (c2) is selected. In (d), the value of the flag F2 is 1 and the value of the flag F4 is 1 In this case, select (d1). Otherwise, select (d2).

【0137】この構成によって本発明の逆数演算方法
は、さらに、状態を示す4つのフラグF1乃至F4によ
り、5つの中間値保持レジスタの更新処理((a)乃至
(e))と、4つのフラグの更新処理((f)乃至(i))とが
制御されるという効果がある。本発明の逆数演算方法
は、さらに、前記初期化ステップは、整数Aを素数p未
満になるまで繰返しpの値で減算し、減算結果をもって
中間値保持レジスタUa,Wを初期化すると構成しても
よい。
With this configuration, the reciprocal operation method of the present invention further updates the five intermediate value holding registers ((a) to (a)) by using the four flags F1 to F4 indicating the states.
(e)) and the update processing ((f) to (i)) of the four flags are controlled. In the reciprocal operation method according to the present invention, the initialization step may further comprise repeatedly subtracting the integer A by a value of p until the integer A becomes less than a prime number p, and initializing the intermediate value holding registers Ua and W with the subtraction result. Is also good.

【0138】この構成によって本発明の逆数演算方法
は、さらに、剰余体上において、法pの下では、A≡A
−p(mod p)により、素数p以上の整数Aに対し
ても、素数pで減算し、整数Aを素数p未満の値とし、
初期値を素数p未満とすることが可能という効果があ
る。本発明の逆数演算方法は、さらに、前記更新ステッ
プは、前記(a2)(Ub/2mod p)として、Ubが
偶数の場合には、Ubを1ビット右算術シフトし、Ub
が奇数の場合には、Ubにpの値を加算又は減算し、1
ビット右算術シフトし、前記(c1)(Vb/2 mod
p)として、Vbが偶数の場合には、Vbを1ビット右
算術シフトし、Vbが奇数の場合には、Vbにpの値を
加算又は減算し、1ビット右算術シフトすると構成して
もよい。
With this configuration, the reciprocal operation method according to the present invention further provides A≡A
-P (mod p) also subtracts the integer A that is greater than or equal to the prime number p by the prime number p to make the integer A less than the prime number p,
There is an effect that the initial value can be smaller than the prime number p. In the reciprocal operation method according to the present invention, further, in the updating step, when the Ub is an even number, the Ub is shifted by one bit right arithmetically as (a2) (Ub / 2 mod p),
Is odd, the value of p is added to or subtracted from Ub,
Arithmetic shift right by bit, and the above (c1) (Vb / 2 mod
As p), when Vb is an even number, Vb is arithmetically shifted right by 1 bit, and when Vb is an odd number, the value of p is added or subtracted from Vb and arithmetically shifted right by 1 bit. Good.

【0139】さらに、nは、1以上かつ2n-1<p<2n
の関係式を満す正の整数であり、前記更新ステップは、
前記(a2)として、Ubが奇数の場合において、Ubが2
n-1以下ならば、Ubにpの値を加算し、Ubが2n-1
上ならば、Ubにpの値を減算し、前記(c1)として、V
bが奇数の場合において、Vbが2n-1以下ならば、V
bにpの値を加算し、Vbが2n-1以上ならば、Vbに
pの値を減算すると構成してもよい。
Further, n is 1 or more and 2 n-1 <p <2 n
Is a positive integer that satisfies the relationship of
As (a2), when Ub is an odd number, Ub is 2
If n-1 or less, adds the value of p in Ub, if Ub is 2 n-1 or more, the value of p by subtracting the Ub, as the (c1), V
When b is an odd number and Vb is 2 n-1 or less, V
The value of p may be added to b, and if Vb is 2 n-1 or more, the value of p may be subtracted from Vb.

【0140】この構成によって本発明の逆数演算方法
は、さらに、剰余体上において、法pの下では、Ub≡
Ub−p≡Ub+p(mod p)により、変数Ubが
奇数ならば、素数pを加算または減算することにより、
偶数にし、2で除算することが可能という効果がある。
Vbについても同様の効果がある。本発明の逆数演算装
置は、あらかじめ定められた正の素数pを法とした剰余
体上で、整数Aの逆数を求める逆数演算装置であって、
初期値として整数A,2,−p,0,A−pをそれぞれ
保持する中間値レジスタUa,Ub,Va,Vb,W
と、中間値レジスタUb及びVbの一方の値を選択する
第1セレクタと、第1セレクタの選択結果を剰余体上で
2で割る除算部と、中間値レジスタUb及び除算部の除
算結果の一方を選択し、中間値レジスタUaに出力する
第2セレクタと、中間値レジスタVb及び除算部の除算
結果の一方を選択し、中間値レジスタVaに出力する第
3セレクタと、第2セレクタの選択結果と第3セレクタ
の選択結果とを加算し、中間値レジスタWに出力する加
算器と、中間値レジスタUa及び加算結果の一方を選択
し、中間値レジスタUbに出力する第4セレクタと、中
間値レジスタVa及び加算結果の一方を選択し、中間値
レジスタVbに出力する第5セレクタと、中間値レジス
タUbの値が0になるまで、第1乃至第5セレクタの選
択を制御するとともに、中間値レジスタUa,Ub,V
a,Vb,Wの同時更新を繰返し行い、中間値レジスタ
Ubの値が0になったとき、中間値レジスタUaの値を
整数Aの逆数として出力する制御部とを備える。
With this configuration, the reciprocal operation method according to the present invention further provides, on the remainder field, under the modulus p, Ub≡
By Ub−p≡Ub + p (mod p), if the variable Ub is odd, by adding or subtracting the prime number p,
There is an effect that it is possible to make an even number and divide by two.
Vb has the same effect. The reciprocal operation device of the present invention is a reciprocal operation device that obtains a reciprocal of an integer A on a modulo modulo a predetermined positive prime p.
Intermediate value registers Ua, Ub, Va, Vb, W respectively holding integers A, 2, -p, 0, Ap as initial values
A first selector for selecting one of the intermediate value registers Ub and Vb, a division unit for dividing the selection result of the first selector by 2 on the remainder, and one of the division results for the intermediate value register Ub and the division unit , A second selector that outputs the result to the intermediate value register Ua, a third selector that selects one of the intermediate value register Vb and the division result of the divider, and outputs the result to the intermediate value register Va, and a selection result of the second selector An adder that adds the intermediate value and the selection result of the third selector and outputs the result to the intermediate value register W; a fourth selector that selects one of the intermediate value register Ua and the addition result and outputs the result to the intermediate value register Ub; A fifth selector that selects one of the register Va and the addition result and outputs it to the intermediate value register Vb, and controls selection of the first to fifth selectors until the value of the intermediate value register Ub becomes zero. The intermediate value register Ua, Ub, V
a control section that repeatedly updates a, Vb, and W repeatedly and outputs the value of the intermediate value register Ua as the reciprocal of the integer A when the value of the intermediate value register Ub becomes 0.

【0141】この構成によって本発明の逆数演算装置
は、逐次的に行っていた処理の一部を並列化し、5つの
中間値レジスタを並列に更新することが可能となり、逐
次処理装置に比べ、演算に費やす時間を短くするという
効果がある。また、レジスタUa,Vaを並行して更新
する際に、第1セレクタにより、2で除算(1ビット算
術右シフト処理)される値が、中間値レジスタUb及び
Vbの一方の値から択一的に選択され、1つの1ビット
算術右シフト器で兼用することが可能となり、並列処理
装置に比べ、回路規模を小さくするという効果がある。
With this configuration, the reciprocal operation device of the present invention can parallelize a part of the processing that has been performed sequentially, and can update the five intermediate value registers in parallel. Has the effect of reducing the time spent on When the registers Ua and Va are updated in parallel, the value to be divided by two (1-bit arithmetic right shift processing) by the first selector is selected from one of the intermediate value registers Ub and Vb. And a single 1-bit arithmetic right shifter can also be used, which has the effect of reducing the circuit scale as compared with a parallel processing device.

【0142】さらに、前記制御部は、状態を示すための
4つのフラグF1乃至F4を保持するフラグ部と、4つ
のフラグの値に応じて第1乃至第5セレクタの選択を制
御するセレクタ制御部と、中間値レジスタUbの値が0
になるまで、4つのフラグF1乃至F4を同時に更新す
るととも、5つの中間値レジスタUa,Ub,Va,V
b,Wを更新させる更新部とを備える。
Further, the control section includes a flag section for holding four flags F1 to F4 for indicating states, and a selector control section for controlling selection of the first to fifth selectors in accordance with the values of the four flags. And the value of the intermediate value register Ub is 0
, The four flags F1 to F4 are updated simultaneously, and the five intermediate value registers Ua, Ub, Va, V
b, an updating unit for updating W.

【0143】この構成によって本発明の逆数演算装置
は、さらに、状態を示す4つのフラグF1乃至F4によ
り、第1乃至第5セレクタの選択が制御され、5つの中
間値レジスタの更新処理を制御するという効果がある。
さらに、前記除算部は、第1セレクタの選択結果が奇数
である場合に素数pを加減算する加算器と、加算器によ
る加算結果を1ビット右算術シフトする1ビット右算術
シフト器とを備える。
With this configuration, in the reciprocal operation device of the present invention, the selection of the first to fifth selectors is further controlled by the four flags F1 to F4 indicating the states, and the update processing of the five intermediate value registers is controlled. This has the effect.
Further, the division unit includes an adder that adds and subtracts a prime number p when the selection result of the first selector is an odd number, and a 1-bit right arithmetic shifter that performs a 1-bit right arithmetic shift on the addition result by the adder.

【0144】この構成によって本発明の逆数演算装置
は、さらに、剰余体上において、法pの下では、素数p
を加算または減算しても合同ということにより、値に応
じて、素数pを加算または減算し、選択結果を偶数に
し、2で除算(1ビット右算術シフト)することが可能
という効果がある。本発明の逆数演算プログラムを記録
したコンピュータ読み取り可能な記録媒体は、あらかじ
め定められた正の素数pを法とした剰余体上で、整数A
の逆数を求める逆数演算プログラムを記録した記録媒体
であって、5つの中間値保持レジスタUa,Ub,V
a,Vb,Wを、Ua=A,Ub=2,Va=−p,V
b=0,W=A−pに初期化する初期化ステップと、次
の(a)乃至(e)を並列に実行する更新ステップと、(a)U
aの値を第1の値に更新すること、第1の値は(a1)U
b、または(a2)(Ub/2 mod p)であり、(b)
Ubの値を、(b1)W、または(b2)Uaに更新すること、
(c)Vaの値を第2の値に更新すること、第2の値は(c
1)(Vb/2 modp)、または(c2)Vbであり、
(d)Vbの値を、(d1)W、または(d2)Vaに更新するこ
と、(e)Wの値を、第1の値と第2の値とを加算した値
に更新すること、Ubの値が0でないとき、更新ステッ
プを再度実行し、0のとき、Uaの値を整数Aに対する
逆数として出力する出力ステップとを記録し、前記更新
ステップは、前記(a1)と(c1)の組、(a2)と(c2)の組を選
択し、(b)(d)について、(b1)と(d1)の組み以外の組を選
択し、5つの中間値保持レジスタを並列に更新すること
をコンピュータに実行させるプログラムを記録する。
With this configuration, the reciprocal operation device of the present invention further provides a prime p
Is added or subtracted, the prime number p is added or subtracted according to the value to make the selection result an even number and divided by 2 (one-bit right arithmetic shift). The computer-readable recording medium on which the reciprocal operation program of the present invention has been recorded is formed of an integer A on a modulo modulo a predetermined positive prime number p.
Recording medium for recording a reciprocal operation program for calculating the reciprocal of the five intermediate value holding registers Ua, Ub, V
a, Vb, W, Ua = A, Ub = 2, Va = −p, V
an initialization step of initializing b = 0, W = A−p, an update step of executing the following (a) to (e) in parallel, and (a) U
updating the value of a to a first value, the first value being (a1) U
b or (a2) (Ub / 2 mod p), and (b)
Updating the value of Ub to (b1) W or (b2) Ua;
(c) updating the value of Va to a second value, wherein the second value is (c
1) (Vb / 2 modp) or (c2) Vb,
(d) updating the value of Vb to (d1) W or (d2) Va, (e) updating the value of W to a value obtained by adding the first value and the second value, When the value of Ub is not 0, the updating step is executed again. When the value of Ub is 0, an output step of outputting the value of Ua as an inverse of the integer A is recorded. Select the pair (a2) and (c2), and for (b) and (d), select a pair other than the pair (b1) and (d1), and update the five intermediate value holding registers in parallel Recording a program that causes a computer to do what it does.

【0145】この構成によって本発明の逆数演算プログ
ラムを記録したコンピュータ読み取り可能な記録媒体
は、並列処理可能なコンピュータ等のハードウェア上
で、逆数演算プログラムを実行することにより、実行し
たハードウェアは、逐次的に行っていた処理の一部を並
列化し、5つの中間値保持レジスタを並列に更新するこ
とが可能となり、逐次処理装置に比べ、演算に費やす時
間を短くするという効果がある。また、変数Ua,Va
を並行して更新する際に、(a2)と(c1)の組が選択されな
いことにより、2で除算(1ビット算術右シフト処理)
される変数が、変数Ub,Vbの中から択一的に選択さ
れ、1つの1ビット算術右シフト器で兼用することが可
能となり、並列処理装置に比べ、回路規模を小さくする
という効果がある。
The computer readable recording medium having the reciprocal operation program according to the present invention recorded thereon by this configuration can be implemented by executing the reciprocal operation program on hardware such as a computer capable of parallel processing. Part of the processing that has been performed sequentially can be parallelized, and the five intermediate value holding registers can be updated in parallel. This has the effect of shortening the time spent for computation as compared with the sequential processing device. Also, the variables Ua, Va
When updating in parallel, division by 2 (1-bit arithmetic right shift processing) because the pair of (a2) and (c1) is not selected
The variable to be executed is selected from among the variables Ub and Vb, and can be shared by one 1-bit arithmetic right shifter, which has the effect of reducing the circuit scale as compared with the parallel processing device. .

【0146】本発明の逆数演算プログラムを記録したコ
ンピュータ読み取り可能な記録媒体は、さらに、前記更
新ステップは、状態を示す4つのフラグF1乃至F4を
管理し、前記(a1)または(a2)、(b1)または(b2)、(c1)ま
たは(c2)、(d1)または(d2)のそれぞれ一方をフラグF1
乃至F4が示す値に応じて選択することをコンピュータ
に実行させるプログラムを記録する。
In the computer-readable recording medium storing the reciprocal operation program according to the present invention, the updating step manages four flags F1 to F4 indicating a state, and the updating step (a1) or (a2), (a (b1) or (b2), (c1) or (c2), (d1) or (d2) is set to a flag F1.
A program for causing a computer to execute selection according to the values indicated by F4 is recorded.

【0147】さらに、前記初期化ステップは、4つのフ
ラグF1,F2,F3,F4を、F1=0,F2=Ua
[0](Uaの最下位ビットの値),F3=0,F4=
W[s](Wの符号ビットの値)に初期化し、前記更新
ステップは、次の(f)乃至(i)を並列に実行し、(f)フラ
グF1の値を反転すること、(g)フラグF2の値を、フ
ラグF1の値が1かつフラグF3の値が0の場合には、
(g1)第1の値の最下位ビットの値に更新し、フラグF1
の値が1かつフラグF3の値が1の場合には、(g2)第2
の値の最下位ビットの値に更新し、それ以外の場合に
は、(g3)更新しないこと、(h)フラグF3の値を、フラ
グF1の値が0かつフラグF2の値が1の場合には、(h
1)F4の値に更新し、それ以外の場合には、(h2)更新し
ないこと、(i)フラグF4の値を、フラグF1の値が1
の場合には、(i1)第1の値と第2の値とを加算した値の
符号ビットの値に更新し、フラグF1の値が0の場合に
は、(i2)更新しないこと、とすることをコンピュータに
実行させるプログラムを記録する。
Further, in the initialization step, four flags F1, F2, F3, and F4 are set as follows: F1 = 0, F2 = Ua
[0] (the value of the least significant bit of Ua), F3 = 0, F4 =
W [s] (the value of the sign bit of W), the updating step executes the following (f) to (i) in parallel, and (f) inverts the value of the flag F1, (g) ) When the value of the flag F2 is 1 and the value of the flag F3 is 0,
(g1) Update to the value of the least significant bit of the first value, and
Is 1 and the value of the flag F3 is 1, the (g2) second
Is updated to the value of the least significant bit of the value of (a), otherwise (g3) is not updated, (h) the value of the flag F3 is 0, and the value of the flag F1 is 0 and the value of the flag F2 is 1. Contains (h
1) Update to the value of F4, otherwise (h2) Do not update, (i) Change the value of flag F4 to 1
In the case of (i1), update to the value of the sign bit of the value obtained by adding the first value and the second value, and if the value of the flag F1 is 0, (i2) do not update. Recording a program that causes a computer to do what it does.

【0148】さらに、前記更新ステップは、前記(a)に
おいて、フラグF3の値が1の場合には、(a1)を選択
し、フラグF3の値が0の場合には、(a2)を選択し、前
記(b)において、フラグF2の値が1かつフラグF4の値
が0の場合には、(b1)を選択し、それ以外の場合には、
(b2)を選択し、前記(c)において、フラグF3の値が1
の場合には、(c1)を選択し、フラグF3の値が0の場合
には、(c2)を選択し、前記(d)において、フラグF2の値
が1かつフラグF4の値が1の場合には、(d1)を選択
し、それ以外の場合には、(d2)を選択することをコンピ
ュータに実行させるプログラムを記録する。
Further, in the updating step, in (a), when the value of the flag F3 is 1, (a1) is selected, and when the value of the flag F3 is 0, (a2) is selected. Then, in (b), if the value of the flag F2 is 1 and the value of the flag F4 is 0, (b1) is selected; otherwise,
(b2) is selected, and in (c), the value of the flag F3 is set to 1
In the case of (c), (c1) is selected, and when the value of the flag F3 is 0, (c2) is selected. In (d), the value of the flag F2 is 1 and the value of the flag F4 is 1 In this case, a program that causes the computer to select (d1), and otherwise select (d2) is recorded.

【0149】この構成によって本発明の逆数演算プログ
ラムを記録したコンピュータ読み取り可能な記録媒体
は、並列処理可能なコンピュータ等のハードウェア上
で、逆数演算プログラムを実行することにより、実行し
たハードウェアは、さらに、状態を示す4つのフラグF
1乃至F4により、5つの中間値保持レジスタの更新処
理((a)乃至(e))と、4つのフラグの更新処理((f)乃
至(i))とが制御されるという効果がある。
With this configuration, a computer-readable recording medium on which the reciprocal operation program of the present invention is recorded can be executed by executing the reciprocal operation program on hardware such as a computer capable of parallel processing. Further, four flags F indicating the state
With 1 to F4, there is an effect that the update processing of the five intermediate value holding registers ((a) to (e)) and the update processing of the four flags ((f) to (i)) are controlled.

【0150】本発明の逆数演算プログラムを記録したコ
ンピュータ読み取り可能な記録媒体は、さらに、前記初
期化ステップは、整数Aを素数p未満になるまで繰返し
pの値で減算し、減算結果をもって中間値保持レジスタ
Ua,Wを初期化することをコンピュータに実行させる
プログラムを記録するとしてもよい。この構成によって
本発明の逆数演算プログラムを記録したコンピュータ読
み取り可能な記録媒体は、並列処理可能なコンピュータ
等のハードウェア上で、逆数演算プログラムを実行する
ことにより、実行したハードウェアは、さらに、剰余体
上において、法pの下では、A≡A−p(mod p)
により、素数p以上の整数Aに対しても、素数pで減算
し、整数Aを素数p未満の値とし、初期値を素数p未満
とすることが可能という効果がある。
The computer-readable recording medium on which the reciprocal operation program of the present invention is recorded is further characterized in that in the initialization step, the integer A is repeatedly subtracted by the value of p until it becomes less than the prime number p, and the result of the subtraction is an intermediate value. A program for causing a computer to initialize the holding registers Ua and W may be recorded. With this configuration, a computer-readable recording medium on which the reciprocal operation program of the present invention is recorded can be executed by executing the reciprocal operation program on hardware such as a computer capable of performing parallel processing. On the body, under the modulus p, A≡A-p (mod p)
As a result, even for an integer A equal to or larger than the prime number p, there is an effect that the integer A can be subtracted by the prime number p, the integer A can be set to a value smaller than the prime number p, and the initial value can be set to be smaller than the prime number p.

【0151】本発明の逆数演算プログラムを記録したコ
ンピュータ読み取り可能な記録媒体は、さらに、前記更
新ステップは、前記(a2)(Ub/2 mod p)とし
て、Ubが偶数の場合には、Ubを1ビット右算術シフ
トし、Ubが奇数の場合には、Ubにpの値を加算又は
減算し、1ビット右算術シフトし、前記(c1)(Vb/2
mod p)として、Vbが偶数の場合には、Vbを
1ビット右算術シフトし、Vbが奇数の場合には、Vb
にpの値を加算又は減算し、1ビット右算術シフトする
ことをコンピュータに実行させるプログラムを記録する
としてもよい。
In the computer-readable recording medium recording the reciprocal operation program according to the present invention, the updating step may further include: (a2) (Ub / 2 mod p), when Ub is an even number, Ub If the arithmetic operation is shifted right by one bit and Ub is an odd number, the value of p is added or subtracted from Ub, the arithmetic operation is shifted right by one bit, and the above (c1) (Vb / 2
mod p), when Vb is an even number, Vb is arithmetically shifted right by 1 bit, and when Vb is an odd number, Vb is Vb.
, A program that causes a computer to add or subtract the value of p and perform a right arithmetic shift by one bit may be recorded.

【0152】さらに、nは、1以上かつ2n-1<p<2n
の関係式を満す正の整数であり、前記更新ステップは、
前記(a2)として、Ubが奇数の場合において、Ubが2
n-1以下ならば、Ubにpの値を加算し、Ubが2n-1
上ならば、Ubにpの値を減算し、前記(c1)として、V
bが奇数の場合において、Vbが2n-1以下ならば、V
bにpの値を加算し、Vbが2n-1以上ならば、Vbに
pの値を減算することをコンピュータに実行させるプロ
グラムを記録するとしてもよい。
Further, n is 1 or more and 2 n-1 <p <2 n
Is a positive integer that satisfies the relationship of
As (a2), when Ub is an odd number, Ub is 2
If n-1 or less, adds the value of p in Ub, if Ub is 2 n-1 or more, the value of p by subtracting the Ub, as the (c1), V
When b is an odd number and Vb is 2 n-1 or less, V
A program that causes a computer to add the value of p to b and, if Vb is equal to or greater than 2 n−1 , to subtract the value of p from Vb may be recorded.

【0153】この構成によって本発明の逆数演算プログ
ラムを記録したコンピュータ読み取り可能な記録媒体
は、並列処理可能なコンピュータ等のハードウェア上
で、逆数演算プログラムを実行することにより、実行し
たハードウェアは、さらに、剰余体上において、法pの
下では、Ub≡Ub−p≡Ub+p(mod p)によ
り、変数Ubが奇数ならば、素数pを加算または減算す
ることにより、偶数にし、2で除算することが可能とい
う効果がある。Vbについても同様の効果がある。
With this configuration, a computer-readable recording medium storing the reciprocal operation program of the present invention can be implemented by executing the reciprocal operation program on hardware such as a computer capable of parallel processing. Furthermore, on the remainder field, under the modulus p, if Ub≡Ub−p≡Ub + p (mod p), if the variable Ub is an odd number, the prime number p is added or subtracted to obtain an even number and divided by 2 The effect is that it is possible. Vb has the same effect.

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

【図1】逆数演算方法を示すフローチャートその1であ
る。
FIG. 1 is a first flowchart illustrating a reciprocal operation method.

【図2】逆数演算方法を示すフローチャートその2であ
る。
FIG. 2 is a second flowchart illustrating a reciprocal operation method;

【図3】逆数演算方法を示すフローチャートその3であ
る。
FIG. 3 is a third flowchart illustrating a reciprocal operation method;

【図4】変数Ua,Ub,Va,Vb,Wと変数u,
v,B,Dとの対応関係を示すテーブルである。
FIG. 4 shows variables Ua, Ub, Va, Vb, W and variables u,
6 is a table showing a correspondence relationship with v, B, and D.

【図5】フラグF1乃至F5が更新される処理を、従来
の逆数演算方法の処理に対応付けたテーブルである。
FIG. 5 is a table in which processing of updating flags F1 to F5 is associated with processing of a conventional reciprocal operation method.

【図6】従来の逆数演算方法に対応付けて、フラグF1
乃至F5により実行される処理のテーブルである。
FIG. 6 shows a flag F1 in association with a conventional reciprocal operation method.
7 is a table of processing executed by F5.

【図7】フラグF1乃至F5の値の組み合わせにより実
行される処理を示したテーブルである。
FIG. 7 is a table showing a process executed based on a combination of values of flags F1 to F5.

【図8】逆数演算装置のブロック図である。FIG. 8 is a block diagram of a reciprocal operation device.

【図9】演算部と制御部との詳細なブロック図である。FIG. 9 is a detailed block diagram of a calculation unit and a control unit.

【図10】各セレクタの入力選択を示すテーブルであ
る。
FIG. 10 is a table showing input selection of each selector.

【図11】逆数演算装置の各構成部と逆数演算方法にお
ける各処理との対応関係を示すテーブルである。
FIG. 11 is a table showing a correspondence relationship between each component of the reciprocal operation device and each process in the reciprocal operation method.

【図12】ステップS111とステップ121とに該当
する回路のブロック図である。
FIG. 12 is a block diagram of a circuit corresponding to steps S111 and S121.

【図13】ステップS112とステップ122とに該当
する回路のブロック図である。
FIG. 13 is a block diagram of a circuit corresponding to steps S112 and S122.

【図14】ステップS113とステップ123とに該当
する回路のブロック図である。
FIG. 14 is a block diagram of a circuit corresponding to steps S113 and 123.

【図15】ステップS114とステップ124とに該当
する回路のブロック図である。
FIG. 15 is a block diagram of a circuit corresponding to steps S114 and 124.

【図16】ステップS115とステップ125とに該当
する回路のブロック図である。
FIG. 16 is a block diagram of a circuit corresponding to steps S115 and 125.

【図17】演算部と制御部との1サイクル内におけるレ
ジスタ転送の概略図である。
FIG. 17 is a schematic diagram of register transfer between an arithmetic unit and a control unit in one cycle.

【図18】演算数Aを271とした場合における、逆数
演算方法、及び逆数演算装置による演算結果を示すテー
ブルとタイミングチャートである。
FIG. 18 is a table and a timing chart showing a reciprocal calculation method and a calculation result by a reciprocal calculation device when the number of operations A is 271;

【図19】逆数演算方法を示すフローチャートその1で
ある。
FIG. 19 is a first flowchart illustrating a reciprocal operation method.

【図20】逆数演算方法を示すフローチャートその2で
ある。
FIG. 20 is a second flowchart illustrating the reciprocal operation method;

【図21】従来の逆数演算方法に対応付けて、フラグF
1乃至F4により実行される処理のテーブルである。
FIG. 21 is a diagram showing a flag F associated with a conventional reciprocal operation method.
It is a table of processing performed by 1 to F4.

【図22】フラグF1乃至F4の値の組み合わせにより
実行される処理を示したテーブルである。
FIG. 22 is a table showing a process executed by a combination of values of flags F1 to F4.

【図23】逆数演算装置のブロック図である。FIG. 23 is a block diagram of a reciprocal operation device.

【図24】演算部と制御部との詳細なブロック図であ
る。
FIG. 24 is a detailed block diagram of a calculation unit and a control unit.

【図25】セレクタの入力選択を示すテーブルである。FIG. 25 is a table showing input selection of a selector.

【図26】演算部と制御部との1サイクル内におけるレ
ジスタ転送の概略図である。
FIG. 26 is a schematic diagram of register transfer between an arithmetic unit and a control unit in one cycle.

【図27】演算数Aを271とした場合における、逆数
演算方法、及び逆数演算装置による演算結果を示すテー
ブルとタイミングチャートである。
FIG. 27 is a table and a timing chart showing a reciprocal calculation method and a calculation result by a reciprocal calculation device when the number of calculations A is 271;

【図28】従来の逆数演算方法(バイナリユークリッド
互除法)のアルゴリズムである。
FIG. 28 is an algorithm of a conventional reciprocal operation method (binary Euclidean mutual division method).

【図29】従来の逆数演算方法のフローチャートその1
である。
FIG. 29 is a flowchart of a conventional reciprocal operation method (1);
It is.

【図30】従来の逆数演算方法のフローチャートその2
である。
FIG. 30 is a flowchart of a conventional reciprocal operation method, part 2
It is.

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

801 初期値設定部 802 補正値記憶部 803 演算部 804 制御部 805 出力部 901乃至905 レジスタ 911乃至916 セレクタ 921,922 加算器 931 1ビット算術右シフト器 941乃至945 フリップフロップ 951乃至954 セレクタ 961 NOTゲート 801 Initial value setting unit 802 Correction value storage unit 803 Operation unit 804 Control unit 805 Output unit 901 to 905 Registers 911 to 916 Selectors 921 and 922 Adder 931 1-bit arithmetic right shifter 941 to 945 Flip-flop 951 to 954 Selector 961 NOT Gate

───────────────────────────────────────────────────── フロントページの続き (72)発明者 奥村 康男 大阪府門真市大字門真1006番地 松下電器 産業株式会社内 Fターム(参考) 5J104 AA18 AA21 JA23 NA22  ──────────────────────────────────────────────────続 き Continued on the front page (72) Inventor Yasuo Okumura 1006 Kazuma Kadoma, Kadoma-shi, Osaka Matsushita Electric Industrial Co., Ltd. F-term (reference) 5J104 AA18 AA21 JA23 NA22

Claims (17)

【特許請求の範囲】[Claims] 【請求項1】 あらかじめ定められた正の素数pを法と
した剰余体上で、整数Aの逆数を求める逆数演算方法で
あって、 5つの中間値保持レジスタUa,Ub,Va,Vb,W
を、Ua=A,Ub=2,Va=−p,Vb=0,W=
A−pに初期化する初期化ステップと、 次の(a)乃至(e)を並列に実行する更新ステップと、 (a)Uaの値を第1の値に更新すること、第1の値は(a
1)Ub、または(a2)(Ub/2 mod p)であり、 (b)Ubの値を、(b1)W、または(b2)Uaに更新するこ
と、 (c)Vaの値を第2の値に更新すること、第2の値は(c
1)(Vb/2 modp)、または(c2)Vbであり、 (d)Vbの値を、(d1)W、または(d2)Vaに更新するこ
と、 (e)Wの値を、第1の値と第2の値とを加算した値に更
新すること、 Ubの値が0でないとき、更新ステップを再度実行し、
0のとき、Uaの値を整数Aに対する逆数として出力す
る出力ステップと、を有し、 前記更新ステップは、 前記(a1)と(c1)の組、(a2)と(c2)の組を選択し、(b)(d)
について、(b1)と(d1)の組み以外の組を選択し、5つの
中間値保持レジスタを並列に更新することを特徴とする
逆数演算方法。
1. A reciprocal operation method for obtaining a reciprocal of an integer A on a modulo modulo a predetermined positive prime p, comprising: five intermediate value holding registers Ua, Ub, Va, Vb, W
Ua = A, Ub = 2, Va = −p, Vb = 0, W =
An initialization step of initializing to Ap; an update step of executing the following (a) to (e) in parallel; (a) updating the value of Ua to a first value, a first value Is (a
1) Ub or (a2) (Ub / 2 mod p), (b) updating the value of Ub to (b1) W or (b2) Ua, and (c) changing the value of Va to the second And the second value is (c
1) (Vb / 2 modp) or (c2) Vb, (d) updating the value of Vb to (d1) W or (d2) Va, (e) changing the value of W to the first And updating the value of Ub to a value obtained by adding the value of Ub and the second value. When the value of Ub is not 0, the updating step is performed again.
When 0, an output step of outputting the value of Ua as the reciprocal to the integer A, wherein the updating step selects the set of (a1) and (c1) and the set of (a2) and (c2) (B) (d)
, A set other than the set of (b1) and (d1) is selected, and the five intermediate value holding registers are updated in parallel.
【請求項2】 前記更新ステップは、状態を示す4つの
フラグF1乃至F4を管理し、 前記(a1)または(a2)、(b1)または(b2)、(c1)または(c
2)、(d1)または(d2)のそれぞれ一方をフラグF1乃至F
4が示す値に応じて選択することを特徴とする請求項1
記載の逆数演算方法。
2. The updating step manages four flags F1 to F4 indicating a state, wherein (a1) or (a2), (b1) or (b2), (c1) or (c
2), (d1) or (d2) is set to one of the flags F1 to F
2. A method according to claim 1, wherein the selection is made in accordance with a value indicated by the value (4).
The reciprocal calculation method described.
【請求項3】 前記初期化ステップは、 4つのフラグF1,F2,F3,F4を、F1=0,F
2=Ua[0](Uaの最下位ビットの値),F3=
0,F4=W[s](Wの符号ビットの値)に初期化
し、 前記更新ステップは、 次の(f)乃至(i)を並列に実行し、 (f)フラグF1の値を反転すること、 (g)フラグF2の値を、フラグF1の値が1かつフラグ
F3の値が0の場合には、(g1)第1の値の最下位ビット
の値に更新し、フラグF1の値が1かつフラグF3の値
が1の場合には、(g2)第2の値の最下位ビットの値に更
新し、それ以外の場合には、(g3)更新しないこと、 (h)フラグF3の値を、フラグF1の値が0かつフラグ
F2の値が1の場合には、(h1)F4の値に更新し、それ
以外の場合には、(h2)更新しないこと、 (i)フラグF4の値を、フラグF1の値が1の場合に
は、(i1)第1の値と第2の値とを加算した値の符号ビッ
トの値に更新し、フラグF1の値が0の場合には、(i2)
更新しないこと、 ことを特徴とする請求項2記載の逆数演算方法。
3. The initialization step comprises: setting four flags F1, F2, F3, and F4 as F1 = 0, F
2 = Ua [0] (value of the least significant bit of Ua), F3 =
0, F4 = W [s] (the value of the sign bit of W). The updating step executes the following (f) to (i) in parallel, and (f) inverts the value of the flag F1. (G) When the value of the flag F1 is 1 and the value of the flag F3 is 0, the value of the flag F2 is updated to the value of the least significant bit of the (g1) first value, and the value of the flag F1 is updated. Is 1 and the value of the flag F3 is 1, (g2) update to the value of the least significant bit of the second value; otherwise, (g3) do not update, (h) the flag F3 Is updated to the value of (h1) F4 when the value of the flag F1 is 0 and the value of the flag F2 is 1, otherwise, (h2) is not updated. When the value of the flag F1 is 1, the value of the flag F1 is updated to (i1) the value of the sign bit of the value obtained by adding the first value and the second value, and when the value of the flag F1 is 0, Contains (i2)
3. The reciprocal operation method according to claim 2, wherein updating is not performed.
【請求項4】 前記更新ステップは、 前記(a)において、 フラグF3の値が1の場合には、(a1)を選択し、フラグ
F3の値が0の場合には、(a2)を選択し、 前記(b)において、 フラグF2の値が1かつフラグF4の値が0の場合には、
(b1)を選択し、それ以外の場合には、(b2)を選択し、 前記(c)において、 フラグF3の値が1の場合には、(c1)を選択し、フラグ
F3の値が0の場合には、(c2)を選択し、 前記(d)において、 フラグF2の値が1かつフラグF4の値が1の場合には、
(d1)を選択し、それ以外の場合には、(d2)を選択するこ
とを特徴とする請求項3記載の逆数演算方法。
4. In the updating step, in the step (a), when the value of the flag F3 is 1, (a1) is selected, and when the value of the flag F3 is 0, (a2) is selected. In the above (b), when the value of the flag F2 is 1 and the value of the flag F4 is 0,
(b1) is selected; otherwise, (b2) is selected. In (c), when the value of the flag F3 is 1, (c1) is selected, and the value of the flag F3 is changed. In the case of 0, (c2) is selected. In the above (d), when the value of the flag F2 is 1 and the value of the flag F4 is 1,
4. The reciprocal operation method according to claim 3, wherein (d1) is selected, and in other cases, (d2) is selected.
【請求項5】 前記初期化ステップは、 整数Aを素数p未満になるまで繰返しpの値で減算し、
減算結果をもって中間値保持レジスタUa,Wを初期化
することを特徴とする請求項1乃至4のいずれかに記載
の逆数演算方法。
5. The initialization step: repeatedly subtracting an integer A by a value of p until the integer A becomes less than a prime number p;
5. The reciprocal operation method according to claim 1, wherein the intermediate value holding registers Ua and W are initialized with the subtraction result.
【請求項6】 前記更新ステップは、 前記(a2)(Ub/2 mod p)として、 Ubが偶数の場合には、Ubを1ビット右算術シフト
し、 Ubが奇数の場合には、Ubにpの値を加算又は減算
し、1ビット右算術シフトし、 前記(c1)(Vb/2 mod p)として、 Vbが偶数の場合には、Vbを1ビット右算術シフト
し、 Vbが奇数の場合には、Vbにpの値を加算又は減算
し、1ビット右算術シフトすることを特徴とする請求項
1乃至5のいずれかに記載の逆数演算方法。
6. The updating step is as follows: (a2) (Ub / 2 mod p), when Ub is an even number, Ub is right-shifted by 1 bit, and when Ub is an odd number, Ub is shifted to Ub. The value of p is added or subtracted, and arithmetically shifted right by 1 bit. As (c1) (Vb / 2 mod p), when Vb is even, Vb is arithmetically shifted right by 1 bit and Vb is odd. 6. The reciprocal operation method according to claim 1, wherein, in such a case, the value of p is added or subtracted from Vb and arithmetically shifted right by one bit.
【請求項7】 nは、1以上かつ2n-1<p<2nの関係
式を満す正の整数であり、 前記更新ステップは、 前記(a2)として、Ubが奇数の場合において、 Ubが2n-1以下ならば、Ubにpの値を加算し、 Ubが2n-1以上ならば、Ubにpの値を減算し、 前記(c1)として、Vbが奇数の場合において、 Vbが2n-1以下ならば、Vbにpの値を加算し、 Vbが2n-1以上ならば、Vbにpの値を減算すること
を特徴とする請求項6記載の逆数演算方法。
7. n is a positive integer that is 1 or more and satisfies a relational expression of 2 n -1 <p <2 n , and the updating step comprises: (a2) when Ub is an odd number, If Ub is 2 n-1 or less, the value of p is added to Ub. If Ub is 2 n-1 or more, the value of p is subtracted from Ub. As (c1), when Vb is an odd number, 7. The reciprocal operation according to claim 6, wherein if Vb is 2 n-1 or less, the value of p is added to Vb, and if Vb is 2 n-1 or more, the value of p is subtracted from Vb. Method.
【請求項8】 あらかじめ定められた正の素数pを法と
した剰余体上で、整数Aの逆数を求める逆数演算装置で
あって、 初期値として整数A,2,−p,0,A−pをそれぞれ
保持する中間値レジスタUa,Ub,Va,Vb,W
と、 中間値レジスタUb及びVbの一方の値を選択する第1
セレクタと、 第1セレクタの選択結果を剰余体上で2で割る除算部
と、 中間値レジスタUb及び除算部の除算結果の一方を選択
し、中間値レジスタUaに出力する第2セレクタと、 中間値レジスタVb及び除算部の除算結果の一方を選択
し、中間値レジスタVaに出力する第3セレクタと、 第2セレクタの選択結果と第3セレクタの選択結果とを
加算し、中間値レジスタWに出力する加算器と、 中間値レジスタUa及び加算結果の一方を選択し、中間
値レジスタUbに出力する第4セレクタと、 中間値レジスタVa及び加算結果の一方を選択し、中間
値レジスタVbに出力する第5セレクタと、 中間値レジスタUbの値が0になるまで、第1乃至第5
セレクタの選択を制御するとともに、中間値レジスタU
a,Ub,Va,Vb,Wの同時更新を繰返し行い、中
間値レジスタUbの値が0になったとき、中間値レジス
タUaの値を整数Aの逆数として出力する制御部と、 を備えることを特徴とする逆数演算装置。
8. A reciprocal arithmetic unit for calculating a reciprocal of an integer A on a modulo modulo a predetermined positive prime number p, wherein integers A, 2, -p, 0, A- intermediate value registers Ua, Ub, Va, Vb, W respectively holding p
A first value for selecting one of the intermediate value registers Ub and Vb
A selector, a division unit for dividing the selection result of the first selector by 2 on the remainder field, a second selector for selecting one of the intermediate value register Ub and the division result of the division unit, and outputting the selected result to the intermediate value register Ua. A third selector that selects one of the value register Vb and the division result of the division unit and outputs the result to the intermediate value register Va, and adds the selection result of the second selector and the selection result of the third selector to the intermediate value register W. An adder to be output, a fourth selector for selecting one of the intermediate value register Ua and the addition result, and outputting to the intermediate value register Ub, and selecting one of the intermediate value register Va and the addition result for output to the intermediate value register Vb And the first to fifth selectors until the value of the intermediate value register Ub becomes zero.
In addition to controlling the selection of the selector, the intermediate value register U
and a control unit that repeatedly updates a, Ub, Va, Vb, and W repeatedly and outputs the value of the intermediate value register Ua as the reciprocal of the integer A when the value of the intermediate value register Ub becomes 0. A reciprocal operation device characterized by the above-mentioned.
【請求項9】 前記制御部は、 状態を示すための4つのフラグF1乃至F4を保持する
フラグ部と、 4つのフラグの値に応じて第1乃至第5セレクタの選択
を制御するセレクタ制御部と、 中間値レジスタUbの値が0になるまで、4つのフラグ
F1乃至F4を同時に更新するととも、5つの中間値レ
ジスタUa,Ub,Va,Vb,Wを更新させる更新部
と、 を備えることを特徴とする請求項8記載の逆数演算装
置。
9. The control unit includes: a flag unit that holds four flags F1 to F4 for indicating a state; and a selector control unit that controls selection of the first to fifth selectors according to the values of the four flags. And an updating unit for simultaneously updating the four flags F1 to F4 until the value of the intermediate value register Ub becomes 0 and updating the five intermediate value registers Ua, Ub, Va, Vb, W. 9. The reciprocal operation device according to claim 8, wherein
【請求項10】 前記除算部は、 第1セレクタの選択結果が奇数である場合に素数pを加
減算する加算器と、 加算器による加算結果を1ビット右算術シフトする1ビ
ット右算術シフト器と、 を備えることを特徴とする請求項8又は9記載の逆数演
算装置。
10. A division unit, comprising: an adder for adding and subtracting a prime number p when a selection result of the first selector is an odd number; a 1-bit right arithmetic shifter for right-arithmically shifting the addition result by the adder; The reciprocal operation device according to claim 8, comprising:
【請求項11】 あらかじめ定められた正の素数pを法
とした剰余体上で、整数Aの逆数を求める逆数演算プロ
グラムを記録した記録媒体であって、 5つの中間値保持レジスタUa,Ub,Va,Vb,W
を、Ua=A,Ub=2,Va=−p,Vb=0,W=
A−pに初期化する初期化ステップと、 次の(a)乃至(e)を並列に実行する更新ステップと、 (a)Uaの値を第1の値に更新すること、第1の値は(a
1)Ub、または(a2)(Ub/2 mod p)であり、 (b)Ubの値を、(b1)W、または(b2)Uaに更新するこ
と、 (c)Vaの値を第2の値に更新すること、第2の値は(c
1)(Vb/2 modp)、または(c2)Vbであり、 (d)Vbの値を、(d1)W、または(d2)Vaに更新するこ
と、 (e)Wの値を、第1の値と第2の値とを加算した値に更
新すること、 Ubの値が0でないとき、更新ステップを再度実行し、
0のとき、Uaの値を整数Aに対する逆数として出力す
る出力ステップと、 を記録し、 前記更新ステップは、 前記(a1)と(c1)の組、(a2)と(c2)の組を選択し、(b)(d)
について、(b1)と(d1)の組み以外の組を選択し、5つの
中間値保持レジスタを並列に更新することをコンピュー
タに実行させるプログラムを記録したコンピュータ読み
取り可能な記録媒体。
11. A recording medium recording a reciprocal operation program for obtaining a reciprocal of an integer A on a modulo modulo a predetermined positive prime number p, comprising: five intermediate value holding registers Ua, Ub, Va, Vb, W
Ua = A, Ub = 2, Va = −p, Vb = 0, W =
An initialization step of initializing to Ap; an update step of executing the following (a) to (e) in parallel; (a) updating the value of Ua to a first value, a first value Is (a
1) Ub or (a2) (Ub / 2 mod p), (b) updating the value of Ub to (b1) W or (b2) Ua, and (c) changing the value of Va to the second And the second value is (c
1) (Vb / 2 modp) or (c2) Vb, (d) updating the value of Vb to (d1) W or (d2) Va, (e) changing the value of W to the first And updating the value of Ub to a value obtained by adding the value of Ub and the second value. When the value of Ub is not 0, the updating step is performed again.
When 0, an output step of outputting the value of Ua as the reciprocal of the integer A is recorded, and the updating step selects the set of (a1) and (c1) and the set of (a2) and (c2). (B) (d)
, A computer-readable recording medium storing a program for causing a computer to select a set other than the set of (b1) and (d1) and update the five intermediate value holding registers in parallel.
【請求項12】 前記更新ステップは、状態を示す4つ
のフラグF1乃至F4を管理し、 前記(a1)または(a2)、(b1)または(b2)、(c1)または(c
2)、(d1)または(d2)のそれぞれ一方をフラグF1乃至F
4が示す値に応じて選択することを特徴とする請求項1
1記載のコンピュータ読み取り可能な記録媒体。
12. The updating step manages four flags F1 to F4 indicating a status, wherein (a1) or (a2), (b1) or (b2), (c1) or (c
2), (d1) or (d2) is set to one of the flags F1 to F
2. A method according to claim 1, wherein the selection is made in accordance with a value indicated by the value (4).
The computer-readable recording medium according to claim 1.
【請求項13】 前記初期化ステップは、 4つのフラグF1,F2,F3,F4を、F1=0,F
2=Ua[0](Uaの最下位ビットの値),F3=
0,F4=W[s](Wの符号ビットの値)に初期化
し、 前記更新ステップは、 次の(f)乃至(i)を並列に実行し、 (f)フラグF1の値を反転すること、 (g)フラグF2の値を、フラグF1の値が1かつフラグ
F3の値が0の場合には、(g1)第1の値の最下位ビット
の値に更新し、フラグF1の値が1かつフラグF3の値
が1の場合には、(g2)第2の値の最下位ビットの値に更
新し、それ以外の場合には、(g3)更新しないこと、 (h)フラグF3の値を、フラグF1の値が0かつフラグ
F2の値が1の場合には、(h1)F4の値に更新し、それ
以外の場合には、(h2)更新しないこと、 (i)フラグF4の値を、フラグF1の値が1の場合に
は、(i1)第1の値と第2の値とを加算した値の符号ビッ
トの値に更新し、フラグF1の値が0の場合には、(i2)
更新しないこと、 ことをコンピュータに実行させるプログラムを記録した
請求項12記載のコンピュータ読み取り可能な記録媒
体。
13. The initialization step includes: setting four flags F1, F2, F3, and F4 to F1 = 0, F1
2 = Ua [0] (value of the least significant bit of Ua), F3 =
0, F4 = W [s] (the value of the sign bit of W). The updating step executes the following (f) to (i) in parallel, and (f) inverts the value of the flag F1. (G) When the value of the flag F1 is 1 and the value of the flag F3 is 0, the value of the flag F2 is updated to the value of the least significant bit of the (g1) first value, and the value of the flag F1 is updated. Is 1 and the value of the flag F3 is 1, (g2) update to the value of the least significant bit of the second value; otherwise, (g3) do not update, (h) the flag F3 Is updated to the value of (h1) F4 when the value of the flag F1 is 0 and the value of the flag F2 is 1, otherwise, (h2) is not updated. When the value of the flag F1 is 1, the value of the flag F1 is updated to (i1) the value of the sign bit of the value obtained by adding the first value and the second value, and when the value of the flag F1 is 0, Contains (i2)
13. The computer-readable recording medium according to claim 12, wherein a program for causing a computer to execute the updating is recorded.
【請求項14】 前記更新ステップは、 前記(a)において、 フラグF3の値が1の場合には、(a1)を選択し、フラグ
F3の値が0の場合には、(a2)を選択し、 前記(b)において、 フラグF2の値が1かつフラグF4の値が0の場合には、
(b1)を選択し、それ以外の場合には、(b2)を選択し、 前記(c)において、 フラグF3の値が1の場合には、(c1)を選択し、フラグ
F3の値が0の場合には、(c2)を選択し、 前記(d)において、 フラグF2の値が1かつフラグF4の値が1の場合には、
(d1)を選択し、それ以外の場合には、(d2)を選択するこ
とをコンピュータに実行させるプログラムを記録した請
求項13記載のコンピュータ読み取り可能な記録媒体。
14. In the updating step, in (a), when the value of the flag F3 is 1, (a1) is selected, and when the value of the flag F3 is 0, (a2) is selected. In the above (b), when the value of the flag F2 is 1 and the value of the flag F4 is 0,
(b1) is selected; otherwise, (b2) is selected. In (c), when the value of the flag F3 is 1, (c1) is selected, and the value of the flag F3 is changed. In the case of 0, (c2) is selected. In the above (d), when the value of the flag F2 is 1 and the value of the flag F4 is 1,
14. The computer-readable recording medium according to claim 13, wherein a program for causing a computer to select (d1) and otherwise select (d2) is recorded.
【請求項15】 前記初期化ステップは、 整数Aを素数p未満になるまで繰返しpの値で減算し、
減算結果をもって中間値保持レジスタUa,Wを初期化
することをコンピュータに実行させるプログラムを記録
した請求項11乃至14のいずれかに記載のコンピュー
タ読み取り可能な記録媒体。
15. The initialization step comprises repeatedly subtracting an integer A by a value of p until the integer A becomes less than a prime number p.
15. The computer-readable recording medium according to claim 11, wherein a program for causing a computer to initialize the intermediate value holding registers Ua and W with the subtraction result is recorded.
【請求項16】 前記更新ステップは、 前記(a2)(Ub/2 mod p)として、 Ubが偶数の場合には、Ubを1ビット右算術シフト
し、 Ubが奇数の場合には、Ubにpの値を加算又は減算
し、1ビット右算術シフトし、 前記(c1)(Vb/2 mod p)として、 Vbが偶数の場合には、Vbを1ビット右算術シフト
し、 Vbが奇数の場合には、Vbにpの値を加算又は減算
し、1ビット右算術シフトすることをコンピュータに実
行させるプログラムを記録した請求項11乃至15のい
ずれかに記載のコンピュータ読み取り可能な記録媒体。
16. The updating step is as follows: (a2) (Ub / 2 mod p), when Ub is an even number, Ub is arithmetically shifted right by 1 bit, and when Ub is an odd number, Ub is shifted to Ub. The value of p is added or subtracted, and arithmetically shifted right by 1 bit. As (c1) (Vb / 2 mod p), when Vb is even, Vb is arithmetically shifted right by 1 bit and Vb is odd. 16. The computer-readable recording medium according to claim 11, wherein a program for causing a computer to add or subtract a value of p to or from Vb and to perform a right arithmetic shift by one bit is recorded.
【請求項17】 nは、1以上かつ2n-1<p<2nの関
係式を満す正の整数であり、 前記更新ステップは、 前記(a2)として、Ubが奇数の場合において、 Ubが2n-1以下ならば、Ubにpの値を加算し、 Ubが2n-1以上ならば、Ubにpの値を減算し、 前記(c1)として、Vbが奇数の場合において、 Vbが2n-1以下ならば、Vbにpの値を加算し、 Vbが2n-1以上ならば、Vbにpの値を減算すること
をコンピュータに実行させるプログラムを記録した請求
項16記載のコンピュータ読み取り可能な記録媒体。
17. n is a positive integer that satisfies a relational expression of 1 or more and 2 n−1 <p <2 n , and the updating step includes the step of: (a2) when Ub is an odd number, If Ub is 2 n-1 or less, the value of p is added to Ub. If Ub is 2 n-1 or more, the value of p is subtracted from Ub. As (c1), when Vb is an odd number, if Vb is 2 n-1 or less, adds the value of p to Vb, claim Vb is if 2 n-1 or more, which records a program for executing the subtracting the value of p in Vb to the computer 17. The computer-readable recording medium according to item 16.
JP2000372115A 2000-12-06 2000-12-06 Reciprocal operation method and reciprocal operation device, and computer-readable recording medium with reciprocal operation program recorded thereon Pending JP2002175180A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2000372115A JP2002175180A (en) 2000-12-06 2000-12-06 Reciprocal operation method and reciprocal operation device, and computer-readable recording medium with reciprocal operation program recorded thereon

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2000372115A JP2002175180A (en) 2000-12-06 2000-12-06 Reciprocal operation method and reciprocal operation device, and computer-readable recording medium with reciprocal operation program recorded thereon

Publications (1)

Publication Number Publication Date
JP2002175180A true JP2002175180A (en) 2002-06-21

Family

ID=18841710

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2000372115A Pending JP2002175180A (en) 2000-12-06 2000-12-06 Reciprocal operation method and reciprocal operation device, and computer-readable recording medium with reciprocal operation program recorded thereon

Country Status (1)

Country Link
JP (1) JP2002175180A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010122246A (en) * 2008-11-17 2010-06-03 Fujitsu Ltd Inverse computing device and inverse computing program
CN112799637A (en) * 2021-01-22 2021-05-14 西安电子科技大学 High-throughput modular inverse computation method and system in parallel environment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010122246A (en) * 2008-11-17 2010-06-03 Fujitsu Ltd Inverse computing device and inverse computing program
CN112799637A (en) * 2021-01-22 2021-05-14 西安电子科技大学 High-throughput modular inverse computation method and system in parallel environment
CN112799637B (en) * 2021-01-22 2023-03-14 西安电子科技大学 High-throughput modular inverse computation method and system in parallel environment

Similar Documents

Publication Publication Date Title
JP2722411B2 (en) Implementation of modular reduction by Montgomery method
JP4870932B2 (en) Extended Montgomery Modular Multiplier Supporting Multiple Precision
US5982900A (en) Circuit and system for modulo exponentiation arithmetic and arithmetic method of performing modulo exponentiation arithmetic
JP2722413B2 (en) Implementation method of modular multiplication by Montgomery method
US6795553B1 (en) Method and apparatus for modular inversion for information security and recording medium with a program for implementing the method
JPWO2006098015A1 (en) Data conversion apparatus and data conversion method
KR20080028271A (en) Bit field operating circuit
US8117251B2 (en) Computation of a multiplication operation with an electronic circuit and method
Gutub et al. Efficient scalable VLSI architecture for Montgomery inversion in GF (p)
JPH08101779A (en) Electronic circuit for modular calculation in finite region
JP3302043B2 (en) Encryption communication method and system
JP5397061B2 (en) Arithmetic processing device, control method thereof, and arithmetic processing program
JP2002175180A (en) Reciprocal operation method and reciprocal operation device, and computer-readable recording medium with reciprocal operation program recorded thereon
US7296049B2 (en) Fast multiplication circuits
JP3577134B2 (en) Data processing device
US20220100472A1 (en) Arithmetic circuit
CN115270155A (en) Method for obtaining maximum common divisor of big number expansion and hardware architecture
JPWO2011036746A1 (en) Arithmetic unit
JP2000207387A (en) Arithmetic unit and cipher processor
CN113467752B (en) Division operation device, data processing system and method for private calculation
JP2010122246A (en) Inverse computing device and inverse computing program
JP4850884B2 (en) Power-residue calculator
JP2004226516A (en) Power remainder computing method and program for the same
JP3851024B2 (en) Multiplier
JP3137599B2 (en) Circuit for calculating the remainder of B raised to the power of C modulo n