Algorithms for optoelectronic implementation of modified signed-digit division, square-root, logarithmic, and exponential functions Abdallah K. Cherri and Mohammad S. Alam
Algorithms for computing complex elementary functions based on the modified signed-digit 共MSD兲 number system representations are proposed. An arithmetic unit that performs parallel one-step addition 共subtraction兲, multiplication, and division is proposed to achieve the computation of complex functions such as the square-root, logarithm, exponential, and other related operations. An optoelectronic correlator-based architecture is suggested for implementing the proposed MSD algorithms to compute the above-mentioned elementary functions. We utilized the symbolic substitution technique to reduce the number of computation rules involved. © 2001 Optical Society of America OCIS code: 200.0200.
1. Introduction
Researchers in the optical engineering community are exploring suitable number system representations and highly parallel algorithms to handle ultrafast arithmetic operations for digital data involving long operands so as to enhance significantly the performance of computing systems. Nonbinary1 number systems such as the residue, redundant, multiple-valued, and signed-digit number representations are widely investigated by optical engineering researchers to achieve ultrafast arithmetic operations. Among them, the signed-digit2 and highradix signed-digit3 number representations are promising number systems for digital optical computing. The inherent redundancy associated with signed-digit number systems, such as the modified signed-digit 共MSD兲 number system, guarantees the propagation of carry to only one digit during the addition operation, instead of the entire operand length. Signed-digit arithmetic operations for trinary signeddigit 共TSD兲 and quaternary signed-digit 共QSD兲 numA. K. Cherri is with the Department of Electrical and Computer Engineering, Kuwait University, P.O. Box 5969, Safat 13060 Kuwait 共
[email protected]兲. M. S. Alam is with the Department of Electrical and Computer Engineering, University of Alabama, 328 Houser Hall, Tuscaloosa, Alabama 35487-0286 共
[email protected]兲. Received 21 December 1999; revised manuscript received 16 November 2000. 0003-6935兾01兾081236-08$15.00兾0 © 2001 Optical Society of America 1236
APPLIED OPTICS 兾 Vol. 40, No. 8 兾 10 March 2001
ber systems have been proposed and investigated extensively in which arithmetic operations are based on three-step, two-step, and one-step schemes with a reduced number of computation rules.3–15 More recently, parallel TSD and QSD multiplication and division were proposed that utilize the two-step and one-step TSD and QSD adders.15–19 The TSD and QSD adders and multipliers exploit optical correlation by an incoherent correlator in which new joint spatial encodings for the TSD and QSD numbers were introduced.18,19 In addition, a one-step algorithm for MSD addition and subtraction was reported.14,18 Over the past two decades, the signed-digit arithmetic techniques have been widely investigated to implement carry-free addition, borrow-free subtraction, and fast multiplication and division operations. The application of signed-digit arithmetic to optically or optoelectronically implement complex operations such as the square-root, logarithm, and exponential functions are yet to be seen. Accordingly, in this paper we propose parallel MSD algorithms to implement multiplication, division, and other complex functions such as the square-root, logarithm, and exponential functions. The implementation of these functions relies heavily on having fast optical addition, subtraction, multiplication, and division units. By exploiting the similarities among these algorithms and by using appropriate initialization and precomputed and stored selection values, we show that all the above-mentioned functions can be implemented by using the unit designed for division. Fur-
thermore, other related functions such as Y兾公X, 公X兾Y, 1兾公X and hyperbolic operations can be evaluated by use of the appropriate identities and the algorithms that we describe in this paper. To the best of our knowledge, this is the first time that MSD arithmetic-based optoelectronic computing techniques have been used to implement complex functions such as the square-root, logarithm, and exponential and other related operations. 2. Modified Signed-Digit Arithmetic
A decimal number X can be represented in terms of an n-digit MSD number as
兺 x 2, j
i
j⫽0
where the variable xi can take any value from the digit set 兵1 , 0, 1其 to produce the appropriate decimal representation. Multiple representation of the same number leads to redundancy in the MSD system. For example, 共15兲10 ⫽ 关1000 1 兴MSD or, equivalently, 共15兲10 ⫽ 关100 1 1兴MSD ⫽ 关01111兴MSD ⫽ 关11 111兴MSD. We can directly obtain negation of a MSD number by complementing the corresponding MSD positive number. The addition of two MSD numbers consists of three steps as shown by the following equations2: step one 3 Xi ⫹ Yi ⫽ 2ti⫺1 ⫹ wi ,
(1a)
step two 3 wi ⫹ ti ⫽ 2ti⫺1⬘ ⫹ wi ⬘,
(1b)
step three 3 Si ⫽ wi ⬘ ⫹ ti⫺1⬘.
MSD Digit Groups G1 ⫽ 1 1 ; G2 ⫽ 01 , 1 0; G3 ⫽ 00, 11 , 1 1; G4 ⫽ 01, 10; G5 ⫽ 11 CP Digit Groups xi yi
NLOP Digit Groups xi⫺1yi⫺1
SLOP Digit Groups xi⫺2yi⫺2
C1 ⫽ G2 ⫹ G4; N1 ⫽ G1; N2 ⫽ G2; S1 ⫽ G1 ⫹ G2 ⫹ G3 C2 ⫽ G1 ⫹ G3 ⫹ G5; N3 ⫽ G3; N4 ⫽ G4; S2 ⫽ G4 ⫹ G5 N5 ⫽ G5; MSD Computation Rules C1 N1 3 0; C1 N2 S1 3 0; C1 N2 S2 3 1; C1N3 3 1; C1N4S1 3 1 ; C1N4S2 3 0; C1N5 3 0; C2 N1 3 1 ; C2 N2 S1 3 1 ; C2 N2 S2 3 0; C2 N3 3 0; C2 N4 S1 3 0; C2 N4 S2 3 1; C2 N5 3 0
n⫺1
X⫽
Table 1. Computation Rules for the One-Step MSD Addition
(1c)
The t and w variables are called the transfer and weight digits, respectively. By examining the operands in digit position i ⫺ 1 共i.e., xi⫺1 yi⫺1兲 together with the operands in digit position i 共i.e., xi yi 兲, then we can obtain two-step addition.5,6 However, onestep MSD addition was recently reported18 that considered the operands in the digit position i, called the current position 共CP, i.e., xi yi 兲; the operands in the digit position i ⫺ 1, referred to as the next lowerorder position 共NLOP, i.e., xi⫺1 yi⫺1兲; and the operands in the digit position i ⫺ 2, denoted as the second lower-order position 共SLOP, i.e., xi⫺2 yi⫺2兲. The truth table for the one-step MSD scheme is shown in Table 1. Recently Casasent and colleagues20 –22 applied the basic correlator architecture shown in Fig. 1 to implement an optical numeric coprocessor. This coprocessor performs addition and multiplication in the MSD number system using the numeric method of symbolic substitution.23 More recently we have shown the application of the cascaded correlation system to perform TSD and QSD arithmetic operations.15–19 Furthermore, an efficient one-step MSD adder was implemented in Ref. 18. In the symbolic substitution approach, the value of each signed digit is encoded by symbols that are recognized and replaced by other symbols to achieve
logic functions. Thus the symbolic substitution method consists of two-pattern processing phases, called the recognition phase and the substitution phase. In Fig. 1, the first correlator 共P1–P3兲 performs the recognition phase, and the second correlator 共P3–P5兲 performs the substitution phase of the symbolic substitution algorithm. The operation of the optical system shown in Fig. 1 is described in detail in Refs. 17 and 22. In the symbolic substitution-based optical processor of Fig. 1, the number of cascaded correlators can be reduced when each pair of correlator stages for the recognition and the substitution phases is combined into a single correlator. This is achieved if each symbolic substitution stage is formulated as a matrix–vector 共M-V兲 multiplication 共y ⫽ Mx兲 for each input of the recognition digits 共the input vector x兲 and the associated pair of the output substitution digits 共the output vector y兲. The unknown matrix M is the solution of this M-V multiplication equation, and it is used as the matched spatial filter 共MSF兲 at plane P2 of Fig. 1.
Fig. 1. Basic symbolic substitution cascaded correlator architecture after Ref. 17. 10 March 2001 兾 Vol. 40, No. 8 兾 APPLIED OPTICS
1237
Fig. 2. One-step MSD addition: 共a兲 five-pixel encodings for CP, NLOP, and SLOP digit classes; 共b兲 spatial encodings that are used in the input Y matrix; and 共c兲 the superimposed spatial encodings that are used in the X matrix, Y matrix, and the M solution of the M-V equation.
3. Modified Signed-Digit Multiplication
It was shown in Ref. 18 that the formulation of the M-V equation for MSD addition in Table 1 leads to a compact solution as demonstrated in Fig. 2. In this section we present MSD multiplication that is simpler than one that was proposed recently.22 The multiplication of two n-bit binary numbers A and B 共A is called the multiplicand and B is the multiplier兲 creates a 2n-bit product. Multiples or partial products, each of which is a product of the multiplicand and a digit of the multiplier, are formed, shifted relative to the multiplier and the multiplicand, and then added up. The process can be expressed as n⫺1
P ⫽ AB ⫽
兺 i⫽0
2n⫺1
Abi ri ⫽
兺 i⫽0
n⫺1
Pi ⫽
兺 pp , i
(2)
i⫽0
where ppi is the partial product. For MSD numbers, because each multiplier is 0, 1, or 1 , the partial product is 0, equal to the 共shifted兲 multiplicand, or equal to the complement of the 共shifted兲 multiplicand. Therefore, in MSD number representation, the partial products can be generated in parallel. At this 1238
APPLIED OPTICS 兾 Vol. 40, No. 8 兾 10 March 2001
point, the basic process of multiplying two n-digit operands becomes the addition of n partial products generated in parallel. Generating the partial products can be achieved by use of the vector outerproduct matrix of the multiplicand and the multiplier and by use of an optical perfect shuffle.22,24 Appropriate shifting of partial products can be performed with reflectors, prisms, fibers, or holograms.24 Our main concern in this section is to obtain the MSD computation rules 共truth table兲 to generate the partial products that will be used in the one-step MSD adder. Table 2 shows the truth table that is used to generate the partial products for the MSD multiplication. In Table 2 the second column represents the input recognition digits 共the x values兲, and the third column represents the output substitution digits 共the y values兲. We obtain the solution for the M-V equation by using a four-pixel spatial encoding per MSD digit. The nine possible MSD inputs of Table 2 can be written as the columns of the input matrix X: X⫽
冋
册
1 1 1 1 0 0 1 0 1 . 1 1 1 1 0 1 0 1 0
Table 2. Truth Table for MSD Multiplication
Multiplicand and Multiplier ai bi
Group 1 2 3
1 1 1 1 0 0 1 0 1
4 5 6
Product Pi
1 1 1 1 0 1 0 1 0
1 1 1 0 0 0
The corresponding nine outputs obtained from Table 2 can be written as the columns of the output matrix Y: Y ⫽ 关1
1
1 1 0
0
0
0
0兴.
To reduce the space– bandwidth product and hence increase the throughput for a given SLM, it is preferable to reduce the number of columns in the X matrix. This can be achieved by the observation that the order of the operands does not affect the result 共i.e., 1 ⫻ 0 yields the same result as 0 ⫻ 1, 1 ⫻ 0 yields the same result as 0 ⫻ 1 , and 1 ⫻ 1 yields the same output as 1 ⫻ 1 兲. Therefore three columns from the X and Y matrices can be eliminated. Now it is necessary for us to introduce a new spatial encoding scheme by superimposing25 共i.e., logical OR operation兲 all encoded digits for each operand. The new encoding scheme is shown in Fig. 3共a兲. The new input and output matrices X and Y are given by X ⫽ 关1 ⫹ 1
1 ⫹ 1 1 ⫹ 1 0 ⫹ 0
Y ⫽ 关1
1 0
1
0
0 ⫹ 1 0 ⫹ 1兴,
0兴,
where ⫹ denotes a logical OR and not a sum. Using the encodings of Figs. 3共a兲 and 3共b兲 in the corresponding X and Y input and output matrices, respectively, we obtain
冤
1 1 X⫽ 0 0 Y⫽ M⫽
冋 冋
1 0 1 0
1 1 1 0
0 0 1 1
1 0 1 1
冥
1 1 , 1 1
册
1 1 0 0 0 0 , 0 0 1 0 0 0
册
0.81 ⫺0.27 ⫺0.18 ⫺0.27 . ⫺0.36 0.45 0.63 ⫺0.54
Therefore the output matrix can be written as
冋
Fig. 3. MSD multiplication: 共a兲 four-pixel encodings for MSD digit, 共b兲 spatial encodings that are used in the input Y matrix, and 共c兲 the superimposed spatial encodings that are used in the X matrix.
sults. It should be mentioned that, in practice, in any optical architecture, thresholding must be applied at output plane P3. After thresholding at a value of 0.5, we obtain the correct output. Note that further improvement of the MSD multiplier is possible when we consider the joint spatial encoding scheme18 involving more than two pairs of digits. This will eliminate two extra columns from the X and Y matrices, as illustrated in Fig. 4. 4. Modified Signed-Digit Division
High-speed division24,26 based on the conversion method uses fast multiplication1 where the divisor D and the dividend N is considered as the denominator and numerator corresponding to the quotient Q as shown in Eq. 共3兲. If we multiply both the numerator and the denominator by the same factor m0, or even by k factors m0, m1, . . . , mk⫺1, and mk such that the denominator converges to 1, then the numerator will converge to Q as shown in the following equation: k⫺1
册
0.54 0.63 0.36 0.45 0.36 0.09 Y ⫽ MX ⫽ . 0.09 0.27 0.72 0.09 ⫺0.27 0.18 Because the X matrix is not a square matrix, a nonexact pseudoinverse matrix M is obtained for the solution. Therefore a thresholding at the output correlation plane P3 is needed to yield the final re-
N Q⫽ ⫽ D
N
兿m
i
i⫽0 k⫺1
D
兿
.
(3)
mi
i⫽0
Thus the crucial step in this method is the selection of mk factors to ensure convergence of the denominator to 1. Fortunately, one method of selecting mk factors is related to the denominator D, and the process 10 March 2001 兾 Vol. 40, No. 8 兾 APPLIED OPTICS
1239
Table 3. Example of MSD Divisiona
k
Uk
Qk
1 2 3 4 5 6 7 8 9 10
⫺0.37510 ⫺0.7510 ⫺1.510 ⫺1.37510 ⫺0.921910 ⫺0.921910 0.197310 0.394510 0.789110 ⫺0.425010
⫺0.37510 ⫽ 0.01 0102 ⫺0.37510 ⫽ 0.01 0102 ⫺0.37510 ⫽ 0.01 0102 ⫺0.4218710 ⫽ 0.1 001011 2 ⫺0.44824210 ⫽ 0.1 0001112 ⫺0.46224910 ⫽ 0.1 0001011 2 ⫺0.46224910 ⫽ 0.1 0001011 2 ⫺0.46224910 ⫽ 0.1 0001011 2 ⫺0.46224910 ⫽ 0.1 0001011 2 ⫺0.46134610 ⫽ 0.1 00010101 2
N兾D ⫽ ⫺0.37510兾0.812510 ⫽ ⫺0.46153810 ⫽ 0.1 000101001 2.
a
malized, it can be expressed as 1 ⫺ X, where 0 ⬍ X ⱕ 1兾2. One simple way to obtain the multiplication constants is shown below: mk ⫽ 1 ⫹ sk2⫺k,
再
1 if Dk ⱕ 1 ⫺ ␣2⫺k 0 if 1 ⫺ ␣2⫺k ⬍ Dk ⬍ 1 ⫹ ␣2⫺k , sk ⫽ ⫺1 if Dk ⱖ 1 ⫹ ␣2⫺k
(7a) (7b)
where ␣ ⬍ 1 is a suitable and easily computable small value. By defining the auxiliary variable Uk ⬅ 2k共Dk ⫺ 1兲 and taking ␣ ⫽ 3兾4, we can use the following iterations to compute the quotient Q ⫽ N兾D:
Fig. 4. Alternative MSD multiplication: 共a兲 the superimposed spatial encodings that are used in the X matrix and 共b兲 solution of the M-V equation.
of fast division can now be reduced to the following iterative relations: Dk⫹1 ⫽ Dk mk,
(4)
Nk⫹1 ⫽ Nk mk,
(5)
mk⫹1 ⫽ 2 ⫺ Dk⫹1,
(6)
where D0 ⫽ D, N0 ⫽ N, and m0 ⫽ 2 ⫺ D0. Next, another fast algorithm for the division of two MSD numbers is represented. The proposed algorithm relies on use of addition and shifting operations and avoids multiplication. The processing speed of this latter technique might be slower than the conversion scheme; however, in this technique the same derived iterative form can be easily used to compute other elementary functions as discussed in Sections 5 and 6. Recall that in Eqs. 共4兲 and 共5兲, Nk 3 Q as Dk 3 1. At step k the selection of values can be made to perform the following: If Dk is less than 1, then multiply it by a value slightly larger than 1; if it is larger than 1, then multiply it by a value that is smaller than 1. Because D is usually fractional and bit nor1240
APPLIED OPTICS 兾 Vol. 40, No. 8 兾 10 March 2001
Uk⫹1 ⫽ 2共Uk ⫹ sk ⫹ Uk sk2⫺k兲,
(8a)
Qk⫹1 ⫽ Qk共1 ⫹ sk2⫺k兲.
(8b)
The initial values of the scheme are U1 ⫽ 2共D1 ⫺ 1兲 ⫽ 2共Dd0 ⫺ 1兲,
(9a)
Q1 ⫽ Q0 d0 ⫽ Nd0,
(9b)
and sk ⫽
d0 ⫽
再
1 if Uk ⱕ ⫺ 3兾4 0 if ⫺3兾4 ⬍ Uk ⬍ 3兾4, ⫺1 if Uk ⱖ 3兾4
(10a)
2 if 1兾2 ⬍ D ⬍ 3兾4 . 1 if 3兾4 ⬍ D ⬍ 1
(10b)
再
Here d0 ensures that U1 lies within the unit interval. Table 3 shows an example to illustrate the abovementioned algorithm. Note that in this algorithm, d0 is used only once and the sk values can be precomputed and stored in look-up tables. Therefore these factors were selected on the fly, depending on the value of k and Uk. Also, Uk2⫺k is nothing more than shifted copies of Uk. Thus the above-mentioned algorithms require mainly addition and shifting operations. 5. Modified Signed-Digit-Based, Square-Root Operation
An algorithm for the computation of 公X is derived in a similar way as the division algorithms for N兾D
Table 4. Example of the Calculation of a MSD Square-Root Functiona
k
Uk
Qk
1 2 3 4 5 6 7 8 9 10
3.510 ⫺1.2510 0.593810 1.187510 ⫺1.787610 0.260410 0.520710 1.041510 ⫺1.925510 0.137810
1.37510 ⫽ 1.101 2 0.687510 ⫽ 0.1012 0.8593710 ⫽ 0.1111 100012 0.85937510 ⫽ 0.111011 2 0.80566410 ⫽ 0.110101 111 1 1 2 0.83084110 ⫽ 0.11101 1 2 0.83084110 ⫽ 0.11101 1 012 0.83084110 ⫽ 0.11101 1 012 0.82759510 ⫽ 0.11101 1 0001 12 0.82921110 ⫽ 0.1111 11 00101 12
Table 5. Example of MSD Logarithmic Function Calculationa
k
Uk
Lk
1 2 3 4 5 6 7 8
⫺1.010 ⫺0.510 ⫺1.010 ⫺0.12510 ⫺0.2510 ⫺0.510 ⫺1.010 ⫺0.0078110
⫺1.0986110 ⫺1.3217510 ⫺1.3217510 ⫺1.3823810 ⫺1.3823810 ⫺1.3823810 ⫺1.3823810 ⫺1.3862710
⫽ ⫽ ⫽ ⫽ ⫽ ⫽ ⫽ ⫽
1 000110011 001 12 1 .0111 001011 2 1 .0111 001011 2 1 .01111 1 1 0001 2 1 .01111 1 1 0001 2 1 .01111 1 1 0001 2 1 .01111 1 1 0001 2 1 .01111 1 1 1001 2
X ⫽ 0.2510; log共X兲 ⫽ ⫺1.38629410 ⫽ 1 .01111 1 1 1001 112
a
X ⫽ 0.687510; 公X ⫽ 0.829215610 ⫽ 0.1111 11 00101 1 1 1 2.
a
6. Natural Logarithm and Exponential Functions
described in Section 4 with the conversion method. Here X replaces N and 公X represents D. Thus 公X can be evaluated as follows:
For a given value of X, the logarithmic function can be described as follows: k
X k
冑X ⫽
X
X
⫽
兿m
k
X
i
⫽
i⫽1
冑X 冑X k m i 兿 i⫽1
冉
兿m
i
i⫽1 k
X
X⫽
兿m
i
i⫽1
冊
1兾2
2
.
R0 ⫽ X0 ⫽ X,
(12)
k
Rk⫹1 ⫽ R
兿m ⫽R m , i
k
k
(13a)
i⫽1
.
兿m
(15)
i
i⫽1
Applying the logarithm operation on both sides of Eq. 共15兲, we obtain
冉
k
log X ⫽ log X
兿
冊 冉兿 冊 k
mi ⫺ log
i⫽1
mi .
(16)
i⫽1
k mi 3 1, and therefore log共X It is evident that if X 兿i⫽1 k k 兿i⫽1 mi 兲 3 0, then ⫺log共兿i⫽1 mi 兲 3 log X. Because this algorithm is similar to the division algorithm, the same multipliers mk, the constant d0, and the selection constants sk can be used to compute the logarithm of X. If we define k
k
Xk⫹1 ⫽ X
i
i⫽1 k
(11)
k k Thus if we force 兿i⫽1 mi2 3 1兾X and 兿i⫽1 mi 3 1兾公X k as k 3 ⬁, then we have X 兿i⫽1 mi 3 X兾公X ⫽ 公X. If k k we now define Rk⫹1 ⫽ X 兿i⫽1 mi and Xk⫹1 ⫽ X 兿i⫽1 2 mi , then we can obtain the following recurrences to compute 公X:
兿m
兿m
2 i
⫽ Xk mk . 2
(13b)
Xk⫹1 ⬅ X
兿m ⫽X m , i
i⫽1
i⫽1
k
k
冉兿 冊 k
Note the similarity between the division algorithm and the square-root algorithm. To avoid the repeated multiplication by mk, the following algorithm is used to compute the square root:
R1 ⫽
再 再
4 if 1兾4 ⱕ X ⬍ 1兾2, , 1 if 1兾2 ⬍ X ⬍ 1 X0 d0兾2 if 1兾4 ⱕ X ⬍ 1兾2 , X0 d0 if 1兾2 ⬍ X ⬍ 1
U1 ⫽ 2共X0 d0 ⫺ 1兲, Rk⫹1 ⫽ Rk共1 ⫹ sk2⫺k兲, Vk⫹1 ⫽ Uk ⫹ sk ⫹ Uk sk2⫺k, Uk⫹1 ⫽ 2共Vk ⫹ sk ⫹ Vk sk2⫺k兲.
mi ⫽ Lk ⫺ log mk,
i⫽1
Uk ⬅ 2k共Xk ⫺ 1兲,
(17)
then the complete algorithm can be written as
R0 ⫽ X0 ⫽ X, d0 ⫽
Lk⫹1 ⬅ ⫺log
(14)
An example illustrating this square-root algorithm is presented in Table 4. Therefore, using appropriate initializations, we can use the same unit to compute both the division and the square-root functions.
U1 ⫽ 2共Xd0 ⫺ 1兲,
(18a)
L1 ⫽ ⫺log d0,
(18b)
Uk⫹1 ⫽ 2共Uk ⫹ sk ⫹ sk Uk2⫺k兲,
(18c)
Lk⫹1 ⫽ Lk ⫺ log共1 ⫹ sk2⫺k兲.
(18d)
Note that Lk⫹1 3 log X, and log d0 and log共1 ⫹ sk2⫺k兲 can be precomputed and selected during the iterations. Even though the algorithms described here are for natural logarithms, a logarithm for any other base can be calculated by an appropriate adjustment of certain constants. Table 5 shows an example to illustrate the application of this algorithm. The exponential value of X is obtained in the following manner. First assume that X is multiplied 10 March 2001 兾 Vol. 40, No. 8 兾 APPLIED OPTICS
1241
Table 6. Example of the Calculation of MSD Exponential Functiona
k
Uk
Ek
1 2 3 4 5 6 7 8 9 10 11
0.173310 0.346610 0.693110 1.386310 0.832610 ⫺0.304210 ⫺0.608410 ⫺1.216710 ⫺0.429610 ⫺0.859110 0.282710
1.010 ⫽ 1.02 1.010 ⫽ 1.02 1.010 ⫽ 1.0 1.010 ⫽ 1.02 1.062510 ⫽ 1.0012 1.09570310 ⫽ 1.0001100012 1.09570310 ⫽ 1.0001100012 1.09570310 ⫽ 1.0001100012 1.09142310 ⫽ 1.00011001 11 111 1 2 1.09142310 ⫽ 1.00011001 11 111 1 2 1.090410910 ⫽ 1.00011001 11 1 11 1 2
X ⫽ 0.12510; exp共X兲 ⫽ 1.09050710 ⫽ 1.00011001 11 1 11 12.
a
by log 2. For a given set of constants mk, X can be expressed as
冉
k
X ⫽ X ⫺ log
兿
冊
k
mi ⫹ log
i⫽1
兿m.
(19)
i
i⫽1
k k If 共X ⫺ log 兿i⫽1 mi 兲 3 0, therefore log共兿i⫽1 mi 兲 3 X, k then 兿i⫽1 mi 3 exp共X兲. If we now define
mk ⬅ 共1 ⫺ sk2⫺k兲, k
Xk⫹1 ⬅ X ⫺ log
兿m ⫽X i
k
⫺ log mk,
i⫽1
k
Ek⫹1 ⬅
兿m ⫽E m , i
k
k
i⫽1
Uk ⬅ 2kXk,
(20)
then the complete algorithm for computing the exponential function can be described analytically as U1 ⫽ 2共X ⫺ log d0兲,
E1 ⫽ d0,
(21a)
Uk⫹1 ⫽ 2关Uk ⫺ 2k log共1 ⫺ sk2⫺k兲兴,
(21b)
Ek⫹1 ⫽ Ek共1 ⫺ sk2⫺k兲.
(21c)
Note that Ek⫹1 3 exp共X兲 and d0 and sk are the same constants defined for the division algorithm. The above-mentioned algorithm can be easily modified to evaluate the exponential corresponding to other powers. Table 6 shows an example to illustrate the evaluation of the exponential of X. 7. Conclusion
We have presented efficient algorithms for performing elementary MSD arithmetic operations such as addition, multiplication, and division. Based on this MSD arithmetic unit, we described a number of algorithms to evaluate division, square-root, logarithmic, and exponential functions. For optical implementation, a symbolic substitution-based cascaded correlator architecture is used to perform all the MSD operations. We explored the similarity between these algorithms to design a single unit to perform all operations. We have shown that, by use of appropriate initialization, precomputation, shift1242
APPLIED OPTICS 兾 Vol. 40, No. 8 兾 10 March 2001
ing, and prestored selection values, all presented functions can be implemented by use of the unit designed for division. It is worth mentioning that other related functions such as Y兾公X, 公X兾Y, 1兾公X and hyperbolic functions can be evaluated with appropriate identities and the algorithms we developed in this paper. References 1. K. Hwang, Computer Arithmetic Principles: Architecture and Design 共Wiley, New York, 1979兲. 2. A. Avizienis, “Signed-digit number representations for fast parallel arithmetic,” IRE Trans. Electron. Comput. EC-10, 389 – 400 共1961兲. 3. K. Hwang and D. K. Panda, “High-radix symbolic substitution and superposition techniques for optical matrix algebraic computations,” Opt. Eng. 31, 2422–2433 共1992兲. 4. R. P. Bocker, B. L. Drake, M. E. Lasher, and T. B. Henderson, “Modified signed-digit addition and subtraction using optical symbolic substitution,” Appl. Opt. 25, 2456 –2457 共1986兲. 5. A. K. Cherri and M. A. Karim, “Modified signed digit arithmetic using an efficient symbolic substitution,” Appl. Opt. 27, 3824 –3827 共1988兲. 6. Y. Li and G. Eichmann, “Conditional symbolic modifiedsigned-digit arithmetic using optical content-addressable memory logic elements,” Appl. Opt. 26, 2328 –2333 共1987兲. 7. A. K. Cherri and N. I. Khachab, “Canonical quaternary signeddigit arithmetic using optoelectronics symbolic substitution,” Opt. Laser Technol. 28, 397– 403 共1996兲. 8. M. S. Alam, Y. Ahuja, A. K. Cherri, and A. Chatterjea, “Symmetrically recoded quaternary signed-digit arithmetic using a shared content-addressable memory,” Opt. Eng. 35, 1141– 1149 共1996兲. 9. A. K. Cherri, M. S. Alam, and A. A. S. Awwal, “Optoelectronics symbolic substitution based canonical modified signed-digit arithmetic,” Opt. Laser Technol. 29, 151–157 共1997兲. 10. A. K. Cherri, “Symmetrically recoded modified signed-digit optical addition and subtraction,” Appl. Opt. 33, 4378 – 4382 共1994兲. 11. B. Ha and Y. Li, “Parallel modified signed-digit arithmetic using an optoelectronic shared content-addressable-memory processor,” Appl. Opt. 33, 3647–3662 共1994兲. 12. G. Li, L. Liu, H. Cheng, and H. Jing, “Simplified quaternary signed-digit arithmetic and its optical implementation,” Opt. Commun. 137, 389 –396 共1997兲. 13. G. Li, F. Qian, H. Ruan, and L. Liu, “Parallel optical negabinary computing: algorithm and optical implementation,” Opt. Eng. 38, 403– 414 共1999兲. 14. A. K. Cherri, “Classified one-step high-radix signed-digit arithmetic units,” Opt. Eng. 37, 2324 –2333 共1998兲. 15. M. S. Alam, “Parallel optoelectronics trinary signed-digit division,” Opt. Eng. 38, 441– 448 共1999兲. 16. M. K. Habib and A. K. Cherri, “Two-step optoelectronics quaternary signed-digit adder using optical correlation,” Opt. Laser Technol. 30, 377–390 共1998兲. 17. M. K. Habib and A. K. Cherri, “Parallel quaternary signeddigit arithmetic operations: addition, subtraction, multiplication and division,” Opt. Laser Technol. 30, 515–525 共1999兲. 18. A. K. Cherri, “Signed-digit arithmetic for optical computing: digit grouping and pixel assignment for spatial encoding,” Opt. Eng. 38, 422– 431 共1999兲. 19. A. K. Cherri, M. K. Habib, and M. S. Alam, “Optoelectronic recoded and nonrecoded trinary signed-digit adder that uses optical correlation,” Appl. Opt. 37, 2153–2163 共1998兲. 20. D. P. Casasent and E. C. Botha, “Optical correlator production system neural net,” Appl. Opt. 31, 1030 –1040 共1992兲.
21. D. Casasent and P. Woodford, “Symbolic substitution modified signed-digit optical adder,” Appl. Opt. 33, 1498 –1506 共1994兲. 22. K. Al-Ghoneim and D. P. Casasent, “High-accuracy pipelined iterative-tree optical multiplication,” Appl. Opt. 33, 1517–1527 共1994兲. 23. A. Huang, “Parallel algorithm for optical digital computer,” in Proceedings of the IEEE 10th International Optical Computing Conference 共Institute of Electrical and Electronics Engineers, New York, 1983兲, pp. 13–17.
24. K. Hwang and A. Louri, “Optical multiplication and division using modified signed-digit symbolic substitution,” Opt. Eng. 28, 364 –372 共1989兲. 25. A. Louri, “Optical content-addressable memory parallel processor: architecture algorithms and design concepts,” Appl. Opt. 31, 3241–3258 共1992兲. 26. F. Qian, G. Li, and M. S. Alam, “Optoelectronic quotientselected modified signed-digit division,” Opt. Eng. 共to be published兲.
10 March 2001 兾 Vol. 40, No. 8 兾 APPLIED OPTICS
1243