CE 40763 Digital Signal Processing Fall 1992 Fast Fourier transform (FFT)

Preview:

DESCRIPTION

CE 40763 Digital Signal Processing Fall 1992 Fast Fourier transform (FFT). Hossein Sameti Department of Computer Engineering Sharif University of Technology. Motivation. - PowerPoint PPT Presentation

Citation preview

CE 40763Digital Signal Processing

Fall 1992

Fast Fourier transform (FFT)Hossein Sameti

Department of Computer Engineering Sharif University of Technology

Many real-life systems can be modeled by LTI systems use convolution for computing the output use DFT to compute convolution

Fast Fourier Transform (FFT) is a method for calculating Discrete Fourier Transform (DFT) Only faster!

Definition of DFT: How many computations?

Motivation

2

otherwise

NkenxkXN

n

Nknj

0

0)()(1

0

2

N pt. DFT of x(n)Q: For each k: How many adds and how many mults?

A: (N-1) complex adds and N complex mults.

How many k values do we have? N22 2)1(. NNNNComputNum )( 2NO

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Motivation

3

otherwise

NkenxkXN

n

Nknj

0

0)()(1

0

2

)( 2NODirect computation:

FFT: )log( 2NNO

Ideal case: .)(ConstO

N Direct FFT

10^3 O(10^6) O(10^3*log10^3)=O(10^4)

10^6 O(10^12) O(10^6*log10^6)=O(2*10^7)

Example:

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

4

Algorithms for calculating FFT

FFT

Decimation in time

Decimation in frequency

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Decimation in time

5

otherwise

NkenxkXN

n

Nknj

0

0)()(1

0

2

• The main idea: use the divide and conquer method

• It works by recursively breaking down a problem into two or more sub-problems of the same (or related) type, until these become simple enough to be solved directly.

• The solutions to the sub-problems are then combined to give a solution to the original problem.

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Decimation in time

6

otherwise

NkenxkXN

n

Nknj

0

0)()(1

0

2

1

0

21

0

2

)()()(N

n

NknjN

n

Nknj

enxenxkX

N: power of 2

n: even n: oddn: even n=2r r:0N/2-1n:0N-2

n: odd n=2r+1 r:0N/2-1n:1N-1

1

2

0

)12(212

0

)2(2

)12()2()(N

r

Nrkj

N

r

Nrkj

erxerxkX

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

7

Decimation in time

1

2

0

)12(212

0

)2(2

)()()(N

r

Nrkj

N

r

Nrkj

erhergkX

1

2

0

)12(212

0

)2(2

)12()2()(N

r

Nrkj

N

r

Nrkj

erxerxkX

12

02/

2212

02/

2

)()()(

N

rN

krjN

kjN

rN

krjerheergkX

12

0

2/2

)()(N

r

Nkrj

ergkG

12

02/

2

)()(

N

rN

krjerhkH

Suppose:

)()()(2

kHekGkX Nkj

• What are G(k) and H(k)?

8

Decimation in time

12

0

2/2

)()(N

r

Nkrj

ergkG

12

0

2/2

)()(N

r

Nkj

erhkH

)()()(2

kHekGkX Nkj

• In G(k) and H(k), k varies between 0 and N/2-1.• However, in X(k) , k varies between 0 and N-1.

Solution: use the relationship between DFS and DFT.

We thus need to replicate G(k) and H(k) “once”, to get X(k).

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

9

Decimation in time

)(nx

g(r)

h(r)

2N

2N

pt. DFT2N

pt. DFT2N

)(kG

)(kH

Nkj

e2

+

)(kX

kNW

(twiddle factor)

After replication

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

10

Decimation in time

)(nx

g(r)

h(r)

pt. DFT2N

pt. DFT2N

12

0 N

12

0 N

12

NN

12

NN

)0(G

)0(H

)0()2

( GNG

)0()2

( HNH

)0()0()0( 0 HWGX N

)0()0()2

( 2/ HWGNX NN

)()()(2

kHekGkX Nkj

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

11

Example of Decimation in time (N=8))()()( kHWkGkX k

N

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

12

Example of Decimation in time (N=8)

N/2 pt. DFT block

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

13

Example of Decimation in time (N=8)

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

14

Example of Decimation in time (N=8)

1

0

2

)()(N

n

Nknj

enrkR

2N2

)1(22

)0(2

)1()0()(kjkj

ererkR

kjerrkR )1()0()(

r(0)

r(1)

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

15

Example of Decimation in time (N=8)

kjerrkR )1()0()(

0k )1()0()0( rrR

1k )1()0()1( rrR

r(0)

r(1)

)4()0()0( xxR

)4()0()1( xxR

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

16

Example of Decimation in time (N=8)

Flow graph of a the 2-pt. DFT

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

17

Example of Decimation in time (N=8)

How many stages do we have? N2log

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

General form of a butterfly

18

)2

(22

NrN

jNr

N eW

)2

(22

.N

Njr

Nj

ee

rN

je

2

rNW

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

19

Revised form of a butterfly

2Nr

NW r

NW

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

20

Revised form of a butterfly

2 mults+ 2 adds

1 mult+ 2 adds

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Final figure for 8-pt DFT

21

In-place computation (only N storage locations are needed)Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Computational complexity

22

• How many stages do we have N2log

• Each stage has N inputs and N outputs.

• Each butterfly has 2 inputs and 2 outputs.

• Each stage has butterflies.2N

• Each butterfly needs 1 mult and 2 adds.

Total number of operations: NNN N loglog2

2 2 adds

NNN N log2

log2 2 mults

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Indexing of the inputs and outputs

23

Output indexing is in order.

input indexing is shuffled.

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Bit reversing

24

)0(X ]000[0

)1(X ]100[1

)2(X ]010[2

)3(X ]110[3

)4(X 4

)5(X 5

)6(X 6

)7(X 7

]001[

]101[

]011[

]111[

]100[

]000[

]001[

]010[

]011[

]100[

]101[

]110[

]111[

]001[

0

4

2

6

1

5

3

7

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Re-arranging the input order

25Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Re-arranging the input order

26Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Decimation in frequency

27

otherwise

NkenxkXN

n

Nknj

0

0)()(1

0

2

• The main idea: use the divide and conquer method (this time in the frequency domain)

• Divide the computation into two parts: even indices of k and odd indices of k.

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

28

Decimation in frequency

otherwise

NkenxkXN

n

Nknj

0

0)()(1

0

2

rk 2

1

0

2/)(2

20)()2(

N

n

Nnrj NrenxrX

1

2

2/)(21

2

0

2/)(2

)()()2(N

Nn

Nnrj

N

n

Nnrj

enxenxrX

2Nmn

1

2

0

2/

)2

)((212

0

2/)(2

)2

()()2(N

m

N

Nmrj

N

n

Nnrj

eNmxenxrX

1

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

29

Decimation in frequency

1

2

0

2/)(21

2

0

2/)(2

)2

()()2(N

m

Nmrj

N

n

Nnrj

eNmxenxrX

1

2

0

2/)(21

2

0

2/)(2

)2

()()2(N

n

Nnrj

N

n

Nnrj

eNnxenxrX

1

2

0

2/)(2

))2

()(()2(N

n

Nnrj

eNnxnxrX

)(ng

N/2 pt. DFT of g(n)

20 Nr

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

30

Decimation in frequency

1

2

0

2/)(2

))2

()(()2(N

n

Nnrj

eNnxnxrX

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

31

Decimation in frequency

12 rk

1

0

)12(2

20)()12(

N

n

Nnrj NrenxrX

1

2

)12(212

0

)12(2

)()()12(N

Nn

Nnrj

N

n

Nnrj

enxenxrX

2Nmn

12

0

)2

)(12(212

0

)12(2

)2

()()12(N

m

N

Nmrj

N

n

Nnrj

eNmxenxrX

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

32

Decimation in frequency

12

0

)2

)(12(212

0

)12(2

)2

()()12(N

m

N

Nmrj

N

n

Nnrj

eNmxenxrX

12

0

))(12(2)12(2

212

0

)12(2

)2

()()12(N

m

Nmrj

N

rN

jN

n

Nnrj

eNmxeenxrX

-1

12

0

))(12(212

0

)12(2

)2

()()12(N

n

Nnrj

N

n

Nnrj

eNnxenxrX

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

33

Decimation in frequency

12

0

))(12(212

0

)12(2

)2

()()12(N

n

Nnrj

N

n

Nnrj

eNnxenxrX

12

0

)12(2

))2

()(()12(N

n

Nnrj

eNnxnxrX

1

2

0

2/)(22

]))2

()([()12(N

n

Nnrj

Nnj

eeN

nxnxrX

)(nh

N/2 pt. DFT of h(n) Nnj

e2

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

34

Decimation in frequency

1

2

0

2/)(22

]))2

()([()12(N

n

Nnrj

Nnj

eeNnxnxrX

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

35

Decimation in frequency

Format of the Last stage Butterfly in Decimation in frequency

36Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

37

Decimation in frequency

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

38

Decimation in frequency (re-order the output)

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

39

Decimation in frequency (ordered input and output)

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Change x with X (i.e., input nodes with output nodes) Change X with x (i.e., output nodes with input nodes) Reverse the order of the flow graphs. The same system function is achieved.

40

Transposition theorem

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

41

Decimation in frequency

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Transposed version of the previous figure (Decimation in Time)

42Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

How can we deal with twiddle factors? Should we store them in a table (i.e, use a

lookup table) or should we calculate them? What happens if N is not a factor of 2? It can be shown that if N=RQ, then an N pt.

DFT can be expressed in terms of R Q-pt. DFT or Q R pt. DFTs (Cooley-Tukey algorithm).

Practical issues

43Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Recommended