CORDIC Algorithm for Sinusoidal Calculations

International Journal of Emerging Technologies and Engineering (IJETE)
Volume 1 Issue 5, June 2014, ISSN 2348 – 8050
CORDIC Algorithm for Sinusoidal Calculations
Ms. Ankita Sharma1, Mrs. Neha Sharma2, Mr. Jitender Chhabra3
1
M.Tech. Scholar, SGTIET, Gurgaon.
Asst. Professor, SGTIET, Gurgaon
3
Asst. Professor, AKGEC, Ghaziabad.
2
ABSTRACT
This paper describes the application of the CORDIC
Algorithm’s to find the sine and cosine of an angle in
integer form. The only operations it requires are
addition, subtraction, bit shift and table lookup which
makes it the first choice if the hardware multiplier is
not available. The algorithm is implemented here for
an angle of 30o and the Active-HDL results are shown
along with sine and cosine values in the tabular form
for different rotation angles.
X = r cos , Y = r sin 
(x’) = (x. cos () – y.sin ())
(y’) = (y.cos () +x.sin ())
(1)
(2)
(3)
Keywords – CORDIC, Cosine, HDL, Sine, Vectorrotation.
1. INTRODUCTION
Trigonometric Functions are widely used in analysis
and design of various mathematical models.
Trigonometric functions are needed to be calculated in
various industrial, mechanical and computational
applications. These functions are calculated mainly
using two techniques mainly the Polynomial
Approximation Method & Look up Table method.
Both these methods have their relative advantages and
disadvantages and are used accordingly in the
applications favoring the preferences. In the recent
years a new computation technique named CORDIC
came in to existence which combined the merits of
both the methods and provides a much more efficient
computation technique which also extends its
advantages
even
in
the
hardware
VLSI
Implementations. This CORDIC algorithm was
devised by Jack E. Volder in 1959 for the computation
of Trigonometric functions, Multiplication, Division,
Logarithms and other complex calculations.[1]
2. MATHEMATICAL ANALYSIS
General equations for a vector rotation lay the
foundation for derivation of the Volder's CORDIC
algorithm. If a vector V with coordinates (x, y) is
rotated through an angle  then a new vector V ' can be
obtained with coordinates (x', y') where x' and y' can be
obtained using x, y and  by the following method.[2]
As shown in Fig. 1.
Fig. 1: Rotation of a vector V by angle 
x’ = cos()[x - y.tan()]
y’ = cos()[y + x.tan()]
(4)
(5)
Now if tan() =2-ithe value inside the bracket can
besimplified.In digital hardware this denotes a simple
shift operation. Furthermore, if those rotations are
performed iteratively and in both directions every
value of tan () is presentable with  = arctan(2-i) the
cosine term could also be simplified and since cos() =
cos(-) it is a constant for a fixed number of iterations.
This iterative rotation can now be expressed as:
xi+1 = ki[xi – yi.di.2-i]
yi+1= ki [yi – xi.di.2-i]
(6)
(7)
where, i denotes the number of rotation required to
reach the required angle of the required vector,
cos(arctan(2-i )) and di = ±1. The product of the Ki’s
represents the so-called K factor :
k=∏
(8)
∏
where
= cos0cos1cos2cos3cos4
.................cosn-1
( is the angle of rotation here for n times rotation).
Kiis the gain and its value changes as the number of
106
www.ijete.org
International Journal of Emerging Technologies and Engineering (IJETE)
Volume 1 Issue 5, June 2014, ISSN 2348 – 8050
iteration increases. For 8-bit hardware CORDIC
approximation method the value of kiis given as:
ki= ∏ cos  = cos0 . cos1 . cos2. cos3 . cos4 .
cos5 . cos6 . cos7
=cos45.cos26.565.. cos0.04469 = 0.6073
(9)
TABLE 1 Values of Angles for 8-bit CORDIC H/W
0
d-i =
2-i=tani
1
i=
arctan(2-i)
45o

inradian
0.7854
1
0.5
0.4636
2
0.25
26.565o
14.036o
3
0.125
0.1244
4
0.0625
7.125o
3.576o
5
0.03125
0.0312
6
0.015625
1.7876o
0.8938o
7
0.0078125
0.4469o
0.0078
i
TABLE 2Choosing the signs of the rotation angles to
force z to zero
i
0
1
2
3
4
5
6
7
8
9
0.2450
0.0624
0.0156
From the TABLE 1 it can be seen that precision up to
0.4469 is possible for 8-bit CORDIC hardware.To
simplify each rotation, picking αi (angle of rotation in
ith iteration) such that αi = di. 2-i . diis such that it has
value +1 or -1 depending upon the rotation i. e.
di{+1,-1} . Then
xi+1 = xi - di yi2i
yi+1 = yi - di xi 2-I
zi+1 = zi - di tan-12-I
the sign of z; that is, di= sign ( zi) is chosen, where the
sign function is defined to be -1 or +1 depending on
whether the argument is negative or non-negative.[4][7] Table 2 shows the process of selecting the signs of
the rotation anglesfor a desired rotation of +30 degree.
zi+1
zi-αi
+30.0-45.0
-15.0+26.6
+11.6-14.0
-2.4+7.1
+4.7-3.6
+1.1-1.8
-0.7+0.9
+0.2-0.4
-0.2+0.2
+0.0-0.1
-15
11.6
-2.4
4.7
1.1
-0.7
0.2
-0.2
0
-0.1
Fig. 2 depicts the initial 3 iterationsin the process of
vector rotation.
(9)
(10)
(11)
xo, yo
x2, y2
The computation of xi+1 or yi+1requires an i-bit right
shift and an add/subtract. If the function tan-12-i is pre
computed and stored in table (TABLE 1) for different
values of i, a single add/subtract suffices to compute
zi+1. Each CORDIC iteration thus involves two shifts, a
table lookup and three additions. If the rotation is done
by the same set of angles (with + or - signs), then the
expansion factor K, is a constant, and can be pre
computed.[3] For example to rotate by 30 degrees, the
following sequence of angles be followed that add up
to  30 degree.
30.0 45.0 - 26.6 + 14.0 - 7.1 + 3.6 + 1.8 - 0.9 + 0.4 0.2 + 0.1
= 30.1
In effect, what actually happens in CORDIC is that z is
initialized to 30 degree and then, in each step, the sign
of the next rotation angle is selected to try to change
o
45
o
14
26.6
o
x3, y3
x1, y1
Figure 2: First 3 of 10 iterations leading from (x0,y0)
to ( x3,y3) in rotating by +30, rotation mode.
3. ALGORITHMIC APPROACH
This approach shows how to use CORDIC in rotation
mode to calculate sine and cosine of an angle, and
assumes the desired angle is given in radians and
represented in a fixed point format. Referring to
determine the sine or cosine for an angle β, the y or x
coordinate of a point on the unit circle corresponding
to the desired angle must be found. (Refer Fig. 3)
107
www.ijete.org
International Journal of Emerging Technologies and Engineering (IJETE)
Volume 1 Issue 5, June 2014, ISSN 2348 – 8050
Start
Enter the value of ɸ
Draw a unit circle with radius = stating vector v0 = [1, 0]
For 1st iteration rotate the vector by 45o to get the vector v1
Make next iteration to rotate the vector to in the direction of achieving the desired angle ɸ using
the step angle αi = tan-1(2-i)
Calculate updated value of ɸ using ɸi = ɸi-1 - diαi
No
Yes
Is ɸi
positive?
Rotate vector
counterclockwise
Rotate vector
clockwise
Find the updated vector vi by making next iteration
Is the updated
angle close to ɸ
No
Yes
Measure the value of x-coordinate to get the value of cosɸ& measure the value of ycoordinate to get the value of sinɸ
Stop
Fig. 3 Flowchart for CORDIC Algorithm
108
www.ijete.org
International Journal of Emerging Technologies and Engineering (IJETE)
Volume 1 Issue 5, June 2014, ISSN 2348 – 8050
Using CORDIC, we would start with the vector vo:
for i = 1, 2, 3, ….
vo= [1,0]
4. RESULTS
(12)
In the first iteration, this vector would be rotated 45°
counterclockwise to get the vector v1. Successive
iterations will rotate the vector in one or the other
direction by size decreasing steps, until the desired
angle has been achieved. Step i size is arctan(1/(2i−1))
Fig. 4, 5, 6, and 7 shows the Active HDL simulation
results in the form of a continuous waveform with ten
Timing states for an integer input angle of 30o. TABLE
3 consist of the end results of the simulation for three
different angles: 30o, 40o, and 60o
Fig. 4 Waveform for States m0, m1, m2 and m3
Fig. 5 Waveform for States m4, m5 and m6
109
www.ijete.org
International Journal of Emerging Technologies and Engineering (IJETE)
Volume 1 Issue 5, June 2014, ISSN 2348 – 8050
Fig. 6 Waveform for States m7 and m8
Fig. 7 Magnitude of sine and cosine of angle 30
S. No.
TABLE 3 Sine and Cosine values of some angles
Input angle in derges
Sine value
(sfloat2)
Cosine value
(cfloat2)
1.
30o
0.50781
0.85156
2.
o
0.70313
0.69531
o
0.86719
0.49219
3.
45
60
110
www.ijete.org
International Journal of Emerging Technologies and Engineering (IJETE)
Volume 1 Issue 5, June 2014, ISSN 2348 – 8050
5. CONCLUSION
This paper presents mathematical and analytical
aspects of implementing the CORDIC algorithm for
sinusoidal calculations. This method can provide n-bit
accuracy for n iterations. This method is much simpler
than the conventional methods as the computations are
reduced to only shift and add operations instead of the
complex multiplication operations. On the other hand,
when a hardware multiplier is available (e.g. in a DSP
microprocessor), table-lookup methods and power
series are generally faster than CORDIC.
REFERENCES
[1] R.Andraka,A Survey of CORDIC Algorithms for
FPGA Based Computers, CM/SIGDA Sixth
International Symposium on FPGAs, February1998,
Monterey, CA, pp.191-200.
[2] J.Volder,The CORDIC Computing Technique, IRE
Trans. Comput.,Sept.1959, pp.330-334.
[3] Nuha A.S. Alwan, A Fully Pipelined Systolic
Array forSinusoidal Sequence Generation, IEEE
Transactions on Computers, Vol. 55, No. 5, May 2006,
636-639.
[4]AmitAcharyya, KoushikMaharatna, Coordinate
Rotation Based Low Complexity N-DFastICA
Algorithm and Architecture, IEEE Transactions on
Signal Processing, Vol. 59, No. 8, August 2011, 39974011.
[5] Alvaro Vazquez, Julio Villalba, Redundant
Floating-point Decimal CORDICAlgorithm, IEEE
Transactions on Computers, Vol. 52, No. 6, July 2011,
1012-1025.
[6] Pramod Kumar Meher, CORDIC Designs for Fixed
Angle of Rotation, IEEE Transactions on Very Large
Scale Integration (VLSI)Ssystems, Vol. 21, No. 2,
February 2013, 217-228
[7] Hai Huang and Liyi Xiao, CORDIC Based Fast
Radix-2 DCT Algorithm, IEEE Signal Processing
Letters, Vol. 20, No. 5, May 2013, 483-486.
111
www.ijete.org