CORDIC Background 2A
Copyright c 20-202 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Please send corrections or suggestions to youngwlim@hotmail.com. This document was produced by using OpenOffice and Octave.
CORDIC Background J. P. Deschamps, G. A. Bioul, G.D. Sutter, Synthesis of Arithmetic Circuits 2A Background 3
Vector Rotation x, y x 0, y 0 y y 0 x, y x 0, y 0 R R x x 0 rotate by θ x 0, y 0 x, y x y = x 0 cos θ y 0 sin θ = x 0 sin θ + y 0 cosθ 2A Background 4
Vector Rotation 2 x, y x 0, y 0 y 0 y 0 x 0 x 0 In the rotated coordinate invariant length x 0, y 0 2A Background 5
Vector Rotation 3 x = x 0 cosθ y 0 sin θ y = x 0 sin θ + y 0 cosθ x, y x, y x 0, y 0 x 0 sin θ x 0 x 0, y 0 y 0 y y 0 x 0 y 0 cos θ x 0 sin θ y 0 sin θ x y 0 cos θ 2A Background 6
Successive Rotations Given Vector Given Angle Rotate Computing new coordinates Given Unit Vector Given Angle θ Rotate x = cosθ y = sin θ Given Vector x 0, y 0 Rotate x n = x 0 cos θ y 0 sin θ Given Angle θ = x 0 sin θ + y 0 cos θ y n θ 0 θ i θ i+ θ n 0 x 0 y 0 x i y i x i+ y i+ x n y n 2A Background 7
CORDIC Rotation θ 0 θ i θ i+ θ n 0 x 0 y 0 x i y i x i+ y i+ x n y n x i+ y i+ = x i cosθ i y i sin θ i = x i sin θ i + y i cos θ i Pseudo-rotation x i+ = cosθ i x i y i tanθ i y i+ = cos θ i x i + y i x ' i+ = x i y i y ' i+ = x i + y i x i+ = y i+ = x + tan 2 i y i θ i x + tan 2 i + y i θ i 2A Background 8
cos θ in term of tan θ θ r a cos θ = a r sin θ = b r b r = a 2 + b 2 cos θ = a r = a a 2 + b 2 = + b /a 2 = + tan 2 θ tan θ = b a 2A Background 9
Pseudo-rotation factor of /cos θ r cosθ, r sinθ r cosθ cosθ, r sin θ cosθ θ r r cos θ r sin θ θ r r sin θ r cos θ cosθ > θ s r t r : r cos θ = s : r r cos θ : r sin θ = r : t s = r cosθ s = r sin θ cosθ 2A Background 0
Pseudo-rotation x i+, y i+ x i+, y i+ x ' i+, y ' i+ x i, y i x i, y i R R x i+ = cosθ i x i y i tanθ i y i+ = cos θ i x i + y i x ' i+ = x i y i y ' i+ = x i + y i 2A Background
Pseudo-rotation 2 x i+, y i+ x ' i+, y ' i+ x i, y i x ' i+, y ' i+ x i, y i R R x ' i+ y ' i+ = x i+ / cos θ i = y i+ / cosθ i x ' i+ > x i+ y ' i+ > y i+ cosθ > 2A Background 2
CORDIC Iteration Equations α 0 α i α i+ α n 0 x 0 y 0 x i y i x i+ y i+ x n y n x i+ = x i cosθ i y i sin θ i = cosθ i x i y i y i+ = x i sin θ i + y i cos θ i = cosθ i x i + y i = / + tan 2 θ i x i y i = / + tan 2 θ i x i + y i Pseudo-rotation x 0 y 0 x ' i i x ' i+ y ' y ' i + x ' n y ' n x ' i+ y ' i+ + y ' i = x ' i cos θ i sin θ i + tan 2 θ i = x ' i sinθ i + y ' i cos θ i + tan 2 θ i x ' n = {x 0 cos θ i y 0 sin θ i } { + tan 2 θ i } y ' n = {x 0 sin θ i + y 0 cos θ i } { + tan 2 θ i } θ n = θ θ i 2A Background 3
CORDIC Iteration Equations 2 Pseudo-rotation x 0 y 0 x ' i i x ' i+ y ' y ' i + x ' n y ' n x ' i+ y ' i+ + y ' i = x ' i cos θ i sin θ i + tan 2 θ i = x ' i sinθ i + y ' i cos θ i + tan 2 θ i x ' n = {x 0 cos θ i y 0 sin θ i } { + tan 2 θ i } y ' n = {x 0 sin θ i + y 0 cos θ i } { + tan 2 θ i } θ n = θ θ i θ i Choose such that = j j 2 0 = 2 i {+, } x ' i+ 2 i y ' i+ 2 i + y ' i θ i+ = θ i tan 2 i +2 i 2 i j 2 j 2 2 j 2 3 j 2 4 2A Background 4
CORDIC Iteration Equations 3 θ i +2 i Choose such that = 2 i = 2 i {+, } x ' i+ 2 i y ' i+ 2 i + y ' i θ i+ = θ i tan 2 i, 2 0, 2 0, 2, 2, 2 2, 2 3, 2 4, 2 2, 2 3, 2 4 = ±2 i cos θ i = + + 2 2i sinθ i = ±2 i + 2 2i +cos θ i sin θ i i +sin θ i +cos θ = + 2 2i + 2 i ±2 i + 2A Background 5
CORDIC Iteration Equations 4 Allowed angles at the step i = 0 Allowed angles at the step i =, 2 0, 2 0, 2, 2, 2 2, 2 3, 2 4, 2 2, 2 3, 2 4 2A Background 6
CORDIC Iteration Equations 5 Allowed angle at the step i = 2 Allowed angle at the step i = 3, 2 0, 2 0, 2, 2, 2 2, 2 3, 2 4, 2 2, 2 3, 2 4 2A Background 7
CORDIC Iteration Equations 6 θ i Choose such that = 2 i = 2 i {+, } +2 i x ' i+ 2 i y ' i+ 2 i + y ' i θ i+ = θ i tan 2 i +cos θ sin θ +sin θ +cosθ = = + 2 n + 2 + 2 2 n ±2 n + + 2 2 ±2 + + 2 0 + 2 0 ±2 0 + + 2 2 n + 2 2 + 2 2 0 + 2 n + 2 ±2 n + ±2 + + 2 0 ±2 0 + K = / + tan 2 θ i = 0.607 +cos θ i sin θ i +sin θ i +cos θ i +cos θ i sin θ i +sin θ i +cos θ i = K +cosθ sin θ θ +sin θ +cos / K = + tan 2 θ i =.647 = A = CORDIC Gain 2A Background 8
CORDIC Iteration Equations 7 θ i Choose such that = 2 i = 2 i {+, } +2 i x ' i+ 2 i y ' i+ 2 i + y ' i θ i+ = θ i tan 2 i +cos θ sin θ +sin θ +cosθ = + 2 2 n + 2 2 + 2 2 0 Use pre-computed value + 2 n + 2 ±2 n + ±2 + n iterations each iteration involves only adding and shifting + 2 0 ±2 0 + Similar to shift-and-add multiplication x ' i+ 2 i y ' i+ 2 i + y ' i 2A Background 9
CORDIC Iteration Equations 8 Pseudo-rotation x 0 y 0 x ' i i x ' i+ y ' y ' i + x ' n y ' n x ' i+ y ' i+ + y ' i = x ' i cos θ i sin θ i + tan 2 θ i = x ' i sinθ i + y ' i cos θ i + tan 2 θ i x ' n = {x 0 cos θ i y 0 sin θ i } { + tan 2 θ i } y ' n = {x 0 sin θ i + y 0 cos θ i } { + tan 2 θ i } θ n = θ θ i θ i Choose such that tan α i = θ i 2 i {+, } x ' i+ 2 i y ' i+ 2 i + y ' i θ i+ = θ i tan 2 i x ' n = / K x 0 cos θ y 0 sin θ y ' n = / K x 0 sin θ + y 0 cosθ θ n = θ tan 2 i K = { / + tan 2 α i } 2A Background 20
CORDIC Iteration Equations 9 Pseudo-rotation x 0 y 0 x ' i i x ' i+ y ' y ' i + x ' n y ' n θ i Choose such that = 2 i {+, } x ' i+ 2 i y ' i+ 2 i + y ' i θ i+ = θ i tan 2 i x ' n = / K x 0 cos θ y 0 sin θ y ' n = / K x 0 sin θ + y 0 cosθ θ n = θ tan 2 i pre-compute K = { / + tan 2 θ i } = 0.607 set x 0 = K = 0.607 y 0 = 0 then x ' n = / K K cos θ 0 sin θ = cos θ y ' n = / K K sin θ + 0 cos θ = sin θ 2A Background 2
Example: cos75, sin75 - Step 0 i = 0 x 0 y 0 = 0.607 0 θ 0 = 75 θ i > 0 =+ =? : θ 0 = 75 > 0 σ 0 = + 2 i =2 0 = tan 2 i = tan = 45 x ' i+ 2 i y ' i+ 2 i + y ' i θ i+ = θ i tan 2 i x ' = 0.607 0 + = 0.607 y ' = 0.607 + + 0 = 0.607 θ = θ 0 45 = 30 2A Background 22
Example: cos75, sin75 - Step i = x ' y ' = 0.607 θ = 30 θ i > 0 =+ =? : θ = 30 > 0 σ = + 2 i =2 = 0.5 tan 2 i = tan 0.5 = 26.565 x ' i+ 2 i y ' i+ 2 i + y ' i θ i+ = θ i tan 2 i x ' 2 = 0.607 0.607 + 0.5 = 0.3035 y ' 2 = 0.607 + 0.5 + 0.607 = 0.905 θ 2 = θ 26.565 = 3.435 2A Background 23
Example: cos75, sin75 - Step 2 i = 2 x ' 2 2 y ' = 0.3035 0.905 θ 2 = 3.435 θ i > 0 =+ =? : θ 2 = 3.435 > 0 σ 2 = + 2 i =2 2 = 0.25 tan 2 2 = tan 0.25 = 4.036 x ' i+ 2 i y ' i+ 2 i + y ' i θ i+ = θ i tan 2 i x ' 3 = 0.3035 0.905 + 0.25 = 0.0759 y ' 3 = 0.3035 + 0.25 + 0.905 = 0.9864 θ 3 = θ 2 4.036 = 0.60 2A Background 24
Example: cos75, sin75 - Step 3 i = 3 x ' 3 3 y ' = 0.0759 0.9864 θ 3 = 0.60 θ i > 0 =+ =? : θ 3 = 0.60 < 0 σ 3 = 2 i =2 3 = 0.25 tan 2 3 = tan 0.25 = 7.25 x ' i+ 2 i y ' i+ 2 i + y ' i θ i+ = θ i tan 2 i x ' 4 = 0.0759 0.9864 0.25 = 0.992 y ' 4 = 0.0759 0.25 + 0.9864 = 0.9373 θ 4 = θ 3 + 7.25 = 3.476 2A Background 25
Example: cos75, sin75 - Step 4 i = 4 x ' 4 4 y ' = 0.992 0.9373 θ 4 = 3.476 θ i > 0 =+ =? : θ 4 = 3.476 < 0 σ 4 = 2 i =2 4 = 0.0625 tan 2 4 = tan 0.0625 = 3.576 x ' i+ 2 i y ' i+ 2 i + y ' i θ i+ = θ i tan 2 i x ' 5 = 0.992 0.9373 0.0625 = 0.2578 y ' 5 = 0.992 0.0625 + 0.9373 = 0.9249 θ 5 = θ 4 + 3.576 = 0. 2A Background 26
References [] http://en.wikipedia.org/ [2] CORDIC FAQ, www.dspguru.com [3] R. Andraka, A survey of CORDIC algorithms for FPGA based computers [4] J. S. Walther, A Unified Algorithm for Elementary Functions [5] J. P. Deschamps, G. A. Bioul, G.D. Sutter, Synthesis of Arithmetic Circuits