CORDIC Background (4A
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 4A Background 3
Vector Rotation ( y = x 0 sin α + y 0 cos α (x, y (x 0, y 0 y y 0 (x, y (x 0, y 0 R R x x 0 x = x 0 cos α y 0 sin α 4A Background 4
Vector Rotation (2 (x, y (x 0, y 0 y 0 y 0 x 0 x 0 4A Background 5
Vector Rotation (3 (x, y (x 0, y 0 x 0 sin α (x, y (x 0, y 0 y 0 cosα y 0 sin α x 0 cos α x = x 0 cos α y 0 sin α y = x 0 sin α + y 0 cos α 4A Background 6
Iterative Rotation 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 4A 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 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 4A Background 8
cos θ θ 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 4A Background 9
Pseudo-rotation factor of /cos θ θ (r cos θ, r sin θ r r sin θ r cos θ ( r cosθ cosθ, r sin θ cosθ θ r r cos θ θ r sin θ s r t r : r cos θ = s : r r cos θ : r sin θ = r : t s = r cosθ s = r sin θ cosθ 4A 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 y i+ = cos α i (x i + y i x ' i+ = ( x i y i y ' i+ = (x i + y i 4A 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+ 4A 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 4A 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 4A 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 +sin α i +cosα i = + 2 2i ( + 2 i ±2 i + 4A 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 4A 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 4A Background 7
CORDIC Iteration Equations (6 α 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 ( +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 = 0.607 ( +cos( α i sin ( α i +sin( α i +cos( α i ( +cos( α i sin ( α i +sin( α i +cos( α i ( +cosα sin α α = K +sin α +cos K = { + tan 2 α i } =.647 4A Background 8
CORDIC Iteration Equations (7 α 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 ( +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 4A 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 = 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 } 4A 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 } =.647 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 α 4A 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 4A 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 4A 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 4A 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 4A 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. 4A 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