DSP Lab Manual - DSP (KEC-553) - 2021-22
DSP Lab Manual - DSP (KEC-553) - 2021-22
GREATER NOIDA
(An Autonomous Institute)
Accredited by NAAC and Approved by AICTE
(Affiliated to Dr. A.P.J. Abdul Kalam Technical University, Uttar
Pradesh, Lucknow)
LABORATORY MANUAL
COURSE: B.TECH. (EC) SEMESTER: V
INSTITUTE VISION
INSTITUTE MISSION
• To impart quality education and hone student’s skills and competencies making them
future ready.
• To foster an ecosystem for research, product development, innovation, incubation and
entrepreneurship.
• To instill values and ethics to produce socially responsible technocrats addressing global
problems.
• To develop an environment for sharing and exchange of resources globally for lifelong
learning.
DEPARTMENT VISION
To prepare the students for global competence, with core knowledge in Electronics and
Communication Engineering having focus on research to meet the needs of industry and
society.
DEPARTMENT VISION
M1: To become dynamic and vigorous knowledge hub with an exposure to state of art
technologies for connecting world.
M3: To train students to take up innovative projects in group with sustainable and
inclusive technology relevant to the industry and social needs.
PEO3: Toeffectively bridge the gap between industry and academics for
effectivecommunication skill, professional attitude, and a desire to learn.
PSO1: Apply the knowledge of mathematics, science, and electronics & communication
engineering to work effectively in the industry based on same or related area.
PSO2: Use their skills to work in modern electronics & communication engineering tools,
software, and equipment’s to design solutions for complex problems in the related
field that meet the specified needs of the society.
COURSE OBJECTIVES
COURSE OUTCOMES
At the end of this course students will demonstrate the ability to:
1. Create and visualize various discrete/digital signals using MATLAB/Scilab.
2. Implement and test the basic operations of Signal processing.
3. Examine and analyze the spectral parameters of window functions.
4. Design IIR and FIR filters for band pass, band stop, low pass and high pass filters.
5. Design the signal processing algorithms using MATLAB/Scilab
PO’s
PO12
PSO1
PO10
PO11
PSO2
PSO3
PO8
PO7
PO9
PO6
PO3
PO1
PO2
PO4
PO5
CO’s
KEC553. 1 3 1 1 3 2 3 2
KEC553. 2 3 2 2 3 2 3 2
KEC553. 3 3 2 2 3 2 3 2
KEC553.4 3 2 2 3 2 3 2
KEC553.5 3 3 2 3 2 3 2
Average 3 2 1.8 2.4 2 3 2
1. Student entry in the lab is ensured strictly as per the allocated time slots or seeking prior
proper permission from the lab faculty or instructor.
2. Students are expected to conduct themselves in a responsible manner while working in the
laboratory.
3. They should keep their bags on the shelf provided outside the lab and carry only essential
items such as lab record, manual, pen-pencil, copy and calculator etc. inside the lab.
4. Students are not allowed to carry food items (not even chewing gum), beverages and water
bottles while working in the laboratory.
5. They are expected to observe good housekeeping practices and ensure equipment, sitting
stools and components to be handled carefully and kept at proper place after finishing the
work to keep the lab clean and tidy.
6. While working in the lab
Avoid stretching electrical cables and connectors while using the equipment.
Rig the circuit and get it verified from the lab instructor before connecting it to
power source.
Pay proper attention towards earthling of electrical equipment. Ensure proper
ventilation in the lab while working.
Ensure use of wire clippers, insulating tape, plug-pins to prevent any electrical
shocking hazards.
In case of any short circuit, sensing burning smell or observing any smoke
switch off power supply and immediately report to the faculty/lab instructor
available in the lab.
7. In case of any minor injury please contact the lab instructor or lab faculty. The first aid Box
is available in the department in front of Room No 208.
8. In case of any fire emergency, contact the faculty or lab instructor. For your information, the
fire safety equipment is available on each floor near notice board.
In the record, the index page should be filled properly by writing the corresponding experiment
number, experiment name, date on which it was done and the page number.
EVALUATION SCHEME
EXPERIMENT NO.-1
OBJECTIVE
Introduction to MATLAB and or Open Source Software, Scilab (Using Spoken TutorialMOOCs).
INTRODUCTION TO MATLAB:
MATLAB stands for matrix laboratory. It is a technical computing environment for high
performance numeric computation and visualization developed by Math Works, Inc. (an American
privately held corporation that specializes in mathematical computing software). It integrates
numerical analysis, matrix computation, signal processing and graphics and is an easy-to-use
environment, where problems and solutions are expressed just as they are written mathematically,
without traditional programming. MATLAB allows expressing the entire algorithm in a few dozen
lines, to compute the solution with great accuracy in a few minutes on a computer, and to readily
manipulate a three-dimensional display of the result in color.
MATLAB is an interactive system whose basic data element is a matrix that does not require
dimensioning. It enables us to solve many numerical problems in a fraction of the time that it
would take to write a program and execute in language such as FORTRAN, BASIC, or C. It also
features a family of application specific solutions, called toolboxes. Areas in which toolboxes are
available include signal processing, image processing, control systems design, dynamic systems
simulation, system identification, neural networks, wavelength communication and others. It can
handle linear, non-linear, continuous-time, discrete-time, multivariable and multirate systems.
Starting MATLAB:
Enter MATLAB by double-clicking on the MATLAB shortcut icon (MATLAB R2017a) on your
Windows desktop. When you start MATLAB, a special window called the MATLAB desktop
appears. The desktop is a window that contains other windows. The major tools within or
accessible from the desktop are:
The Command Window
The Command History
The Workspace
The Current Directory
The Help Browser
VIVA QUESTIONS
1. Explain the application of MATLAB
2. Differentiate digital and analog signals?
EXPERIMENT NO.-2
OBJECTIVE:
Write a MATLAB Program for the generation of basic signals such as unit impulse, unit step,
ramp, exponential, sinusoidal and cosine.
EQUIPMENT REQUIRED:
PROGRAM: -
clc;
clear all;
close all;
n=-10:1:10;
L=length(n);
for i=1:L
if n(i)==0
x1(i)=1;
else
x1(i)=0;
end;
if n(i)>=0
x2(i)=1;
x3(i)=n(i);
else
x2(i)=0;
x3(i)=0;
end;
end;
% to generate exponential sequence
a=0.85;
x4=a.^n;
% to generate sinusoidal sequence
f=0.1;
x5=sin(2*pi*f*n);
figure;
subplot(3,2,1);
stem(n,x1);
xlabel('time n ---->');
ylabel('amplitude---->');
title('Unit impulse signal');
subplot(3,2,2);
stem(n,x2);
xlabel('time n ---->');
ylabel('amplitude---->');
title('Unit step signal')
subplot(3,2,3);
stem(n,x3);
xlabel('time n ---->');
ylabel('amplitude---->');
title('Unit remp signal');
subplot(3,2,4);
stem(n,x4);
xlabel('time n ---->');
ylabel('amplitude---->');
title('exponential signal');
subplot(3,2,[5,6]);
stem(n,x5);
xlabel('time n ---->');
ylabel('amplitude---->');
title('sinusoidal signal');
OUTPUT:
RESULT:
Basic functions such as unit impulse, unit step, ramp, exponential, sinusoidal and cosine are
generated successfully using MATLAB.
VIVA QUESTIONS:
1. What are Singularity functions and how they are related to each other?
2. How step and ramp functions are plotted in MATLAB?
3. How sinusoidal functions can be plotted in MATLAB?
4. How can we label x axis and y axis of any waveform output in MATLAB?
EXPERIMENT NO.-3
OBJECTIVE
Implement IIR Butterworth analog Low Pass for a 4 KHz cut off frequency.
EQUIPMENT REQUIRED:
THEORY:
Filter Designer is a powerful graphical user interface (GUI) in the Signal Processing Toolbox for
designing and analysing filters. Filter Designer enables you to quickly design digital FIR or IIR
filters by setting filter performance specifications, by importing filters from your MATLAB
workspace or by adding, moving, or deleting poles and zeros. Filter Designer also provides tools
for analyzing filters, such as magnitude and phase response plots and pole-zero plots.
A Tip of the Day dialog displays with suggestions for using Filter Designer. Then, the GUI
displays with a default filter.
The GUI has three main regions:
1) The Current Filter Information region
2) The Filter Display region and
3) The Design panels
The upper half of the GUI displays information on filter specifications and responses for the
current filter. The Current Filter Information region, in the upper left, displays filter properties,
namely the filter structure, order, number of sections used and whether the filter is stable or not. It
also provides access to the Filter manager for working with multiple filters. The Filter Display
region, in the upper right, displays various filter responses, such as, magnitude response, group
delay and filter coefficients. The lower half of the GUI is the interactive portion of Filter Designer.
The Design Panel, in the lower half is where the filter specifications are displayed. It controls what
is displayed in the other two upper regions. Other panels can be displayed in the lower half by
using the sidebar buttons.
Infinite impulse response (IIR) is a property applying to many linear time-invariant systems.
Common examples of linear time-invariant systems are most electronic and digital filters. Systems
with this property are known as IIR systems or IIR filters and are distinguished by having
an impulse response which does not become exactly zero past a certain point, but continues
indefinitely.
PROGRAMMING STEPS:
1. Type fdatool in MATLAB command prompt.
2. Under response type panel select Lowpass.
3. Under Design method panel select IIR Butterworth.
4. Specify any filter order.
5. Under frequency specifications specify cut off frequency fc as 4 kHz.
6. Under Analysis button in the fdatool window you can observe various responses like
magnitude response, phase response etc. for the filter.
7. Using realize model button on the left corner of fda tool we can see the block diagram of the
filter.
This panel displays the different analysis
OUTPUT responses for the filter. In this case phase
response.
Here we can specify the design method for the filter. In this case frequency for filter in Hz or KHz.
choose IIR Butterworth type design method. Above this panel we
can choose the response type of filter lowpass or highpass.
Fig. 3.2: FDA tool window output group delay response of filter
Fig 3.3: FDA tool output for Pole zero plot of filter
RESULT:
IIR Butterworth filter is implemented successfully using MATLAB fda tool.
VIVAQUESTIONS:
1. What is IIR filter?
2. What are the design methods available for a Butterworth filter?
3. How many kinds of responses are available for a filter?
4. What is fda tool?
5. What are the different design methods available for IIR filter?
6. How many kinds of responses we can model for a filter using fda tool?
EXPERIMENT NO.-4
OBJECTIVE:
Verify Blackman and Hamming windowing techniques.
EQUIPMENT REQUIRED:
Hardware required Software Required
PC MATLAB R2017a
By common convention, the unqualified term Blackman window refers to Blackman's "not very
serious proposal" of α = 0.16 (a0 = 0.42, a1 = 0.5, a2 = 0.08), which closely approximates the "exact
Blackman", with a0 = 7938/18608 ≈ 0.42659, a1 = 9240/18608 ≈ 0.49656, and a2 =
1430/18608 ≈ 0.076849. These exact values place zeros at the third and fourth side lobes but result
in a discontinuity at the edges and a 6 dB/oct fall-off. The truncated coefficients do not null the side
lobes as well but have an improved 18 dB/oct fall-off.
A filter designed with the Hamming window has minimum stopband attenuation of 53dB, which is
enough for most implementations of digital filters. The transition region is somewhat wider than
that of the Hann and Bartlett-Hanning windows, whereas the stopband attenuation is considerably
higher. Unlike minimum stopband attenuation, the transition region can be changed by changing
the filter order. The transition region narrows, whereas the minimum stopband attenuation remains
unchanged as the filter order increases. The Hamming window coefficients are expressed as:
the window sampling specified by 'sflag', which can be either 'periodic' or 'symmetric' (the default).
The 'periodic' flag is useful for DFT/FFT purposes, such as in spectral analysis. The DFT/FFT
contains an implicit periodic extension and the periodic flag enables a signal windowed with a
periodic window to have perfect periodic extension. When 'periodic' is
specified, blackman computes a length N+1 window and returns the first N points. When using
windows for filter design, the 'symmetric' flag should be used.w = hamming (L) returns an L-point
symmetric Hamming window.w = hamming (L,sflag) returns a Hamming window using the
window sampling specified by sflag.
clc;
clear all;
close all;
wc=0.5*pi;
N=25;
b=fir1(N,wc/pi,blackman(N+1));
w=0:.01:pi;
h=freqz(b,1,w);
plot(w/pi,abs(h),'-.');grid;
xlabel('Normalised frequency\omega/\pi');
ylabel('Magnitude');
title('Frequency response of blackman window');
OUTPUT:
RESULT:
The Blackman and Hamming windows have been verified using MATLAB using WVtool and
coding.
VIVA QUESTIONS
1. What is hamming window function?
2. What is Blackman window function?
3. What is WVtool? Explain the syntax and execution.
4. How can we implement blackman window using WVtool?
5. How can we implement the hamming window using WVtool?
EXPERIMENT NO.-5
OBJECTIVE:
Evaluate 4-point DFT and IDFT of x(n) = 1, 0 ≤ n ≤ 3; 0 elsewhere.
EQUIPMENT REQUIRED:
Hardware required Software Required
PC MATLAB R2017a
THEORY:
Given a sequence of N samples s[n], indexed by n = 0..N-1, the Discrete FourierTransform (DFT)
is defined as X(k), where k=0..N-1:
𝑁−1 −𝑗 2𝜋𝑛𝑘 /𝑁
X(k)= 𝑛=𝑜 𝑥(𝑛)𝑒 0≤𝑘 ≤𝑁−1 (i)
X[k] are often called the 'Fourier Coefficients' or 'Harmonics'. The sequence x[n] can be calculated
from X[k] using the Inverse Discrete Fourier Transform
𝑗 2𝜋𝑛𝑘
1 𝑁−1
x(n) =
𝑁 𝑘=0 𝑋 𝑘 𝑒 𝑁 0≤𝑛 ≤𝑁−1 (ii)
The DFT is the most important discrete transform, used to perform Fourier analysis in many
practical applications. In digital signal processing, the function is any quantity or signal that varies
over time, such as the pressure of a sound wave, a radio signal, or daily temperature readings,
sampled over a finite time interval (often defined by a window function). The DFT is also used to
efficiently solve partial differential equations, and to perform other operations such as convolutions
or multiplying large integers.
PROGRAM:
%DFT%
clc;
clear all;
close all;
a=input ('Enter the input sequence');
N=length (a);
disp('Length of input sequence '); N
for k=1:N;
X(k)=0;
for i=1:N;
X(k)=X(k)+a(i)*exp((-j*pi*2/N)*((i-1)*(k-1)));
end;
end;
k=1:N;
disp('Output is ');
X(k)
subplot(2,1,1);
stem(k,abs(X(k)));
grid;
xlabel ('Discrete frequency (k)');
ylabel('Magnitude of X(k)');
title('Magnitude Response of DFT');
subplot(2,1,2);
stem(angle(X(k))*180/(pi));
grid;
xlabel('Discrete frequency (k)');
ylabel('Phase angle of X(k)');
title('Phase Response of X(k)');
grid;
OUTPUT:
%IDFT%
clc;
clear all;
close all;
a=input('Enter the input sequence');
disp('Length of input sequence is');
N=length(a); N
for n=1:N;
x(n)=0;
for k=1:N;
x(n)=x(n)+a(k)*exp((j*pi*2*(n-1)*(k-1)/N));
end;
end;
n=1:N;
x=1/N*x(n);
disp('Output is');
x(n)
stem(n,abs(x));
grid;
xlabel('Discrete time (n)');
ylabel('Magnitude of x(n)');
title('Magnitude Response of the IDFT');
grid;
OUTPUT:
RESULT:
DFT and IDFT are studied successfully with the help of MATLAB.
VIVA QUESTIONS:
1. Define Symmetric and Anti-Symmetric Signals?
2. Define Continuous and Discrete Time Signals?
3. What are the Different types of representation of discrete time signals?
4. What are the Different types of Operation performed on signals?
5. Define DFT.How DFT can be calculated in matrix form?
6. How can you plot the magnitude response of DFT and IDFT using MATLAB?
7. Which MATLAB function plots the discrete graph in the software?
EXPERIMENT NO.-6
OBJECTIVE:
Verify Linear Convolution of two sequences using FFT.
EQUIPMENT REQUIRED:
Hardware required Software Required
PC MATLAB R2017a
THEORY:
Linear convolution using FFT:
Compute the output of a linear filter described by impulse response h(n)= {1,2,3,2,1} and input
x(n)= {1,1,1,1} using FFT algorithm.
The no of samples contained in x(n) and h(n) are M=5 and L=4. The number of samples contained
in y(n) are N=M+L-1=8, where y(n)=x(n)*h(n).Here, we will perform linear convolution through
circular convolution using FFT algorithm.
Step-1: Obtain the N-point DFTs of the sequences x (n) and h (h):
x(n) →X(k)
h (n) → H (k)
Step-3: Obtain N-point IDFT of the sequence Y(k),to yield the final output y(n)
Y (k) → y (n), for n=0,1,2,.....,N-1
PROGRAM:
%Verify Linear Convolution of two sequences using FFT
clc;
close all;
x=[1 1 1 1]; %No of samples in first sequence (M)
h=[1 2 3 2 1]; %No of samples in first sequence (L)
N=8; %Total no of samples in output sequence(N=M+L-1)
n=0:N-1;
%Linear convolution through circular convolution using FFT algorithm
X8f=fft(x,8); %DFT of sequence first sequence=X(k)
% fft(X,N) is the N-point fft, padded with zeros if X has less than N points
OUTPUT:
RESULT
Linear Convolution of two sequences using FFT with the help of MATLAB is verified.
VIVA QUESTIONS:
1. Explain the significance of convolution.
2. Define linear convolution.
3. Why linear convolution is called as a periodic convolution?
4. Why zero padding is used in linear convolution?
5. What are the four steps to find linear convolution?
6. What is the length of the resultant sequence in linear convolution?
7. How linear convolution will be used in calculation of LTI system response?
8. List few applications of linear convolution in LTI system design.
9. Give the properties of linear convolution.
10. How linear convolution can be used to calculate the DFT of a signal?
EXPERIMENT NO.-7
OBJECTIVE:
Verify Circular Convolution of two sequences using FFT.
EQUIPMENT REQUIRED:
Hardware required Software Required
PC MATLAB R2017a
THEORY:
Circular-convolution using FFT:
Step-1: Obtain the N-point DFTs of the sequences x (n) and h (h):
x(n) →X(k)
h (n) → H (k)
Step-3: Obtain N-point IDFT of the sequence Y(k),to yield the final output y(n)
Y (k) → y (n), for n=0,1,2,.....,N-1
PROGRAM:
clc;
close all;
x=input('Enter x(n):\n');
h=input('Enter h(n):\n');
m=length(x); %length of sequence x(n)
n=length(h); %length of sequence h(n)
N=max(m,n); %length of output sequence y(n) %For equating both sequence length
x=[x,zeros(1,N-m)];
h=[h,zeros(1,N-n)];
n=0:N-1
X=fft(x); %DFT of sequence x(n)
H=fft(h); %DFT of sequence h(n)
%performing element-wise multiplication
Y=X.*H; %DFT of output sequence y(n)
y=ifft(Y); %IDFT of Y(k)
subplot(3,1,1)
OUTPUT:
RESULT
Circular Convolution of two sequences using FFT with the help of MATLAB is verified.
VIVA QUESTIONS:
1. What is the difference between linear and circular convolution? Explain
2. What is the formula to calculate the length of circularly convoluted sequence?
3. How can we relate circular convolution and DFT?
4. Calculate circular convolution of two sequences using DFT.
5. Calculate circular convolution of two sequences of different length using linear convolution
EXPERIMENT NO.-8
OBJECTIVE
EQUIPMENT REQUIRED:
THEORY:
To Interpolate and visualize 1-D data using the FFT method, The following steps are to be taken
PROGRAM:
clc;
clear all;
close all;
dx = 3*pi/30;
x = 0:dx:3*pi;
f = cos(x);
plot(x,f,'o')
N = 100;
y = interpft(f,N);
dy = dx*length(x)/N;
x2 = 0:dy:3*pi;
y = y(1:length(x2));
hold on
plot(x2,y,'.')
title('FFT Interpolation of Periodic Function')
OUTPUT: -
VIVAQUESTIONS:
1. How is FFT able to compute DFT efficiently?
2. What are the different algorithms to calculate FFT?
3. How can we calculate magnitude and phase response of FFT using MATLAB?
4. What is the predefined function for FFT in MATLAB?
EXPERIMENT NO.-9
OBJECTIVE:
To implement Tone Generation.
EQUIPMENT REQUIRED:
THEORY:
Dual Tone Multi-Frequency or DTMF is a method for instructing a telephone switching system of
the telephone number to be dialled, or to issue commands to switching systems or related telephony
equipment. The DTMF dialling system traces its roots to a technique AT&T developed in the
1950s called MF (Multi-Frequency) which was deployed within the AT&T telephone network to
direct calls between switching facilities using in-band signalling. DTMF signalling has many
applications such as telephone dialling, data entry, credit checking, and voice mail system control.
A DTMF signal Consists of two superimposed sinusoidal waveforms with frequencies chosen from
a set of eight standardized frequencies. These frequencies should be generated and detected
according to the CCITT Recommendation. The DTMF system uses eight different frequency
signals transmitted in pairs to represent sixteen different numbers, symbols and letters.
DTMF GENERATOR
DTMF signalling uses two tones to represent each key on the touch pad. There are 12 distinct
tones. When any key is pressed the tone of the column and the tone of the row are generated. As an
example, pressing the '5' button generates the tones 770 Hz and 1336 Hz. In this example, use the
number 10 to represent the '*' key and 11 to represent the '#' key.The frequencies were chosen to
avoid harmonics: no frequency is a multiple of another, the difference between any two frequencies
does not equal any of the frequencies, and the sum of any two frequencies does not equal any of the
frequencies.
The frequencies of the tones are as follows:
DTMF RECEIVER
At the receiver the tone frequencies are detected, and the number decoded. The DFT algorithm can
be used to detect frequencies, but since there are only 7 frequency components (4 low frequencies
and 3 high frequencies), a more efficient method is the Goertzel algorithm. This method detects the
frequency components by passing the received signal through 7 bandpass filters. The filter
bandwidths are adjustable as a percentage of the center frequency by adjusting the bandwidth
parameter on the DTMF Receiver block mask.
dspdtmf
When the simulation is run, the spectrogram of the received tone will be constructed. If the version
of the model designed for audio hardware is used, the received tone is played through the system
soundcard. The detected dialed numbers will be shown on the numeric display scope. The
following parameters can be adjusted:
1) Frequency bias for each tone (from the DTMF Generator mask dialog)
2) Channel noise power and signal gain (from the Channel mask dialog)
3) Receiver bandpass filter frequency bandwidth (from the DTMF Receiver mask dialog)
OUTPUT:
RESULT:
The DTMF generator and receiver has been successfully implemented using MATLAB Simulink.
VIVAQUESTIONS:
1. How keystrokes from the telephone keypad are translated into dual tone signals over the
audio link?
2. How many distinct tones are there in the DTMF?
3. How can you obtain various blocks used in DTMF generator and receiver in the simulink?
Name them.
4. What is a Goertzel Algorithm?
EXPERIMENT NO.-10
OBJECTIVE:
To implement floating point arithmetic.
EQUIPMENT REQUIRED:
THEORY:
Bits Usage
63 Sign (0 = positive, 1 = negative)
62 to 52 Exponent, biased by 1023
51 to 0 Fraction f of the number 1.f
Because MATLAB stores numbers of type single using 32 bits, they require less memory than
numbers of type double, which use 64 bits. However, because they are stored with fewer bits,
numbers of type single are represented to less precision than numbers of type double.
PROGRAMS
Creating Floating-Point Data
Use double-precision to store values greater than approximately 3.4 x 1038 or less than
approximately -3.4 x 1038. For numbers that lie between these two limits, either double- or single-
precision can be used but single requires less memory.
x = 25.783;
The whos function shows that MATLAB has created a 1-by-1 array of type double for the value
you just stored in x:
whos x
Name Size Bytes Class
x 1x1 8 double
Use isfloat if it is to be verified that x is a floating-point number. This function returns logical 1
(true) if the input is a floating-point number, and logical 0 (false) otherwise:
isfloat(x)
ans = logical1
Other numeric data can be converted, characters or strings, and logical data to double precision
using the MATLAB function, double. This example converts a signed integer to double-precision
floating point:
xAttrib = whos('x');
xAttrib.bytes
ans =4
Other numeric data can be converted, characters or strings, and logical data to single precision
using the single function. This example converts a signed integer to single-precision floating point:
This example performs arithmetic on data of types char and double. The result is of type double:
c = 'uppercase' - 32;
class(c)
ans =double
char(c)
ans = UPPERCASE
Single-Precision Operations
Basic arithmetic operations can be performed with single and any of the following other classes.
The result is always single:
1) single
2) double
3) char
4) logical
In this example, 7.5 defaults to type double, and the result is of type single:
Numbers larger than realmax or smaller than -realmax are assigned the values of positive and
negative infinity, respectively:
realmax + .0001e+308
ans =Inf
realmax - .0001e+308
ans =Inf
realmax('single') + .0001e+038
ans =singleInf
-realmax('single') - .0001e+038
ans =singleInf
Double-Precision Accuracy
Because there are only a finite number of double-precision numbers, that cannot represent all
numbers in double-precision storage. On any computer, there is a small gap between each double-
precision number and the next larger double-precision number. The size of this gap can be
determined, which limits the precision of your results, using the eps function. For example, to find
the distance between 5 and the next larger double-precision number, enter
format long
eps(5)
ans = 8.881784197001252e-16
This tells that there are no double-precision numbers between 5 and 5 + eps(5). If a double-
precision computation returns the answer 5, the result is only accurate to within eps(5).
The value of eps(x) depends on x. This example shows that, as x gets larger, so does eps(x):
eps(50)
ans = 7.105427357601002e-15
If eps is entered with no input argument, MATLAB returns the value of eps(1), the distance
from 1 to the next larger double-precision number.
Single-Precision Accuracy
Similarly, there are gaps between any two single-precision numbers. If x has
type single, eps(x) returns the distance between x and the next larger single-precision number. For
example,
x = single(5);
eps(x)
returns
ans =single4.7684e-07
Note that this result is larger than eps(5). Because there are fewer single-precision numbers than
double-precision numbers, the gaps between the single-precision numbers are larger than the gaps
between double-precision numbers. This means that results in single-precision arithmetic are less
precise than in double-precision arithmetic.
For a number x of type double, eps(single(x)) gives an upper bound for the amount that x is
rounded when conversion is done from it from double to single. For example, when conversion is
done from the double-precision number 3.14 to single, it is rounded by
eps(single(3.14))
ans =single2.3842e-07
e = 1 - 3*(4/3 - 1)
e = 2.2204e-16
Similarly, 0.1 is not exactly representable as a binary number. Thus, you get the following
nonintuitive behavior:
a = 0.0;
for i = 1:10
a = a + 0.1;
end
a == 1
ans = logical0
Note that the order of operations can matter in the computation:
b = 1e-16 + 1 - 1e-16;
c = 1e-16 - 1e-16 + 1;
b == c
ans =logical0
There are gaps between floating-point numbers. As the numbers get larger, so do the gaps, as
evidenced by:
(2^53 + 1) - 2^53
ans =0
Since pi is not really π, sin(pi) is not exactly zero:
sin(pi)
ans =1.224646799147353e-16
sqrt(1e-16 + 1) - 1
ans =0
Some functions in MATLAB, such as expm1 and log1p, may be used to compensate for the effects
of catastrophic cancellation.
RESULT:
Floating point arithmetic is implemented successfully using MATLAB.
VIVAQUESTIONS
1. What is double precision floating point arithmetic?
2. What is single precision floating point arithmetic?
3. How can we use whos function to create double precision and single precision data?
4. What are the MATLAB functions to perform arithmetic operations on double precision data?
EXPERIMENT NO.-11
OBJECTIVE:
To study about DSP Processors and architecture ofTMS320C6713 DSP processor.
Feature Use
Most DSP algorithms, including filtering, transforms, etc.
Fast-Multiply accumulate
are multiplication- intensive
Many data-intensive DSP operations require reading a
Multiple-access memory
program instruction and multiple data items
Efficient handling of data arrays and first-in, first-out
Specialized addressing modes
buffers in memory
Efficient control of loops for many iterative DSP algorithms.
Specialized program control
Fast interrupt handling for frequent I/O
On-chip peripherals like A/D converters allow for small low
On-chip peripherals and I/O
cost system designs. Similarly, I/O
Digital signal processors are used for a wide range of applications, from communications and
control to speech and image processing. They are found in cellular phones, fax/modems, disk
drives, radios, printers, hearing aids, MP3 players, HDTV, digital cameras, and so on. Specialized
(particularly in terms of their on-board peripherals) DSPs are used in electric motor drives and a
range of associated automotive and industrial applications. Overall, DSPs are concerned primarily
with real-time signal processing. Real-time processing means that the processing must keep pace
with some external event; whereas non real-time processing has no such timing constraint. The
external event to keep pace with is usually the analog input. While analog-based systems with
discrete electronic components including resistors and capacitors are sensitive to temperature
changes, DSP-based systems are less affected by environmental conditions such as temperature.
DSPs enjoy the major advantages of microprocessors. They are easy to use, flexible, and
economical.
Table 11.1: Main Texas Instruments (TI) and Analog Devices (ADI) DSP families, together with
their typical use and performance
The hardware experiments in this DSP lab are carried out on the Texas Instruments TMS320C6713
DSP Starter Kit (DSK), based on the TMS320C6713 floating point DSP running at 225MHz. The
basic clock cycle instruction time is 1/(225 MHz) = 4.44 nanoseconds. During each clock cycle, up
to eight instructions can be carried out in parallel, achieving up to 8 × 225 = 1800 million
instructions per second (MIPS).
The C6713 processor has 256KB of internal memory and can potentially address 4GB of external
memory. The DSK board includes a 16MB SDRAM memory and a 512KB Flash ROM. It has an
on-board 16-bit audio stereo codec (the Texas Instruments AIC23B) that serves both as an A/D and
a D/A converter. There are four 3.5 mm audio jacks for microphone and stereo line input, and
speaker and head-phone outputs. The AIC23 codec can be programmed to sample audio inputs at
the following sampling rates:fs = 8, 16, 24, 32, 44.1, 48, 96 kHz.
The ADC part of the codec is implemented as a multi-bit third-order noise-shaping delta-sigma
converter that allows a variety of oversampling ratios that can realize the above choices of fs. The
corresponding oversampling decimation filters act as anti-aliasing pre-filters that limit the spectrum
of the input analog signals effectively to the Nyquist interval [−fs/2, fs/2]. The DAC part is
similarly implemented as a multi-bit second-order noise-shaping delta-sigma converter whose
oversampling interpolation filters act as almost ideal reconstruction filters with the Nyquist interval
as their pass band.
The DSK also has four user-programmable DIP (Dual In-line Package) switches and four LEDs
that can be used to control and monitor programs running on the DSP.All features of the DSK are
managed by the Code Composer Studio (CCS), which is a complete integrated development
environment (IDE) that includes an optimizing C/C++ compiler, assembler, linker, debugger, and
program loader.
The CCS communicates with the DSK via a USB connection to a PC. In addition to facilitating all
programming aspects of the C6713 DSP, the CCS can also read signals stored on the DSP’s
memory, or the SDRAM, and plot them in the time or frequency domains. The following block
diagram depicts the overall operations involved in all the hardware experiments in the DSP lab.
Processing is interrupt-driven at the sampling rate fs, as explained below.
The AIC23 codec is configured (through CCS) to operate at one of the above sampling rates f s.
Each collected sample is converted to a 16-bit two’s complement integer (a short data type in C).
The codec samples the audio input in stereo, that is, it collects two samples for the left and right
channels. At each sampling instant, the codec combines the two 16-bit left/right samples into a
single 32-bit unsigned integer word (an unsigned int, or Uint32 data type in C), and ships it over
to a 32-bit receive-register of the multichannel buffered serial port (McBSP) of the C6713
processor, and then issues an interrupt to the processor
Upon receiving the interrupt, the processor executes an interrupt service routine (ISR) that
implements desired sample processing algorithm programmed with the CCS (e.g. filtering, audio
effects, etc.).During the ISR, the following actions take place: the 32-bit input sample (denoted by
x in the diagram) is read from the McBSP, and sent into the sample processing algorithm that
computes the corresponding 32-bit output word (denoted by y), which is then written back into a
32-bit transmit-register of the McBSP, from where it is transferred to the codec and reconstructed
into analog format, and finally the ISR returns from interrupt, and the processor begins waiting for
the next interrupt, which will come at the next sampling instant.
The C6x notation is used to designate a member of the Texas Instruments (TI) TMS320C6000
family of digital signal processors. The architecture of the C6x digital signal processor is very well
suited to numerically intensive calculations. Based on a very-long-instruction-word (VLIW)
architecture, the C6x is TI’s most powerful processor family.
The architectural structure of the TMS320C67xx DSP comprises of the central processing unit
(CPU), memory, and on-chip peripherals. The C67xx DSPs use an advanced modified Harvard
architecture that maximizes processing power with eight buses.
Separate program and data spaces allow simultaneous access to program instructions and data,
providing a high degree of parallelism. For example, three reads and one write can be performed in
a single cycle. Instructions with parallel store and application-specific instructions 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 all
be performed in a single machine cycle. Also, the C67xx DSP includes the control mechanisms to
manage interrupts, repeated operations, and function calling.
The C67xx DSP can generate up to two data-memory addresses per cycle using the two auxiliary
register arithmetic units (ARAU0 and ARAU1). The PB can carry data operands stored in program
space (for instance, a coefficient table) to the multiplier and adder for multiply/accumulate
operations or to a destination in data space for data move instructions (MVPD and READA). This
capability, in conjunction with the feature of dual-operand read, supports the execution of single-
cycle, 3-operand instructions such as the FIRS instruction. The C67xx DSP also has an on-chip
bidirectional bus for accessing on-chip peripherals. This bus is connected to DB and EB through
the bus exchanger in the CPU interface. Accesses that use this bus can require two or more cycles
for reads and writes, depending on the peripheral’s structure.
The C67xx DSP performs 2s-complement arithmetic with a 40-bit arithmetic logic unit (ALU) and
two 40-bit accumulators (accumulators A and B). The ALU can also perform Boolean operations.
The ALU uses these inputs:
The ALU can also function as two 16-bit ALUs and perform two 16-bit operations simultaneously.
Accumulators
Accumulators A and B store the output from the ALU or the multiplier/adder block. They can also
provide a second input to the ALU; accumulator A can be an input to the multiplier/adder. Each
accumulator is divided into three parts:
Instructions are provided for storing the guard bits, for storing the high- and the low-order
accumulator words in data memory, and for transferring 32-bit accumulator words in or out of data
memory. Also, either of the accumulators can be used as temporary storage for the other.
Barrel Shifter
The C67xx DSP barrel shifter has a 40-bit input connected to the accumulators or to data memory
(using CB or DB), and a 40-bit output connected to the ALU or to data memory (using EB). The
barrel shifter can produce 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 of the instruction, the shift count field
(ASM) of status register ST1, or in temporary register T (when it is designated as a shift count
register).The barrel shifter and the exponent encoder normalize the values in an accumulator in a
single cycle. The LSBs of the output are filled with 0s, and the MSBs can be either zero filled or
sign extended, depending on the state of the sign-extension mode bit (SXM) in ST1. Additional
shift capabilities enable the processor to perform numerical scaling, bit extraction, extended
arithmetic, and overflow prevention operations.
Multiplier/Adder Unit
The multiplier/adder unit performs 17_17-bit 2’s-complement multiplication with a 40-bit addition
in a single instruction cycle. The multiplier/adder block consists of several elements: a multiplier,
an adder, signed/unsigned input control logic, fractional control logic, a zero detector, a rounder
(2’s complement), overflow/saturation logic, and a 16-bit temporary storage register (T). The
multiplier has two inputs: one input is selected from T, a data-memory operand, or accumulator A;
the other is selected from program memory, data memory, accumulator A, or an immediate value.
The fast, on-chip multiplier allows the C67xx DSP to perform operations efficiently such as
convolution, correlation, and filtering. 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 Euclidian distance and in implementing symmetrical
and LMS filters, which are required for complex DSP algorithms.
These are the some of the important parts of the processor and you are instructed to go through the
detailed architecture once which helps you in developing the optimized code for the required
application.
RESULT:
The architecture of DSP processor-TMS 320C67xx is studied successfully.
VIVA QUESTIONS
1. Define signal and signal processing.
2. Differentiate digital and analog signals?
3. How DSP processors differ from conventional processors?
4. Expand the abbreviation TMS320C67xx.
5. What kind of processor is DSP processor?
6. What are the main building blocks of DSP processor?
7. What is the main function of MAC unit?
8. Explain VLIW architecture?
9. What is meant by circular buffer?
10. What is meant by emulator and JTAG?