33
Copyright © 2003 Texas Instrumen Free Ebooks Download Free Ebooks Download By: By: ebooks.edhole.com

Mba ebooks

Embed Size (px)

DESCRIPTION

lots of ebooks and awesome study material

Citation preview

Page 1: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.

Free Ebooks Download Free Ebooks Download

By:By:

ebooks.edhole.com

Page 2: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.

DSP C5000DSP C5000

Chapter 19Chapter 19

Fast Fourier TransformFast Fourier Transform

ebooks.edhole.com

Page 3: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 3

Discrete Fourier TransformDiscrete Fourier Transform Allows us to compute an approximation of Allows us to compute an approximation of

the Fourier Transform on a discrete set of the Fourier Transform on a discrete set of frequencies from a discrete set of time frequencies from a discrete set of time samples.samples.

Where Where k k are the index of the discrete are the index of the discrete frequencies and frequencies and n n the index of the time samplesthe index of the time samples

dtetxfX ftj 2)()(

dtetxfX ftj 2)()(

1 ,,1 ,0for 21

0

NkenxkX

nN

kjN

n

1 ,,1 ,0for 21

0

NkenxkX

nN

kjN

n

ebooks.edhole.com

Page 4: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 4

Inverse Discrete Fourier TransformInverse Discrete Fourier Transform

The inverse formulaThe inverse formula is: is:

Where, again, Where, again, k k are the index of the discrete are the index of the discrete frequencies and frequencies and n n the index of the time the index of the time samples.samples.

We have the following properties:We have the following properties: Discrete time periodic spectraDiscrete time periodic spectra Periodic time discrete spectraPeriodic time discrete spectra

1 ,,1 ,0for 1 21

0

NnekXN

nxn

N

kjN

k

1 ,,1 ,0for 1 21

0

NnekXN

nxn

N

kjN

k

ebooks.edhole.com

Page 5: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 5

DFT ComputationDFT Computation We can write the DFT:We can write the DFT:

We need:We need: N(N-1) N(N-1) complex ‘complex ‘+’ +’ NN22 complex ‘complex ‘×’×’

NjN

n

eNknxkX2

Nkn-

N

1

0

Wwith 1 ,,1 ,0for W

NjN

n

eNknxkX2

Nkn-

N

1

0

Wwith 1 ,,1 ,0for W

N + x

128 16256 163841024 1047552 10485764096 16773120 16777216

ebooks.edhole.com

Page 6: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 6

Fast Fourier Transform 1 of 3Fast Fourier Transform 1 of 3 Cooley-Tukey algorithm:Cooley-Tukey algorithm:

Based on decimation, leads to a factorization of Based on decimation, leads to a factorization of computations.computations.

Let us first look at the classical radix 2 Let us first look at the classical radix 2 decimation in time.decimation in time.

This particular case of the algorithm requires This particular case of the algorithm requires the time sequence length to be a power of 2.the time sequence length to be a power of 2.

First we split the computation between odd and First we split the computation between odd and even samples:even samples:

12nk-N

12/

0

k2n-N

12/

0

W12 W2

N

n

N

n

nxnxkX 12nk-N

12/

0

k2n-N

12/

0

W12 W2

N

n

N

n

nxnxkX

ebooks.edhole.com

Page 7: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 7

Fast Fourier Transform 2 of 3Fast Fourier Transform 2 of 3 Using the following property:Using the following property:

The DFT can be rewritten:The DFT can be rewritten:

For For kk=0, 1, …, =0, 1, …, N-1N-1

kn-

2

N

12/

0

k-N

kn-

2

N

12/

0

W12W W2

N

n

N

n

nxnxkX kn-

2

N

12/

0

k-N

kn-

2

N

12/

0

W12W W2

N

n

N

n

nxnxkX

2

N2N WW

2

N2N WW

ebooks.edhole.com

Page 8: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 8

Fast Fourier Transform 3 of 3Fast Fourier Transform 3 of 3 Using the property that:Using the property that:

The entire DFT can be computed with only The entire DFT can be computed with only kk=0, 1, …,=0, 1, …,N/N/2-1.2-1.

andand

kN

2

Nk

N WW

kN

2

Nk

N WW

kn-

2

N

12/

0

k-N

kn-

2

N

12/

0

W12W W2

N

n

N

n

nxnxkX kn-

2

N

12/

0

k-N

kn-

2

N

12/

0

W12W W2

N

n

N

n

nxnxkX

kn-

2

N

12/

0

k-N

kn-

2

N

12/

0

W12W W22

N

n

N

n

nxnxN

kX kn-

2

N

12/

0

k-N

kn-

2

N

12/

0

W12W W22

N

n

N

n

nxnxN

kX

ebooks.edhole.com

Page 9: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 9

ButterflyButterfly This leads to basic building block of the This leads to basic building block of the

FFT,FFT, the the butterflybutterfly..

TFD N/2TFD N/2

TFD N/2TFD N/2

x(0)x(0)x(2)x(2)

x(N-2)x(N-2)

x(1)x(1)x(3)x(3)

x(N-1)x(N-1)

X(0)X(0)X(1)X(1)

X(N/2-1)X(N/2-1)

X(N/2)X(N/2)X(N/2+1)X(N/2+1)

X(N-1)X(N-1)

WW00

WW11

WWN/2-1N/2-1

----

--

We need:We need:

•N/2(N/2-1) N/2(N/2-1) complex ‘complex ‘+’ for +’ for each each N/2 N/2 DFT.DFT.

•((N/2N/2))2 2 complex ‘complex ‘×’ for each ×’ for each DFT.DFT.

•N/2 N/2 complex ‘complex ‘×’ at the input of ×’ at the input of the butterflies.the butterflies.

•N N complex ‘complex ‘+’ for the butter-+’ for the butter-flies.flies.

•Grand total:Grand total:

NN22/2 /2 complex ‘complex ‘+’+’

N/2(N/2+1) N/2(N/2+1) complex ‘complex ‘×’×’

ebooks.edhole.com

Page 10: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 10

RecursionRecursion If If N/2 N/2 is even, we can further split the computation of is even, we can further split the computation of

each DFT of size each DFT of size N/2N/2 into two computations of half size into two computations of half size DFT. When DFT. When N=2N=2rr this can be done until DFT of size 2 (i.e. this can be done until DFT of size 2 (i.e. butterfly with two elements).butterfly with two elements).

x(0)x(0)

x(4)x(4)

x(2)x(2)

x(6)x(6)

x(1)x(1)

x(5)x(5)

x(3)x(3)

x(7)x(7)

X(0)X(0)

X(1)X(1)

X(2)X(2)

X(3)X(3)

X(4)X(4)

X(5)X(5)

X(6)X(6)

X(7)X(7)

WW8800

WW8811

WW8822

WW8833

--

--

--

----

--

--

--

--

--

--

--

WW8800

WW8800

WW8811

WW8811

WW8800

WW8800

WW8800

WW8800

WW8800=1=1

11stst stage stage22ndnd stage stage33rdrd stage stage

ebooks.edhole.com

Page 11: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 11

Number of OperationsNumber of Operations

If If NN==22rr, , we have we have r=r=loglog22((NN) stages. For each ) stages. For each one we have:one we have: N/2N/2 complex ‘ complex ‘×’ (some of them are by ‘1’).×’ (some of them are by ‘1’). NN complex ‘+’. complex ‘+’.

Thus the grand total of operations is:Thus the grand total of operations is: N/2N/2 log log22((NN)) complex ‘ complex ‘×’.×’. NN log log22((NN)) complex ‘ complex ‘+’.+’.

N + x

128 896 4481024 10240 51204096 49152 24576

These counts can be compared with the ones for the DFTThese counts can be compared with the ones for the DFT

ebooks.edhole.com

Page 12: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 12

Shuffling the Data, Bit Reverse OrderingShuffling the Data, Bit Reverse Ordering At each step of the algorithm, data are split At each step of the algorithm, data are split

between even and odd values. This results in between even and odd values. This results in scrambling the order.scrambling the order.

x(0)

x(1)

x(2)

x(3)

x(4)

x(5)

x(6)

x(7)

x(0)

x(2)

x(4)

x(6)

x(1)

x(3)

x(5)

x(7)

x(0)

x(4)

x(2)

x(6)

x(1)

x(5)

x(3)

x(7)

Recursion of the algorithmRecursion of the algorithm

index address

000 000

100 001

010 010

110 011

001 100

101 101

011 110

111 111

ebooks.edhole.com

Page 13: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 13

Reverse Carry PropagationReverse Carry Propagation This scrambling when we use radix 2 FFT can This scrambling when we use radix 2 FFT can

be obtained by the Reverse Carry Propagation be obtained by the Reverse Carry Propagation (RCP) algorithm.(RCP) algorithm.

We start with address We start with address 00 then we add then we add N/2 N/2 to to obtain the next address. If there is a carry, it obtain the next address. If there is a carry, it propagates towards the least significant bit.propagates towards the least significant bit.

When the data arrive in natural order, they are When the data arrive in natural order, they are scrambled in this way.scrambled in this way.

n Address[x(n+1)] Address[x(n)]

000 RCP(000+100)=100 000

001 RCP(100+100)=010 100

010 RCP(010+100)=110 010

011 RCP(110+100)=001 110

100 RCP(001+100)=101 001

101 RCP(101+100)=011 101

110 RCP(011+100)=111 011

111 111

ebooks.edhole.com

Page 14: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 14

Algorithm Parameters 1 of 2Algorithm Parameters 1 of 2

The FFT can be computed according to the The FFT can be computed according to the following pseudo-code:following pseudo-code: For each For each stagestage

For each For each group of butterflygroup of butterfly For each For each butterflybutterfly

compute butterflycompute butterfly endend

endend endend

ebooks.edhole.com

Page 15: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 15

Algorithm Parameters 2/2Algorithm Parameters 2/2

The parameters are shown below:The parameters are shown below:

1st stage 2nd stage 3rd stage … Last stage

Node Spacing

1 2 3 … N/2

Butterflies per group

1 2 3 … N/2

Number of groups

N/2 N/4 N/8 … 1

Twiddle factor

… / 2

0

N kNW

k

/ 4

0,1

N kNW

k

/8

0, ,3

N kNW

k

0, , / 2 1

kNW

k N

ebooks.edhole.com

Page 16: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 16

ScalingScaling The DFT computation for each The DFT computation for each k k is :is :

To prevent overflow we need to have:To prevent overflow we need to have:

This is guaranteed provided a scale factor This is guaranteed provided a scale factor 1/N1/N

kn-N

1

0

W

N

n

nxkX kn-N

1

0

W

N

n

nxkX

1 kX 1 kX

1 W1

kn-N

1

0

N

n

nxN

kX 1 W1

kn-N

1

0

N

n

nxN

kX

ebooks.edhole.com

Page 17: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 17

Quantization NoiseQuantization Noise Quantization step is :Quantization step is :

If words have If words have b+1b+1 bits and bits and x(n)x(n) belongs to belongs to [-1,1] [-1,1]

If we assume that each real multiplication If we assume that each real multiplication gives rise to a noise source of power gives rise to a noise source of power

The total amount of noise power for each The total amount of noise power for each X(k) X(k) is given byis given by

b 2 b 2

2e

NrN

rb

et 2

2/222 log with

3

24

NrNrb

et 2

2/222 log with

3

24

ebooks.edhole.com

Page 18: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 18

Signal to Quantization Noise Ratio (SQNR)Signal to Quantization Noise Ratio (SQNR)DFT caseDFT case

If we assume If we assume x(n)x(n) uniform in [-1,1], after uniform in [-1,1], after scaling, variance of data become:scaling, variance of data become:

And because each And because each X(k)X(k) comes from comes from N N summations:summations:

SQNR for DFT with scaling is given by:SQNR for DFT with scaling is given by:

22

3

1

Nx 2

2

3

1

Nx

NX 3

12 NX 3

12

rbdBSQNRt

X 66log10)( 2

2

rbdBSQNRt

X 66log10)( 2

2

N SQNR(dB) ENOB

128 48 81024 30 54096 18 3

ENOBENOB: effective number of bits, gives the effective resolution given a SNR. Based on the : effective number of bits, gives the effective resolution given a SNR. Based on the assumption that 6dB of assumption that 6dB of SNR SNR equates to 1 bit of precision.equates to 1 bit of precision.

16 bits per word16 bits per word

ebooks.edhole.com

Page 19: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 19

Signal to Quantization Noise Ratio (SQNR)Signal to Quantization Noise Ratio (SQNR)FFT case 1 of 3FFT case 1 of 3

The computation of one The computation of one XX((kk) requires ) requires N-1 N-1 butterflies:butterflies:

x(0)x(0)

x(4)x(4)

x(2)x(2)

x(6)x(6)

x(1)x(1)

x(5)x(5)

x(3)x(3)

x(7)x(7)

X(0)X(0)

X(1)X(1)

X(2)X(2)

X(3)X(3)

X(4)X(4)

X(5)X(5)

X(6)X(6)

X(7)X(7)

WW8800

WW8811

WW8822

WW8833

--

--

----

--

--

--

--

--

WW8800

WW8800

WW8811

WW8811

WW8800

WW8800

WW8800

WW8800

N/2 butterflies N/2 butterflies of the 1of the 1stst stage stage

N/4 butterflies N/4 butterflies of the 2of the 2ndnd stage stage

1 butterfly of 1 butterfly of the last stage the last stage

ebooks.edhole.comebooks.edhole.com

Page 20: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 20

Signal to Quantization Noise Ratio (SQNR)Signal to Quantization Noise Ratio (SQNR)FFT case 2 of 3FFT case 2 of 3

Butterfly computationButterfly computation

To prevent overflow, we only need to scale the To prevent overflow, we only need to scale the inputs of each butterfly by inputs of each butterfly by 1/21/2

XXnn(l)(l)

--WW

XXnn(k)(k)

XXn+1n+1(l)(l)

XXn+1n+1(k)(k)

kXWlXkX

kXWlXlX

nnn

nnn

1

1

kXWlXkX

kXWlXlX

nnn

nnn

1

1

XXnn(l)(l)

--WW

XXnn(k)(k)

XXn+1n+1(l)(l)

XXn+1n+1(k)(k)

1/21/2

1/21/2

• Because we have Because we have rr stages, the global stages, the global scaling factor for one output is:scaling factor for one output is:

N

r1

2

1

N

r1

2

1

ebooks.edhole.comebooks.edhole.com

Page 21: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 21

Signal to Quantization Noise Ratio (SQNR)Signal to Quantization Noise Ratio (SQNR)FFT case 3 of 3FFT case 3 of 3

Quantization noise source at one stage is attenuated by Quantization noise source at one stage is attenuated by scale factors of all the following stages.scale factors of all the following stages.

This gives an equivalent noise source of:This gives an equivalent noise source of:

for each output.for each output. SQNR for FFT with scaling is given by: SQNR for FFT with scaling is given by:

3

22

2

112

3

2 222

brb

t

3

22

2

112

3

2 222

brb

t

336log10)( 2

2

rbdBSQNR

t

X

336log10)( 2

2

rbdBSQNR

t

X

N SQNR(dB) ENOB

128 66 111024 57 9,54096 51 8,5

16 bits per word16 bits per word

ebooks.edhole.comebooks.edhole.com

Page 22: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 22

FFT Algorithm with Block Floating Point FFT Algorithm with Block Floating Point ScalingScaling

Input data in bit reverse orderInput data in bit reverse order

Set-up for next stageSet-up for next stage

Set-up for next groupSet-up for next group

Set-up for next butterflySet-up for next butterfly

Scale inputs of butterfly (Scale inputs of butterfly (×1/2)×1/2)

More butterflies ?More butterflies ?

More groups ?More groups ?

More stages ?More stages ?

End of algorithmEnd of algorithm

Compute butterflyCompute butterfly

ebooks.edhole.comebooks.edhole.com

Page 23: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 23

Case Study ‘C54xCase Study ‘C54x Use of audioFFTUse of audioFFT**

((**) this program is the same as \ti\examples\dsk5416\bios\audio except for some slight ) this program is the same as \ti\examples\dsk5416\bios\audio except for some slight modifications that will be emphazised when necessarymodifications that will be emphazised when necessary

Block Block

processingprocessing

PCM3002 PCM3002 ADC ADC

PCM3002 PCM3002 DAC DAC

pipRxpipRx

pipTxpipTx

inBufferinBuffer

outBufferoutBuffer

ebooks.edhole.comebooks.edhole.com

Page 24: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 24

Audio ProgramAudio Program Block processing is Block processing is echoecho() function in () function in

audio.c : audio.c : In the original program: Data from input In the original program: Data from input

stream are copied directly in output stream.stream are copied directly in output stream. In the modified program :In the modified program :

The input stream is split between left and right in The input stream is split between left and right in two separate buffers.two separate buffers.

Each buffer is processedEach buffer is processed Bit-reverse scramblingBit-reverse scrambling Forward transformForward transform Bit reverse scramblingBit reverse scrambling Inverse transformInverse transform

Resulting left and right buffers are interleaved in the Resulting left and right buffers are interleaved in the output stream.output stream.

ebooks.edhole.comebooks.edhole.com

Page 25: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 25

DSPLIB functionsDSPLIB functions The DSP Library (DSPLIB) is a collection of The DSP Library (DSPLIB) is a collection of

high-level optimized DSP function modules for high-level optimized DSP function modules for the ‘C54x and ‘C55x DSP platform.the ‘C54x and ‘C55x DSP platform.

‘‘C54x DSPLIB functions for FFT computationC54x DSPLIB functions for FFT computation

ebooks.edhole.comebooks.edhole.com

Page 26: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 26

Block Processing 1 of 3Block Processing 1 of 3 EchoEcho( )( )

Include and declarationsInclude and declarations

ebooks.edhole.comebooks.edhole.com

Page 27: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 27

Block Processing 2 of 3Block Processing 2 of 3 Dsplib functions callsDsplib functions calls

ebooks.edhole.comebooks.edhole.com

Page 28: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 28

‘‘C54x DSPLIB Bit ReversalC54x DSPLIB Bit Reversal

ebooks.edhole.comebooks.edhole.com

Page 29: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 29

Block Processing 3 of 3Block Processing 3 of 3 Linker .cmd fileLinker .cmd file

ebooks.edhole.comebooks.edhole.com

Page 30: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 30

‘‘C54x DSPLIB FFTC54x DSPLIB FFT

ebooks.edhole.comebooks.edhole.com

Page 31: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 31

To Run the Build ProcessTo Run the Build Process Project optionsProject options

ebooks.edhole.comebooks.edhole.com

Page 32: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 32

To Change the Size of the Processing BufferTo Change the Size of the Processing Buffer

• Change buffer length declaration in Change buffer length declaration in echoecho function (audio.c) function (audio.c)

• Change the call to Change the call to cfft cfft and and cifftcifft according to the size of the FFT (must be hard coded) according to the size of the FFT (must be hard coded)

• Change buffer alignment in linker .cmd fileChange buffer alignment in linker .cmd file

ebooks.edhole.comebooks.edhole.com

Page 33: Mba ebooks

Copyright © 2003 Texas Instruments. All rights reserved.ESIEE, Slide 33

Follow on Activities for TMS320C5416 DSKFollow on Activities for TMS320C5416 DSK

Application 8 for the the TMS320C5416 DSK Application 8 for the the TMS320C5416 DSK uses the FFT as a spectrum analyzer to uses the FFT as a spectrum analyzer to display the power in an audio signal at display the power in an audio signal at various frequencies.various frequencies.

Rather than using the optimized library Rather than using the optimized library DSPLIB for the FFT, it uses a C code version DSPLIB for the FFT, it uses a C code version that is slower, but can be stepped through line that is slower, but can be stepped through line by line using Code Composer Studio.by line using Code Composer Studio.

ebooks.edhole.comebooks.edhole.com