332-dsp-lab-manuall (1)
332-dsp-lab-manuall (1)
PAGE
S.NO. DATE EXPERIMENTTITLE SIGN.
NO
Generation of elementary Discrete-Time sequences
1
Linear and Circular convolution
2
Auto correlation and Cross Correlation
3
Frequency Analysis using DFT
4
Design of FIR filters (LPF/HPF/BPF/BSF) and
demonstrates the filteringoperation
5
Design of Butterworth and Chebyshev IIR filters
6 (LPF/HPF/BPF/BSF) anddemonstrate the filtering
operations
Study of architecture of Digital Signal Processor
7
Study of architecture of Digital Signal Process
8
Perform MAC operation using various addressing modes
9
10 Generation of various signals and random noise
AIM:
To write a program to generate the elementary discrete time sequences using MATLAB.
SOFTWARE REQUIRED:
MATLAB R2014a
ALGORITHM:
PROGRAM:
Clc;
Clearall;
Closeall;
N = 7;
n = 0:1:N-1;
y = ones(1,N);
subplot(3,2,1);
stem(n,y);
xlabel('time');
ylabel('amplitude');
title('unit step seqence');
N1 = 5;
n1 = 0:1:N-1;
y1 = n1;
subplot(3,2,2);
stem(n1,y1);
xlabel('time');
ylabel('amplitude');
title('unit ramp sequence');
N2 = 6;
n2 = 0:0.1:N-1;
2
y2 = sin(2*pi*n2);
subplot(3,2,3);
stem(n2,y2);
xlabel('time');
ylabel('amplitude');
title('sinusoidal seqeuence');
N3 = 4;
n3 = 0:0.1:N3-1;
y3 = cos(2*pi*n3);
subplot(3,2,4);
stem(n3,y3);
xlabel('time');
ylabel('amplitude');
title('cosine sequence');
N4 = 5;
n4 = 0:0.1:N4-1;
a = 3;
y4 = exp(a*n4);
subplot(3,2,5);
stem(n4,y4);
xlabel('time');
ylabel('amplitude');
title('exponential sequence');
n5 = -3:1:3;
y5 = [zeros(1,3),ones(1,1),zeros(1,3)];
subplot(3,2,6);
stem(n5,y5);
xlabel('time');
ylabel('amplitude');
title('unit impluse');
3
OUTPUT:
amplitude
4
0.5
2
0 0
0 1 2 3 4 5 6 0 1 2 3 4 5 6
time time
sinusoidal seqeuence cosine sequence
1 1
0.5 0.5
amplitude
amplitude
0 0
-0.5 -0.5
-1 -1
0 1 2 3 4 5 6 0 0.5 1 1.5 2 2.5 3
time time
5
x 10 exponential sequence unit impluse
2 1
1.5
amplitude
amplitude
1 0.5
0.5
0 0
0 0.5 1 1.5 2 2.5 3 3.5 4 -3 -2 -1 0 1 2 3
time time
RESULT:
Thus the elementary discrete time sequences are generated and plottedusing MATLAB.
4
EXP.NO: 2 LINEAR AND CIRCULAR CONVOLUTIONS
AIM:
SOFTWARE REQUIRED:
MATLAB R2014a
ALGORITHM:
PROGRAM:
LINEAR CONVOLUTION:
clc;
clearall;
closeall;
x=input('Enter the input sequence');
h=input('Enter the impulse sequence');
y=conv(x,h);
subplot(2,2,1);
stem(x);
xlabel('n');
ylabel('amplitude');
title('input sequence');
subplot(2,2,2);
stem(h);
xlabel('n');
ylabel('amplitude');
title('impulse sequence');
subplot(2,2,3);
stem(y);
xlabel('n');
ylabel('amplitude');
title('convoluted sequence');
disp('Convoluted sequence');y
5
INPUT :
y= 5 16 34 60 61 52 32
OUTPUT:
3 6
amplitude
amplitude
2 4
1 2
0 0
1 2 3 4 1 2 3 4
n n
convoluted sequence
80
60
amplitude
40
20
0
0 2 4 6 8
n
6
CIRCULAR CONVOLUTION
clc;
clearall;
closeall;
x=input('Enter the input sequence');
h=input('Enter the impulse sequence');
N1=length(x);
N2=length(h);
N=max(N1,N2);
N3=N1-N2;
if (N3>=0);
h=[h,zeros(1,N3)];
else
x=[x,zeros(1,N3)];
end
for n=1:N;
y(n)=0;
for i=1:N;
j=n-i+1;
if (j<=0)
j=N+j;
end
y(n)=y(n)+[x(i)*h(j)];
end
end
subplot(1,3,1);
stem(y);
xlabel('n');
ylabel('amplitude');
title('convoluted sequence');
disp('Convoluted sequence');y
subplot(1,3,2);
stem(x);
xlabel('n');
ylabel('amplitude');
title('input sequence');
subplot(1,3,3);
stem(h);
xlabel('n');
ylabel('amplitude');
title('impulse sequence');
7
INPUT:
y= 24 22 24 30
OUTPUT :
3.5 3.5
25
3 3
20
2.5 2.5
amplitude
amplitude
amplitude
15 2 2
1.5 1.5
10
1 1
5
0.5 0.5
0 0 0
0 2 4 0 2 4 0 2 4
n n n
RESULT:
Thus the linear and circular convolutions of two sequences wereperformed using
MATLAB.
8
EXP NO: 3 AUTO CORRELATION AND CROSS CORRELATION
AIM:
SOFTWARE REQUIRED:
MATLAB R2014a
ALGORITHM:
PROGRAM:
AUTOCORRELATION:
clc;
clearall;
closeall;
x=input('Enter the input sequence');
y=xcorr(x,x);
subplot(2,1,1);
stem(x);
ylabel('amplitude');
xlabel('x(n)');
subplot(2,1,2);
stem(y);
ylabel('amplitude');
xlabel('y(n)');
disp('The resultant signal is');y
9
INPUT:
OUTPUT:
3
amplitude
0
1 1.5 2 2.5 3 3.5 4
x(n)
30
25
20
amplitude
15
10
0
1 2 3 4 5 6 7
y(n)
10
CROSS CORRELATION:
clc;
clearall;
closeall;
x=input('Enter the first sequence');
h=input('Enter the second sequence');
y=xcorr(x,h);
subplot(3,1,1);
stem(x);
ylabel('amplitude');
xlabel('x(n)');
subplot(3,1,2);
stem(h);
ylabel('amplitude');
xlabel('h(n)');
subplot(3,1,3);
stem(y);
ylabel('amplitude');
xlabel('y(n)');
disp('The resultant signal is:');y
11
INPUT:
OUTPUT:
4
amplitude
0
1 1.5 2 2.5 3 3.5 4
x(n)
10
amplitude
0
1 1.5 2 2.5 3 3.5 4
h(n)
100
amplitude
50
0
1 2 3 4 5 6 7
y(n)
RESULT:
Thus the autocorrelation and cross correlation of two sequences were performed
using MATLAB.
12
EXP.NO:4 FREQUENCY ANALYSIS USING DFT
AIM:
SOFTWARE REQUIRED:
MATLAB R2014a
ALGORITHM:
PROGRAM:
clc;
clearall;
closeall;
xn=input('enter the input sequence');
XK = fft (xn);
subplot(1,4,1);
stem(xn);
xlabel('n');
ylabel('amplitude');
title('input sequence');
subplot(1,4,2);
stem(XK)
xlabel('n');
ylabel('amplitude');
title('output sequence');
disp('resultant sequence XK');XK
subplot(1,4,3);
stem(abs(XK));
xlabel('k');
ylabel('magnitude of x(K)');
title('magnitude plot');
subplot(1,4,4);
stem(angle(XK));
xlabel('k');
ylabel('angle of x(K)');
title('phase plot');
13
INPUT:
XK = 4 0 0 0
OUTPUT:
0.9 0.8
3.5 3.5
0.8 0.6
3 3
0.7 0.4
2.5 2.5
magnitude of x(K)
0.6 0.2
angle of x(K)
amplitude
amplitude
0.5 2 2 0
0.4 -0.2
1.5 1.5
0.3 -0.4
1 1
0.2 -0.6
0.5 0.5
0.1 -0.8
0 0 0 -1
0 2 4 0 2 4 0 2 4 0 2 4
n n k k
RESULT:
Thus the frequency analysis using DFT was performed using MATLAB.
14
EXP.NO:5(a) DESIGN OF FIR FILTER USING HAMMING WINDOW
AIM:
SOFTWARE REQUIRED
MATLAB R2014a
ALGORITHM:
PROGRAM:
clc;
clearall;
closeall;
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
fp=input('Enter the passband frequency');
fs=input('Enter the stopband frequency');
f=input('Enter the sampling frequency');
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
y=hamming(n1);
disp('The window coefficient are as follows');y
b= fir1(n,wp,y);
disp('unit sample response of fir filter is h(n)=');b
disp(b);b
[h,o]=freqz(b,1,256);
15
m=20*log(abs(h));
subplot(2,2,1);
plot(o/pi,m);
ylabel('gain in dB');
xlabel('(a)normalized frequency');
title('LPF');
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);
ylabel('gain in dB');
xlabel('(b)normalized frequency');
title('HPF');
wn=[wpws];
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log(abs(h));
subplot(2,2,3);
plot(o/pi,m);
ylabel('gain in dB');
xlabel('(c)normalized frequency');
title('BPF');
wn=[wpws];
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log(abs(h));
subplot(2,2,4);
plot(o/pi,m);
ylabel('gain in dB');
xlabel('(d)normalized frequency');
title('BSF');
16
INPUT:
y=
0.0800
0.2147
0.5400
0.8653
1.0000
0.8653
0.5400
0.2147
0.0800
unit sample response of fir filter is h(n)=
b=
Columns 1 through 8
Column 9
-0.0061
Columns 1 through 8
Column 9
-0.0061
b=
Columns 1 through 8
Column 9
-0.0061
17
OUTPUT:
LPF HPF
0 0
-50 -10
gain in dB
gain in dB
-100 -20
-150 -30
-200 -40
0 0.5 1 0 0.5 1
(a) normalized frequency (b) normalized frequency
BPF BSF
50 0
0 -10
gain in dB
gain in dB
-50 -20
-100 -30
0 0.5 1 0 0.5 1
(c) normalized frequency (d) normalized frequency
RESULT:
Thus the FIR filter using hamming window is designed using MATLAB.
18
EXP.NO:5(b) DESIGN OF FIR FILTER USING HANNING WINDOW
AIM:
SOFTWARE REQUIRED:
MATLAB R2014a
ALGORITHM:
PROGRAM:
clc;
clearall;
closeall;
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
fp=input('Enter the passband frequency');
fs=input('Enter the stopband frequency');
f=input('Enter the sampling frequency');
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
y=hanning(n1);
disp('the window coefficient are as follows');y
b= fir1(n,wp,y);
disp('unit sample response of fir filter is h(n)=');b
disp(b);b
19
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m);
ylabel('gain in dB');
xlabel('(a)normalized frequency');
title('LPF');
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log(abs(h));
subplot(2,2,2);
plot(o/pi,m);
ylabel('gain in dB');
xlabel('(b)normalized frequency');
title('HPF');
wn=[wpws];
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log(abs(h));
subplot(2,2,3);
plot(o/pi,m);
ylabel('gain in dB');
xlabel('(c)normalized frequency');
title('BPF');
wn=[wpws];
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log(abs(h));
subplot(2,2,4);
plot(o/pi,m);
ylabel('gain in dB');
xlabel('(d)normalized frequency');
title('BSF');
20
INPUT:
b=
Columns 1 through 8
Column 9
-0.0071
Columns 1 through 8
Column 9
-0.0071
b=
Columns 1 through 8
Column 9
-0.0071
21
OUTPUT:
LPF HPF
0 50
-20 0
gain in dB
gain in dB
-40 -50
-60 -100
-80 -150
0 0.5 1 0 0.5 1
(a) normalized frequency (b) normalized frequency
BPF BSF
0 0
-50 -10
gain in dB
gain in dB
-100 -20
-150 -30
-200 -40
0 0.5 1 0 0.5 1
(c) normalized frequency (d) normalized frequency
RESULT:
Thus the FIR filter using hanning window is designed using MATLAB.
22
EXP.NO:5(c) DESIGN OF FIR FILTER USING KAISER WINDOW
AIM:
SOFTWARE REQUIRED:
MATLAB R2014a
ALGORITHM:
PROGRAM:
clc;
clearall;
closeall;
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
fp=input('Enter the passband frequency');
fs=input('Enter the stopband frequency');
f=input('Enter the sampling frequency');
beta=input(‘enter the beta value’);
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
y=kaiser(n1,beta);
disp('The window coefficient are as follows');y
b= fir1(n,wp,y);
disp('unit sample response of fir filter is h(n)=');b
disp(b);b
23
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m);
ylabel('gain in dB');
xlabel('(a)normalized frequency');
title('LPF');
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log(abs(h));
subplot(2,2,2);
plot(o/pi,m);
ylabel('gain in dB');
xlabel('(b)normalized frequency');
title('HPF');
wn=[wpws];
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log(abs(h));
subplot(2,2,3);
plot(o/pi,m);
ylabel('gain in dB');
xlabel('(c)normalized frequency');
title('BPF');
wn=[wpws];
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log(abs(h));
subplot(2,2,4);
plot(o/pi,m);
ylabel('gain in dB');
xlabel('(d)normalized frequency');
title('BSF');
24
INPUT:
Columns 9 through 11
Columns 1 through 8
Columns 9 through 11
Columns 9 through 11
25
OUTPUT:
LPF HPF
0 50
gain in dB -20 0
gain in dB
-40 -50
-60 -100
-80 -150
0 0.5 1 0 0.5 1
(a) normalized frequency (b) normalized frequency
BPF BSF
100 50
0
0
gain in dB
gain in dB
-50
-100
-100
-200 -150
0 0.5 1 0 0.5 1
(c) normalized frequency (d) normalized frequency
RESULT:
Thus the FIR filter using Kaiser Window was designed using MATLAB.
26
EXP.NO:5(d) DESIGN OF FIR FILTER USING RECTANGULAR WINDOW
AIM:
SOFTWARE REQUIRED:
MATLAB R2014a
ALGORITHM:
PROGRAM:
clc;
clear all;
close all;
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');
f=input('enter the sampling frequency');
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);
% computation for odd or even
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
% window function
y=boxcar(n1);
disp('the window coefficient are as follows');
27
% low pass filter design
b=fir1(n,wp,y);
disp('unit sample response of fir filter is h(n)=');b
% frequency response
[h,o]=freqz(b,1,256);
% to find gain
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m);
ylabel('gain in db');
xlabel('(a)normalised frequency');
title('LPF');
28
% band stop filter design
% fir filter design
wn=[wpws];
b=fir1(n,wn,'stop',y);
% frequency response
[h,o]=freqz(b,1,256);
% to find gain
m=20*log10(abs(h));
subplot(2,2,4);
plot(o/pi,m);
ylabel('gain in db');
xlabel('(d)normalised frequency');
title('BSF');
29
INPUT:
Y=1
Columns 1 through 7
Columns 8 through 9
-0.0391 -0.0834
30
Output Waveform:
LPF HPF
20 20
0 0
gain in db
gain in db
-20 -20
-40 -40
-60 -60
0 0.5 1 0 0.5 1
(a) normalised frequency (b) normalised freq
BPF BSF
20 10
0
0
gain in db
gain in db
-20
-10
-40
-60 -20
0 0.5 1 0 0.5 1
(c) normalised freq (d) normalised freq
RESULT:
Thus the FIR filter using Rectangular Window is designed using MATLAB.
31
EXP.NO:6 DESIGN OF BUTTERWORTHIIR FILTER
AIM:
SOFTWARE REQUIRED:
MATLAB R2014a
ALGORITHM:
PROGRAM:
clc;
clearall;
closeall;
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
wp=input('Enter the passband frequency');
ws=input('Enter the stopband frequency');
f=input('Enter the sampling frequency');
w1=2*wp/f;
w2=2*ws/f;
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn,'low');
[h,w]=freqz(b,a,512);
subplot(2,2,1);
plot(w/pi,abs(h));
ylabel('gain in dB');
xlabel('(a)normalized frequency');
title('LPF');
[b,a]=butter(n,wn,'high');
[h,w]=freqz(b,a,512);
subplot(2,2,2);
plot(w/pi,abs(h));
ylabel('gain in dB');
xlabel('(b)normalized frequency');
32
title('HPF');
wn1=[w1 w2];
[b,a]=butter(n,wn1);
[h,w]=freqz(b,a,512);
subplot(2,2,3);
plot(w/pi,abs(h));
ylabel('gain in dB');
xlabel('(c)normalized frequency');
title('BPF');
wn2=[w1 w2];
[b,a]=butter(n,wn2,'stop');
[h,w]=freqz(b,a,512);
subplot(2,2,4);
plot(w/pi,abs(h));
ylabel('gain in dB');
xlabel('(d)normalized frequency');
title('BSF');
33
INPUT
Enter the passbandripple6
Enter the stopbandripple20
Enter the passband frequency1000
Enter the stopband frequency2000
Enter the sampling frequency7000
OUTPUT:
LPF HPF
1 1
gain in dB
gain in dB
0.5 0.5
0 0
0 0.5 1 0 0.5 1
(a) normalized frequency (b) normalized frequency
BPF BSF
1 1.5
1
gain in dB
gain in dB
0.5
0.5
0 0
0 0.5 1 0 0.5 1
(c) normalized frequency (d) normalized frequency
RESULT:
34
EXP.NO:6(b) DESIGN OF CHEBYSHEV-I IIR FILTER
AIM:
SOFTWARE REQUIRED:
MATLAB R2014a
ALGORITHM:
PROGRAM:
clc;
clearall;
closeall;
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
wp=input('Enter the passband frequency');
ws=input('Enter the stopband frequency');
f=input('Enter the sampling frequency');
w1=2*wp/f;
w2=2*ws/f;
[n,wn]=cheb1ord(w1,w2,rp,rs);
[b,a]=cheby1(n,rp,wn,'low');
[h,w]=freqz(b,a,512);
subplot(2,2,1);
plot(w/pi,abs(h));
ylabel('gain in dB');
xlabel('(a)normalized frequency');
title('LPF');
[b,a]=cheby1(n,rp,wn,'high');
[h,w]=freqz(b,a,512);
subplot(2,2,2);
plot(w/pi,abs(h));
ylabel('gain in dB');
xlabel('(b)normalized frequency');
35
title('HPF');
wn1=[w1 w2];
[b,a]=cheby1(n,rp,wn1);
[h,w]=freqz(b,a,512);
subplot(2,2,3);
plot(w/pi,abs(h));
ylabel('gain in dB');
xlabel('(c)normalized frequency');
title('BPF');
wn2=[w1 w2];
[b,a]=cheby1(n,rp,wn2,'stop');
[h,w]=freqz(b,a,512);
subplot(2,2,4);
plot(w/pi,abs(h));
ylabel('gain in dB');
xlabel('(d)normalized frequency');
title('BSF');
36
INPUT
OUTPUT
LPF HPF
1 1
gain in dB
0 0
0 0.5 1 0 0.5 1
(a) normalized frequency (b) normalized frequency
BPF BSF
1 1
gain in dB
gain in dB
0.5 0.5
0 0
0 0.5 1 0 0.5 1
(c) normalized frequency (d) normalized frequency
RESULT:
37
EXP.NO:6(c) DESIGN OF CHEBYSHEV-II IIR FILTER
AIM:
SOFTWARE REQUIRED:
MATLAB R2014a
ALGORITHM:
PROGRAM:
clc;
clearall;
closeall;
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
wp=input('Enter the passband frequency');
ws=input('Enter the stopband frequency');
f=input('Enter the sampling frequency');
w1=2*wp/f;
w2=2*ws/f;
[n,wn]=cheb2ord(w1,w2,rp,rs);
[b,a]=cheby2(n,rp,wn,'low');
[h,w]=freqz(b,a,512);
subplot(2,2,1);
plot(w/pi,abs(h));
ylabel('gain in dB');
xlabel('(a)normalized frequency');
title('LPF');
[b,a]=cheby2(n,rp,wn,'high');
[h,w]=freqz(b,a,512);
subplot(2,2,2);
plot(w/pi,abs(h));
ylabel('gain in dB');
38
xlabel('(b)normalized frequency');
title('HPF');
wn1=[w1 w2];
[b,a]=cheby2(n,rp,wn1);
[h,w]=freqz(b,a,512);
subplot(2,2,3);
plot(w/pi,abs(h));
ylabel('gain in dB');
xlabel('(c)normalized frequency');
title('BPF');
wn2=[w1 w2];
[b,a]=cheby2(n,rp,wn2,'stop');
[h,w]=freqz(b,a,512);
subplot(2,2,4);
plot(w/pi,abs(h));
ylabel('gain in dB');
xlabel('(d)normalized frequency');
title('BSF');
39
INPUT
OUTPUT
LPF HPF
1 1
gain in dB
gain in dB
0.5 0.5
0 0
0 0.5 1 0 0.5 1
(a) normalized frequency (b) normalized frequency
BPF BSF
1 1.5
1
gain in dB
gain in dB
0.5
0.5
0 0
0 0.5 1 0 0.5 1
(c) normalized frequency (d) normalized frequency
RESULT:
40
EXP.NO: 7 STUDY OF ARCHITECTURE OF DIGITAL SIGNAL PROCESSOR
ARCHITECTURE:
The 54x DSP use an advanced, modified Harvard architecture that maximizes processing
power by maintaining one program memory bus and three data memory buses. These processors
also provide an arithmetic logic unit (ALU) that has a high degree of parallelism, application-
specific hardware logic, on chip memory and additional on –chip peripherals. These DSPs
families also provide a highly specialized instruction set which is the basis of the operational
flexibility and the speed of these DSPs. Separate program and the data spaces allow
simultaneous access to program instructions and data, providing the high degree of parallelism.
Two reads and one write operation can be performed in a single cycle. Instructions with parallel
store and application- specific instructions can fully utilize this architecture. In addition, data can
be transferred between data and program spaces. Such parallelism supports a powerful set of
arithmetic, logic and bit manipulation operations that can be performed in a single machine
cycle. Also included are the control mechanisms to manage interrupts, repeated operations and
function calls.
41
3. ACCUMULATORS:
The accumulators, ACCA and ACCB store the output from the ALU or the
Multiplier/adder block. The accumulators can provide a second input to the ALU or the
multiplier /adder. The bit in each accumulator is grouped as follows:
42
Guard bits (bits 32-39)
A high – order word (bits 16-31)
A low order word (bits 0-15)
4 barrel Shifter
The 54x’s barrel shifter has a 40-bit input connected to the accumulator or data memory
(CB, DB) and a 40-bit output connected to the ALU or data memory (EB). The barrel shifter
produces a left shift of 0 to 31 bits and a right shift of 0 to 16 bits on the input data. The shift
requirements are defined in the shift-count field (ASM) of ST1 or defined in the temporary
register (TREG), which is designed as a shift-count register. This shifter and the exponent
detector normalize the values in the accumulator in a single cycle. The least significant bits
(LSBs) of the output are filled with 0s and the most significant bits (MSBs) can neither be zero
filled or sign extended, depending on the state of the sign-extended mode bit (SXM) of
ST1.addtional shift capabilities enable the processor to perform numerical scaling, bit extraction,
extended arithmetic and overflow prevention operation.
5. MULTIPLIER/ADDER:
The multiplier /adder perform 17- bit 2’s complement multiplication with the 40-bit
accumulation in a single instruction cycle. The multiplier /adder block consists of several
elements such as multiplier, adder, signed /unsigned input control, fractional control, a zero
detector, a rounder (2’s complement), overflow/saturation logic and TREG. The multiplier has
two inputs: one input is selected from the TREG, a data memory operand or an accumulator; the
other is selected from the program memory, the data memory, an accumulator or an immediate
value. The fast on-chip multiplier allows the 54x to perform operations such as convolution,
correlation and filtering efficiently. In addition, the multiplier and ALU together execute
multiply/accumulate (MAC) computations and ALU operations in parallel in a single instruction
cycle. This function is used in determining the Euclid distance and in implementing symmetrical
and least mean square (LMS) filters which are required for complex DSP algorithms.
43
and the transition (TRN) register to keep their transition histories and selects the larger word in
the accumulator to be stored in data memory. The CSSU also accelerates Veterbi type butterfly
computation with optimized on – chip hardware.
44
with the shift operation such as ADD, LD and SUB. It also can hold a dynamic bit address for
the BITT instruction. The EXP instruction stores the exponent value computed into the TREG
while the NORM instruction uses the TREG value to normalize the number. For ACS operation
of Viterbi decoding, TREG holds branch metrics used by the DADST and DSADT instructions.
45
16. PROCESSOR-MODE STATUS REGISTER:
The processor – mode status register (PMST) controls memory configurations of the 54x
devices.
46
EXP.NO: 8(a)PERFORM MAC OPERATION USING VARIOUS ADDRESSING MODES
AIM:
To write an assembly language program for the study of direct, indirect and immediate
addressing modes using TMS320C5X.
TOOLS REQUIRED:
DSP HARDWARE:
DSP SOFTWARE:
Assembler
Loader
Debugger
ALGORITHM:
PROGRAM:
47
lap #20h ; the data page number 20h(32) is loaded into
accumulator
lacc 10h ; content of 20h(32) page 10h location
lac 5h,2
lar Aro,#15h ; AR0 loaded with content of dma 1115h
sacl 15h
sacl20h,3 ; accumulator low byte is left shifted by 3 bits and
stored in into dma 1120h
getdata samm ART ;accumulator low byte stored into ART in page0 DP
remains unaffected
ldp #12h ;the data page number 12h is loaded in DP
add 25h
add 7h,2
sub 10h ;the content of dma 0910h is subtracted from the
content of accumulator
sub 12h,2
splk #10h,TREGO ;constant 10h is stored into TREGO
mpy 15h
REG1 .set 010ch
REG2 .set 020ah
REG4 .set 0415h
REG5 .set 0505h
.include “c:/ac0 1inz.asm”
.end ; program end
48
lacc *,4,AR1 ;content of dma 1000h left shifted by 4 bits and loaded
into accumulator. ARP points to auxiliary register 1
lar AR1,#,1010h
sacl * ;accumulator low byte is stored into the dma pointed by
AR1
sacl*+,2,AR0 ;accumulator low byte is shifted by 2 bits and stored
into the dma pointed in AR1
lacc*-2,AR1
getdata lacc*0+
lacc *BR0+ ;accumulator loaded with content of dma pointed by
AR1 and the content of INDEX register added to AR1
with the reverse carry propagation
add #+.0.ar0
sub *.-2 ;content of dma pointed by AR1 is added from the
content of accumulator. The result is stored into the
accumulator AR0is decremented by 1.
splk #10h,TREGO ;constant 10h is stored into TREGO
mpy * ;content of 0915h is multiplied with the content of
TREGO and the result is stored into PREG
REG1 .set 010ch
REG2 .set 020ah
REG4 .set 0415h
REG5 .set 0505h
.include “c:/ac0 1inz.asm”
.end ; program end
49
mpy#0010h ;0010h is multiplied with the content of TREGO
sub #0022h
sub #0011h,3 ;0011h is left shifted by 3 bits subtracted from the
content of accumulator
REG1 .set 010ch
REG2 .set 020ah
REG4 .set 0415h
REG5 .set 0505h
.include “c:/ac0 1inz.asm”
.end ; end of program
RESULT:
Thus the assembly language program for the study of direct, indirect and immediate
addressing modes was written and executed successfullyusing TMS320C5X.
50
EXP.NO:9 GENERATION OF VARIOUS SIGNALS AND RANDOM NOISE
AIM:
To write an assembly language program for the generation of sine wave using
TMS320C5X.
TOOLS REQUIRED:
DSP HARDWARE:
DSP SOFTWARE:
Assembler
Loader
Debugger
ALGORITHM:
PROGRAM:
.ds 1000h
.include "sinetbl.dat" ;load 800 point wavetable
;f1= fs/D = 8000/800 = 10hz.
.ds 0f00h
temp .word 0
mod .word 100 ;Required freq. = mod * f1 = 100*10 = 1000hz.
scale .q15 0.5
;
;Interrupt vectors
;
.ps 080ah
51
rint b getdata ;receive interrupt
xint b xint ;transmit interrupt
;
;Processor initialization
;
.include "c5xinz.asm"
;
;Receive interrupt handler
;
getdata splk #1,gotflag ;set a flag to indicate data available.
lamm DRR
ldp #mod ;set data page pointer.
lacc mod ;load modifier
samm INDX ;store modifier in INDX register.
callwavgen ;calculate current sample output from
wavetable.
and #0FFFCh,0 ;only 14 MSBs are used in ADC &DAC,So
; mask unused two LSBs.
samm DXR ;send digital data to DAC to produce analog
o/p.
clrc INTM ;enable interrupt.
rete ;return back to main from interrupt routine.
52
;
;AC01 register initialization.
;
REG1 .set 0124h
REG2 .set 0212h
REG4 .set 0417h
REG5 .set 0505h
;
;Serial port and AC01 initialization
;
.include "ac01inz.asm"
53
TABULATION:
OUTPUT:
RESULT:
Thus the assembly language program for the generation of sine waveform was written
and executed successfullyusing TMS320C5X.
54
EXP.NO:10(a) IMPLEMENTATION OF FIR LOW PASS FILTER
AIM:
To write an assemble language program for the implementation of FIR low pass filter
using TMS320C5X.
TOOLS REQUIRED:
DSP HARDWARE:
DSP SOFTWARE:
Assembler
Loader
Debugger
ALGORITHM:
PROGRAM:
;
;Interrupt vectors
;
55
.ps 080ah
;
;Processor initialization
;
.include "c5xinz.asm"
;
;Internal memory initialization
;
mar *,AR0
lar AR0,#0200h ;copy 201 co-efficients
rpt #200 ;to address 200h-2C8h(B0).
bldd #FIR_COEFFS,*+,AR0
;
;Receive interrupt handler
;
56
getdata splk #1,gotflag ;set a flag to indicate data available.
lamm DRR ;read ADC data from DRR register.
and #0fffch ;mask LSB two bits.
ldp #rbuf
saclrbuf
lacc rbuf,13 ;load accu-high with ADC data.
ldp #06h ;set page pointer = 6.
sach 0 ;store ADC data(address=300h).
mar *,AR1
lar AR1,#3C8h ;load AR1 with data buffer end addr.
;(data memory).
;
;FILTERING.
;
setc CNF ;convert B0 to program memory.
mpy #0 ;clear product reg.
lacl #0 ;clear accumulator.
rpt #200 ;repeat MACD insru. 201 times.
macd #0ff00h,*- ;convolution process.
apac ;get result in accumulator.
sach 0 ;store result in data buffer.
lacc 0,4
ldp 0
samm DXR ;send digital ADC data to DAC.
clrc CNF ;convert B0 to data memory.
rete ;return from interrupt.
;
;AC01 register initialization.
;
REG1 .set 0124h
REG2 .set 0212h
REG4 .set 0415h
REG5 .set 0505h
;
;Serial port and AC01 initialization
;
.include "ac01inz.asm"
57
TABULATION:
OUTPUT
RESULT:
Thus the assembly language program for the implementation of FIR low pass filter was
written and executed successfullyusing TMS320C5X.
58
EXP.NO:10 (b) IMPLEMENTATION OF FIR HIGH PASS FILTER
AIM:
To write an assembly language program for the implementation of FIR high pass filter
using TMS320C5X.
TOOLS REQUIRED:
DSP HARDWARE:
DSP SOFTWARE:
Assembler
Loader
Debugger
ALGORITHM:
PROGRAM:
59
.ps 080ah
.include "c:\fepl\c5xinz.asm"
;
;Internal memory initialization
;
mar *,AR7
lacl #0
lar AR7,#300h ;clear 300 to 3ffh(data array).
rpt #255
sacl *+
mar *,AR0
lar AR0,#0200h ;copy 201 co-efficients
rpt #200 ;to address 200h-2C8h(B0).
blkd COEFFS,*+,AR0
splk #012h,IMR
call ac01_init ;call to initialize serial port & AC01.
clrc INTM
60
saclrbuf
lacc rbuf,13
ldp #06h
sach 0
mar *,AR1
lar AR1,#3C8h ;load AR1 with data buffer end addr.
setc CNF
mpy #0
lacl #0
rpt #200
macd #0ff00h,*- ;convolution process.
apac
sach 0
lacc 0,4
ldp 0
samm DXR
clrc CNF
rete
;
;AC01 register initialization.
;
REG1 .set 0124h
REG2 .set 0212h
REG4 .set 0415h
REG5 .set 0505h
;
;Serial port and AC01 initialization
;
.include "c:\fepl\ac01inz.asm"
61
TABULATION:
OUTPUT:
RESULT:
Thus the assembly language program for the implementation of FIR high low pass filter
was written and executed successfully using TMS320C5X.
62
EXP.NO:11 IMPLEMENTATION OF IIR FILTER
AIM:
To write an assembly language program for the implementation of IIR filter using
TMS320C5X.
TOOLS REQUIRED:
DSP HARDWARE:
DSP SOFTWARE:
Assembler
Loader
Debugger
ALGORITHM:
PROGRAM:
63
.include "bilinear.cof" ;bilinear IIR filter coefficients
.include "invarian.cof" ;invariance IIR filter coefficients
.ps 080ah
splk #012h,IMR
call ac01_init ;call to initialize serial port & AC01.
lacl #0
ldp #DN
sacl DN ;clear input data delay line.
sacl DNM1
sacl DNM2
clrc INTM
lacc XN,15
lt DNM1
mpy A1
lta DNM2
mpy A2
apac ;DN = x(n) + d(n-1)*a1 + d(n-2)*a2
sach DN,0 ;store pole result
lacl #0
mpy B2
ltd DNM1
mpy B1
64
ltd DN
mpy B0
apac
sach YN,3 ;Y(n) = d(n)*b0 + d(n-1)*b1 + d(n-2)*b2
lacc YN,0 ;store y(n) result
and #0FFFCh,0
samm DXR ;output the filter response y(n) to AIC.
rete
65
TABULATION:
OUTPUT:
RESULT:
Thus the assembly language program for the implementation of IIR filter was written and
executedsuccessfully using TMS320C5X.
66
EX.No: 12 IMPLEMENT AN UP-SAMPLING AND DOWN-SAMPLING
OPERATION IN DSP PROCESSOR
AIM:
To write an assembly language program for sampling the given input signal using
TMS320C5X.
TOOLS REQUIRED:
DSP HARDWARE:
DSP SOFTWARE:
Assembler
Loader
Debugger
ALGORITHM:
PROGRAMM
.entry
.include "c5xinz.asm"
lar AR2,#1000h
splk #012h,IMR ;enable RINT & INT2.
67
call ac01_init ;call to initialize serial port & AC01.
hlt: b hlt
getdatasplk #1,gotflag ;set a flag to indicate data available.
lamm DRR ;read ADC data from DRR register.
and #0fffch ;mask LSB two bits.
68
TABULATION:
OUTPUT:
RESULT:
Thus the assembly language program for the sampling operation was written and
executed successfully using TMS320C5X.
69
EXP.NO: LINEAR CONVOLUTION
AIM:
70
TOOLS REQUIRED:
DSP HARDWARE:
DSP SOFTWARE:
Assembler
Loader
Debugger
ALGORITHM:
Include memory mapped register and set pointer program memory and data memory.
Append 0’s buffer and after impulse response no of zero in length of input sequence.
Zero accumulator and product register.
Multiply accumulator program memory with data memory.
Each time program memory is incremented by one and data memory decremented by one.
Repeat step 4 for n+1 timer where n is length of largest sequence.
Decrement count value ARZ if ARZ≠0 go to step3.
PROGRAM:
71
SACL*+.0.AR0 ; one result is stored
ADRK#7H
MAR*,AR2
MAR*
BANZ loop
.end ; end of program
72
INPUT: OUTPUT:
1000 01 1020 03
1001 02
1021 10
1002 03
1022 22
1003 02
1023 28
1004 01
1024 26
1005 03
1006 04 1025 10
1007 05 1026 05
1008 00 1027 00
RESULT:
Thus the assembly language program for linear convolution was written and executed
successfully using TMS320C5X.
73
EXP.NO: 13 STUDY OF ANTI- ALIASING FILTER
Antialiasing filters:
Anti-aliasing filters are always analog filters as they process the signal before it is
sampled. In most cases, they are also low-pass filters unless band-pass sampling techniques are
used.The sampling process incorporating an ideal low-pass filter as the anti-alias filter is shown
below. The ideal filter has a flat passband and the cut-off is very sharp. Since the cut-off
frequency of this filter is half of that of the sampling frequency, the resulting replicated spectrum
of the sampled signal do not overlap each other. Thus no aliasing occurs.
If the sampling frequency does not satisfy the sampling theorem (i.e., the sampled signal
has frequency components greater than half the sampling frequency), then the sampling process
creates new frequency components .This phenomenon is called aliasing and must obviously be
avoided in a digital control system. Hence, the continuous signal to be sampled must not include
significant frequency components greater than the Nyquist frequency ωs/2.
74
For this purpose, it is recommended to low-pass filter the continuous signal before sampling,
especially in the presence of high-frequency noise. The analog low-pass filter used for this
purpose is known as the antialiasing filter. The antialiasing filter is typically a simple first-order
RC filter, but some applications require a higher-order filter such as a Butterworth or a Bessel
filter. The overall control scheme is shown below.
Because a low-pass filter can slow down the system by attenuating high-frequency dynamics,
the cutoff frequency of the low-pass filter must be higher than the bandwidth of the closed-loop
system so as not to degrade the transient response. A rule of thumb is to choose the filter
bandwidth equal to a constant time the bandwidth of the closed-loop system. The value of the
constant varies depending on economic and practical considerations. For a conservative but more
expensive design, the cutoff frequency of the low-pass filter can be chosen as 10 times the
bandwidth of the closed-loop system to minimize its effect on the control system dynamics, and
then the sampling frequency can be chosen 10 times higher than the filter cutoff frequency so
there is a sufficient attenuation above the Nyquist frequency. Thus, the sampling frequency is
100 times the bandwidth of the closed-loop system. To reduce the sampling frequency, and the
associated hardware costs, it is possible to reduce the antialiasing filter cutoff frequency. In the
extreme case, we select the cutoff frequency slightly higher than the closed-loop bandwidth. For
a low-pass filter with a high roll-off (i.e., a high-order filter), the sampling frequency is chosen as
five times the closed-loop bandwidth. In summary, the sampling period T can be chosen in
general as 5ωb≤2πT≤100ωb where ωb is the bandwidth of the closed-loop system.
75
EX.No: 14 CONVERSION OF ANALOG TO DIGITAL FILTERS
AIM:
To write a program for the conversion of analog to digital filters using MATLAB.
SOFTWARE REQUIRED:
MATLAB R2014a
ALGORITHM:
PROGRAM:
alpha = 0.2;
fs = 200; % Sample Frequency [Hz]
% Laplace Domain
B = 1;
A = [1, alpha];
w = 0:0.2:(fs / 2);
h = freqs(B, A, w);
figure;
plot(w, abs(h .* conj(h)));
% Digital Filter
[b, a] = bilinear(B, A, fs);
figure;
freqz(b, a, 1000);
% Frequency Response of the filter
f = 2;
fs = 10;
[b,a] = butter(6,2*pi*f,'s');
[bz,az] = impinvar(b,a,fs);
freqz(bz,az,1024,fs)
% Impulse Response of the Digital filter
fs = 10;
[b,a] = ellip(3,1,60,2*pi*2.5,'s');
[bz,az] = impinvar(b,a,fs);
impz(bz,az,[],fs)
76
OUTPUT:
77
RESULT:
Thus the analog filter was converted to digital filter using MATLAB.
78