vhdl and cordic algorithim

23
VHDL and Digital Circuit Design (Implementation Of CORDIC Algorithm for trigonometric functions in VHDL) Submitted at : CEERI,Pilani Submitted By :Subeer Rangra 08EBKCS059

Upload: subeer-rangra

Post on 24-May-2015

5.468 views

Category:

Education


4 download

DESCRIPTION

A basic descriptive introduction of VHDL followed by the implementation of Cordic Algorithim via VHDL.

TRANSCRIPT

Page 1: VHDL and Cordic Algorithim

Project onVHDL and Digital Circuit

Design(Implementation Of CORDIC Algorithm for trigonometric

functions in VHDL)

Submitted at : CEERI,Pilani

Submitted By :Subeer Rangra 08EBKCS059

Page 2: VHDL and Cordic Algorithim

VHDL: History VHDL: Basics VHDL: Design Units CORDIC Algorithm

• Key Idea• Rotations• Iterations• Rotation Mode• Hardware

Result Conclusion

CONTENTS

Page 3: VHDL and Cordic Algorithim

VHDL: History

Was developed in the early 1980s for managing design problems that involved large circuits and multiple teams of engineers.

Funded by U.S. Department of Defense. The first publicly available version was released in

1985. In 1986 IEEE (Institute of Electrical and Electronics

Engineers, Inc.) was presented with a proposal to standardize the VHDL.

In 1987 standardization => IEEE 1076-1987 An improved version of the language was released in

1994 => IEEE standard1076-1993.

Page 4: VHDL and Cordic Algorithim

VHDL: Basics

VHDL stands for VHSIC Hardware Description Language

Hardware description language used for modeling digital systems.

It provides designing of digital systems at various levels of abstraction.

Used to write text models that describe a logic circuit.

Page 5: VHDL and Cordic Algorithim

VHDL: Design Units

1. Entity declaration.2. Architecture.3. Configuration.4. Package declaration.5. Package body.

Page 6: VHDL and Cordic Algorithim

Entities

• A black box with interface definition.

• Defines the inputs/outputs of a component (define pins).

• A way to represent modularity in VHDL.

• Similar to symbol in schematic.

• Entity declaration describes and initializes an entity.

Inputs and Outputs

Chip

A

B

C

D

E

Page 7: VHDL and Cordic Algorithim

Architectures

• Every entity has at least one architecture.

• One entity can have several architectures.

• Architectures can be written using these following methodologies..

– Dataflow– Behavioral– Structural (component )

• Architectures can describe design on many levels

– Gate level– RTL (Register Transfer Level)– Behavioral level

ChipA

B

C

D

EX

Y

Page 8: VHDL and Cordic Algorithim

Configurations

• A configuration declaration is used to select one of the possibly many architecture bodies that an entity may have.

• Configuration specifies the design entity used in place of each component instance  (i.e. it plugs the chip into the chip socket and then the socket-chip assembly into the PCB).

• To represent structure in that architecture body of an entity-architecture pair or by a configuration, which reside in library.

Page 9: VHDL and Cordic Algorithim

Packages

Packages contain information common to many design units.1.Package declaration

– constant declarations– type and subtype declarations– function and procedure declarations– global signal declarations– file declarations– component declarations

2.Package body– is not necessary needed– function bodies– procedure bodies

Page 10: VHDL and Cordic Algorithim

CORDIC AlgorithmCOordinate Rotation DIgital

Computer

CORDIC, which stands for COordinate Rotation Digital Computer, is an algorithm developed by Volder in the fifties which allows you to calculate trigonometric functions using simple shift and add operations. This is an advantage for hardware implementations were multipliers are normally resource demanding . The algorithm can be adapted to also compute fix/floating point multiply, divide, log, exponent and square root. The module computes fix point sin and cos values from a given angle.

Page 11: VHDL and Cordic Algorithim

CORDIC AlgorithmKey Idea

• If we have a computationally efficient way of rotating a vector, we can evaluate cos & sin

• At each step, accumulate corresponding x and y increments

• After a number of iterations, x and y increments converge to desired function values

Page 12: VHDL and Cordic Algorithim

Rotations

Page 13: VHDL and Cordic Algorithim

Rotate the vector OE (i) with end point at (x (i), y (i)) by a (i)

x (i+1) = x (i) cos a (i)– y (i) sin a(i) = (x (i) – y (i) tan a (i))/(1 + tan2 a (i))1/2

y (i+1) = y (i) cos a (i) + x (i) sin a (i) = (y (i) + x (i) tan a (i))/(1 + tan2 a (i) ) 1/2

z (i+1) = z (i) + a(i)

Goal: eliminate the divisions by (1 + tan2 a(i)) 1/2 and choose a(i) so that tan a(i) is a power of 2

Take the transformation x (i+1) = x (i) cos a (i)– y (i) sin a (i) y (i+1) = y (i) cos a (i) + x (i) sin a(i)

Rearrange as x (i+1) = cos a • ( x - y tan a ) y (i+1) = cos a • ( x + y tan a )

But we can choose the rotation angles, a 1, a 2, …, a m

So choose, a m = tan-1 2-m

so that tan a m = 2-m

Thus the tan am factors are derived from simple shifts as 2-m corresponds to linear binary shift.

Page 14: VHDL and Cordic Algorithim

Whereas a real rotation does not change the length R(i) of the vector, a pseudorotation step increases its length to:

R(i+1) = R(i) (1 + tan2 a (i))1/2

The coordinates of the new end point E¢(i+1) after pseudorotation is derived by multiplying the coordinates of E(i+1) by the expansion factor

x (i+1) = x (i) – y (i) tan a (i)

y (i+1) = y (i) + x (i) tan a (i) [Pseudorotation]

z (i+1) = z (i) + a (i)

Now the ith step, calculating (xi+1, yi+1) from (xi, yi)can be written

Where

And

which is determined by the direction of the necessary correction Now the product, P Ki = P ( ( 1 + 2-2i )-1 0.6073 is a constant depending on the number of iterations

xi+1 = Ki ( xi - yi di 2-i )

yi+1 = Ki ( yi - xi di 2-i )

Ki = cos( tan-1 2-i ) =

di = 1

1

( 1 + 2-2i )

Page 15: VHDL and Cordic Algorithim

Basic CORDIC Iterations

Pick a(i) such that tan a (i) = di 2 –i, di Î {–1, 1}

x(i+1) = x(i) – di y(i)2–i

y (i+1) = y (i) + di x(i)2–I [CORDIC iteration]

z (i+1) = z (i) – di tan–1 2–i

If we always pseudo rotate by the same set of angles (with + or – signs), then the expansion factor K is a constant that can be pre-computed e (i) = tan –1

2-i

Page 16: VHDL and Cordic Algorithim

Example: pseudo rotation for 30 degrees

30.0 @ 45.0 – 26.6 + 14.0 – 7.1 + 3.6 + 1.8 – 0.9

+ 0.4 – 0.2 + 0.1 = 30.1

e (i) = tan –1 2-i

Page 17: VHDL and Cordic Algorithim

CORDIC Rotation Mode

CORDIC calculations can be made in two ways• Rotation mode • Vector mode Here we use the rotation mode

An input vector is rotated by a specified angle Angle accumulator is initialized with an angle This angle is reduced to zero

An (x,y) pairThe equations are:

and

xi+1 = xi - yi di 2-i yi+1 = yi + xi di 2-i zi+1 = zi - di tan-1( 2-i )

di = -1 if zi < 0 +1 otherwise

Page 18: VHDL and Cordic Algorithim

The results are:

Note Kn is a constant - dependent only on the number of iterations The algorithm would normally be run for a fixed number of

iterations A result with a known accuracy bound Note that the whole calculation requires shifts , add/ subtracts only

xn = Kn ( x0 cos z0 - y0 sin z0 )yn = Kn ( x0 sin z0 + y0 cos z0 ) Zn = 0Kn = p ( 1 + 2-2i )

Set x0 = 1 and y0 = 0 the indicial values of x & y And get the values ofcos(z0) and sin(z0)

Page 19: VHDL and Cordic Algorithim

CORDIC Hardware(Basic)

Page 20: VHDL and Cordic Algorithim

CORDIC HardwareSerial CORDIC Module in HDL Designer

Page 21: VHDL and Cordic Algorithim

Result

CORDIC algorithm for finding the values trigonometric function sine and cosine ,was successfully simulated .

On taking input value of z as the angle which is to be calculated , and initializing the value of K as 0.607252935008881256….for 10 iterations. x as 1 and y as 0,we get the answer for the value of cos(z) and vice versa for sin(z). 

Page 22: VHDL and Cordic Algorithim

Conclusion

CORDIC is not the fastest way to perform multiplications or to compute logarithms and exponentials but, since the same algorithm allows the computation of most mathematical functions using very simple basic operations, it is attractive for hardware implementations.

Page 23: VHDL and Cordic Algorithim

Thank You