DIGITAL SIGNAL PROCESSING LAB IV B.
Tech ISemester
DIGITAL SIGNAL PROCESSING
LABORATORY MANUAL
Subject Code : 15A02711
Regulations : JNTUA – R15
Class : IV-I Semester (EEE)
CHADALAWADA RAMANAMMA ENGINEERING
COLLEGE
(AUTONOMOUS)
Chadalawada Nagar, Renigunta Road, Tirupati – 517 506
Department of Electronics and Communication Engineering
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 1
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
CHADALAWADA RAMANAMMA ENGINEERING
COLLEGE
(AUTONOMOUS)
Chadalawada Nagar, Renigunta Road, Tirupati – 517 506
Department of Electronics and Communication Engineering
INDEX
S. No Name of the Experiment Page No
1 6-15
Random Signal
2 Power And Energy Of Signal 16-19
3 Convolution And Correlation 20-22
4 DTFT 23-28
5 FFT 29-31
6 FIR FILTER 32-34
7 IIR FILTER 35-36
8 ANALOG FILTERS 37-40
9 41-43
10 44-46
11 47-49
12 50-52
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 2
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
13 53-55
14 56-59
INRODUCTION
MATLAB: MATLAB is a software package for high performance numerical
computation and visualization provides an interactive environment with
hundreds of built in functions for technical computation, graphics and animation.
The MATLAB name stands for Matrix Laboratory.
At its core ,MATLAB is essentially a set (a “toolbox”) of routines (called “m files”
or “mex files”) that sit on your computer and a window that allows you to create
new variables with names (e.g. voltage and time) and process those variables
with any of those routines (e.g. plot voltage against time, find the largest
voltage, etc).
It also allows you to put a list of your processing requests together in a file and
save that combined list with a name so that you can run all of those commands
in the same order at some later time. Furthermore, it allows you to run such
lists of commands such that you pass in data and/or get data back out (i.e. the
list of commands is like a function in most programming languages). Once you
save a function, it becomes part of your toolbox (i.e. it now looks to you as if
it were part of the basic toolbox that you started with).
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 3
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
For those with computer programming backgrounds: Note that MATLAB runs as
an interpretive language (like the old BASIC). That is, it does not need to be
compiled. It simply reads through each line of the function, executes it, and then
goes on to the next line. (In practice, a form of compilation occurs when you
first run a function, so that it can run faster the next time you run it.)
MATLAB Windows :
MATLAB works with through three basic windows
Command Window : This is the main window .it is characterized by MATLAB
command prompt >> when you launch the application program MATLAB puts
you in this window all commands including those for user-written programs ,are
typed in this window at the MATLAB prompt
Graphics window: the output of all graphics commands typed in the command
window are flushed to the graphics or figure window, a separate gray window
with white background color the user can create as many windows as the system
memory will allow
Edit window: This is where you write edit, create and save your own programs
in files called M files.
Input-output:
MATLAB supports interactive computation taking the input from the screen and
flushing, the output to the screen. In addition it can read input files and write
output files
Data Type: the fundamental data –type in MATLAB is the array. It encompasses
several distinct data objects- integers, real numbers, matrices, charcter strings,
structures and cells.There is no need to declare variables as real or complex,
MATLAB automatically sets the variable to be real.
Dimensioning: Dimensioning is automatic in MATLAB. No dimension statements
are required for vectors or arrays .we can find the dimensions of an existing
matrix or a vector with the size and length commands.
Where to work in MATLAB?
All programs and commands can be entered either in the a)Command window
b) As an M file using Matlab editor
Note: Save all M files in the folder 'work' in the current directory. Otherwise you
have to locate the file during compiling.
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 4
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
Typing quit in the command prompt>> quit, will close MATLAB Matlab
Development Environment.
For any clarification regarding plot etc, which are built in functions type help
topic i.e. help plot
Basic Instructions in Mat lab
1. T = 0: 1:10
This instruction indicates a vector T which as initial value 0 and final
value 10 with an increment of 1
Therefore T = [0 1 2 3 4 5 6 7 8 9 10]
2. F= 20: 1: 100
Therefore F = [20 21 22 23 24 ……… 100]
3. T= 0:1/pi: 1
Therefore T= [0, 0.3183, 0.6366, 0.9549]
4. zeros (1, 3)
The above instruction creates a vector of one row and three columns whose
values are zero
Output= [0 0 0]
5.zeros( 2,4)
Output = 0000
0000
6. ones (5,2)
The above instruction creates a vector of five rows and two columns Output =
11
11
11
11
11
7. a = [ 1 2 3] b = [4 5 6]
a.*b = [4 10 18]
8 if C= [2 2 2]
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 5
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
b.*C results in [8 10 12]
9. plot (t, x)
If x = [6 7 8 9] t = [1 2 3 4]
This instruction will display a figure window which indicates the plot of x Vs t
10. stem (t,x) :-This instruction will display a figure window as shown
11Subplot: This function divides the figure window into rows and columns.
Subplot (2 2 1) divides the figure window into 2 rows and 2 columns 1
represent number of the figure
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 6
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
Subplot (3 1 2) divides the figure window into 3 rows and 1 column 2 represent
number of the figure
12. Conv
Syntax: w = conv(u,v)
Description: w = conv(u,v) convolves vectors u and v. Algebraically, convolution
is the same operation as multiplying the polynomials whose coefficients are the
elements of u and v.
13.Disp Syntax: disp(X)
Description: disp(X) displays an array, without printing the array name. If X
contains a text string, the string is displayed.Another way to display an array on
the screen is to type its name, but this prints a leading "X=," which is not
always desirable.Note that disp does not display empty arrays.
14.xlabel
Syntax: xlabel('string')
Description: xlabel('string') labels the x-axis of the current axes.
15. ylabel
Syntax : ylabel('string')
Description: ylabel('string') labels the y-axis of the current axes.
16.Title
Syntax : title('string')
Description: title('string') outputs the string at the top and in the center of the
current axes. 17.grid on
Syntax : grid on
Description: grid on adds major grid lines to the current axes.
18.FFT Discrete Fourier transform.
FFT(X) is the discrete Fourier transform (DFT) of vector X. For matrices, the FFT
operation is applied to each column. For N-D arrays, the FFT operation operates
on the first non-singleton dimension.
FFT(X,N) is the N-point FFT, padded with zeros if X has less than N points and
truncated if it has more.
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 7
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
19. ABS Absolute value.
ABS(X) is the absolute value of the elements of X. When X is complex, ABS(X) is
the complex modulus (magnitude) of the elements of X.
20. ANGLE Phase angle.
ANGLE(H) returns the phase angles, in radians, of a matrix with complex
elements.
21. INTERP Resample data at a higher rate using lowpass
interpolation.
Y = INTERP(X,L) resamples the sequence in vector X at L times the original
sample rate.
The resulting resampled vector Y is L times longer, LENGTH(Y) = L*LENGTH(X).
22. DECIMATE Resample data at a lower rate after lowpass filtering.
Y = DECIMATE(X,M) resamples the sequence in vector X at 1/M times the
original sample rate.
The resulting re-sampled vector Y is M times shorter, i.e., LENGTH(Y) =
CEIL(LENGTH(X)/M). By default, DECIMATE filters the data with an 8th order
Chebyshev Type I lowpass filter with cutoff frequency .8*(Fs/2)/R, before
resampling.
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 8
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
1) Generation of a random signal and plot the same as the waveform
showing all the specifications.
Aim:
Apparatus:
Program:
N=input('Enter the value of N:');
n=0:N-1;
x=randn(1,N);
figure;
subplot(2,1,1);
plot(n,x);
xlabel('n');
ylabel('x');
title('Continuous Random signal');
subplot(2,1,2);
stem(n,x);
xlabel('n');
ylabel('x');
title('Discrete Random signal');
Result:
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 9
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
2)Finding Power and (or) Energy of a given signal
Aim :
Appartus:
Program:
%Energy of the Discrete Time Signal
n=0:1:50;
x=(1/2).^n;
figure;
subplot(2,1,1);
stem(n,x);
axis([0 25 0 1]);
disp('The Calculated Energy E of the Signal is ');
E=sum(abs(x).^2);
disp(E);
%Power of the Discrete Time Signal
f=input('enter the frequency = ');
fs=10*f;
n1=0:1/fs:1;
ss=sin(2*pi*f*n1);
disp('The Calculated Power p of the Signal is ');
p=sum(abs(ss).^2)/length(ss);
subplot(2,1,2);
stem(n1,ss)
disp(p);
Result:
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 10
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
3) Convolution and correlation(auto and cross correlation)of discrete
sequence without using built in functions for convolutions and
correlation operations.
Aim
Apparatus:
Program:
%Linear Convolution
clc;
clear all;
close all;
disp('linear convolution program');
x=input('enter i/p x(n):');
m=length(x);
h=input('enter i/p h(n):');
n=length(h);
x=[x,zeros(1,n)];
l1=0:length(x)-1;
subplot(2,2,1);
stem(l1,x);
title('i/p sequence x(n)is:');
xlabel('---->n');
ylabel('---->x(n)');grid;
h=[h,zeros(1,m)];
l2=0:length(h)-1;
subplot(2,2,2);
stem(l2,h);
title('i/p sequence h(n)is:');
xlabel('---->n');
ylabel('---->h(n)');grid;
disp('convolution of x(n) & h(n) is y(n):');
y=zeros(1,m+n-1);
for i=1:m+n-1
y(i)=0;
for j=1:m+n-1
if(j<i+1)
y(i)=y(i)+x(j)*h(i-j+1);
end
end
end
disp(y);
l3=m+n-1;
n1=0:l3-1;
subplot(2,2,[3,4]);
stem(n1,y);
title('Linear Convolution of x(n) & h(n) is :');
xlabel('---->n');
ylabel('---->y(n)');
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 11
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
grid;
%Circular Convolution
clc;
clear all;
close all;
disp('circular convolution program');
x=input('enter i/p x(n):');
m=length(x);
h=input('enter i/p sequence h(n)');
n=length(h);
subplot(2,2,1), stem(x);
title('i/p sequencce x(n)is:');
xlabel('---->n');
ylabel('---->x(n)');grid;
subplot(2,2,2), stem(h);
title('i/p sequencce h(n)is:');
xlabel('---->n');
ylabel('---->h(n)');grid;
disp('circular convolution of x(n) & h(n) is y(n):');
if(m-n~=0)
if(m>n)
h=[h,zeros(1,m-n)];
n=m;
end
x=[x,zeros(1,n-m)];
m=n;
end
y=zeros(1,n);
y(1)=0;
a(1)=h(1);
for j=2:n
a(j)=h(n-j+2);
end
%ciruclar conv
for i=1:n
y(1)=y(1)+x(i)*a(i);
end
for k=2:n
y(k)=0;
% circular shift
for j=2:n
x2(j)=a(j-1);
end
x2(1)=a(n);
for i=1:n
if(i<n+1)
a(i)=x2(i);
y(k)=y(k)+x(i)*a(i);
end
end
end
disp(y);
subplot(2,2,[3,4]),stem(y);
title('Circular convolution of x(n) & h(n) is:');
xlabel('---->n');
ylabel('---->y(n)');
grid;
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 12
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
%Cross Correlation
clc;
clear all;
close all;
z=input('Enter first sequence x(n):');
n1=length(z);
x=fliplr(z);
m=length(x);
h=input('Enter Second sequence h(n):');
n=length(h);
l1=0:n1-1;
figure;
subplot(2,2,1);
stem(l1,z);
title('First sequence x(n)is:');
xlabel('---->n');
ylabel('---->x(n)');
grid;
l2=0:n-1;
subplot(2,2,2);
stem(l2,h);
title('Second sequence h(n)is:');
xlabel('---->n');
ylabel('---->h(n)');
grid;
x=[x,zeros(1,m)];
h=[h,zeros(1,m)];
disp('Cross Correlation of x(n) & h(n) is y(n):');
y=zeros(1,m+n-1);
for i=1:m+n-1
y(i)=0;
for j=1:m+n-1
if(j<i+1)
y(i)=y(i)+x(j)*h(i-j+1);
end
end
end
disp(y);
l3=-(m-1):(n-1);
subplot(2,2,[3,4]);
stem(l3,y);
title('Cross Correlation of x(n) & h(n) is :');
xlabel('---->n');
ylabel('---->y(n)');
grid;
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 13
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
%Auto Correlation
clc;
clear all;
close all;
x=input('Enter the sequence x(n):');
n=length(x);
z=fliplr(x);
m=length(z);
l1=0:n-1;
figure;
subplot(2,1,1);
stem(l1,x);
title('Input Sequence x(n)is:');
xlabel('---->n');
ylabel('---->x(n)');
grid;
x=[x,zeros(1,m)];
z=[z,zeros(1,n)];
disp('Auto Correlation of x(n) & x(n) is y(n):');
y=zeros(1,m+n-1);
for i=1:m+n-1
y(i)=0;
for j=1:m+n-1
if(j<i+1)
y(i)=y(i)+z(j)*x(i-j+1);
end
end
end
disp(y);
l2=-(n-1):(n-1);
subplot(2,1,2);
stem(l2,y);
title('Auto Correlation of x(n) & x(n) is :');
xlabel('---->n');
ylabel('---->y(n)');
grid;
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 14
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
4) Find the DTFT of the given signal
Aim:
Apparatus:
Program:
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 15
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
5) Design N point FFT algorithm
Aim:
Apparatus:
Program:
clc;
clear all;
close all;
x=input('Enter the sequence:');
n=input('Enter the length of fft: ');
%compute fft
disp('Fourier transformed signal');
X=fft(x,n);
subplot(1,2,1);
stem(x);
title('i/p signal');
xlabel('n --->');
ylabel('x(n) -->');grid;
subplot(1,2,2);stem(X);
title('FFT of i/p x(n) is:');
xlabel('Real axis --->');
ylabel('Imaginary axis -->');
grid;
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 16
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
6) Design of FIR filter using windowing technique and verify the
frequency response of the filter
Aim:
Apparatus:
Program:
clc;
clear all;
close all;
rp=input('enter passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter passband freq');
fs=input('enter stopband freq');
f=input('enter sampling freq ');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
c=input('enter your choice of window function 1. rectangular 2. triangular
3.kaiser: \n ');
if(c==1)
y=rectwin(n1);
disp('Rectangular window filter response');
end
if (c==2)
y=triang(n1);
disp('Triangular window filter response');
end
if(c==3)
y=kaiser(n1);
disp('kaiser window filter response');
end
%LPF
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);plot(o/pi,m);
title('LPF');
ylabel('Gain in dB-->');
xlabel('(a) Normalized frequency-->');
%HPF
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);plot(o/pi,m);
title('HPF');
ylabel('Gain in dB-->');
xlabel('(b) Normalized frequency-->');
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 17
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
%BPF
wn=[wp ws];
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);plot(o/pi,m);
title('BPF');
ylabel('Gain in dB-->');
xlabel('(c) Normalized frequency-->');
%BSF
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);plot(o/pi,m);
title('BSF');
ylabel('Gain in dB-->');
xlabel('(d) Normalized frequency-->');
Result:
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 18
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
7) Design of IIR filter using anyof the available methods and verify the
frequency response of the filter
Aim:
Apparatus:
Program:
% IIR FILTERS LPF & HPF USING MATLAB
clc;
clear all;
close all;
disp('enter the IIR filter design specifications');
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband freq');
ws=input('enter the stopband freq');
fs=input('enter the sampling freq');
w1=2*wp/fs;w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
% IIR FILTERS LPF & HPF USING MATLAB
clc;
clear all;
close all;
disp('enter the IIR filter design specifications');
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband freq');
ws=input('enter the stopband freq');
fs=input('enter the sampling freq');
w1=2*wp/fs;w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
c=input('enter choice of filter 1. LPF 2. HPF \n ');
if(c==1)
disp('Frequency response of IIR LPF is:');
[b,a]=butter(n,wn,'low','s');
end
if(c==2)
disp('Frequency response of IIR HPF is:');
[b,a]=butter(n,wn,'high','s');
end
w=0:.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure,subplot(2,1,1);plot(om/pi,m);
title('magnitude response of IIR filter is:');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
subplot(2,1,2);plot(om/pi,an);
title('phase response of IIR filter is:');
xlabel('(b) Normalized freq. -->');
ylabel('Phase in radians-->');
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 19
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
Result:
8) Design of Analog filters
8) Design of analog filters
Aim:
Apparatus:
Program:
clc;
clear all;
close all;
disp('Enter the Analog filter design specifications');
N=input('Enter the order of the filter');
c=input('Enter the choice of filter 1. LPF 2. HPF 3.BPF 4.BSF \n ');
if(c==1)
disp('Frequency response of Analog LPF is:');
Cf=100;
[b,a]=butter(N,Cf,'S');
freqs(b,a);
end
if(c==2)
disp('Frequency response of Analog HPF is:');
Cf=100;
[b,a]=butter(N,Cf,'HIGH','S');
freqs(b,a);
end
if(c==3)
disp('Frequency response of Analog BPF is:');
Cf1=[10 100];
[b,a]=butter(N,Cf1,'S');
freqs(b,a);
end
if(c==4)
disp('Frequency response of Analog BPF is:');
Cf1=[10 100];
[b,a]=butter(N,Cf1,'STOP','S');
freqs(b,a);
end
Result:
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 20
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
CC STUDIO PROGRAMS
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 21
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
TMS320C6x DIGITAL SIGNAL PROCESSOR
INTRODUCTION
The TMS320C6713 (C6713) is based on the VLIW architecture, which is very
well suited for numerically intensive algorithms. The internal program memory is
structured so that a total of eight instructions can be fetched every cycle. For
example, with a clock rate of 225MHz, the C6713 is capable of fetching eight 32-
bit instructions every 1/(225 MHz) or 4.44 ns. Features of the C6713 include 264
kB of internal memory (8kB as L1P and L1D Cache and 256kB as L2 memory
shared between program and data space), eight functional or execution units
composed of six arithmetic-logic units (ALUs) and two multiplier units, a 32-bit
address bus to address 4 GB (gigabytes), and two sets of 32-bit general-purpose
registers.
The C67xx (such as the C6701, C6711, and C6713) belong to the family of
the C6x floating-point processors, whereas the C62xx and C64xx belong to the
family of the C6x fixed-point processors. The C6713 is capable of both fixed- and
floatingpoint processing.
An application-specific integrated circuit (ASIC) has a DSP core with
customized circuitry for a specific application. A C6x processor can be used as a
standard general-purpose DSp programmed for a specific application. Specific-
purpose digital signal processors are the modem, echo canceler, and others. A
fixed-point processor is better for devices that use batteries, such as cellular
phones, since it uses less power than does an equivalent floating-point
processor. The fixed-point processors, C1x, C2x, and C5x, are 16-bit processors
with limited dynamic range and precision. The C6x fixed-point processor is a 32-
bit processor with improved dynamic range and precision. In a fixed-point
processor, it is necessary to scale the data. Overflow, which occurs when an
operation such as the addition of two numbers produces a result with more bits
than can fit within a processor’s register, becomes a concern.
A floating-point processor is generally more expensive since it has more
“real estate” or is a larger chip because of additional circuitry necessary to
handle integer as well as floating-point arithmetic. Several factors, such as cost,
power consumption, and speed, come into play when choosing a specific DSp.
The C6x processors are particularly useful for applications requiring intensive
computations. Family members of the C6x include both fixed-point (e.g., C62x,
C64x) and floating-point (e.g., C67x) processors. Other DSp’s are also available
from companies such as Motorola and Analog Devices.
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 22
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
TMS320C6X ARCHITECTURE
Figure : Functional block diagram of TMS320C6713
The TMS320C6713 onboard the DSK is a floating-point processor based on the
VLIW architecture [6–10]. Internal memory includes a two-level cache
architecture with 4 kB of level 1 program cache (L1P), 4 kB of level 1 data cache
(L1D), and 256 kB of level 2 memory shared between program and data space.
It has a glueless (direct) interface to both synchronous memories (SDRAM and
SBSRAM) and asynchronous memories (SRAM and EPROM). Synchronous
memory requires clocking but provides a compromise between static SRAM and
dynamic DRAM, with SRAM being faster but more expensive than DRAM. On-chip
peripherals include two McBSPs, two timers, a host port interface (HPI), and a
32-bit EMIF. It requires 3.3 V for I/O and 1.26 V for the core (internal). Internal
buses include a 32-bit program address bus, a 256-bit program data bus to
accommodate eight 32-bit instructions, two 32-bit data address buses, two 64-
bit data buses, and two 64-bit store data buses.With a 32-bit address bus, the
total memory space is 232 = 4GB, including four external memory spaces: CE0,
CE1, CE2, and CE3. Figure shows a functional block diagram of the C6713
processor included with CCS.
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 23
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
TMS320C6X- PROCEDURE FOR USING C60 DEBUGGER
Step1: Open 6177 Diagnostic start Stop Close
Step 2: Project New Project Name Target TMS320C67XX
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 24
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
Step 3: Libraries Add Files to Project My Project C600 CG Tools
Library rts6700.lib
Step 4: File New Source File Write Program in window
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 25
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
Step 5: File Save as CStudio my project sss.c
Step 6: Source Add Files to project CStudio lib confi.c
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 26
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
Step 7: Source Add Files to Project CStudio C600 Tutorial
Dsk6713 hello1 link cmd hello.cmd
Step 8: Project Compile File
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 27
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
Step 9: Project Build all
Step 10: File Load Program Debug Output File
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 28
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
Step 11: Debug Run
Step 12: Veiw Graph Time/Frequency
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 29
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
Step 13: Start Address ‘a’ and DSP data type- 32 bit floating point
Step 14: We will get th required output ………..!!!!!
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 30
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
1)Generation of random signal and plot the same as a waveform
showing all specifications
Aim:
Apparatus:
Program:
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 31
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
2) Finding Power and (or) Energy of a given signal
Aim:
Apparatus:
Program:
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 32
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
3) Convolution and correlation(auto and cross correlation)of discrete
sequence without using built in functions for convolutions and
correlation operations.
Aim
Apparatus:
Program:
/*linear convolution*/
#include<stdio.h>
int x[15],h[15],y[15];
main()
{
int i,j,m,n;
printf("\n enter value for m");
scanf("%d",&m);
printf("\n enter value for n");
scanf("%d",&n);
printf("Enter values for i/p x(n):\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("Enter Values for i/p h(n) \n");
for(i=0;i<n; i++)
scanf("%d",&h[i]);
// padding of zeros
for(i=m;i<=m+n-1;i++)
x[i]=0;
for(i=n;i<=m+n-1;i++)
h[i]=0;
/* convolution operation */
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
{
y[i]=y[i]+(x[j]*h[i-j]);
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 33
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
}}
//displaying the o/p
for(i=0;i<m+n-1;i++)
printf("\n The Value of output y[%d]=%d",i,y[i]);
}
/* program to implement circular convolution */
#include<stdio.h>
int m,n,x[30],h[30],y[30],i,j, k,x2[30],a[30];
void main()
{
printf(" Enter the length of the first sequence\n");
scanf("%d",&m);
printf(" Enter the length of the second sequence\n");
scanf("%d",&n);
printf(" Enter the first sequence\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf(" Enter the second sequence\n");
for(j=0;j<n;j++)
scanf("%d",&h[j]);
if(m-n!=0) /*If length of both sequences are not equal*/
{
if(m>n) /* Pad the smaller sequence with zero*/
{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++) /*folding h(n) to h(-n)*/
a[j]=h[n-j];
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 34
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
/*Circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
/*circular shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf(" The circular convolution is\n");
for(i=0;i<n;i++)
printf("%d \t",y[i]);
}
/*cross correlation*/
#include<stdio.h>
#include<math.h>
int y[10];
main()
{i
nt i,j;
int x[15]={1,2,3,4,0,0,0,0,0,0,0,0,0,0,0};
int h[15]={4,3,2,1,0,0,0,0,0,0,0,0,0,0,0};
int n=4;
for(i=-(n-1);i<=(n-1);i++)
{
y[i]=0;
for(j=0;j<=4;j++)
y[i]+= x[j] * h[j-i];
}f
or(i=-(n-1);i<n;i++)
printf("%d\n",y[i]);
}
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 35
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
/*auto correlation*/
#include<stdio.h>
#include<math.h>
int y[10];
main()
{
int i,j,k;
int x[15]={0,0,0,0,0,1,1,1,1,1,0,0,0,0,0};
int n=15;
k=n-1;
for(i=-(n-1);i<=(n-1);i++)
{
y[i+k]=0;
for(j=0;j<=5;j++)
y[i+k]+=x[j+k] * x[i+j+k];
}f
or(i=-(n-1);i<n;i++)
printf("%d\n",y[i+k]);
}
Result:
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 36
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 37
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
4)Find the DTFT of the given signal
Aim:
Apparatus:
Program:
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 38
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
5) Design N point FFT algorithm
Aim:
Apparatus:
Program:
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 39
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
6) Design of FIR filter using windowing technique and verify the
frequency response of the filter
Aim:
Apparatus:
Program:
#include<stdio.h>
#include<math.h>
#define pi 3.1415
int n,N,c;
float wr[64],wt[64];
void main()
{
printf("\n enter no. of samples,N= :");
scanf("%d",&N);
printf("\n enter choice of window function\n 1.rect \n 2. triang \n c= :");
scanf("%d",&c);
printf("\n elements of window function are:");
switch(c)
{
case 1:
for(n=0;n<=N-1;n++)
{
wr[n]=1;
printf(" \n wr[%d]=%f",n,wr[n]);
}
break;
case 2:
for(n=0;n<=N-1;n++)
{
wt[n]=1-(2*(float)n/(N-1));
printf("\n wt[%d]=%f",n,wt[n]);
}
break;
}}
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 40
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
7)Design of IIR filter using anyof the available methods and verify the
frequency response of the filter
Aim:
Apparatus:
Program:
//IIRFILTERS USING C
#include<stdio.h>
#include<math.h>
int i,w,wc,c,N;
float H[100];
float mul(float, int);
void main()
{
printf("\n enter order of filter ");
scanf("%d",&N);
printf("\n enter the cutoff freq ");
scanf("%d",&wc);
printf("\n enter the choice for IIR filter 1. LPF 2.HPF ");
scanf("%d",&c);
switch(c)
{
case 1:
for(w=0;w<100;w++)
{
H[w]=1/sqrt(1+mul((w/(float)wc),2*N));
printf("H[%d]=%f\n",w,H[w]);
}
break;
case 2:
for(w=0;w<=100;w++)
{
H[w]=1/sqrt(1+mul((float)wc/w,2*N));
printf("H[%d]=%f\n",w,H[w]);
}
break;
}}
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 41
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
float mul(float a,int x)
{
for(i=0;i<x-1;i++)
a*=a;
return(a);
}
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 42
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
8) Design of Analog filters
Aim:
Apparatus:
Program:
% IIR filters LPF & HPF
clc;
clear all;
close all;
warning off;
disp('enter the IIR filter design specifications');
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband freq');
ws=input('enter the stopband freq');
fs=input('enter the sampling freq');
w1=2*wp/fs;w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
c=input('enter choice of filter 1. LPF 2. HPF \n ');
if(c==1)
disp('Frequency response of IIR LPF is:');
[b,a]=butter(n,wn,'low','s');
end
if(c==2)
disp('Frequency response of IIR HPF is:');
[b,a]=butter(n,wn,'high','s');
end
w=0:.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure,subplot(2,1,1);plot(om/pi,m);
title('magnitude response of IIR filter is:');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
subplot(2,1,2);plot(om/pi,an);
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 43
DIGITAL SIGNAL PROCESSING LAB IV B.Tech ISemester
title('phase response of IIR filter is:');
xlabel('(b) Normalized freq. -->');
ylabel('Phase in radians-->');////
DEPT OF ECE|C.R. ENGINEERING COLLEGE Page 44