chapter 8 dsp algorithm implementation wang weilian [email protected] school of information science...

55
CHAPTER 8 DSP Algorithm Implementation Wang Weilian [email protected] School of Information Science and Technology Yunnan University

Upload: judith-franklin

Post on 28-Dec-2015

235 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

CHAPTER 8 DSP Algorithm Implementation

CHAPTER 8 DSP Algorithm Implementation

Wang Weilian

[email protected]

School of Information Science and Technology

Yunnan University

Page 2: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

OUTLINEOUTLINE

• Concepts Relating to DSP Algorithm

– Matrix Representation

– Precedence Graph

– Structure Verification

• Structure Simulation and Verification Using MATLAB

• Computation of DFT

– Goertzel’s Algorithm

– FFT

– Inverse DFT computation

• Summary

Page 3: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

• Consider the structure figure:

• The structure can be described by a set of equations:

1 5

2 1 3

13 2

4 3 2

15 4

1 5

( ) ( ) ( )

( ) ( ) ( )

( ) ( )

( ) ( ) ( )

( ) ( )

( ) ( ) ( )

W z X z W z

W z W z W z

W z z W z

W z W z W z

W z z W z

Y z W z W z

Page 4: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

• In the time-domain, the equivalent set of equations is as follows:

• The above set of equations are non-computable in the present order.

Page 5: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

• Reorder the above equations as follows:

• The above ordered set of equations can be implemented in the sequential order and is computable.

Page 6: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

• A simple way to examine the computability of structure equations is by writing the equations in a matrix form.

• Define four matrices as follows:

Page 7: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

• The first ordered set of equations can be described in the compact matrix form:

• The matrix equation is not computable because all elements of the matrix F on the diagonal and above diagonal are not all zeros.

Page 8: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

MATRIX REPRESENTATION OF THE DIGITAL FILTER STRUCTURE

• Computability condition: all elements of the F matrix on the diagonal and above diagonal must be zeros.

• The F matrix for the second ordered set of equations is

• It can be seen that the above F matrix satisfies the computability condition.

Page 9: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

PRECEDENCE GRAPHPRECEDENCE GRAPH

• Precedence graph can be used to test the computability of a digital filter structure. It is developed from the signal flow-graph of the digital filter structure.

• The signal flow-graph description of

is shown below

Page 10: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

PRECEDENCE GRAPHPRECEDENCE GRAPH

• The reduced signal flow-graph is

• The precedence graph of the above figure is

Page 11: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

STRUCTURE VERIFICATIONSTRUCTURE VERIFICATION

• A digital filter structure is verified to ensure that no computational and / or other errors taken place and that the structure is indeed characterized by H (z).

• Consider a causal 3rd order IIR transfer function

• Its unit sample response is {h[n]}, then

Page 12: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

STRUCTURE VERIFICATIONSTRUCTURE VERIFICATION

• From the above equation, we arrive at

in the time-domain, the equivalent convolution sum is

for n=0,1,2,…,6, we have

Page 13: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

STRUCTURE VERIFICATIONSTRUCTURE VERIFICATION

• The above equations can be written in the matrix form

in the partitioned form, it can be written as

Page 14: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

STRUCTURE VERIFICATIONSTRUCTURE VERIFICATION

where

• Solving the second equation, we get

• Substituting above in the first equation, we arrive at

• In the case of N-th order IIR filter, the coefficients of its transfer function can be determined from the first 2N+1 impulse response samples.

Page 15: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

STRUCTURE VERIFICATIONSTRUCTURE VERIFICATION

Page 16: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

STRUCTURE VERIFICATIONSTRUCTURE VERIFICATION

Page 17: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

Structure Simulation & Verification Using MATLAB

Structure Simulation & Verification Using MATLAB

• As shown earlier, the set of equations describing the filter structure must be ordered properly to ensure computability.

• The procedure is to express the output of each adder and filter output variable in terms of all incoming variables.

Page 18: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

Structure Simulation & Verification Using MATLAB

Structure Simulation & Verification Using MATLAB

Page 19: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

• From the computed impulse response samples, the structure can be verified by determining the transfer function coefficients using the M-file strucver.

• The M-file filter implements IIR filter in the transposed direct form II structure shown below for a 3rd order filter.

• As indicated in the figure, d(1) has been assumed to be equal to 1.

Structure Simulation & Verification Using MATLAB

Structure Simulation & Verification Using MATLAB

Page 20: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

Structure Simulation & Verification Using MATLAB

Structure Simulation & Verification Using MATLAB

Page 21: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

Structure Simulation & Verification Using MATLAB

Structure Simulation & Verification Using MATLAB

Page 22: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

COMPUTATION OF DFTCOMPUTATION OF DFT

Page 23: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

GOERTZEL’S ALGORITHMGOERTZEL’S ALGORITHM

• Goertzel’s algorithm is a recursive DFT computation scheme making use of the identity

• We can write

• Define

1kNNW

Page 24: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

GOERTZEL’S ALGORITHMGOERTZEL’S ALGORITHM

then we have

• is the direct convolution of the causal sequence

with a causal sequence

[ ]ky n

Page 25: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

GOERTZEL’S ALGORITHMGOERTZEL’S ALGORITHM

• A second order realization

• According to the above figure, DFT computation equations are

Page 26: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

GOERTZEL’S ALGORITHMGOERTZEL’S ALGORITHM

Page 27: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

FAST FOURIER TRANSFORM ALGORITHMS

FAST FOURIER TRANSFORM ALGORITHMS

• The basic idea behind the fast Fourier transform ( FFT)

– Decompose the N-point DFT computation into computations of smaller-size DFTs

– Take advantage of the periodicity and symmetry of the complex number .

kNNW

Page 28: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

• Consider a sequence of length . Using 2-band polyphase decomposition, we can express its z-transform as

[ ]x n 2uN

Page 29: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 30: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 31: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 32: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 33: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 34: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 35: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 36: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 37: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 38: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 39: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

• Examination of the above flow-graph reveals that each stage of the DFT computation process employs the same basic computational module

• Basic computational module is called butterfly computation.

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 40: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 41: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 42: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 43: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 44: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-TIME FFT ALGORITHMDECIMATION-IN-TIME FFT ALGORITHM

Page 45: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-FREQUENCY FFT ALGORITHM

DECIMATION-IN-FREQUENCY FFT ALGORITHM

Page 46: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-FREQUENCY FFT ALGORITHM

DECIMATION-IN-FREQUENCY FFT ALGORITHM

Page 47: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-FREQUENCY FFT ALGORITHM

DECIMATION-IN-FREQUENCY FFT ALGORITHM

Page 48: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-FREQUENCY FFT ALGORITHM

DECIMATION-IN-FREQUENCY FFT ALGORITHM

Page 49: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-FREQUENCY FFT ALGORITHM

DECIMATION-IN-FREQUENCY FFT ALGORITHM

Page 50: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DECIMATION-IN-FREQUENCY FFT ALGORITHM

DECIMATION-IN-FREQUENCY FFT ALGORITHM

Page 51: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

INVERSE DFT COMPUTATIONINVERSE DFT COMPUTATION

Page 52: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

INVERSE DFT COMPUTATIONINVERSE DFT COMPUTATION

Page 53: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

INVERSE DFT COMPUTATIONINVERSE DFT COMPUTATION

Page 54: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

DFT AND IDFT COMPUTATION USING MATLAB

DFT AND IDFT COMPUTATION USING MATLAB

• The following functions in the MATLAB package can be used to compute DFT and IDFT:

fft(x) ifft(x) fft(x,N) ifft(x,N)

• Since vectors in MATLAB are indexed from 1 to N, the DFT and the IDFT computed in the above MATLAB functions make use of the expressions:

( 1)( 1)

1

( 1)( 1)

1

[ ] [ ] ,1

1[ ] [ ] ,1

Nn kN

n

Nn k

Nk

X k x n W k N

x n X k W n NN

Page 55: CHAPTER 8 DSP Algorithm Implementation Wang Weilian wlwang@ynu.edu.cn School of Information Science and Technology Yunnan University

SUMMARYSUMMARY

• Some common factors in the implementation of DSP algorithm

• The implementation carried out by the set of equations describing the algorithm

• The computability condition of these equations

• Fast Fourier transform (FFT)

• MATLAB-based implementation of digital filtering algorithms