CORDIC Algorithm: A Digital Approach to Elementary Function Evaluation, Slides of Logic

The CORDIC (COordinate Rotation Digital Computer) algorithm is a method for evaluating elementary functions such as sin(z), cos(z), and tan-1(y) using iterative rotations. the key ideas behind the CORDIC algorithm, its implementation, and its advantages over traditional methods.

Typology: Slides

2021/2022

Uploaded on 09/12/2022

jennyfer
jennyfer 🇬🇧

5

(5)

236 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CORDIC Algorithm
COordinate Rotation DIgital Computer
Example: vector rotation:
=
y
x
y
x
)cos()sin(
)sin()cos(
'
'
φφ
φφ
x
y
x'
y'
φ
Implementation cost:
2 multiplications
2 addition or subtraction
2 sin() and cos()
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download CORDIC Algorithm: A Digital Approach to Elementary Function Evaluation and more Slides Logic in PDF only on Docsity!

CORDIC Algorithm

COordinate Rotation DIgital Computer

  • Example: vector rotation:

= ^ −

y

x

y

x

sin( ) cos( )

cos( ) sin( )

φ φ

φ φ

x

y

x'

y'

φ

Implementation cost:

  • 2 multiplications
  • 2 addition or subtraction
  • 2 sin() and cos()

How do we compute sin(φ) or cos(φ)?

  • Easy, but expensive (for high accuracy): Direct table look-up:
  • Exploit symmetry of the sine function:

φ (^) sin(φ)

sin(φ)=sin(π − φ) sin(-φ)=-sin(φ) also: sin(φ)=cos(π/2 − φ) Only one quadrant needed

Direct Table Look-up (Example)

from Peter Cheung, Imperial College London

Direct Table Look-up (Example)

  • Trade-off between memory and the logic for multiplexing and complement computation
  • Sine tables are provided in several DSPs
  • Note: a BRAM on our Spartan-6 can hold 2K x 9 bit (considering the example, extra logic is not required)
  • For higher precision: two level table look-up:

sin(α + β) = sin(α) cos(β) + cos(α) sin(β) (trick: coarse table for α and fine table for β) Requires two multiplications and one addition

CORDIC Algorithm

COordinate Rotation DIgital Computer

  • Method for elementary function evaluation

(e.g., sin( z ), cos( z ), tan -1( y ))

  • The modern CORDIC algorithm was first described in

1959 by Jack E. Volder. It was developed to replace the analog resolver in the B-58 bomber's navigation computer. (from Wikipedia)

  • Used in Intel 80x87 coprocessor and Intel 80486
  • Commonly used for FPGAs
  • Complexity Comparable to Division

from Wikipedia

CORDIC Algorithm: Key Ideas

  • Rather than computing sin(φ) directly, we iteratively rotate β towards φ
  • Ideal search within first quadrant: - Step 1: set β = 45° - Step 2: if φ >= β then β = β + (45/2)° else β = β - (45/2)° - Step 3: if φ >= β then β = β + (45/4)° else β = β - (45/4)° - Continue by halving step size of β in each iteration
  • Search is stable if b[i]>b[i+1]>=b[i]/

CORDIC Algorithm:

  • What does it mean to rotate tan( β ) = ± 2 -i^ rather then rotating ± β · 2 -i^ in each iteration?
  • For smaller angles, it converges against the same:
  • Important: ± 2 -i^ is a simple shift! (can in some cases be directly implemented within the routing)
  • Rotation by an arbitrary angle is difficult, so we perform psuedorotations

from Wikipedia

i 2 -i^ arctan(2 -i )360/2π^ 45 2 -i

- 1 0.5 26.56505118 * 4.065051177 * 22. 0 1 45 * - 2 0.25 14.03624347 0.753717879 11. - 3 0.125 7.125016349 0.106894615 5. - 4 0.0625 3.576334375 0.013826201 2. - 5 0.03125 1.789910608 0.001743421 1. - 6 0.015625 0.89517371 0.000218406 0. - 7 0.0078125 0.447614171 2.73158E-05 0. - 8 0.00390625 0.2238105 3.41494E-06 0. - 9 0.001953125 0.111905677 4.26882E-07 0.
  • 10 0.000976563 0.055952892 5.33607E-08 0.
  • 11 0.000488281 0.027976453 6.6701E-09 0.
  • 12 0.000244141 0.013988227 8.33763E-10 0.
  • 13 0.00012207 0.006994114 1.0422E-10 0.
  • 14 6.10352E-05 0.003497057 1.30276E-11 0.
  • 15 3.05176E-05 0.001748528 1.62844E-12 0.
  • 16 1.52588E-05 0.000874264 2.03555E-13 0.
  • 17 7.62939E-06 0.000437132 2.54444E-14 0.
  • 18 3.8147E-06 0.000218566 3.18056E-15 0.
  • 19 1.90735E-06 0.000109283 3.97577E-16 8.58307E-
  • 20 9.53674E-07 5.46415E-05 4.96903E-17 4.29153E-
    • 4.06505=26.565-45/ CORDIC Rotation Angles

CORDIC Hardware (Bit-parallel, unrolled)

  • Implementation cost: three ADD/SUB ALUs per iteration.
  • Shift operations: hardwired
  • rotate angles ( a (^) i ) are fit into the logic
  • Typically with pipeline register after each iteration (results in very high throughput)
  • Improvement of the angle resolution by almost one signal bit iteration. http://en.wikibooks.org/wiki/Digital_Circuits/CORDIC

CORDIC Hardware (Bit-parallel, iterative)

  • Lower throughput (n times less)
  • The barrel-shifter is variable and costs logic
  • an is stored in a small register file

http://en.wikibooks.org/wiki/Digital_Circuits/CORDIC

CORDIC Algorithm: Gain

  • Cordic uses iterative rotations in steps of tan( β ) = ± 2 -i

x i+1 = cos( tan -1^ 2 -i ) ) · [ x i – y i · d i · 2 -i^ ] y i+1 = cos( tan -1^ 2 -i ) ) · [ y i + x i · d i · 2 -i^ ]

  • How we deal with cos ( tan-1 ( ± 2 -i^ ) )?
  • The cosine is symmetric: cos ( tan-1 (2 -i) ) = cos ( tan-1 ( - 2 -i) )
  • cos ( tan -1 (2 -i) ) is the gain K i of an iteration
  • We can compute K offline for all n iterations:
  • The gain approaches 0.6037, if n goes to infinity

= (^) ∏ n

K Ki

i

i K (^) i 2 1 2

1 cos(arctan( 2 − )) −

= =

CORDIC Algorithm: Gain

  • In order to compensate the gain, we have to scale the result with the reciprocal value of the gain:
  • We can compute A offline for all n iterations
  • A approaches 1.647, if n goes to infinity
  • No overhead if combined with other scaleing values

∏ = + − n

A 1 2 2 i

CORDIC Uses

OPERATION MODE INITIALIZE DIRECTION Sine, Cosine Rotation (^) x =1/ An , y =0, z = α Reduce z to Zero Polar to Rect. Rotation x =(1/ An ) Xmag , y =0, z = Xphase Reduce z to Zero General Rotation Rotation (^) x =(1/ An ) x 0 , y =(1/ An ) y 0 , z = α Reduce z to Zero Arctangent Vector x =(1/ An ) x 0 , y =(1/ An ) y 0 , z = 0 Reduce y to Zero Vector Magnitude Vector x =(1/ An ) x 0 , y =(1/ An ) y 0 , z = 0 Reduce y to Zero Rect. to Polar Vector x =(1/ An ) x 0 , y =(1/ An ) y 0 , z = 0 Reduce y to Zero Arcsine, Arccosine Vector x =(1/ An ), y =0, arg =sin α or cos α

Reduce y to Value in arg Register

  • Can Use CORDIC For Others Also:
    • Linear Functions
    • Hyperbolic Functions
    • Square Rooting
    • Logarithms, Exponentials

CORDIC – Rotation/Vector Modes

• Rotation Mode:

1 1 1 1

tan (2 )

i i i i i i i i i i i i i i

x x y d

y y x d

z z d

− −

[ ] [ ]

0 0 0 0 0 0 0 0

2 0

cos sin cos sin 0 1 2 1, 0 1, otherwise

n n n n n n n i i i i

x A x z y z y A y z x z z A

d z

= − = + = = +

= −^ < +

• Vector Mode:

1 1 1 1

tan (2 )

i i i i i i i i i i i i i i

x x y d

y y x d

z z d

− −

0 2 02

0 0 0 2 0

0 tan 1

1 2 1, 0 1, otherwise

n n n n n (^) i n i

i i

x A x y y z z y x A

d y

= +

= + −

= +

= +^ < −