100% found this document useful (2 votes)
747 views48 pages

EC3492-DIGITAL SIGNAL LABORATORY Manual

This document contains MATLAB programs to generate basic discrete time signals and perform linear and circular convolutions. It includes programs to generate unit step, unit ramp, sine, cosine, exponential and unit impulse signals. It also has programs for linear convolution, circular convolution, auto correlation and cross correlation with input from the user.

Uploaded by

geethamom6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
747 views48 pages

EC3492-DIGITAL SIGNAL LABORATORY Manual

This document contains MATLAB programs to generate basic discrete time signals and perform linear and circular convolutions. It includes programs to generate unit step, unit ramp, sine, cosine, exponential and unit impulse signals. It also has programs for linear convolution, circular convolution, auto correlation and cross correlation with input from the user.

Uploaded by

geethamom6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 48

EXP.

NO : 1 GENERATION OF ELEMENTARY DISCRETE-TIME


DATE : SEQUENCES

AIM:
To generate a discrete time signal sequence (Unit step, Unit ramp, Sine, Cosine, Exponential, Unit
impulse) using MATLAB function.

APPARATUS REQUIRED:

SL.NO. APPARATUS /COMPONENT SPECIFICATION QTY


1. Personal computer with windows 7 -- 1
2. MATLAB R2013a version -- 1

PROCEDURE:
 Start the Program
 Get the dimension of ‘a’
 Discrete output is obtained for a>=0 and zeros of all other values.
 Output is generated in stem format
 Terminate the process.

PROGRAMS: (GENERATION OF BASIC SIGNALS)

%Program for generation of sine wave


t=0:0.01: pi;
y=sin(2*pi*t);
subplot(3,1,2);
stem(t,y);
ylabel('amplitude');
xlabel('time period');
title('sine wave')

1
%Program for generation of cosine wave
t=0:0.01: pi;
y=cos(2*pi*t);
subplot(3,1,3);
stem(t,y);
ylabel('amplitude');
xlabel('time period');
title('cosine wave')

%Program for generation of unit impulse signal


t=-3:1:3;
y=[zeros(1,3),ones(1,1),zeros(1,3)];
Subplot (2, 2,1);
stem (t,y);
ylabel('amplitude');
xlabel('time period');
title('unit impulse')

%Program for generation of unit step signal


n=input('enter the sample length of unit step sequence');
t=0:1:n-1;
y=ones(1,n);
subplot(2,2,2);
stem(t,y);
ylabel('amplitude');
xlabel('sequence');
title('unit step')

2
%Program for generation of unit ramp signal
n1=input('enter the sample length of unit ramp sequence');
t=0:n1;
subplot(2,2,3);
stem(t,t);
ylabel('amplitude');
xlabel('sequence');
title('unit ramp')

%Program for generation of exponential signal:


n2=input('enter the length of the exponential sequence');
t=0:n2;
a=input('enter the a value');
y2=exp(a*t);
subplot(2,2,4);
stem(t,y2);
ylabel('amplitude');
xlabel('time period');
title('exponential sequence')

OUTPUT:

3
Enter the sample length of unit step sequence 8
Enter the length of ramp sequence 6
Enter the length of the exponential sequence 8
Enter the n value 5

unit impulse unit step


1 1
amplitude

amplitude
0.5 0.5

0 0
-4 -2 0 2 4 0 2 4 6 8
time period sequence
17
unit ramp x 10 exponential sequence
6 3
amplitude

amplitude

4 2

2 1

0 0
0 2 4 6 0 2 4 6 8
sequence time period

RESULT:
Thus the MATLAB programs for discrete time signal sequence (Unit step, Unit ramp, Sine, Cosine,
Exponential, Unit impulse) using MATLAB function written and the results were plotted.

EXP.NO : 2
LINEAR AND
4 CIRCULAR CONVOLUTIONS
DATE :
AIM:
To write MATLAB programs for Linear And Circular Convolutions

APPARATUS REQUIRED:

SL.NO. APPARATUS /COMPONENT SPECIFICATION QTY


1. Personal computer with windows 7 -- 1
2. MATLAB R2013a version -- 1

PROCEDURE:
 Start the MATLAB program.
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 If any error occurs in the program correct the error and run it again
 For the output see command window\ Figure window
 Stop the program.

PROGRAM:

%Program for linear convolution


%to get the input sequence
n1=input('enter the length of input sequence');
n2=input('enter the length of impulse sequence');
x=input('enter the input sequence');
h=input('enter the impulse sequence');
%convolution operation
y=conv(x,h);
%to plot the signal
subplot(3,1,1);
5
stem(x);
ylabel('amplitude');
xlabel('n1....>');
title('input sequence')
subplot(3,1,2);
stem(h);
ylabel('amplitude');
xlabel('n2....>');
title('impulse signal')
subplot(3,1,3);
stem(y);
ylabel('amplitude');
xlabel('n3');
disp('the resultant signal is');y

% Program for circular convolution


clc;
clear all;
close all;
%to get the input sequence
g=input('enter the input sequence');
h=input('enter the impulse sequence');
N1=length(g);
N2=length(h);
N=max(N1,N2);
N3=N1-N2
%loop for getting equal length sequence
if(N3>=0)
h=[h,zeros(1,N3)];
else
g=[g,zeros(1,-N3)];
end

6
%computation of circular convoluted sequence
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)+g(i)*h(j);
end
end
figure;
subplot(3,1,1);
stem(g);
ylabel('amplitude');
xlabel('n1..>');
title('input sequence')
subplot(3,1,2);
stem(h);
ylabel('amplitude');
xlabel('n2');
title('impulse sequence')
subplot(3,1,3);
stem(y);
ylabel('amplitude');
xlabel('n3');
disp('the resultant signal is');

7
OUTPUT : LINEAR CONVOLUTION

Enter the length of input sequence 4


Enter the length of impulse sequence 4
Enter the input sequence [1 2 3 4]
Enter the impulse sequence [4 3 2 1]
The resultant signal is
y= [ 4 11 20 30 20 11 4]

input sequence
4
amlitude

0
1 1.5 2 2.5 3 3.5 4
n1....>
impulse signal
4
amlitude

0
1 1.5 2 2.5 3 3.5 4
n2....>

40
amlitude

20

0
1 2 3 4 5 6 7
n3

8
OUTPUT : CIRCULAR CONVOLUTION
Enter the input sequence [1 2 2 1]
Enter the impulse sequence [4 3 2 1]
The resultant signal is
y = [ 15 17 15 13 ]

input sequence
2
amplitude

0
1 1.5 2 2.5 3 3.5 4
n1..>
impulse sequence
4
amplitude

0
1 1.5 2 2.5 3 3.5 4
n2

20
amplitude

10

0
1 1.5 2 2.5 3 3.5 4
n3

RESULT:
Thus the MATLAB programs for linear convolution and circular convolution written and the results
were plotted.

EXP.NO : 3
AUTO CORRELATION AND CROSS CORRELATION
DATE : 9
AIM:
To write MATLAB programs for auto correlation and cross correlation

APPARATUS REQUIRED:

SL.NO. APPARATUS /COMPONENT SPECIFICATION QTY


1. Personal computer with windows 7 -- 1
2. MATLAB R2013a version -- 1

PROCEDURE:
 Start the MATLAB program.
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 If any error occurs in the program correct the error and run it again
 For the output see command window\ Figure window
 Stop the program.

PROGRAM: (Cross-Correlation of the Sequences)

clc;
clear all;
close all;
x=input('Enter the sequence 1: ');
h=input('Enter the sequence 2: ');
y=xcorr(x,h);
figure;
subplot(3,1,1); stem(x);

10
xlabel('n->');
ylabel('Amplitude->');
title('Input sequence 1');
subplot(3,1,2);
stem(fliplr(y));
stem(h);
xlabel('n->');
ylabel('Amplitude->');
title('Input sequence 2');
subplot(3,1,3);
stem(fliplr(y));
xlabel('n->');
ylabel('Amplitude->');
title('Output sequence');
disp('The resultant is');
fliplr(y);

OUTPUT: (Cross-Correlation of the Sequences)

Enter the sequence 1: [1 3 5 7]


Enter the sequence 2: [2 4 6 8]

11
PROGRAM: (Auto Correlation Function)
clc;
close all;
clear all;
x=input('Enter the sequence 1: ');
y=xcorr(x,x);
figure;
subplot(2,1,1);
stem(x);
ylabel('Amplitude->');
xlabel('n->');
title('Input sequence');
subplot(2,1,2);
stem(fliplr(y));
ylabel('amplitude');
xlabel('n->');
title('Output sequence');
disp('the resultant is ');
fliplr(y);

OUTPUT: (Auto Correlation Function)


Enter the sequence [1 2 3 4]

12
RESULT:
Thus the MATLAB programs for auto correlation and cross correlation written and the results were
plotted

EXP.NO : 4
FREQUENCY
13 ANALYSIS USING DFT
DATE :
AIM:
To write MATLAB programs for Frequency Analysis using DFT

APPARATUS REQUIRED:

SL.NO. APPARATUS /COMPONENT SPECIFICATION QTY


1. Personal computer with windows 7 -- 1
2. MATLAB R2013a version -- 1

PROCEDURE:
 Start the MATLAB program.
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 If any error occurs in the program correct the error and run it again
 For the output see command window\ Figure window
 Stop the program.

PROGRAM: (COMPUTATION OF FFT OF A SIGNAL)


%program for computation of fft
Clear all;
Close all;
xn=input('enter the input sequence');
n=input ('enter the number of points in fft');
l=length (xn);
if (n<1)
disp (n>=1);
end
xk=fft(xn,n);
stem(xk);
14
xlabel('real axis');
ylabel('imaginary axis');
title('fft');
disp('the values....');xk

OUTPUT:

PROGRAM: (Spectrum Analysis Using DFT)

N=input('type length of DFT= ');


T=input('type sampling period= ');
freq=input('type the sinusoidal freq= ');
k=0:N-1;
f=sin(2*pi*freq*1/T*k); F=fft(f); stem(k,abs(F));
grid on; xlabel('k');
ylabel('X(k)');

INPUT:
type length of DFT=32
type sampling period=64
type the sinusoidal freq=11

15
OUTPUT:

RESULT:
Thus the Spectrum Analysis of the signal using DFT is obtained using MATLAB.

EXP.NO : 5 DESIGN OF FIR FILTERS (LPF/HPF/BPF/BSF)


16
DEMONSTRATES THE FILTERING OPERATION
DATE :
AIM:
To write a program to design the FIR low pass, High pass, Band pass and Band stop filters using
RECTANGULAR & HANNING window and find out the response of the filter by using MATLAB.

APPARATUS REQUIRED:

SL.NO. APPARATUS /COMPONENT SPECIFICATION QTY


1. Personal computer with windows 7 -- 1
2. MATLAB R2013a version -- 1

PROCEDURE:
 Start the MATLAB program.
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 If any error occurs in the program correct the error and run it again
 For the output see command window\ Figure window
 Stop the program.

PROGRAM: (Rectangular Window)


%program for the design of FIR low pass, high pass, band pass and band stop
filter using rectangular window
clc;
clear all;
close all;
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');

17
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=boxcar(n1);
%lowpass filter
b=fir1(n,wp,y);
[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.....>');
%highpass filter
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......>');
%bandpass filter
wn=[wp ws];0
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));

18
subplot(2,2,3);
plot(o/pi,m);
ylabel('gain in db....>');
xlabel('(c)normalized frequency....>');
%bandstop filter
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);
ylabel('gain in db....>');
xlabel('(d)normalized frequency.....>');

OUTPUT

PROGRAM: (Hanning Window)

19
%program for the design of FIR lowpass, high pass, band pass, band stop filter
using hanning window
clc;
clear all;
close all;
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);

%lowpass filter
b=fir1(n,wp,Y);
[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');

%highpass filter

20
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...>');

%bandpass filter
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);
ylabel('gain in db.....>');
xlabel('(c)normalized frequency....>');

%bandstop filter
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);
ylabel('gain in db...>');
xlabel('(d)normalized frequency....>')

OUTPUT:

21
RESULT:
Thus the program to design FIR low pass, high pass, band pass and band stop Filters using
Rectangular & Hanning Window was written and response of the filter using MATLAB was
executed.

EXP.NO : 6 DESIGN OF BUTTERWORTH AND CHEBYSHEV IIR FILTERS


(LPF/HPF/BPF/BSF)
22 AND DEMONSTRATE THE FILTERING
DATE : OPERATIONS
AIM:
To write a program to design the IIR Butterworth & Chebyshew Filter (LPF/HPF/BPF/BSF) by
using MATLAB.

APPARATUS REQUIRED:

SL.NO. APPARATUS /COMPONENT SPECIFICATION QTY


1. Personal computer with windows 7 -- 1
2. MATLAB R2013a version -- 1

PROCEDURE:
 Start the MATLAB program.
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 If any error occurs in the program correct the error and run it again
 For the output see command window\ Figure window
 Stop the program.

PROGRAM:
% Butterworth filter
% get the input values
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband frequency');
ws=input('enter the stopband frequency');
fs=input('enter the sampling frequency');
w1=2*wp/fs;
w2=2*ws/fs;
%filter order
23
[n,wn]=buttord(w1,w2,rp,rs);
%lowpass filter
%either coefficient
[b,a]=butter(n,wn);
%frequency response
[h,w]=freqz(b,a,512);
subplot(2,2,1);
plot(w,abs(h));
xlabel('normalized frequency');
ylabel('abs(h)');
title('lpf')
%high pass filter
%filter coefficient
[b,a]=butter (n,wn,'high');
%frequency response
[h,w]=freqz(b,a,512);
subplot(2,2,2);
plot(w,abs(h));
xlabel('normalised frquency');
ylabel('abs(h)');
title('hpf')
%band pass filter
%filter coefficient
wn1=[w1 w2];
[b,a]=butter(n,wn1);
%frequency response
[h,w]=freqz(b,a,512);
subplot(2,2,3);
plot(w,abs(h));
xlabel('normalised frequency');
ylabel('abs(h)');
title('bpf')

24
%band pass filter
%filter coefficient
wn2=[w1 w2];
[b,a]=butter(n,wn2,'stop');
%frequency response
[h,w]=freqz(b,a,512);
subplot(2,2,4);
plot(w,abs(h));
xlabel('normalised frequency');
ylabel('abs(h)');
title('bsf')

% chebyshew filter

% get the input values


rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband frequency');
ws=input('enter the stopband frequency');
fs=input('enter the sampling frequency');
w1=2*wp/fs;
w2=2*ws/fs;
%filter order
[n,wn]=cheb1ord(w1,w2,rp,rs);
%lowpass filter
%either coefficient
[b,a]=cheby1(n,rp,wn);
%frequency response
[H,w]=freqz(b,a,512);
subplot(2,2,1);
plot(w,abs(H));
xlabel('normalised frequency');
ylabel('abs(H)');
title('LPF')
25
%high pass filter
%filter coefficient
[b,a]=cheby1(n,rp,wn,'High');
%frequency response
[H,w]=freqz(b,a,512);
subplot(2,2,2);
plot(w,abs(H));
xlabel('normalised frequency');
ylabel('abs(H)');
title('HPF')
%band pass filter
%filter coefficient
wn1=[w1,w2];
[b,a]=cheby1(n,rp,wn1);
%frequency response
[H,w]=freqz(b,a,512);
subplot(2,2,3);
plot(w,abs(H));
xlabel('normalised frequency');
ylabel('abs(H)');
title('BPF')
%band stop filter
%filter coefficient
wn2= [w1, w2];
%frequency response
[b,a]=cheby1(n,rp,wn2,'stop');
[H,w]=freqz(b,a,512);
subplot(2,2,4);
plot(w,abs(H));
xlabel('normalised frequency');
ylabel('abs(H)');
title('BSF')

OUTPUT
26
IIR : (BUTTERWORTH FILTER)

Enter the pass band ripple 6


lpf hpf
1 1
Enter the stop band ripple 25
Enter the pass band frequency 1300

abs(h)

abs(h)
0.5 0.5
Enter the stop band frequency 3000
Enter the sampling frequency 8000
0 0
0 1 2 3 4 0 1 2 3 4
normalized frequency normalised frquency
bpf bsf
1 1
abs(h)

abs(h)
0.5 0.5

0 0
0 1 2 3 4 0 1 2 3 4
normalised frequency normalised frequency

IIR : (CHEBYSHEW FILTER)

Enter the pass band ripple 6


LPF HPF
Enter the stop band ripple 25 1 1

Enter the pass band frequency 1300


abs(H)

abs(H)

0.5 0.5
Enter the stop band frequency 3000
Enter the sampling frequency 8000
0 0
0 1 2 3 4 0 1 2 3 4
normalised frequency normalised frequency
BPF BSF
1 1
abs(H)

abs(H)

0.5 0.5

0 0
0 1 2 3 4 0 1 2 3 4
normalised frequency normalised frequency

27
RESULT:
Thus the program to design IIR Butterworth & Chebyshew Filter (LPF/HPF/BPF/BSF) by using
MATLAB was executed.

EXP.NO : 7
STUDY OF ARCHITECTURE
28 OF DIGITAL SIGNAL PROCESSOR
DATE :
AIM:
To study the architecture of digital signal processor TMS320C6678/6718.

ARCHITECTURE OF DIGITAL SIGNAL PROCESSOR – TMS320C6678/6718

Functional Block Diagram of TMS320C6678 DSP Processor

BASIC ARCHITECTURAL FEATURES

29
A programmable DSP device should provide instructions similar to a conventional microprocessor. The
instruction set of a typical DSP device should include the following,
a. Arithmetic operations such as ADD, SUBTRACT, MULTIPLY etc
b. Logical operations such as AND, OR, NOT, XOR etc
c. Multiply and Accumulate (MAC) operation
d. Signal scaling operation
In addition to the above provisions, the architecture should also include,
a. On chip registers to store immediate results
b. On chip memories to store signal samples (RAM)
c. On chip memories to store filter coefficients (ROM)

DSP COMPUTATIONAL BUILDING BLOCKS


Each computational block of the DSP should be optimized for functionality and speed and in the
meanwhile the design should be sufficiently general so that it can be easily integrated with other
blocks to implement overall DSP systems.

Multipliers
The advent of single chip multipliers paved the way for implementing DSP functions on a VLSI
chip. Parallel multipliers replaced the traditional shift and add multipliers now days. Parallel
multipliers take a single processor cycle to fetch and execute the instruction and to store the result.
They are also called as Array multipliers.
The key features to be considered for a multiplier are
a. Accuracy
b. Dynamic range
c. Speed
Shifters
Shifters are used to either scale down or scale up operands or the results.
Barrel Shifters
In conventional microprocessors, normal shift registers are used for shift operation. As it requires one
clock cycle for each shift, it is not desirable for DSP applications, which generally involves more
shifts. In other words, for DSP applications as speed is the crucial issue, several shifts are to be
accomplished in a single execution cycle. This can be accomplished using a barrel shifter, which
connects the input lines representing a word to a group of output lines with the required shifts
determined by its control inputs.
Multiply and Accumulate Unit

30
Most of the DSP applications require the computation of the sum of the products of a series of
successive multiplications. In order to implement such functions a special unit called a multiply and
Accumulate (MAC) unit is required.
Arithmetic and Logic Unit
A typical DSP device should be capable of handling arithmetic instructions like ADD, SUB, INC,
DEC etc., and logical operations like AND, OR, NOT, XOR etc.
On-chip Memories
In order to have a faster execution of the DSP functions, it is desirable to have some memory located
on chip. As dedicated buses are used to access the memory, on chip memories are faster. Speed and
size are the two key parameters to be considered with respect to the on-chip memories.
Speed:
On-chip memories should match the speeds of the ALU operations in order to maintain the single
cycle instruction execution of the DSP.
Size:
In a given area of the DSP chip, it is desirable to implement as many DSP functions as possible. Thus
the area occupied by the on-chip memory should be minimum so that there will be a scope for
implementing more number of DSP functions on-chip.

RESULT:
Thus the functional architecture of TMS320C6678/6718 Digital Signal Processor was studied.

EXP.NO : 8 PERFORM MAC OPERATION USING VARIOUS ADDRESSING


DATE : MODES
31
AIM:
To study the various addressing mode of TMS320C6678/6718 DSP processor.

APPARATUS REQUIRED:
TMS320C6678/6718 DSP processor

ADDRESSING MODES:
The addressing modes on the DSP are linear, circular using BK0, and circular using BK1. The
addressing mode is specified by the addressing mode register (AMR).All registers can perform linear
addressing. Only eight registers can perform circularaddressing: A4-A7 is used by the D1 unit and
B4-B7 is used by the D2 unit. No other unitscan perform circular addressing.
LDB (U)/LDH (U)/LDW, STB/STH/STW, LDNDW, LDNW, STNDW, STNW, LDDW,STDW,
ADDAB/ ADDAH/ ADDAW/ ADDAD and SUBAB/SUBAH/SUBAW instructions all use AMR to
determine what type of addresscalculations are performed for these registers. There is no SUBAD
instruction.
ADDRESSING MODE REGISTER (AMR)
For each of the eight registers (A4-A7, B4-B7) that can perform linear or circular addressing, the
addressing mode register (AMR) specifies the addressing mode. A 2-bit field for each register selects
the address modification mode: linear (the default) or circular mode. With circular addressing, the
field also specifies which BK (block size) field to use for a circular buffer. The mode select & block
size fields are choosing by writing values to AMR. The register details about AMR are available at
TMS320C6678 DSP CPU and Instruction Set Reference Guide.

LINEAR ADDRESSING MODE


LD and ST Instructions
For load and store instructions, linear mode simply shifts the offsetR/cst operand to the left by 3, 2,
1, or 0 for double word, word, half word, or byte access, respectively; and then performs an add or a
subtract to base R (depending on the operation specified). The LDNDW and STNDW instructions
also support non-scaled offsets. In non-scaled mode, the offsetR/cst is not shifted before adding or
subtracting from the base R.
For the pre-increment, pre-decrement, positive offset, and negative offset address generation options,
the result of the calculation is the address to be accessed in memory. For post-increment or post-
decrement addressing, the value of base R before the addition or subtraction is the address to be
accessed from memory.
ADDA AND SUBA INSTRUCTIONS

32
For integer addition and subtraction instructions, linear mode simply shifts the src1/cst operand to
the left by 3, 2, 1, or 0 for double word, word, half word, or byte data sizes, respectively, and then
performs the add or subtract specified.
CIRCULAR ADDRESSING MODE
The BK0 and BK1 fields in AMR specify the block sizes for circular addressing
LD and ST Instructions
As with linear address arithmetic, offsetR/cst is shifted left by 3, 2, 1, or 0 according to the data size,
and is then added to or subtracted from base R to produce the final address.Circular addressing
modifies this slightly by only allowing bits N through 0 of the result to be updated, leaving bits 31
through N + 1 unchanged after address arithmetic. The resulting address is bounded to 2(N + 1)
range, regardless of the size of the offsetR/cst. The circular buffer size in AMR is not scaled; for
example, a block-size of 8 is 8 bytes, not 8 times the data size (byte, half word, and word). So, to
perform circular addressing on an array of 8 words, a size of 32 should be specified, or N = 4.
Example shows an LDW performed with register A4 in circular mode and BK0 = 4, so the buffer
size is 32 bytes, 16 half words, or 8 words. The value in AMR for this example is 0004 0001h.

ADDA AND SUBA INSTRUCTIONS


As with linear address arithmetic, offsetR/cst is shifted left by 3, 2, 1, or 0 according to the data size,
and is then added to or subtracted from base R to produce the final address. Circular addressing
modifies this slightly by only allowing bits N through 0 of the result to be updated, leaving bits 31
through N + 1 unchanged after address arithmetic. The resulting address is bounded to 2(N + 1)
range, regardless of the size of the offsetR/cst. The circular buffer size in AMR is not scaled; for
example, a block size of 8 is 8 bytes, not 8 times the data size (byte, half word, and word). So, to
perform circular addressing on an array of 8 words, a size of 32 should be specified, or N = 4.

RESULT:
Thus, the various addressing mode of DSP processor TMS320C6678/6718 was studied

EXP.NO : 9 GENERATION OF VARIOUS SIGNALS


DATE : AND33
RANDOM NOISE
AIM :
To generate various elementary signals ( sine wave, a square wave ) and random noise

APPARATUS REQUIRED

SL.N HARDWARE / SOFTWARE SPECIFICATIO QT


O.1. Arduino Due Board N
-- Y1
2. Arduino Software with PC -- 1

ARDUINO CODE

float sineWave, squareWave, noise;


void setup() {
Serial.begin(9600);
}
void loop() {
// Generate sine wave
sineWave = sin(millis()/1000.0 * 2 * PI) * 0.5 + 0.5;
// Generate square wave
squareWave = (int)(millis()/1000.0 * 2) % 2 == 0 ? 1.0 : 0.0;
// Generate random noise
noise = random(10000) / 10000.0;
Serial.print("Sine wave: ");
Serial.print(sineWave -20);
Serial.print(", Square wave: ");
Serial.print(squareWave -10 );
Serial.print(", Noise: ");
Serial.println(noise);
delay(10);
}

34
PROCEDURE
 Initialize Constant value in the code.

 Verify code in Arduino 1.8.19 software.

 Upload the Arduino Code in the Arduino Due Board.

 These signals are output to the two DAC channels using the analogWrite() function.

 Then generate the corresponding output signals.

OUTPUT

RESULT :
Thus various elementary signals and random noise are generated using Arduino Due Board.

EXP.NO : 10 DESIGN AND DEMONSTRATION OF FIR FILTER FOR LOW PASS AND
DATE : HIGH PASS FILTERING
35
AIM :
To design and demonstrate of FIR Filter for Low pass, High pass filtering using Arduino.

APPARATUS REQUIRED

SL.N HARDWARE / SOFTWARE SPECIFICATIO QT


O.1. Arduino Due Board N
-- Y1
2. Arduino Software with PC -- 1

ARDUINO CODE
LOW PASS FILTER

const int analogPin = A0;


const float alpha = 0.5; // filter constant
float filteredValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(analogPin);
filteredValue = alpha * sensorValue + (1 - alpha) * filteredValue;
Serial.println(filteredValue);
delay(10);
}

36
OUTPUT

HIGH PASS FILTER

//Global Variables
int sensorPin = 0;
int sensorValue = 0;
float EMA_a = 0.3;
int EMA_S = 0;
int highpass = 0;
void setup(){
Serial.begin(115200)
EMA_S = analogRead(sensorPin);
}
void loop(){
sensorValue = analogRead(sensorPin);
EMA_S = (EMA_a*sensorValue) + ((1-EMA_a)*EMA_S);
highpass = sensorValue - EMA_S;
Serial.println(highpass);
delay(20);
}
OUTPUT

37
PROCEDURE
 Initialize Constant value in the code.

 Verify code in Arduino 1.8.19 software.

 Upload the Arduino Code in the Arduino Due Board.

 These signals are output to the two DAC channels using the analogWrite() function.

 Then generate the corresponding output signals.

RESULT :
Thus FIR Filter for Low pass & High pass filtering using Arduino Due Board was designed
and demonstrated.

EXP.NO : 11 DESIGN AND DEMONSTRATION OF IIR FILTERS FOR LOW PASS &
38
HIGH PASS FILTERING
DATE :
AIM :
To design the Butterworth and Chebyshev IIR filter for low pass, high pass filtering using the DSP
Processor and simulation software CCS Compiler.

APPARATUS REQUIRED

Hardware: Computer System/ Laptop, TMS 320C6678


Software: BIOS Setup Software
TI Emulator Pack Software
TI Emulator Keystone Platform Software
Code Composer Studio 5.3v

CREATION OF TARGET CONFIGURATION FILE


1. Set the EVM Boot Mode to "No Boot" and power on the EVM

2. Open up the CCSv5.3

3. Create a New Target Configuration, by selecting the tab File->New and clicking Target
Configuration File.

4. Enter a configuration file name (say "evmc6678l_xds100v1.ccxml") in the file name field and
hit finish button (the procedure assumes you are using On-boardXDS100 - class USB emulation).

5. Select the connection type as "Texas Instruments XDS100v1 USB emulator" forXDS100 or
"Blackhawk XDS560v2-USB Mezzanine Emulator" for XDS560 inthe drop down list and enter
device number (6678) in the Board or Device to select TMS320C6678

6. Click the Advanced tab and click on C66xx_0.

7. In the Initialization script, browse for the evmc6678l.gel file from the directory
39
<CCS Installation Directory>\ccsv6\ccs_base\emulation\boards\evmc6678l\gel as shown below:

8. Repeat the same for all the 8 cores.

9. Click View->Target configurations to list the available target configurations.The configuration


file (evmc6678l_xds100v1.ccxml) created above will be under "User Defined" section

10. Right click on the configuration file and select Launch Selected Configuration.This will
launch the configuration and open the debug view.

BUILDING AND RUNNING THE PROGRAM IN CCS 5.3V

11. The first step isto create a project in CCS for this example. To do so follow the steps below.

 Open CCS (preferably with a new workspace).


 Open File New CCS Project.
 In the project name field enter IIR_Filter.

12. Select Project Type: as C6000.

13. Device Variant: as Generic C66xx Device

14. In the Project Templates window select Empty Project.

15. It should open an empty project with name IIR_Filter.

16. Now that we have a project, we are going to create a source file that will use the MCSDK
Platform Library to

a) Initialize our EVM atstart-up,

b) Write a simple string to the UART (console port)

c) To display the result.

17. Select File->New->Source File, enter Source File name as IIR_Filter.c, and then click Finish.

18. It should open IIR_Filter.c empty file in the eclipse editor.

19. Type the source code in the editor.

20. Build the program.

21. Load the generated object file (*.out) on to Target board.

40
22. Run the program using F5.

23. Observe the waveform that appears on the CRO screen.

PROGRAM
//IIR LOW PASS
#include "L138_LCDK_aic3106_init.h"
#include "math.h"
#define N 2
#define wc 250
int i,w,c;
float H[1000];
float mul(float,int);
int main(void)
{
L138_initalise_intr(FS_8000_HZ,ADC_GAIN_0DB,DAC_AT TEN_0DB,LCDK_LINE_INPUT);}
interrupt void interrupt4(void)
{
for(w=0;w<=1000;w++)
{
H[w]=1/sqrt(1+mul((w/(float)wc),2*N));
printf("\nH[%d]=%f",w,H[w]);
}
}
float mul(float a,int x)
{
for(i=0;i<x-1;i++)
{
a*=a;
}
return(a);
}
OUTPUT:

41
PROCEDURE

42
 Start the program.

 Open new file

 Type the program

 Save in current directory

 Compile and Run the program

 If any error occurs in the program correct the error and run it again

 For the output see command window\ Figure window

 Stop the program

RESULT :
Thus an IIR filter was designed and demonstrated using DSP Processor and the frequency
response were plotted.

43
EXP.NO : 12 IMPLEMENT AN UP-SAMPLING AND DOWN-SAMPLING OPERATION
DATE : USING DSP PROCESSOR

AIM :
To implement the up sampling and down sampling process using DSP Processor using composer
software CCS.

APPARATUS REQUIRED

Hardware : Computer System/ Laptop, TMS 320C6678 / 6718.


Software : BIOS Setup Software
TI Emulator Pack Software
TI Emulator Keystone Platform Software
Code Composer Studio 5.3v

CREATION OF TARGET CONFIGURATION FILE

1. Set the EVM Boot Mode to "No Boot" and power on the EVM

2. Open up the CCSv5.3

3. Create a New Target Configuration, by selecting the tab File->New and clicking Target
Configuration File.

4. Enter a configuration file name (say "evmc6678l_xds100v1.ccxml") in the file name field and
hit finish button (the procedure assumes you are using On-boardXDS100 - class USB emulation).

5. Select the connection type as "Texas Instruments XDS100v1 USB emulator" forXDS100 or
"Blackhawk XDS560v2-USB Mezzanine Emulator" for XDS560 inthe drop down list and enter
device number (6678) in the Board or Device to select TMS320C6678

6. Click the Advanced tab and click on C66xx_0.

7. In the Initialization script, browse for the evmc6678l.gel file from the directory

<CCS Installation Directory>\ccsv6\ccs_base\emulation\boards\evmc6678l\gel as shown below:


44
8. Repeat the same for all the 8 cores.

9. Click View->Target configurations to list the available target configurations.The configuration


file (evmc6678l_xds100v1.ccxml) created above will be under "User Defined" section

10. Right click on the configuration file and select Launch Selected Configuration.This will
launch the configuration and open the debug view.

BUILDING AND RUNNING THE PROGRAM IN CCS 5.3V

11. The first step is to create a project in CCS for this example. To do so follow the steps below.

 Open CCS (preferably with a new workspace).


 Open File New CCS Project.
 In the project name field enter ID_Process.

12. Select Project Type: as C6000 & Device Variant: as Generic C66xx Device

13. In the Project Templates window select Empty Project.

14. It should open an empty project with name ID_Process.

15. Now that we have a project, we are going to create a source file that will use the MCSDK
Platform Library to

a) Initialize our EVM atstart-up,

b) Write a simple string to the UART (console port)

c) To display the result.

16. Select File->New->Source File, enter Source File name as ID_Process.c, & then click Finish.

18. It should open ID_Process.c empty file in the eclipse editor.

19. Type the source code in the editor.

20. Build the program.

21. Load the generated object file (*.out) on to Target board.

22. Run the program using F5.

23. Observe the waveform that appears on the CRO screen.

45
PROGRAM

//Multirate Signal Processing in scilab


//Upsampling a sinusoidal signal by a factor of 2
clear;
clc;
n = 0:%pi/200:2*%pi;
x = sin(%pi*n); //original signal
upsampling_x = zeros(1,2*length(x)); //upsampled by a factor of 2
upsampling_x(1:2:2*length(x)) = x;
subplot(2,1,1)
plot(1:length(x),x);
xtitle('original singal')
subplot(2,1,2)
plot(1:length(upsampling_x),upsampling_x);
xtitle('Upsampled Signal by a factor of 2');

OUTPUT

46
/* program to perform Decimation */

//Multirate Signal Processing in scilab


//Downsampling a sinusoidal signal by a factor of 2
clear;
clc;
n = 0:%pi/200:2*%pi;
x = sin(%pi*n); //original signal
downsampling_x = x(1:2:length(x)); //downsampled by a factor of 2
subplot(2,1,1)
plot(1:length(x),x);
xtitle('original singal')
subplot(2,1,2)
plot(1:length(downsampling_x),downsampling_x);
xtitle('Downsampled Signal by a factor of 2');

OUTPUT :

47
PROCEDURE
 Start the program.

 Open new file

 Type the program

 Save in current directory

 Compile and Run the program

 If any error occurs in the program correct the error and run it again

 For the output see command window\ Figure window

 Stop the program

RESULT :
Thus the implementation of down sampling and up sampling along with sampling rate
conversion was performed using DSP Processor and the output is verified using code
composer studio

48

You might also like