1959 Decimal-Binary Conversions in CORDIC
1959 Decimal-Binary Conversions in CORDIC
335
0.10
13545 0.11
0 01
POSITIVE
90
1.00
180
0 000
I\il
-1350or 225>
NEGATIVE
1.01
-45or 3150
-900or 2700 1.10
INTRODUCTION A unique concept for a special-purpose digital computer is described in this issue.' This computer embodies a unique method for the rapid serial evaluation of sines, cosines, transformations between polar and rectangular coordinates, and other operations concerned with coordinate rotations. For this reason, the name of the computer is derived from the initial letters of the words COordinate Rotation DIgital Computer. The versatility of CORDIC is enhanced by utilizing the novel configuration of the arithmetic unit for decimal-binary conversions as well as for trigonometric calculations. Since angles are inherent in trigonometric calculations, it follows that many independent and computed variables in a specific CORDIC application will be angles. Therefore, this treatment is directed specifically to the conversion of angles. In CORDIC, angles are represented as binary fractions of a half revolution with two's complements for inegative angles, as shown in Fig. 1. Since a one to the left of the binary point is used to represent a negative quantity in the two's complement system, angles from + 1800 to slightly less than +360 are interpreted internally as negative angles measured clockwise from 00. Before the conversion technique is explained, the basic philosophy of computation in CORD)IC will be summarized, the arithmetic unit, as shown in Fig. 2 of Volder's paper,1 consists of three shift registers, three
manuscript received, June 25, 1959. 1 Convair, a Div. of General Dynamics Corp., Fort Worth, Tex.
SUBTRACTOR
0
ADDER-
S///Fr04TF75 |
|
REGISTR
,USTRAETlR
-ti ADDER-
A16GZ ,61S7 R
+ADDER-+ SUBTRACTOR
adder-subtractors, and suitable interconnections. Each programmed operation is accomplished in a fixed number of steps. Each step involves the modification of a number by adding or subtracting a constant. The settings of all three adder-subtractors are controlled by the sign of the quantity in one of the arithmetic unit registers. In this way, calculations related to the addition or
be executed simultaneously.
CONVENTIONAL CONVERSION TECHNIQUE
336
September
*, 9 into a set of ten odd integers is necessary. technique in which the 8, 4, 2, 1 code and binary arith- 0, 1, For any specific digit position, the "largest transmetic is utilized. The conventional conversion technique is based upon the 8, 4, 2, 1 code definition of the formed value" is defined as the largest absolute value value of a decimal digit, N, located i places to the left of of odd integers selected for that digit position and multiplied by the appropriate power of ten. In order for the the units position, as given by + code to be useful in the inverse transformation from = X4(8 10i) + X3(4. 10i) + X2(2. 10i) N N* 10i10 = + 34.1~ +X(. O)binary to decimal, it is necessary and sufficient that the + X1(1 10i) 10i) (1) following conditions be satisfied. 1) With reference to a particular digit position, the where Xi=0 or 1. The constants 8 10i, 4 10i, 2 10i, sum of the largest transformed values for all less and 1 10i, evaluated in binary for all values of i of be used, are required in the conversion. The transformasignificant digit positions must be smaller than the power of ten for the aforementioned particular tion from degrees and minutes to fractions of a half revodigit position under consideration. lution is incorporated by expressing the binary con2) Condition 1 must be satisfied for each digit stants in the desired units. A conversion is accomplished position. by executing the operations indicated in (1). These operations are shown in Table I for an angle of 450, The set of ten odd integers -9, -7, -1, + 1, which is expressed in 8, 4, 2, 1 code as (0100) (0101). Conversion of the magnitude of a negative angle is ac- +9 satisfies the foregoing conditions for positions in which all decimal digits, 0 through 9, are possible, and complished in the same way, and the result is then comset will be used for illustration purposes. plemented by subtracting the binary magnitude from this The equation transforming a decimal digit N, having one of the values, 0, 1, * .* , 9, into a digit Y having, respectively, the values -9, -7, * * , +9, is TABLE I (2) Y==2N-9. 8, 4, 2, 1 Constants Constants-Binary of Half Code Product Terms Fraction Variables Degrees Revolution The equation for the inverse transformation iS 0 = 0.01110010 X (3) 80 0.00000000 N -Y + 9.
+
X4(8.
40
20
0.00111001
10 8
1
4 2
0.00000110
0.000010 0 0.00001011
0.00011100
x
X
0.00000011 0.00000001
x x x x
0 0 1 0 1
0.00111001
= = =
= =
0.00000000
Applying the factor of in (3) to the-8, 4, 2, 1 weights results in the code equation
N+ C N=Y44+Y33+Y2 + Y1-2
4J
CONVERSION BASED UPON CODE In Table I, it is shown that at each step, a binary constant is either added or not added, depending upon whether the 8, 4, 2, 1 code variable is 1 or 0, respectively. In order to use the CORDIC principle, it is necessary either to add or to subtract a constant. The use of addition or subtraction is controlled by a code variable placed in the sign digit position of an arithmetic unit register. The problem of conversion by adding and subtracting constants will be considered first. Subsequently, the method of properly positioning the code variables for control will be presented. By analogy to the way in which a code variable of +1 is used to establish the addition of a constant, a variable of -1 may be used to establish subtraction. Therefore, it is desired that a binary code with 1 and -1 variables be used to represent decimal angles in CORDIC. For convenience, the desired code will be called a (plus-minus) code. The 8, 4, 2, 1 weights cannot be applied directly to a four-digit code because
where Y5= +1 or -1 and C=9/2. A factor of 10i may be applied to each term in (4), as was done in (1), to account for the position of the digit N. The pattern of the Yj variables of the code of (4), with C =9/2 and with 0's used to represent - l's, is identical to that of the well-known Excess-3 code.2 It should be noted that the value of C in (4) is determined by the choice of integers upon which the transformation equations are based. In general, the transformation of a set of n +1 integers N =0, 1, * ,n (n odd) into odd integers Y= -n, -n +2, * , -1, +1, ,n X-2, n leads to the inverse transformation, N= y+a N Y and a value of C= n/2. This form of transformation always leads to a code which (by analogy to the Excess3 code) is equivalent to an "Excess" code. It follows that if the proper ("Excess") code is used for each digit position, no code conversion is necessary. However, if it is desired to use the 8, 4, 2, 1 code, the required conversion can be readily accomplished by adding a binary constant to each 8, 4, 2, 1-coded digit. D. Van Nostrand Co., Inc., New York, N. Y., pp. 182-184; 1955.
2 R. K. Richards, "Arithmetic Operations in Digital Computers,"
1959
337
The basic conversion procedure illustrated for the portion of the CORDIC arithmetic unit shown in Fig. 8, 4, 2, 1 code may be used with the code provided the 2. This simultaneous action will be illustrated by means constant term C 10i for all decimal digit positions is of an example in which different codes from the added in binary to the accumulated sum. As an example, Excess-3-equivalent code are used for certain decimal 450 will be converted from (Excess-3) code to binary. digit positions. Since the hundreds-of-degrees position Since the constant for this code is (9/2) tOi, the sum of requires only four digits (0-3), the application of (5) the constants for the two digits is 491'. The code produces a constant C=3/2 and a code which is representation (with l's omitted) for 450 is (- +++) equivalent to the 8, 4, 2, 1 (or "Excess-0") code. Only (+-- -), and the conversion is illustrated in Table II. the last two binary digits of this code are required.
TABLE II
Constants Degrees
491 40 20 10
Code Variables
Product Terms
= = =
(Correction) ++1 -1
-
5 4 2
1
x x x
X
X
-1 +1 +1
-1
= = =
=
0.001110000011
POSITIONING OF + VARIABLES FOR ADDER-SUBTRACTOR CONTROL Successive digits of the code must control successive settings of the adder-subtractors in order for the proper sequence of additions and subtractions to occur as indicated in Table II. The settings of the addersubtractors during conversion operations are established by the value of the sign digit located in the Y Register (decimal-to-binary) or in the Angle Register (binary-todecirnal). The settings relative to each other are indicate(c in Fig. 2 by the sign of tj, a +1 or -1 variable determined by the value of the controlling sign digit. In positioning the code digits for control, the technique of binary nonrestoring division is useful because in this operation, successive quotient digits are given by the signs of successive remainders. Dividing the number representing the code of the angle by 1 produces the complements of successive code digits (in space) as the signs of successive remainders (in time). This binary nonrestoring division by 1 is easily implemented in CORDIC by means of the customary rules given below. 1) If remainder is positive, subtract divisor; if remainder is negative, add divisor. 2) Shift divisor one place to right.111 3) Repealt 1 and 2. The positioning of digits of the code for 450 is illustrated by following the above rules, as shown in Table III.
TABLE III
Si f
(+++)(+-- -)=0111
Subtract
Add
1 1111
1000
Remainder
1000 1000
1000
Subtract
Subtract
Subtract
1 0011
1
+
+
+
0001 1 0000
1000
1
0000
oooo
1111
1111
1100 1 1110 1 11
Similarly, a conlstant C=-5/2 is used for the tens-ofminutes position, where only six digits (0-5) are used. The corresponding code is equivalent to an "Excess5" code. Three (instead of four) binary digits may be THE COMPLETE DECIMAL-TO-BINARY CONVERSION The positioning of code digits for control and the used for this position if desired. generation of the binary angle by addition and subtracIn decimal-to-binary conversion, the code for the tion of constants take place simultaneously within the desired angle is placed in the Y register (Fig. 2), and
338
September
OperationTop AdderSubtractor
Subtract
Register Contents
OperationBottom AdderSubtractor
Register Contents
Value
Y=0.10111010101101011
X=1.0
Add
Angle
Angle
1.00011100011011101
1.00011100011011101
0.10001110001110010
199059.5'
199059.5'
Y=1.10111010101101011
Add X=0.1
Subtract Angle
Add
-100
Y=0.00111010101101011
Subtract Add
X=0.01
0.10001110001101011
0.01000111000111001
99059.5
+ 500
Y=1.11111010101101011
X=0.001 Subtract
Angle
Angle
Add
0.11010101010100100
0.00111000111000111
149059.5'
- 400
Y=0.00011010101101011
0.10011100011011101
0.00011100011100100
109059.5'
+ 200
Subtract
Subtract Subtract
Add
X=0.0001
Y=0.00001010101101011
X=0.00001
Add
Angle
Angle
0.10111000111000001 0.00001110001110010
0.11000111000110011
0.00000111000111001
129059.5'
+ 100
Y=0.00000010101101011
X = 0.0000001
139059.5'
+ 50
Add
Y=1.11111110101101011
X = 0.00000001
Angle
0.11001110001101100
0.00000101101100001 0.11001000100001011
0.00000010110110000
144059.5'
- 40
Subtract
Angle
Y=0.00000000101101011
140059.5'
+ 20
Subtract
Add Subtract
X = 0.000000001
Add
Y=1.11111111101101011
X = 0.0000000001
Angle
Subtract
0.11001011010111011
0.00000001011011000
-
142059.5'
10
Y=0.00000000001101011
Angle
Add
X=0.000000000l
141059.5' 30' +
142029.5'
-
Y=1.11111111111101011
Add
Subtract
X = 0.000000000001
Angle
Subtract
40'
Y=0.00000000000101011
X = 0.0000000000001
Angle
Add
0.11001001101101010
0.00000000011110011
141049.5'
+
+
20'
Y=o0.00000000000001011
Subtract
Add Subtract
Add
X =0.0000000000001
Angle
Add
0.11001010001011101
0.00000000001111001
142009.5'
10'
Y= 1.11111111111111011 X = 0.000000000000001
Angle
Subtract
0.11001010011010110
0.00000000000111101
142019 .5'
5'
Y=0.00000000000000011
X = 0.0000000000000001
Angle
Add
0.11001010010011001
0.00000000000110001
142014.5'
+
4'
Y= .11111111111111111
I
Angle Subtract
Angle
0.11001010011001010
0 .00000000000011000 0 .11001010010110010 0 .00000000000001 100 0.1 100101001011 1110
0 .000000000000001 10
142018.5'
2'
X=0 .0000000000000001
Y= 0.00000000000000001 Subtract
Subtract
142016 .51'
1'
X=0.00000000000000001
Y= 0.00000000000000000
Add
Angle
Add
142017 .51'
.5'
Angle
0 .11001010011000100
142018 .0'
1959
339
the divisor of 1 is placed in the X register. A sign digit of 0 in the Y register establishes a (i of -1, which is programmed to set the top adder-subtractor (Fig. 2) to subtract and the bottom adder-subtractor to add. A sign digit of 1 has the opposite effect. The sum of constant terms designated by C in (4) is initially placed in the angle register, and successive constants are introduced to the bottom adder-subtractor as shown in Fig. 2. As one step of the division is taking place to establish the next setting of the adder-subtractors, a constant is the quantity in subtracted to modify being added or rs ity the to modify sini teangle r register at the beginning of the step. The binary angle is taken from the bottom adder-subtractor on the final
to-binary conversion. The major differences occur in loading the arithmetic unit registers and control of the adder-subtractors from the angle register instead of the Y register. In this conversion, the binary angle is initially placed in the angle register, and the binarycoded-decimal angle is formed in the Y register.
CONCLUSION
raccdin
int
computaton smthep
bnar,as sown
in
1i
TablesIVT
sto corretre
BINARY-To-DECIMAL CONVERSION The binary-to-decimal conversion may be accomplished by a similar technique. The sum of constant terms designated by C in (4) is first subtracted from the binary angle. Then the code is generated by a "nonrestoring division" in which the divisors are successive constants of the code. Simultaneously with the "nonrestoring division," the 8, 4, 2, 1 code is formed (if desired) by adding the appropriate constant to the + code. The binary-to-decimal conversion is accomplished with the same constants and control logic as the decimal-
fore technique described herein was devised especially for conversions between mixed radix decimal angles and binary angles in a digital computer with a CORDIC type arithmetic unit. One of the most attractive features of the technique is that the same constants and control logic can be used in both decimal-to-binary and binary-to-decimal conversion. Although the technique was designed for a particular computer, it is felt that certain concepts will be useful in other applications. For this reason, emphasis has been placed more on fundamental concepts than on details of a specific application. Obvious modifications are possible and may be desirable in a particular application of this conversion technique.
ACKNOWLEDGMENT J. E. Volder, who conceived the basic organization of CORDIC, also envisioned a conversion technique which could be accomplished in CORDIC with little or no modification of the arithmetic unit. The author is indebted to Mr. Volder for discussions and suggestions which assisted materially in the development of this conversion technique.
identified with a set of machines of equivalent minimality. A procedure for developing the aggregate of all sets of gates for suchmmnimal machines is evolved, and the problem of selecting components for constructing machines is discussed.
* Manuscript received by the PGEC, February 16, 1959; revised manuscript received, June 1, 1959. t Electronic Components Lab., Wright Air Dev. Center, WrightPatterson AFB, Dayton, Ohio.
chines will be understood to be any two machines which meet Moore's criterion of isomorphism [ij. That is, if bt r ocae nbakbxsteei oeprmn
bohaecneldi
lc oe,teei oeprmn an external observer can perform which will permit a