adsd_fall2011_14_cordic
TRANSCRIPT
-
8/3/2019 ADSD_Fall2011_14_CORDIC
1/48
Dr. Rehan Hafiz Lecture # 14
ADSD Fall 2011
-
8/3/2019 ADSD_Fall2011_14_CORDIC
2/48
Course Website for ADSD Fall 2011
http://lms.nust.edu.pk/
2
Lectures: Tuesday @ 5:30-6:20 pm, Friday @ 6:30-7:20 pm
Contact: By appointment/EmailOffice: VISpro Lab above SEECS Library
Acknowledgement: Material from the following sources has been consulted/used in theseslides:1. A survey of CORDIC algorithms for FPGA based computers, Ray Andraka, Andraka
Consulting Group, Inc2. University of Minnesota : EE 5324 - VLSI Design II - Lectures Slides by Kia Bazargan,
Spring 20063. http://www.indovina.us/~mai/paco/Pacos_cordic_algorithm.xl4. [SHO] Digital Design of Signal Processing System by Dr Shoab A Khan
Material/Slides from these slides CAN be used with following citing reference:
Dr. Rehan Hafiz: Advanced Digital System Design 2010
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/ -
8/3/2019 ADSD_Fall2011_14_CORDIC
3/48
COordinate Rotation DIgital Computer
(CORDIC)
Iterative Technique
Enormous Applications
Linear Functions / Multiplication
Division
Hyperbolic Functions
Square Rooting
Logarithms, Exponentials Sine, Cosine Generation
Does so much with just SHIFT & ADD
-
8/3/2019 ADSD_Fall2011_14_CORDIC
4/48
Rotation of a Vector
V1
x = r cos()
y = r sin()
V2 x'= r cos(+)
x'= r [cos()cos() -sin()sin()]
x'= r [(x/r)cos() (y/r)sin()]
x'= xcos() ysin()
y'= r sin(+)
y'= ycos() + xsin()
V1
(x,y)
V2
(x,y)
rr
-
8/3/2019 ADSD_Fall2011_14_CORDIC
5/48
Re-arranging the Rotation
Transformation
Rotates a vector in a
Cartesian Plane by the
angle
Calculations Re-arranging
So, given a rotation angle ;
these equations require the
computation of tan()
cos =
)tan(..tan1
1
'
)tan(..tan1
1
2
2
xyy
yxx
)sin(.)cos('
)sin(.)cos(
xyy
yxx
-
8/3/2019 ADSD_Fall2011_14_CORDIC
6/48
tan() is not simple to compute
in hardware
tan()
0.00 0.000
5.00 0.087
10.00 0.176
15.00 0.268
20.00 0.364
25.00 0.466
30.00 0.577
35.00 0.700
40.00 0.839
45.00 1.000
)tan(..tan1
1'
)tan(..tan1
1
2
2
xyy
yxx
-
8/3/2019 ADSD_Fall2011_14_CORDIC
7/48
Example: Lets say we want to rotate a vector
(x0,y0) 30-degrees anti-clockwise to (x3,y3)
Requires calculation of tan(30)
Suppose tan (10) is pre-computed & stored in HW
A 30 degree rotation can be modeled by applying 10 degree
rotation three times
& Similarly for y1,y2,y3 (x0,y0)
(x1,y1)
(x2,y2)
(x3,y3)
)10tan(..)10(tan1
1
)10tan(..)10(tan1
1
)10tan(..)10(tan1
1
222
3
112
2
002
1
yxx
yxx
yxx
1
-
8/3/2019 ADSD_Fall2011_14_CORDIC
8/48
Putting a HW efficient
constraint over tan()
tan() is not simple to computein hardware
tan()
0.00 0.0005.00 0.087
10.00 0.176
15.00 0.268
20.00 0.364
25.00 0.466
30.00 0.577
35.00 0.700
40.00 0.839
45.00 1.000
Rotation anglesare restricted sothat tan() = 2-i ,
where i = 0,1,2,3,
Multiplication byTangent is reducedto simple shiftoperation
)tan(..tan1
1'
)tan(..tan1
1
2
2
xyy
yxx
i tan(i) i
i 2-i tan-1(2-i)
0 1 45.000
1 0.5 26.565
2 0.25 14.036
3 0.125 7.125
4 0.0625 3.576
5 0.03125 1.790
6 0.015625 0.895
7 0.0078125 0.448
8 0.00390625 0.2249 0.001953125 0.112
-
8/3/2019 ADSD_Fall2011_14_CORDIC
9/48
Putting a HW efficient
constraint over tan()
tan() = 2-i
tan() =d.2-i
d=-1,+1 dependingupon the rotationdirection
i-2i-
i-
2i-
2...21
1'
2...21
1
dxyy
dyxx
)tan(..tan1
1'
)tan(..tan1
1
2
2
xyy
yxx
-
8/3/2019 ADSD_Fall2011_14_CORDIC
10/48
In CORDIC we use the
pre-computed 2-i table
Principle: A composite rotation of any
arbitrary angle can be represented
by summation() of elementary
rotations
Using elementary angles from the
constrained tan table
Writing 30 in terms of elementary angles
from table
= 30.0 45.0 26.6 + 14.0 7.1 + 3.6
+ 1.8 0.9 + 0.4 0.2 + 0.1
= 30.1
Iter.
Constrain
-ed tan
Rotation for each
iteration
i tan(i) i
i 2-i tan-1(2-i)
0 1 45.000
1 0.5 26.565
2 0.25 14.036
3 0.125 7.125
4 0.0625 3.576
5 0.03125 1.790
6 0.01562 0.895
7 0.00781 0.448
8 0.00390 0.2249 0.00195 0.112
-
8/3/2019 ADSD_Fall2011_14_CORDIC
11/48
-
8/3/2019 ADSD_Fall2011_14_CORDIC
12/48
X
Y
30
Example: Rewriting
Angles in Terms ofai
= 30.0
45.0 26.6 + 14.0 7.1 + 3.6
+ 1.8 0.9 + 0.4 0.2 + 0.1
= 30.1
45
+ 1.10 - (+ 1.8 ) = - 0.70
Rotate the vector in -ve direction
+ 4.70 - (+ 3.6 ) = + 1.10
Rotate the vector in +ve direction
- 2.40 - (- 7.1 ) = + 4.70
Rotate the vector in +ve direction
+11.60 - (+14.00 ) = - 2.40
Rotate the vector in -ve direction
-15.00 - (-26.60 ) = +11.60
Rotate the vector in +ve direction
+30.00 - (+45.00 ) = -15.00
Rotate the vector in -ve direction
Angle Accumulator Angle(current tan value) = Residual Angle
+ve+ve direction, -ve -ve direction
-
8/3/2019 ADSD_Fall2011_14_CORDIC
13/48
The calculation of residual angle results into
another equation in the CORDIC System
Angle Accumulator Angle(current tan value) = Residual Angle
Actually it is
Angle Accumulator = Angle Acc. (Current Value) (Direction)Angle Moved
)2(tan.
2..
2..
i-1
1
i-
1
-i
1
iii
iiii
iiii
dzz
dxyy
dyxx
Iter.Constrain-ed tan
Rotation for eachiteration
i tan(i) =2-i i=tan
-1(2-i)
0 1 45.000
1 0.5 26.565
2 0.25 14.036
3 0.125 7.125
4 0.0625 3.576
5 0.03125 1.790
6 0.01562 0.895
7 0.00781 0.448
8 0.00390 0.2249 0.00195 0.112
1
-i1)]2(.[tan
iii zdz
-
8/3/2019 ADSD_Fall2011_14_CORDIC
14/48
CORDIC- Formal
1
-
8/3/2019 ADSD_Fall2011_14_CORDIC
15/48
CORDIC
Derivation Summary
)tan(..tan1
1
)tan(..tan1
1
2
21
1 i
i
i
i
i
xyy
yxx
ii
i
i-1
-i
1
2...
2...
iiiii
iiiii
dxyKy
dyxKx
1,
21
1
2i-
dKi
Provides an iterative method
of performing vector
rotations by arbitrary angles
Uses only shifts & adds
Ki is just a scaling factor
multiplied in each iteration &
can be applied as a
cumulative gain An to the
final xn,yn
The precision increases with
each iteration n
nAGain-2i
21/1/1
647.1 i
nA
)2(tan.
2..
2..
i-11
i-
1
-i
1
iii
iiii
iiii
dzz
dxyy
dyxx
-
8/3/2019 ADSD_Fall2011_14_CORDIC
16/48
Modes defined by Volder
Rotation - The coordinate components of a
vector and an angle of rotation are given and the
coordinate components of the original vector,
after rotation through the given angle, arecomputed.
Vector - The coordinate components of a vector
are given and the magnitude and angular
argument of the original vector are computed.
CORDIC Th di f d
-
8/3/2019 ADSD_Fall2011_14_CORDIC
17/48
CORDIC
Rotation Mode
Rotates the input vector by aspecified angle
Application Calculating the x,y coordinates
at a given angle Method:
Initialize angle accumulator bydesired angle
Initialize x & y
Decision d: based upon thesign of angle accumulator
Goal : Minimize the AngleAccumulator
The coordinate components of a vector and an
angle of rotation are given and the coordinate
components of the original vector, after rotation
through the given angle, are computed
-
8/3/2019 ADSD_Fall2011_14_CORDIC
18/48
Rotation Mode
1
0
3
2
5
46
(x, y)z
(x, y) z=0
rotates a vector (x,y) by a given angle (z)
CORDIC Th di t t f t
-
8/3/2019 ADSD_Fall2011_14_CORDIC
19/48
CORDIC
Vectoring Mode
Rotates the input vector to x-axiswhile recording the angle requiredto make that rotation
Application
Calculating the angle of a vector
Calculating the magnitude (scaled) Initialize angle accumulator by
ZERO
Goal : Minimize the y componentof the residual vector.
Decision: based on Sign of the
residual y component Angle accumulator will contain
the traversed angle at the end ofthe iterations
The coordinate components of a vector
are given and the magnitude and
angular argument of the original
vector are computed
-
8/3/2019 ADSD_Fall2011_14_CORDIC
20/48
Vector Mode
rotates a vector (x,y) to the x axis whilerecording the angle required to make therotation (z)
0 (x,y)
1
2
3
4
5 (x, 0)z
-
8/3/2019 ADSD_Fall2011_14_CORDIC
21/48
Saving an addition for Angular Measurements
System --- Vector Mode
Can we avoid computing z in vector mode & still be able to know the final
angle ?
The angle of a composite rotation is uniquely defined by the directions of
elementary rotations.
Can be stored using : Decision Vector LUT
So, also skip Addition in Vector Mode
d9 d8 d7 d06 d5 d4 d3 d2 d1 d0 Angle
0 0 0 0 0 0 0 0 0 0 99.77
0.112 + 0.224 +0.448+0.895+1.790+3.576+7.125+14.036 + 26.565 + 45.000
0 0 0 0 0 0 0 0 0 1 9.77
0.112 + 0.224 +0.448+0.895+1.790+3.576+7.125+14.036 + 26.565 -45.000
0 0 0 0 0 0 0 0 1 0 46.64
0.112 + 0.224 +0.448+0.895+1.790+3.576+7.125+14.036 - 26.565 + 45.000
CORDIC
-
8/3/2019 ADSD_Fall2011_14_CORDIC
22/48
CORDIC
Unified Equations
xi+1 = xi yi.m.di.2-i
yi+1 = yi + xi.di.2-i
zi+1 = zi di.ei
Coordinate System m ei
Circular 1 tan -1 (2 -i)
Linear 0 2 -i
Hyperbolic -1 tanh -1 (2 -i)
Mode d
Rotation di = -1 if zi < 0, else +1
Vector di = +1 if yi < 0,else -1
J.Walther,A Unified Algorithm for Elementary Functions, Joint ComputerConference Proceedings
CORDIC Li M d
-
8/3/2019 ADSD_Fall2011_14_CORDIC
23/48
CORDIC-Linear Mode
Multiplication
Lets say you are multiplying 28 by anynumber z
Cordics HW optimization constraintlimits the possible multiplier to powerof 2 (i.e. 2-i)
Thus possible combinations are 28*(1)
28*(0.5)
28*(0.25),..
We can represent any composite
multiplier using these elementarymultipliers
Example 28*(1+0.5+0.25) = 28*(1.75)
Example 28*(1-0.5+0.25) = 28*(0.75)
CORDIC Li M d
-
8/3/2019 ADSD_Fall2011_14_CORDIC
24/48
CORDIC Linear Mode
Decision for d
The iterations work to produce such a combination (d) of elementary multiplierthat reduces the residual multiplier to zero
After every iteration we compare the residual with zero.
If residual is greater than zero (zi>0)
The combination that we have multiplied with till yet; is still less than the desired multiplier
We need to ADD the next elementary multiplier
If residual is less than zero (zi
-
8/3/2019 ADSD_Fall2011_14_CORDIC
25/48
CORDIC-Linear Mode
Multiplication
0
10
20
30
40
50
60
1 2 3 4 5 6 7 8 9 10 11
Series1
CORDIC Li M d
1 2
-
8/3/2019 ADSD_Fall2011_14_CORDIC
26/48
CORDIC-Linear Mode
Multiplication
0
0.2
0.4
0.6
0.8
1
1.2
1 2 3 4 5 6 7 8 9 10 11
1 2
-
8/3/2019 ADSD_Fall2011_14_CORDIC
27/48
Division
0
0.2
0.4
0.6
0.8
1
1.2
1 2 3 4 5 6 7 8 9 10 11
Minimize this
term for division
in vector mode
-
8/3/2019 ADSD_Fall2011_14_CORDIC
28/48
Minimizing yi+1
Means we wish to force y
0, in our iterations Assume we want to find the ratio
Initialize x=4, y=3 & z=0
Minimizing yi+xi.(di.2-I) means
Minimize 3+4( some term)
This term 3+4( some term) can only reach 0;if some term = the ratio i.e. (-3/4)
AND zi+1 is actually storing the updated value of this someterm in every iteration
-
8/3/2019 ADSD_Fall2011_14_CORDIC
29/48
CORDIC Uses
OPERATION MODE INITIALIZE
xo, yo, zo
DIRECTION REQ. OUTPUT
Sine, Cosine of an
angle
Rotation x=1/An, y=0, z=a Reduce z to Zero xn=cos zoYn=sin zo
Polar to Rect. Rotation x=(1/An)Xmag, y=0,
z=Xphase
Reduce z to Zero xn=Xmagcos zo
yn=Xmagsin zoGeneral Rotation
of a vector
Rotation x=(1/An)x0,
y=(1/An)y0, z=a
Reduce z to Zero xn,yn are the
rotated
coordinates
Vector Magnitude Vector x=(1/An)x0,
y=(1/An)y0, z=0
Reduce y to Zero
Arctangent Vector x=(1/An)x0,
y=(1/An)y0, z=0
Reduce y to Zero
Rect. to Polar Vector x=(1/An)x0,
y=(1/An)y0, z=0
Reduce y to Zero Xn is magnitude
Zn is magnitude
Arcsine,
Arccosine
Vector x=(1/An), y=0,
arg=sina or cosa
Reduce y to Value
in arg Register
)/(tan
0
001
0
2
0
2
0
xyzz
y
yxAx
n
n
nn
-
8/3/2019 ADSD_Fall2011_14_CORDIC
30/48
Output Equations
n
i
n
n
nn
nn
A
z
zxzyAy
zyzxAx
2
0000
0000
21
0
]sincos[
]sincos[
Circular - Rotation
n
i
n
n
n
nn
A
xyzz
y
yxAx
2
00
1
0
2
0
2
0
21
)/(tan
0
Circular - Vector
0
000
0
zn
zxyy
xx
n
n
Linear - Rotation
)/(
0
000
0
xyzz
y
xx
n
n
n
n
i
n
n
nn
nn
A
z
zxzyAy
zyzxAx
2
0000
0000
21
0
]sinhcosh[
]sinhcosh[
n
in
n
n
nn
A
xyzz
y
yxAx
2
00
1
0
2
0
2
0
21
)/(tanh
0
Hyperbolic - Rotation
Linear - Vector
Hyperbolic - Vector
-
8/3/2019 ADSD_Fall2011_14_CORDIC
31/48
Micro-Architecture
CORDIC in HW
-
8/3/2019 ADSD_Fall2011_14_CORDIC
32/48
CORDIC in HW
Bit Parallel Architecture
xi+1 = xi yi.m.di.2-i
yi+1 = yi + xi.di.2-i
zi+1 = zi
di.eiCoordinate System m ei
Circular 1 tan -1 (2 -i)
Linear 0 2 -i
Hyperbolic -1 tanh -1 (2 -i)
Mode d
Rotation di = -1 if zi < 0, else +1
Vector di = +1 if yi < 0,else -1
ROM has the angle list
-
8/3/2019 ADSD_Fall2011_14_CORDIC
33/48
Bit-serial CORDIC StructureMUX selection for cross terms depends on the Iteration number
Each iteration takes w cycles
Unrolled
-
8/3/2019 ADSD_Fall2011_14_CORDIC
34/48
Unrolled
CORDIC
xi+1 = xi yi.m.di.2-i
yi+1 = yi + xi.di.2-i
zi+1 = zi
di.ei
-
8/3/2019 ADSD_Fall2011_14_CORDIC
35/48
Discussion on some CORDIC Papers
-
8/3/2019 ADSD_Fall2011_14_CORDIC
36/48
Papers(Please go through the paper)
50 Years of CORDIC: Algorithms,
Architectures, and Applications Pramod K. Meher, Senior Member, IEEE, Javier Valls, Member, IEEE, Tso-Bing Juang,
Member, IEEE, K. Sridharan, Senior Member, IEEE, and Koushik Maharatna, Member,
IEEE
IEEE TRANSACTIONS ON CIRCUITS AND SYSTEMSI: REGULAR PAPERS, VOL. 56, NO. 9, SEPTEMBER 2009
Adaptive CORDIC: Using Parallel Angle
Recoding to Accelerate Rotations Terence K. Rodrigues and Earl E. Swartzlander, Jr., Fellow, IEEE
IEEE TRANSACTIONS ON COMPUTERS, VOL. 59, NO. 4, APRIL 2010
-
8/3/2019 ADSD_Fall2011_14_CORDIC
37/48
-
8/3/2019 ADSD_Fall2011_14_CORDIC
38/48
CORDIC Implementations
The latency of an iterative algorithm like CORDIC is determinedby the product of the number of iterations times the cycle timeof each iteration.
Speeding up CORDIC
Reduce the number of iterations (Solution : e.g. Higher RADIX)
Reduce the execution time for each cycle (Solution : For e.g. UsingFast Adders)
Two bottlenecks in CORDIC
The micro-rotation for any iteration is performed on theintermediate vector computed by the previous iteration(Solution: Unrolling)
The ith iteration could be started only after the completion of theith iteration, since the value of d needs to be estimated (Solution :Predicting Angle Constants in advance)
-
8/3/2019 ADSD_Fall2011_14_CORDIC
39/48
Higher Radix CORDIC - Approach
Diverging pseudorotations only occur when
-
8/3/2019 ADSD_Fall2011_14_CORDIC
40/48
Control CORDIC
Simple method; Can be applied in runtime
there is an overshoot, so this method avoids
them by ensuring that the trajectory of the
moving vector will never overshoot the final
target position.
-
8/3/2019 ADSD_Fall2011_14_CORDIC
41/48
Angle Recoding
Exhaustive algortihm
At every iteration, the angle constant
that will bring the residual angle (Z i
) closest to 0 is chosen from the set
of available angle constants.
HW wise very complicated angle
selection logic !
It is, therefore, most attractive in
static cases where the rotation
angle is fixed and known a priori.
The selection of the angle constants
can be done offline, and the angle
constants saved in a Look-Up Table.
-
8/3/2019 ADSD_Fall2011_14_CORDIC
42/48
Angle Recoding
Dynamic Angle Selection for Angle
-
8/3/2019 ADSD_Fall2011_14_CORDIC
43/48
Dynamic Angle Selection for Angle
Recoding
A simulation was done for Angle Recoding to observe the pattern Observation:
There are contiguous bands of rotation angles, all of which use a particular angle constant
during an intermediate iteration. If a rotation angle lies within a particular band, the angle
constant corresponding to that band is used.
For example, anyrotation angle in the
range [20.295, 35.78)
will use the angle
constant 26.56 degrees.
This implies that the
dynamic angle selection
for Angle Recoding can
be done by performing
an initial comparison
step, to determine the
bands that contain an
angle.
-
8/3/2019 ADSD_Fall2011_14_CORDIC
44/48
Ranges are then defined for every possible combination of Angle constants
Range comparisons increase exponentially with bit width
Parallel Comparators Required in H/W
H/W mapping for
-
8/3/2019 ADSD_Fall2011_14_CORDIC
45/48
H/W mapping for
Parallel Angle Recoding
-
8/3/2019 ADSD_Fall2011_14_CORDIC
46/48
Select fewer angle constants at a time, in a given
evaluation cycle. All the angle constants which
are evaluated together in the same cycle in the
comparison logic are said to constitute a section. When all the angle constants from the section
have been processed in the CORDIC unit, the
absolute value of the residual angle that remains
at the end, is less than half the value of the
smallest angle constant in the section.
H/W mapping for
-
8/3/2019 ADSD_Fall2011_14_CORDIC
47/48
H/W mapping for
Section based Parallel Angle Recoding
-
8/3/2019 ADSD_Fall2011_14_CORDIC
48/48