22
7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 1/22

Unit_7_Implementation_of_FFT_Algorithms.pdf

Embed Size (px)

Citation preview

Page 1: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 1/22

Page 2: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 2/22

Page 3: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 3/22

Page 4: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 4/22

 

Separating the real and imaginary parts, the four equations to be realized in

implementation of DITFFT Butterfly structure are as in eq(6.6).

Observe that with N=2^M, the number of stages in signal flow graph=M, number of 

multiplications = (N/2)log2(N) and number of additions = (N/2)log2(N). Number of 

Butterfly Structures per stage = N/2. They are identical and hence in-place computation is

possible. Also reusability of hardware designed for implementing Butterfly structure is

possible.

However in case FFT is to be computed for a input sequence of length other than

2^M the sequence is extended to N=2^M by appending additional zeros. The process will

not alter the information content of the signal. It improves frequency resolution. To make

the point clear, consider a sequence whose spectrum is shown in fig. 6.5.

(6.5) 

(6.4) 

) j W )(W  j B – (B j AA B j B

) j W )(W  j B(B j A A A j A

 I 

 R I  R I  R I  R

 I 

 R I  R I  R I  R

+++=′+′

++++=′+′

(6.6) 

=′

+=′

++=′

+=′

 I  R

 R I  I  I 

 I  I 

 R R R R

 I  R

 R I  I  I 

 I  I 

 R R R R

W – BW – BA B

 W  BW  – B A B

W  B W  B  A A

 W  – BW  B A A

ffrreeqquueennccyy 

MMaaggnniittuuddee XX(( )) ω 

Fig 6.5: Spectrum of x(n)

w.jntuworld.com

www.jntuworld.com

www.jwwww.android.jntuworld.com

Page 5: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 5/22

Page 6: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 6/22

 

Solution: Minimum size FFT for a 40 point sequence is 64 point FFT. Sequence is extended to 64

by appending additional 24 zeros. The process improves frequency resolution from

Problem P6.2: Derive equations to implement a Butterfly encountered in a DIFFFT

implementation.

Solution: Butterfly structure for DIFFFT:

The input / output relations are

Separating the real and imaginary parts,

Problem P6.3: How many add/subtract and multiply operations are needed to implement a

general butterfly of DITFFT?

Solution: Referring to 4 equations required in implementing DITFFT Butterfly structure,

AAdddd /  / ssuubbttrraacctt ooppeerraattiioonnss 0066 aanndd MMuullttiippllyy ooppeerraattiioonnss 0044 

Problem P6.4: How many add/subtract and multiply operations are needed to implement a

general butterfly of DI FFFT?

Solution: Refer to solution of problem P6.2. Add/subtract operations:06 and multiply

operations :04. It is same as in DITFFT algorithm.

(P6.1) 64 / 2 to40 / 2 π δω π δ   ==

P6.2.1 )())(

 

 I 

 R I  R I  R I  R

 I  R I  R I  R

j W W  j B – (B j A A  B j B

 j B B j A A A j A

+++=′+′

+++=′+′

-1

AR +j AI

BR +j BI

A’R +j A’I

B’R +j B’I

W rN

 B A A  R R R & +=′∴  I  I  I  B  A A +=′

 W – B AW  – B A B r 

 I  I  I 

 R R R R )()( −=′

 R I  I 

 I  R R I  W – B AW  – B A  B )()( +=′

 

P6.2.2

w.jntuworld.com

www.jntuworld.com

www.jwwww.android.jntuworld.com

Page 7: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 7/22

Page 8: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 8/22

Page 9: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 9/22

Page 10: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 10/22

Page 11: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 11/22

Page 12: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 12/22

 

xn0 .word 0 ; 0h 0.0

xn1 . word 16384 ; 4000h 0.5xn2 .word 23170 ; 5A82h 0.707

xn3 . word - 24576 ; E000h -0.25

xn4 .word 12345 ; 3039h 0.3767

xn5 .word 30000 ; 7530h 0.9155xn6 .word 10940 ; 2ABCh 0.334

xn7 .word 12345 ; 3039h 0.3767

; Reserve 16 locations for X(k)

X0R .word 0 ;real part of X(0) =0

X0Im .word 0 ;imaginary part of X(0) =0X1R .word 0

X1Im .word 0

X2R .word 0X2Im .word 0

X3R .word 0X3Im .word 0X4R .word 0

X4Im .word 0

X5R . word 0

X5Im .word 0X6R .word 0

X6Im .word 0

X7R .word 0X7Im .word 0

; 8 locations for W08 to W38, twiddle factorsW08R .word 32767 ;cos(0)=1

W08Im .word 0 ;-sin(0)=0

W18R .word 23170 ;cos(pi/4)= 0.707W18Im .word -23170 ;-sin(pi/4)= -0.707

W28R .word 0 ;cos(pi/2)= 0

W28Im .word -32767 ;-sin(pi/2)= -1

W38R .word -23170 ;cos(3pi/4)= -0.707W38Im .word -23170 ;-sin(3pi/4)= -0.707

; 8 locations for SpectrumS0 .word 0 ;Frequency content at 0

S1 .word 0 ;Frequency content at fs/8

S2 .word 0 ;Frequency content at 2fs/8S3 .word 0 ;Frequency content at 3fs/8

S4 .word 0 ;Frequency content at 4fs/ 

S5 .word 0 ;Frequency content at 5fs/8

S6 .word 0 ;Frequency content at 6fs/8S7 .word 0 ;Frequency content at 7fs/8

w.jntuworld.com

www.jntuworld.com

www.jwwww.android.jntuworld.com

Page 13: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 13/22

Page 14: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 14/22

 

Butterfly subroutine is invoked 12 times. Part of the subroutine is shown in fig. 6.13.

Real part and imaginary of A and B input data of butterfly structure is divided by 4 which

is the scaling factor. Real part of A data which is divided by 2 is stored in temp location.

It is used further in computation of eq (3) and eq (4) of butterfly. Division is carried out

by shifting the data to the right by two places. AR5 points to real part of A input data,

AR2 points to real part of B input data and AR3 points to real part of twiddle factor while

invoking the butterfly subroutine. After all the four equations are computed, the pointers

are in the same position as they were when the subroutine is invoked. Thus, the results

are stored such that in-place computation is achieved. Fig. 6.14 through 6.17 show the

butterfly subroutine for the computation of 4 equations.

 _  _ bbiittrreevv:: SSTTMM ##xx00,,AARR11 SSTTMM ##XX00RR,,AARR22 

SSTTMM ##88,, AARR00 SSTTMM ##77,, AARR33 

lloooopp:: LLDD **AARR11++,,AA SSTTLL AA,, **AARR22++00BB BBAANNZZ lloooopp,, 

**AARR33-- RREETT nnoo  

RReettuurrnn

eess 

AARR11 ppooiinnttss ttoo xxnn00 AARR22 ppooiinnttss ttoo XX00RR IInnddeexx==88,, ccoouunntt==77 

AR3=0nnoo 

= -

CCooppyy xx((nn)) ttoo llooccaattiioonn ooff XX((kk)) iinn aa bbiitt rreevveerrsseedd 

Fig. 6.12: Bit Reverse Subroutine

w.jntuworld.com

www.jntuworld.com

www.jwwww.android.jntuworld.com

Page 15: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 15/22

Page 16: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 16/22

 

((22)) AAII == AAII ++ BBII xx WWRR ++ BBRR xx WWII 

LLDD ##00,, AA MMPPYY **AARR22++,,**AARR33--,, AA MMAACC **AARR22--,,**AARR33,, AA AADDDD **AARR55,,1155,, AA AADDDD ##11,,1144,, AA SSTTHH AA,, 11,, **AARR55-- 

AARR22 AARR33 AARR55 

AA== BBRR xx WWII 

AA== BBII xx WWRR ++ BBRR xx WWII 

MMaakkee AAII 3322 bbiittss aanndd AA== AAII ++ BBII xx WWRR ++ BBRR xx WWII 

RRoouunndd && SSttoorree 

Fig. 6.15: Imaginary part of A output of Butterfly

Load A with AR scaled by 2

Store lower 16 bits as BR

From this, subtract new AR

;;((33)) BBRR== AARR –  – ((BBRR xx WWRR -- BBII xx WWII)) 

LLDD **AARR44++,,AA 

SSUUBB **AARR55++,,AA 

SSTTLL AA,, **AARR22++ 

Fig. 6.16: Real part of B output of Butterfly

;;((44)) BBII== AAII  –  – ((BBII xx WWRR ++BBRR xx WWII)) 

LLDD **AARR44 --,, AA SSUUBB **AARR55--,, AA SSTTLL AA,, **AARR22-- 

RREETT 

nnoopp nnoopp 

Fig. 6.17: Imaginary part of B output of Butterfly

w.jntuworld.com

www.jntuworld.com

www.jwwww.android.jntuworld.com

Page 17: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 17/22

 

Figure 6.18 depicts the part of the main program that invokes butterfly subroutine by

supplying appropriate inputs, A and B to the subroutine. The associated butterfly

structure is also shown for quick reference. Figures 6.19 and 6.20 depict the main

program for the computation of 2nd

and 3rd

stage of butterfly.

STM #X0R,AR1STM #X1R,AR2STM #W08R,AR3CALL _butterfly

STM #X2R,AR1STM #X3R,AR2

STM #W08R,AR3CALL _butterfly

XX00RR xxnn00 

xxnn44 

00..2255  XX11RR 

1

XX22RR xxnn22 

xxnn66 

00..

2255 XX33RR 

2

Fig. 6.18: First stage of Signal Flow graph of DITFFT

XX44RR xxnn11 

xxnn55 

11 /  / 44 

XX55RR 

3

XX66RR xxnn33 

xxnn77 

11 /  / 44 

XX77RR 

4

STM #X4R,AR1STM #X5R,AR2STM #W08R,AR3CALL _butterfly

STM #X6R,AR1STM #X7R,AR2STM #W08R,AR3CALL _butterfly

w.jntuworld.com

www.jntuworld.com

www.jwwww.android.jntuworld.com

Page 18: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 18/22

 

STM #X5R,AR1STM #X7R,AR2

STM #W28R,AR3

CALL _butterfly

STM #X4R,AR1

STM #X6R,AR2STM #W08R,AR3

CALL _butterfly

xx((00)) 

xx((44)) 

xx((22)) 

xx((66)) 

xx((11)) 

xx((55)) 

xx((33)) 

xx((77)) 

11

 /  / 

44 

11

 /  / 

44 

11

 /  / 

44 

11

 /  / 

44 

XX00 

XX11 

XX22 

XX33 

XX44 

XX55 

XX66 

XX77 

11 /  / 44  XX44 

XX66 

WW2

XX55 

XX77 

xx 00  

xx 44  

xx 22  

xx 66  

xx 11  

xx 55  

xx 33  

xx 77  

11 /  / 

44 

11 /  / 

44 

11 /  / 

44 

11 /  / 

44 

XX00 

XX11 

XX22 

XX33 

XX44 

XX55 

XX66 

XX77 

WW22 

XX11 

XX33 

STM #X0R,AR1STM #X2R,AR2

STM #W08R,AR3

CALL _butterfly

STM #X1R,AR1

STM #X3R,AR2

STM #W28R,AR3

CALL _butterfly

11 /  / 44  XX00 

XX22 

Fig. 6.19: Second stage of Signal Flow graph of DITFFT

w.jntuworld.com

www.jntuworld.com

www.jwwww.android.jntuworld.com

Page 19: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 19/22

 

STM #X0R,AR1STM #X4R,AR2

STM #W08R,AR3

CALL _butterfly

11 /  / 44 

WW22 

11 /  / 44 

WW 

XX00 

XX11 

XX22 

XX33 

XX44 

XX55 

XX66 

XX77 

X(5)WW11 

X(1)

11 /  / 44 X(0)

X(4)

STM #X1R,AR1

STM #X5R,AR2

STM #W18R,AR3

CALL _butterfly

STM #X2R,AR1

STM #X6R,AR2STM #W28R,AR3

CALL _butterfly

STM #X3R,AR1STM #X7R,AR2

STM #W38R,AR3

CALL _butterfly

11 /  / 44 

WW22 

11 /  / 44 

WW 

XX00 

XX11 

XX22 

XX33 

XX44 

XX55 

XX66 

XX77 

WW22 

X(2)

X(6)

WW3

X(3)

X(7)

Fig. 6.20: Third stage of Signal Flow graph of DITFFT

w.jntuworld.com

www.jntuworld.com

www.jwwww.android.jntuworld.com

Page 20: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 20/22

Page 21: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 21/22

Page 22: Unit_7_Implementation_of_FFT_Algorithms.pdf

7/27/2019 Unit_7_Implementation_of_FFT_Algorithms.pdf

http://slidepdf.com/reader/full/unit7implementationoffftalgorithmspdf 22/22

 

Observation: difference in address to A input or B input =not constant. TThhee difference

in address to A input or B input of the alternative butterfly=8.

Pseudo algorithm:

Stage 2:

•  AR1=address of X0R•  AR2=address of X2R

•  AR3= address of W0R

•  Repeat 2 times

Compute 4 butterfly equationsAR1=AR1+8

AR2=AR2+8

•  End repeat

•  AR1=address of X1R•  AR2=address of X3R•  AR3= address of W2R

•  Repeat 2 times

Compute 4 butterfly equations

AR1=AR1+8AR2=AR2+8

•  End repeat

Stage 3 A B

First butterfly inputs: X0R X4R

2nd butterfly inputs: X1R X5R3rd butterfly inputs: X2R X6R

4th butterfly inputs: X3R X7R

Observation: difference in address to A input or B input =2

•  Pseudo algorithm:

•  Stage 3:•  AR1=address of X0R

•  AR2=address of X4R

•  AR3= address of W0R•  repeat 4 times

Compute 4 butterfly equations

AR1=AR1+2AR2=AR2+2

AR3=AR3+2

End repeat

w.jntuworld.com www.jwwww.android.jntuworld.com