Digital Design & Signal Simulation Lab 23 Regulation
Digital Design & Signal Simulation Lab 23 Regulation
DEPARTMENT OF
Electronics and communication Engineering
DIGITAL DESIGN & SIGNAL SIMULATION LAB
OBSERVATION
Lab In charge
ABOUT THE DEPARTMENT:
Course Objectives:
Verify the truth tables of various logic circuits.
Design sequential/combinational circuit using Hardware Description Language and verify
their functionality.
Simulate various Signals and Systems through MATLAB
Analyze the output of a system when it is excited by different types of deterministic and
random signals.
Course Outcomes: After completing the course, the student should be able to:
Verify the truth tables of various logic circuits. (L2)
Understand how to simulate different types of signals and system response. (L2)
Design sequential and combinational logic circuits and verify their functionality. (L3, L4)
Analyze the response of different systems when they are excited by different signals and
plot power spectral density of signals. (L4)
Generate different random signals for the given specifications. (L5)
List of Experiments:
PART A
1. Design a simple combinational circuit with four variables and obtain minimal SOP expression
and verify the truth table using Digital Trainer Kit.
2. Verification of functional table of 3 to 8-line Decoder /De-multiplexer
3. 4 variable logic function verification using 8 to1 multiplexer.
4. Design full adder circuit and verify its functional table.
5. Design a four-bit ring counter using D Flip–Flops/JK Flip Flop and verify output.
6. Design a four-bit Johnson’s counter using D Flip-Flops/JK Flip Flops and verify output
7. Verify the operation of 4-bit Universal Shift Register for different Modes of operation.
8. Draw the circuit diagram of MOD-8 ripple counter and construct a circuit using T-Flip-Flops
and Test It with a low frequency clock and sketch the output waveforms.
9. Design MOD–8 synchronous counter using T Flip-Flop and verify the result and sketch the
output waveforms.
10. (a) Draw the circuit diagram of a single bit comparator and test the output
(b) Construct 7 Segment Display Circuit Using Decoder and7 Segment LED and test it.
PART B
1. Write a program to generate various Signals and Sequences: Periodic and Aperiodic, Unit
Impulse, Unit Step, Square, Saw tooth, Triangular, Sinusoidal, Ramp, Sinc function.
2. Perform operations on Signals and Sequences: Addition, Multiplication, Scaling,
Shifting, Folding, Computation of Energy and Average Power.
3. Write a program to find the trigonometric & exponential Fourier series coefficients of a
rectangular periodic signal. Reconstruct the signal by combining the Fourier series
coefficients with appropriate weightings- Plot the discrete spectrum of the signal.
4. Write a program to find Fourier transform of a given signal. Plot its amplitude and phase
spectrum.
5. Write a program to convolve two discrete time sequences. Plot all the sequences.
6. Write a program to find autocorrelation and cross correlation of given sequences.
7. Write a program to verify Linearity and Time Invariance properties of a given
Continuous System.
8. Write a program to generate discrete time sequence by sampling a continuous time
signal. Show that with sampling rates less than Nyquist rate, aliasing occurs while
reconstructing the signal.
9. Write a program to find magnitude and phase response of first order low pass and high
pass filter. Plot the responses in logarithmic scale.
10. Write a program to generate Complex Gaussian noise and find its mean, variance,
Probability Density Function (PDF) and Power Spectral Density (PSD).
11. Generate a Random data (with bipolar) for a given data rate (say 10kbps). Plot the same
for a time period of 0.2 sec.
12. To plot pole-zero diagram in S-plane of given signal/sequence and verify its stability.
INDEX
2
3
10
11
12
13
14
15
16
17
18
19
20
Lab In charge
Expt.No: 1
Minimal SOP expression obtained from a combinational circuit.
Date:
AIM:To Design a simple combinational circuit with four variables and obtain minimal SOP
expression
APPARATUS:
LOGIC DIAGRAM:-
Fig:2.1 SOP
PROCEDURE:-
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
RESULT:
VIVA-VOCE QUESTIONS:
1.Define SOP?
2.Define POS?
3.What is Canonical SOP?
4.What is Canonical POS?
5.Define Minterms?
6.Define Maxterms?
Expt.No: 2
3- to - 8 Decoder/Demultiplexer - 74138.
Date:
A binary decoder is a combinational logic circuit that converts binary information from ncoded
inputs to a maximum of 2n unique outputs. They are used in a wide variety of applications,
including data demultiplexing, seven segment displays, and memory address decoding.
There are several types of binary decoders, but in all cases a decoder is an electronic circuit with
multiple input and multiple output signals, which converts every unique combination of input states
to a specific combination of output states. In addition to integer data inputs, some decoders also
have one or more "enable" inputs. When the enable input is negated (disabled), all decoder outputs
are forced to their inactive states.
A binary decoder is usually implemented as either a stand-alone integrated circuit (IC) or as part of
a more complex IC. In the latter case the decoder may be synthesized by means of a hardware
description language such as VHDL or Verilog. Widely used decoders are often available in the
form of standardized ICs.
The decoder is used for converting the binary code into the octal code. The IC74138 is the 3 x 8
decoder which contains three inputs and 8 outputs and also three enables out of them two are
active low and one is active high. Decoders are used in the circuit where required to get more
outputs than that of the inputs.
Decoders were used in analog to digital conversion in analog decoders, electronic circuits to
convert instructions into CPU control signals and also mainly used in logical circuits, data transfer.
LOGIC DIAGRAM:
Fig:3.1 3 to 8 decoder
TRUTH TABLE:
Selected Enable
Inputs Outputs
Inputs
G1 G2A G2B C B A Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
X 0 X X X X 1 1 1 1 1 1 1 1
X X 1 X X X 1 1 1 1 1 1 1 1
0 X X X X X 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 1 1 1 1 1 1 1
1 0 0 0 0 1 1 0 1 1 1 1 1 1
1 0 0 0 1 0 1 1 0 1 1 1 1 1
1 0 0 0 1 1 1 1 1 0 1 1 1 1
1 0 0 1 0 0 1 1 1 1 0 1 1 1
1 0 0 1 0 1 1 1 1 1 1 0 1 1
1 0 0 1 1 0 1 1 1 1 1 1 0 1
1 0 0 1 1 1 1 1 1 1 1 1 1 0
PROCEDURE :
1. Make the connections as per the circuit diagram .
2. Change the values of G1,G2A,G2B,A,B,and C, using switches.
3. Observe status of Y0, to Y7 on LED’s.
4. Verify the truth table.
RESULT:
VIVA-VOCE QUESTIONS:
Multiplexer is a combinational circuit that is one of the most widely used in digital design. The
multiplexer is a data selector which gates one out of several inputs to a single o/p. . It has n data
inputs & one o/p line & m select lines where 2m= n.Depending upon the digital code applied at the
select inputs one out of n data input is selected & transmitted to a single o/p channel.
A Multiplexer is used in communication systems, which has a transmission system and also a
communication network. A Multiplexer is used to increase the efficiency of the communication
system by allowing the transmission of data, such as audio & video data from different channels
via cables and single lines and it is also used to transmit the data signals from the computer
system of a satellite to the ground system by using a GSM communication
PIN DIAGRAM :
EN_L A B C D0 D1 D2 D3 D4 D5 D6 D7 Y Y’
1 0 0 0 0 X X X X X X X D0 D0’
0 0 0 0 1 X X X X X X X D0 D0’
0 0 0 1 X 0 X X X X X X D1 D1’
0 0 0 1 X 1 X X X X X X D1 D1’
0 0 1 0 X X 0 X X X X X D2 D2’
0 0 1 0 X X 1 X X X X X D2 D2’
0 0 1 1 X X X 0 X X X X D3 D3’
0 0 1 1 X X X 1 X X X X D3 D3’
0 1 0 0 X X X X 0 X X X D4 D4’
0 1 0 0 X X X X 1 X X X D4 D4’
0 1 0 1 X X X X X 0 X X D5 D5’
0 1 0 1 X X X X X 1 X X D5 D5’
0 1 1 0 X X X X X X 0 X D6 D6’
0 1 1 0 X X X X X X 1 X D6 D6’
0 1 1 1 X X X X X X X 0 D7 D7’
0 1 1 1 X X X X X X X 1 D7 D7’
RESULT:
VIVA-VOCE QUESTIONS:
AIM: To Verify the Truth Table of Full Adder and Full Subtractor using IC 7483
APPARATUS:
THEORY:
A combinational logic circuit that performs the addition of two single bits is called Half Adder. A
combinational logic circuit that performs the addition of three single bits is called Full Adder. A
full adder is a digital circuit that performs addition. ... A full adder adds three one-bit binary
numbers, two operands and a carry bit. The adder outputs two numbers, a sum and a carry bit. The
term is contrasted with a half adder, which adds two binary digits.
A full subtractor is a combinational circuit that performs subtraction of two bits, one is minuend.
and other is subtrahend, taking into account borrow of the previous adjacent lower minuend bit.
This circuit has three inputs and two outputs.
INPUTS OUTPUTS
B3 B2 A3 S3 C
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
PROCEDURE:
put switch to ADD mode and
Set A2 to logic high state i.e.'1'.
Set A0,B0,A1, B1 to logic low state i.e. '0'.
Consider A3,B2,B3 as inputs.
S3 and C are Sum and Carry outputs.
Now verify the truth table of Full Adder.
Note: Ignore all other outputs i.e. S0, S1, DS2
INPUTS OUTPUTS
A3 B3 B2 D3 B
0 0 0 0 0
0 0 1 1 1
0 1 0 1 1
0 1 1 0 1
1 0 0 1 0
1 0 1 0 0
1 1 0 0 0
1 1 1 1 1
PROCEDURE:
put switch to SUB mode and
Set A0, B0, A2 to logic low state i.e.'0'.
Set A1, B1 to logic high state i.e. '1'.
Consider B2 as Borrow input.
A3,B2,B3 as inputs.
D3 and B are difference and Borrow Outputs
Now verify the truth table of Full subtractor.
Note: Ignore all other outputs i.e. D0, D1, D2.
RESULT:
VIVA-VOCE QUESTIONS:
AIM:
Design 4bit Ring Counter using D Flip Flop and JK Flip Flop
EQUIPMENT REQUIRED:
Trainer Kit
Patch Chords
A J-K flip-flop is nothing more than an S-R flip-flop with an added layer of feedback. This
feedback selectively enables one of the two set/reset inputs so that they cannot both carry an active
signal to the multivibrator circuit, thus eliminating the invalid condition
PROCEDURE:
3. Apply ORI is low and clock is don’t care then the output is 1000
4. ORI is high and apply Clock inputs and Observe the truth table of Ring Counter
TRUTH TABLE :
RESULT:
VIVA-VOCE QUESTIONS:
AIM: Design Johnson Counter using D Flip Flop and JK Flip Flop
APPARATUS:
THEORY: A Johnson counter is a modified ring counter in which the output from the last flip flop
is inverted and fed back as an input to the first. It is also called as Inverse Feedback Counter or
Twisted Ring Counter.This is an advantage of the Johnson counter that it requires only half number
of flip flops that of a ring counter uses, to design the same Mod.The main difference between the 4
bit ring counter and the Johnson counter is that , in ring counter , we connect the output of last flip
flop directly to the input of first flip flop. But in Johnson counter, we connect the inverted output of
last stage to the first stage input.The Johnson counter is also known as Twisted Ring Counter, with
a feedback. In Johnson counter the input of the first flip flop is connected from the inverted output
of the last flip flop.The Johnson counter or switch trail ring counter is designed in such a way that it
overcomes the limitations of ring counter. Mainly it reduces the number of flip flops required for
designing the circuit
PROCEDURE:
3. Apply Clock inputs and Observe the truth table of Ring Counter and Johnson counter
TRUTH TABLE :
RESULT:
VIVA-VOCE QUESTIONS:
APPARATUS:
PC with HDL
Theory:
Decoder:
A decoder is a combinational logic circuit that is used to change the code into a setof
signals. It is the reverse process of an encoder. A decoder circuit takes multiple inputs and gives
multiple outputs. A decoder circuit takes binary data of ‘n’ inputs into ‘2n ’ unique output. In
addition to input pins, the decoder has a enable pin. This enables the pin when negated, to make the
circuit inactive.
Demultiplexer:
A demultiplexer is a device that takes a single input and gives one of the several output
lines. A demultiplexer takes one single input data and then selects any one of the single output lines
one at a time. It is the reverse process of a multiplexer. It is also called as a DEMUX or a data
distributor. A DEMUX converts the input serial data line into output parallel data. A DEMUX
gives ‘2n’ outputs for ‘n’ selection lines with a single input.
Truth table:
Program:
module decoder3_to_8( in,out, en);
input [2:0] in;
input en;
output [7:0] out;
reg [7:0] out;
always @( in or en)
begin
if (en)
begin
out=8'd0;
case (in)
3'b000: out[0]=1'b1;
3'b001: out[1]=1'b1;
3'b010: out[2]=1'b1;
3'b011: out[3]=1'b1;
3'b100: out[4]=1'b1;
3'b101: out[5]=1'b1;
3'b110: out[6]=1'b1;
3'b111: out[7]=1'b1;
default: out=8'd0;
endcase
end
else
out=8'd0;
end
endmodule
Expected waveform:
Result :
3. variable logic function verification using 8-to-1 multiplexer
Aim: To design 8x1 multiplexer/ Demultiplexer using verilog and simulate the design
APPARATUS:
PC with HDL
Theory:
An 8-to-1 multiplexer consists of eight data inputs D0 through D7, three input select lines S2
through S0 and asingle output line Y. Depending on the select lines combinations, multiplexer
decodes the inputs.
The below figure shows the block diagram of an 8-to-1 multiplexer with enable input
that enable or disable the multiplexer. Since the number data bits given to the MUX are eight
then 3 bits (23=8) are needed toselect one of the eight data bits.
The truth table for an 8-to1 multiplexer is given below with eight combinations of
inputs so as to generate each output corresponds to input.
Program:
module mux8_1(input D0,D1,D2,D3,D4,D5,D6,D7, input
[2:0]S,output reg Y);always @( * )
begin
if (S==3'b000) Y=D0;
else if
(S==3'b00
1) Y=D1;
else if
(S==3'b01
0) Y=D2;
else if
(S==3'b01
1) Y=D3;
else if
(S==3'b10
0) Y=D4;
else if
(S==3'b10
1) Y=D5;
else if
(S==3'b11
0) Y=D6;
else if
(S
=3'b111)
Y=D7;else
Y=0;end
module
Result :
4.Design of Full Adder Circuit and verify its Functional table
Aim: To design Full Adder Circuit and verify its Functional table
APPARATUS: PC with HDL
Theory:
Full adder is a combinational circuit which computer binary addition of three binary inputs.
The truth table of full adder is given below and we can write boolean expression for full adder as
follows
𝑠𝑢𝑚=𝑎⊕𝑏⊕𝑐𝑖𝑛
𝑐𝑎𝑟𝑟𝑦=𝑎.𝑏+𝑏.𝑐𝑖𝑛+𝑐𝑖𝑛.𝑎
Program
modulefull_adder_s(
inputa,b,cin,
outputsum,carry
);
xor(w1,a,b);
xor(sum,w1,cin);//Sum output
and(w2,a,b);
and(w3,b,cin);
and(w4,cin,a);
or(carry,w2,w3,w4);//carry output
endmodule
Result :
5.Design a 4 bit Ring Counter using D Flip-Flop and verify output
Aim: To design a 4 bit Ring Counter using D Flip-Flop and verify output
APPARATUS: PC with HDL
Theory:
A ring counter is a digital circuit with a series of flip flops connected together in a feedback
manner.The circuit is special type of shift register where the output of the last flipflop is fed back to
the input of first flipflop.When the circuit is reset, except one of the flipflopoutput,all others are
made zero. For n-flipflop ring counter we have a MOD-n counter. That means the counter has n
different states.
The circuit diagram for a 4 bit ring counter is shown below:
I have written a Verilog code for a 4-bit ring counter which has the following states:
0001 - 0010 - 0100 - 1000 .... and so on
Program:
//declare the Verilog module - The inputs and output port names.
module ring_counter(
Clock,
Reset,
Count_out
);
endmodule
Expected Waveforms
Result :
6.Design a 4 bit Johnson’s Counter using D Flip-Flop and verify output
Aim: To design a 4 bit Johnson’s Counter using D Flip-Flop and verify output
APPARATUS: PC with HDL
Theory:
A Johnson counter is a digital circuit with a series of flip flops connected together in a
feedback manner.The circuit is special type of shift register where the complement output of the
last flipflop is fed back to the input of first flipflop.This is almost similar to ring counter with a few
extra advantages.When the circuit is reset all the flipflop outputs are made zero. For n-flipflop
Johnson counter we have a MOD-2n counter. That means the counter has 2n different states.
The circuit diagram for a 3 bit Johnson counter is shown below:
I have written a Verilog code for a 4-bit Johnson counter which has the following states:
0000 - 0001 - 0011 - 0111 - 1111 - 1110 - 1100 - 1000 - 0000 .... and so on
Program:
//declare the Verilog module - The inputs and output port names.
module johnson_counter(
Clock,
Reset,
Count_out
);
endmodule
Expected Waveforms
Result :
7.Verify the operation of 4 bit Universal Shift Register for different modes
of operation
Aim: To Verify the operation of 4 bit Universal Shift Register for different modes
APPARATUS: PC with HDL
Theory:
A universal shift register is a sequential logic that can store data within and on every clock pulse it
transfers data to the output port.
The universal shift register can be used as
1. Parallel In Parallel Out shift register
2. Parallel In Serial Out shift register
3. Serial In Parallel Out shift register
4. Serial In Serial Out shift register
Program
moduleuniversal_shift_reg(
inputclk,rst_n,
input[1:0] select,// select operation
input[3:0]p_din,// parallel data in
inputs_left_din,// serial left data in
inputs_right_din,// serial right data in
outputreg[3:0]p_dout,//parallel data out
outputs_left_dout,// serial left data out
outputs_right_dout// serial right data out
);
always@(posedgeclk)begin
if(!rst_n)p_dout<=0;
elsebegin
case(select)
2'h1:p_dout<={s_right_din,p_dout[3:1]};// Right Shift
2'h2:p_dout<={p_dout[2:0],s_left_din};// Left Shift
2'h3:p_dout<=p_din;// Parallel in - Parallel out
default:p_dout<=p_dout;// Do nothing
endcase
end
end
assigns_left_dout=p_dout[0];
assigns_right_dout=p_dout[3];
Endmodule
Result :
8.Draw the Circuit diagram of Mod-8 Ripple Counter and Construct a
Circuit using T-Flip Flop and test it with a low frequency clock and
sketch theoutput waveforms
Aim: To Verify the operation Mod-8 Ripple Counter and Construct a Circuit using T-Flip Flop
APPARATUS: PC with HDL
Theory:
To proceed with Verilog Code, we shall first understand the structure of the 3-bit Ripple Counter.
The top design block consists of three T-Flip Flop. For time being ignore the input and output of
T-Flip Flop. Let us consider the overall outside structure of Ripple Counter. We have two inputs
i.e., clock and reset and q is output. The output q is in 4-bit vector form.
Program
moduleripplecounter(clk,rst,q);
inputclk,rst;
output [2:0]q;
Result :
9. Design Mod-8 synchronous Counter using T-Flip Flop and verify the
result and sketch theoutput waveforms
Aim: To Design Mod-8 synchronous Counter using T-Flip Flop and verify the result and sketch
theoutput waveforms
wire [6:0] W;
wire [7:0] S;
tff0 u1 (SW[0],KEY[0],S[7]);
tff0 u2 (W[0], KEY[0],S[6]);
tff0 u3 (W[1], KEY[0],S[5]);
tff0 u4 (W[2], KEY[0],S[4]);
tff0 u5 (W[3], KEY[0],S[3]);
tff0 u6 (W[4], KEY[0],S[2]);
tff0 u7 (W[5], KEY[0],S[1]);
tff0 u8 (W[6], KEY[0],S[0]);
endmodule
endmodule
module seg7(bcd,leds);
input [3:0] bcd;
outputreg [6:0] leds;
always @ (bcd)
case (bcd)
0: leds = 7'b0000001;
1: leds = 7'b1001111;
2: leds = 7'b0010010;
3: leds = 7'b0000110;
4: leds = 7'b1001100;
5: leds = 7'b0100100;
6: leds = 7'b0100000;
7: leds = 7'b0001111;
8: leds = 7'b0000000;
9: leds = 7'b0000100;
10: leds = 7'b0001000;
11: leds = 7'b1100000;
12: leds = 7'b0110001;
13: leds = 7'b1000010;
14: leds = 7'b0110000;
15: leds = 7'b0111000;
default: leds = 7'bx;
endcase
endmodule
Result :
10(a).Draw the Circuit diagram of a single bit Comparator and test the
output
Aim: To Draw the Circuit diagram of a single bit Comparator and test the output
The figure below shows the block diagram of a single bit magnitude comparator. This comparator
compares the two bits and produces one of the 3 outputs as L (A<B), E (A=B) and G (A>B).
Truth Table
Program
Result :
10(b).Construct 7 segment display circuit using decoder and 7 segment
LED and test it
Aim: To Construct 7 segment display circuit using decoder and 7 segment LED and test it
APPARATUS: PC with HDL
Theory:
In a 7-segment LED display, either all the anodes or all the cathodes of the LEDs in the seven
segments are tied together and brought out at a single pin, and the device is accordingly called
either a common-anode or a common-cathode display.
Program
moduleseg7(
input[3:0]data_in,
outputreg[7:0]display_out,
output[7:0]AN
);
assign AN =8'b11111110;
always @(*)begin
case(data_in)
4'b0000:
display_out =8'b00000011;//a,b,c,d,e,f,g,dot (zero)
4'b0001:
display_out =8'b10011111;//one
4'b0010:
display_out =8'b00100101;//two
4'b0011:
display_out =8'b00001101;//three
4'b0100:
display_out =8'b10011001;//four
4'b0101:
display_out =8'b01001001;//five
4'b0110:
display_out =8'b01000001;//six
4'b0111:
display_out =8'b00011111;//seven
4'b1000:
display_out =8'b00000001;//eight
4'b1001:
display_out =8'b00001001;//nine
4'b1010:
display_out =8'b00010001;//A
4'b1011:
display_out =8'b11000001;//b
4'b1100:
display_out =8'b01100011;//C
4'b1101:
display_out =8'b10000101;//d
4'b1110:
display_out =8'b01100001;//E
4'b1111:
display_out =8'b01110001;//F
endcase
end
endmodule
Expected Waveforms
Result :
PART-B
1.Generation of Various Signals and Sequences(Periodic & aperiodic)
AIM: Generate various signals and sequences (Periodic and aperiodic), such as Unit Impulse,
Unit Step, Square, Sawtooth, Triangular, Sinusoidal, Ramp, Sinc.
APPARATUS: PC with MATLAB
PROCEDURE:
1. Open MATLAB
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and run the program
6. For the output see command window\Figure window
THEORY:
If the amplitude of the signal is defined at every instant of time then it is called continuous
time signal. If the amplitude of the signal is defined at only at some instants of time then it is
called discrete time signal. If the signal repeats itself at regular intervals then it is called
periodic signal. Otherwise they are called aperiodic signals.
EX: Ramp, Impulse, unit step, sinc- Aperiodic signals square, sawtooth, triangular sinusoidal–
periodic signals.
»plot(x,y) When multiple curves appear on the same axis, it is a good idea to create a legend to label
and distinguish them. The command legend does exactly this.
»legend('cos(x)','sin(x)')
The text that appears within single quotes as input to this command, represents the legend
labels. We must be consistent with the ordering of the two curves, so since in the plot
command we asked for cosine to be plotted before sine, we must do the same here.
At any point during a MATLAB session, you can obtain a hard copy of the current plot by
either issuing the command print at the MATLAB prompt, or by using the command menus
on the plot window. In addition, MATLAB plots can by copied and pasted (as pictures) in
your favorite word processor (such as Microsoft Word). This can be achieved using the Edit
menu on the figure window. Another nice feature that can be used in conjunction with plot is
the command grid, which places grid lines to the current axis (just like you have on graphing
paper). Type help grid for more information. Other commands for data visualization that exist
in MATLAB include subplot create an array of (tiled) plots in the same window log log plot
using log-log scales semi logx plot using log scale on the x-axis semi logy plot using log scale
on they-axis
The Sinc function computes the mathematical Sinc function for an input vector or matrix x. Viewed
as a function of time, or space, the Sinc function is the inverse Fourier transform of the rectangular
pulse in frequency centered at zero of width 2p and height. The Sinc function has a value of 1 when
x is equal to zero, and a value of for allot here elements of x.
PROGRAM:
PERIODIC SIGNALS AND SEQUENCES:
1.Generate Sinusoidal signal
clc; clear
all;close
all;
N = input('Enter the number of cycles ...:: ');t
= 0:0.05:N;
x = sin(2*pi*t);
subplot(1,2,1);
plot(t,x);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Sinusoidal');
subplot(1,2,2);
stem(t,x);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Sinusoidal');
OUTPUT
Enter the number of cycles ...::
OUTPUT
Enter the number of cycles ..... ::
OUTPUT
Enter the number of cycles ....... ::
Enter the period ...... ::
VIVA-VOICE:
1 Define the different signals like step, ramp, impulse, sinusoidal and exponential.
2. What is the difference between analog signals and digital signals?
3. Express the ramp signal in terms of step.
4. Draw the different signal waveforms.
5. t=-25:0.1:25;a=1;b=((sin(t))./t);x=b.*(t<0)+a.*(t==0)+b.*(t>0
2.Operations on Signals and sequences
AIM:
To perform various operations on signals and sequence such as addition, multiplication,
scaling, shifting and folding computation of energy and average power using MATLAB
Code.
APPARATUS: PC with MATLAB
PROCEDURE:
1. Open MATLAB
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and run the program
6. For the output see command window\Figure window
THEORY:
SignalAddition
Addition: any two signals can be added to form a
third signal, z(t)=x(t)+y(t)
Multiplication:
Multiplication of two signals can be obtained by multiplying their values at every instant. Z
z(t)=x(t)y(t)
Time reversal/Folding: Time reversal of a signal
x(t) can be obtained by folding the signal about
t=0.Y(t)=y(-t) Signal Amplification/Scaling:
Y(n)=ax(n)if a<1attenuation a >1amplification
Time shifting: The time shifting of x(n) obtained by delay or advance the signal in time by using
y(n)=x(n+k)
If k is a positive number, y(n) shifted to the right ie the shifting delays the signal If k is a
negative number, y(n) it gets shifted left. Signal Shifting advances the signal
PROGRAM:
clc; clear
all;close
all;
t=0:0.01:1;
% generating two input signals
x1=sin(2*pi*4*t);
x2=sin(2*pi*8*t);
subplot(2,2,1);
plot(t,x1);
xlabel('time');
ylabel('amplitude');
title('signal1:sine wave of frequency 4Hz');
subplot(2,2,2);
plot(t,x2);
xlabel('time');
subplot(4,1,3);
ylabel('amplitude');
title('signal2:sine wave of frequency 8Hz');
% addition of signals
y1=x1+x2;
subplot(2,2,3);
plot(t,y1);
xlabel('time');
ylabel('amplitude');
title('resultant signal:signal1+signal2');
% multiplication of signals
y2=x1.*x2;
subplot(2,2,4);
plot(t,y2);
xlabel('time');
ylabel('amplitude');
title('resultant signal:dot product of signal1 and signal2');
% scaling of a signal1
A=10;
y3=A*x1;
figure;
subplot(2,2,1);
plot(t,x1);
xlabel('time');
ylabel('amplitude');
title('sine wave of frequency 4Hz')
subplot(2,2,2);
plot(t,y3);
xlabel('time');
ylabel('amplitude');
title('amplified input signal1 ');
% folding of a signal1
l1=length(x1); nx=0:l1
-1; subplot(2,2,3);
plot(nx,x1);
xlabel('nx');
ylabel('amplitude');
title('sine wave of frequency 4Hz') y4=fliplr(x1);
nf= -fliplr(nx);
subplot(2,2,4);
plot(nf,y4);
xlabel('nf');
ylabel('amplitude');
title('folded signal');
%shifting of a signal
figure;
t1=0:.01:pi;
x3=8*sin(2*pi*2*t1);
subplot(3,1,1);
plot(t1,x3);
xlabel('time t1');
ylabel('amplitude');
title('sine wave of frequency 2Hz');
subplot(3,1,2);
plot(t1+10,x3);
xlabel('t1+10');
ylabel('amplitude');
title('right shifted signal');
subplot(3,1,3);
plot(t1 -10,x3);
xlabel('t1 -10');
ylabel('amplitude');
title('left shifted signal');
%operations on sequences
n1=1:1:9;
s1=[1 2 3 0 5 8 0 2 4];
figure;
subplot(2,2,1);
stem(n1,s1);
xlabel('n1');
ylabel('amplitude');
title('input sequence1');
n2= -2:1:6;
s2=[1 1 2 4 6 0 5 3 6];
subplot(2,2,2);
stem(n2,s2);
xlabel('n2');
ylabel('amplitude');
title('input sequence2');
% addition of sequences
s3=s1+s2; subplot(2,2,3);
stem(n1,s3);
xlabel('n1');
ylabel('amplitude'); title('sum
of two sequences');
% multiplication of sequences
s4=s1.*s2;
subplot(2,2,4);
stem(n1,s4);
xlabel('n1');
ylabel('amplitude');
title('product of two sequences');
% scaling of a sequence figure;
subplot(2,2,1);
stem(n1,s1);
xlabel('n1');
ylabel('amplitude');
title('input sequence1');
s5=4*s1; subplot(2,2,2);
stem(n1,s5);
xlabel('n1');
ylabel('amplitude'); title('scaled sequence1');
subplot(2,2,3);
stem(n1 -2,s1);
xlabel('n1');
ylabel('amplitude');
title('left shifted sequence1');
subplot(2,2,4);
stem(n1+2,s1);
xlabel('n1');
ylabel('amplitude');
title('right shifted sequence1');
% folding of a sequence
l2=length(s1);
nx1=0:l2-1;
figure; subplot(2,1,1);
stem(nx1,s1);
xlabel('nx1');
ylabel('amplitude');
title('input sequence1');
s6=fliplr(s1);
nf2=-fliplr(nx1);
subplot(2,1,2);
stem(nf2,s6);
xlabel('nf2');
ylabel('amplitude');
title('folded sequence1');
% program for energy of a sequence
e1=sum(abs(z1).^2);
% program for energy of a signal
t=0:pi:10*pi;
z2=cos(2*pi*50*t).^2;
e2=sum(abs(z2).^2);
% program for power of a sequence
p1= (sum(abs(z1).^2))/length(z1);
% program for power of a signal
p2=(sum(abs(z2).^2))/length(z2);
OUTPUT WAVEFORMS:
RESULT:
Various operations on signals and sequences are performed
VIVA-VOCE:
AIM: To find the Fourier Transform of a given signal and plotting its magnitude and phase
spectrum.
APPARATUS: PC with MATLAB
PROCEDURE:
1. Open MATLAB
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and run the program
6. For the output see command window\Figure window
THEORY:
FOURIER TRANSFORM:
The Fourier transform as follows. Suppose that ƒ is a function which is zero outside of some
interval [−L/2, L/2]. Then for any T ≥ L we may expand ƒ in a Fourier series on the interval
[−T/2,T/2], where the "amount" of the wave e2πinx/T in the Fourier series of ƒ is given by By
definition Fourier Transform of signal f(t) is defined as
PROGRAM:
clc;
clearall;
closeall;
fs=1000;
N=1024; % length of fft sequence
t=[0:N-1]*(1/fs);
% input signal
x=0.8*cos(2*pi*100*t);
subplot(3,1,1);
plot(t,x);
axis([0 0.05 -1 1]);
grid;
xlabel('t');
ylabel('amplitude');
title('input signal');
% magnitude spectrum
x1=fft(x);
k=0:N-1;
Xmag=abs(x1);
subplot(3,1,2);
plot(k,Xmag);
grid; xlabel('t');
ylabel('amplitude');
title('magnitude of fft signal')
%phase spectrum
Xphase=angle(x1)*(180/pi);
subplot(3,1,3);
plot(k,Xphase);
grid;
xlabel('t');
ylabel('angle in degrees');
title('phase of fft signal');
OUTPUT WAVEFORMS:
RESULT:
Magnitude and phase spectrum of FFT of a given signal is plotted
VIVA VOICE:
1. Define Fourier Transform?
2. Compare FS and FT?
3. Applications of Fourier Transform?
4.Convolution between Signals & Sequences
AIM: Write the program for convolution between two signals and also between two sequences.
APPARATUS: PC with MATLAB
PROCEDURE:
1. Open MATLAB
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and run the program
6. For the output see command window\Figure window
THEORY:
Convolution involves the following operations.
1. Folding
2. Multiplication
3. Addition
4. Shifting
Convolution is an integral concatenation of two signals. It is used for the determination of the
output signal of a linear time-invariant system by convolving the input signal with the impulse
response of the system. Note that convolving two signals is equivalent to multiplying the Fourier
transform of the two signals.
These operations can be represented by a Mathematical Expression as follows:
x[n]= Input signal Samples
h[ n-k]= Impulse response co-efficient.
y[ n]= Convolution output.
n = No. of Input samples
h = No. of Impulse response co-efficient.
Example : X(n)={1 2 -1 0 1}, h(n)={ 1,2,3,-1}
PROGRAM:
clc; closeall;
clearall;
%program for convolution of two sequences
x=input('enter input sequence '); h=input('enter impulse
response '); y=conv(x,h);
subplot(3,1,1);
stem(x); xlabel('n');
ylabel('x(n)'); title('input
sequence')subplot(3,1,2);
stem(h);
xlabel('n');
ylabel('h(n)');
title('impulse response sequence')
subplot(3,1,3);
stem(y);
xlabel('n');
ylabel('y(n)'); title('linear
convolution')
disp('linear convolution y=');disp(y)
%program for signal convolution
t=0:0.1:10;
x1=sin(2*pi*t);
h1=cos(2*pi*t);
y1=conv(x1,h1);
figure;
subplot(3,1,1);
plot(x1); xlabel('t');
ylabel('x(t)'); title('input
signal')subplot(3,1,2);
plot(h1); xlabel('t');
ylabel('h(t)'); title('impulse
response')subplot(3,1,3); plot(y1);
xlabel('n');
ylabel('y(n)'); title('linear
convolution');
OUTPUT:
enter input sequence: [1 3 4 5]
enter impulse response: [2 1 4]
linear convolution y=
2 7 15 26 21 20
OUTPUT WAVEFORMS:
RESULT:
Convolution between signals and sequences is computed.
VIVA-VOCE:
1. Define convolution.
AIM: To compute Auto correlation and Cross correlation between signals and sequences.
PROCEDURE:
1. Open MATLAB
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and run the program
6. For the output see command window\Figure window
THEORY:
Correlations of sequences:
It is a measure of the degree to which two sequences are similar. Given two real-valued
sequences x(n) and y(n) of finite energy,
Convolution involves the following operations.
1. Shifting
2. Multiplication
3. Addition
PROGRAM:
clc; closeall;
clearall;
% two input sequences x=input('enter input
sequence');
h=input('enter the impulse suquence');
subplot(2,2,1);
stem(x);
xlabel('n');
ylabel('x(n)'); title('input
sequence');subplot(2,2,2);
stem(h);
xlabel('n');
ylabel('h(n)'); title('impulse
sequence');
% cross correlation between two
y=xcorr(x,h);
subplot(2,2,3);
stem(y); xlabel('n');
ylabel('y(n)');
title(' cross correlation between two sequences ');
% auto correlation of input sequence
z=xcorr(x,x);
subplot(2,2,4);
stem(z); xlabel('n');
ylabel('z(n)');
title('auto correlation of input sequence');
% cross correlation between two signals
% generating two input signals
t=0:0.2:10;
x1=3*exp(-2*t);
h1=exp(t); figure;
subplot(2,2,1);
plot(t,x1);
xlabel('t');
ylabel('x1(t)'); title('input
signal');subplot(2,2,2);
plot(t,h1);
xlabel('t');
ylabel('h1(t)'); title('impulse
signal');
% cross correlation
subplot(2,2,3);
z1=xcorr(x1,h1); plot(z1);
xlabel('t');
ylabel('z1(t)'); title('cross correlation
');
% auto correlation
subplot(2,2,4);
z2=xcorr(x1,x1);
plot(z2); xlabel('t');
ylabel('z2(t)'); title('auto correlation
');
Output:
enter input sequence [1 2 5 7]
enter the impulse sequence [2 6 0 5 3]
OUTPUT WAVEFORMS:
RESULT:
Auto correlation and Cross correlation between signals and sequences is computed.
VIVA-VOCE:
1. Define Correlation.
AIM: Write a MATLAB program to verify the linearity and time invariance of the system.
PROCEDURE:
1. Open MATLAB
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and run the program
6. For the output see command window\Figure window
THEORY:
linearity property:
Any system is said to be linear if it satisfies the superposition principal. Superposition principal
state that Response to a weighted sum of input signal equal to the corresponding weighted sum of
the outputs of the system to each of the individual input signals. If x(n) is a input signal and y(n)
is a output signal then y(n)=T[x(n)]
y1(n)=T[x1(n)] and y2(n)=T[x2(n)]
x3=[a*x1(n) +b *x2(n) ]
Y3(n)= T [x3(n)]
T [a*x1(n)+b*x2(n)] = a y1(n)+ b y2(n)
PROGRAM:
%Program2:%
clc; clearall;
closeall;
n=0:40; a=2; b=-3;
x1=cos(2*pi*0.1*n);
x2=cos(2*pi*0.4*n);
x=a*x1+b*x2; y=x.^2;
y1=x1.^2;
y2=x2.^2;
yt=a*y1+b*y2;
d=y-yt;
d=round(d); ifd
disp('Given system is not satisfy linearity property');else
disp('Given system is satisfy linearity property');end
subplot(3,1,1),
stem(n,y); grid;
subplot(3,1,2),
stem(n,yt); grid;
subplot(3,1,3),
stem(n,d);
grid;
VIVA-VOICE:
PROCEDURE:
1. Open MATLAB
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and run the program
6. For the output see command window\Figure window
THEORY:
Sampling Theorem:
\A bandlimited signal can be reconstructed exactly if it is sampled at a rate atleast twice the
maximum frequency component in it."
The maximum frequency component of g(t) is fm. To recover the signal g(t) exactly from its
samples it has to be sampled at a rate fs ≥ 2fm.
The minimum required sampling rate fs = 2fm is called ' Nyquist rate
PROGRAM:
clc; clearall;
closeall;
t=-10:.01:10;T=4;
fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x);
xlabel('time');
ylabel('x(t)'); title('continous time signal');
grid;
n1=-4:1:4;
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;
x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);
stem(n1,x1);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs<2fm');holdon;
subplot(2,2,2);
plot(n1,x1);grid;
n2=-5:1:5;
x2=cos(2*pi*fm/fs2*n2);
subplot(2,2,3);
stem(n2,x2);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs=2fm');holdon;
subplot(2,2,3);
plot(n2,x2) grid;
n3=-20:1:20;
x3=cos(2*pi*fm/fs3*n3);
subplot(2,2,4);
stem(n3,x3);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs>2fm')holdon;
subplot(2,2,4);
plot(n3,x3) grid;
OUTPUT WAVEFORMS:
AIM: To find magnitude and phase response of first order low pass and high pass filter. Plotthe
responses in logarithmic scale.
APPARATUS: PC with MATLAB
PROCEDURE:
1. Open MATLAB
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. For the output see command window\Figure window
THEORY:
To get the phase response in the time domain you need to estimate the delay between the input
and the output at the test frequency and then convert to phase. For sure, taking the angleof the
RMS ratio will not yield that delay. If you really want to estimate the delay in the time
domain, there is a function called find delay that may be of use.
However, the alternative approach is to work in the frequency domain, i.e., use the ratio of the
frequency response of the output to the frequency response of the input to directly estimate the
magnitude and phase response of the system. The code that follows shows how to do that for a
simple low pass filter. Keep in mind, that any approach you use may begin to suffer as youtest
frequency gets close to the Nyquist frequency. You can experiment with this code to see how
close you can get before this simple approach begins to break down.
PROGRAM:
clc; clearall;
closeall;
w=0:0.01:1;
z=exp(1j*w);
alpha=0.3;
l=0.35*(1+z.^(-1)./(1-(0.3*z.^(-1))));
m=abs(l);
subplot(2,2,1);
plot(m);
title('magnitude plot of LPF');n=angle(l);
subplot(2,2,2);
plot(n);
title('phase plot of LPF');
h=0.65*(1-z.^(-1)./(1-(0.3*z.^(-1))));
d=abs(h);
subplot(2,2,3);
plot(d);
title('magnitude plot of HPF');k=angle(h);
subplot(2,2,4);
plot(k);
title('phase plot of HPF');
OUTPUT WAVEFORMS:
RESULT:
THEORY:
Gaussian noise is statistical noise that has a probability density function (abbreviated pdf) of the
normal distribution (also known as Gaussian distribution). In other words, the values the noise
can take on are Gaussian-distributed. It is most commonly used as additive white noise to yield
additive white Gaussian noise (AWGN). Gaussian noise is properly defined as the noise with a
Gaussian amplitude distribution. says nothing of the correlation of the noise in time or ofthe
spectral density of the noise. Labeling Gaussian noise as 'white' describes the correlation of the
noise. It is necessary to use the term "white Gaussian noise" to be correct. Gaussian noise is
sometimes misunderstood to be white Gaussian noise, but this is not the case.
PROGRAM:
clc; clear all;
close all;
OUTPUT WAVEFORMS:
RESULT:
Gaussian noise and its characteristics are studied.
VIVA VOICE:
1. Define mean, skew and kurtosis.
2. Define PDF and PSD.
3. What is the significance of Gaussian noise?
10.To plot pole-zero diagram in S-plane/Z-plane of given
signal/sequence and verify its stability
AIM: Write the program for locating poles and zeros and plotting pole-zero maps in s-plane
and z-plane for the given transfer function.
APPARATUS: PC with MATLAB
PROCEDURE:
1. Open MATLAB
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and run the program
6. For the output see command window\Figure window
THEORY:
The Z-transform, like many other integral transforms, can be defined as either a one-sided or
two-sided transform.
PROGRAM:
clc;
clear all;close
all;
%enter the numerator and denamenator cofficients in square bracketsnum=input('enter numerator
co-efficients');
den=input('enter denominator co-efficients');
% find poles and zeros
poles=roots(den)
zeros=roots(num)
% find transfer function H(s)
h=tf(num,den);
% plot the pole-zero map in s-planesgrid;
pzmap(h);
grid on;
title('locating poles and zeros on s-plane');
%plot the pole zero map in z-planefigure
zplane(poles,zeros);grid on;
title('locating poler and zeros on z-plane');
OUTPUT:
%locating poles of zero on s-
plane enter numerator
coefficient[1 2 3]
enter denominator coefficient[7 6 5]
OUTPUT WAVEFORMS:
OUTPUT:
%locating poles of zero on z-
plane enter numerator
coefficient[1 2 3]
enter denominator coefficient[1 2 3]
RESULT:
VIVA VOICE:
PROGRAM:
% Description: This M-file plots the truncated Fourier Series
% representation of a square wave as well as its
% amplitude and phase spectrum.clear; %
clear all variables clf; % clear all figures
N = 11; % summation limit (use N odd)
wo = pi; % fundamental frequency (rad/s)c0 = 0; % dc bias
t = -3:0.01:3; % declare time values figure(1) % put first two
plots on figure 1
% Compute yce, the Fourier Series in complex exponential formyce = c0*ones(size(t)); %
initialize yce to c0
forn = -N:2:N, % loop over series index n (odd)cn = 2/(j*n*wo); %
Fourier Series Coefficient
yce = yce + real(cn*exp(j*n*wo*t)); % Fourier Series computationend
subplot(2,1,1)
plot([-3 -2 -2 -1 -1 0 0 1 1 2 2 3],... % plot original y(t)
[-1 -1 1 1 -1 -1 1 1 -1 -1 1 1], ':');
hold;
plot(t,yce); % plot truncated exponential FSxlabel('t (seconds)');
ylabel('y(t)');
ttle = ['EE341.01: Truncated Exponential Fourier Series with N = ',...num2str(N)];
title(ttle);hold;
% Compute yt, the Fourier Series in trigonometric formyt = c0*ones(size(t)); %
initialize yt to c0
forn = 1:2:N, % loop over series index n (odd)cn = 2/(j*n*wo); %
Fourier Series Coefficient
yt = yt + 2*abs(cn)*cos(n*wo*t+angle(cn)); % Fourier Series computationend
subplot(2,1,2)
plot([-3 -2 -2 -1 -1 0 0 1 1 2 2 3],... % plot original y(t)
[-1 -1 1 1 -1 -1 1 1 -1 -1 1 1], ':');
hold; % plot truncated trigonometric FSplot(t,yt);
xlabel('t (seconds)'); ylabel('y(t)');
ttle = ['EE341.01: Truncated Trigonometric Fourier Series with N = ',...num2str(N)];
title(ttle);hold;
% Draw the amplitude spectrum from exponential Fourier Seriesfigure(2) % put next plots
on figure 2
subplot(2,1,1)
stem(0,c0); % plot c0 at nwo = 0hold;
forn = -N:2:N, % loop over series index n
cn = 2/(j*n*wo); % Fourier Series Coefficientstem(n*wo,abs(cn))
% plot |cn| vsnwo
end
forn = -N+1:2:N-1, % loop over even series index ncn = 0; % Fourier
Series Coefficient stem(n*wo,abs(cn)); % plot |cn| vsnwo
end
xlabel('w (rad/s)')
ylabel('|cn|')
ttle = ['EE341.01: Amplitude Spectrum with N = ',num2str(N)];title(ttle);
grid;
hold;
% Draw the phase spectrum from exponential Fourier Seriessubplot(2,1,2)
stem(0,angle(c0)*180/pi); % plot angle of c0 at nwo = 0hold;
forn = -N:2:N, % loop over odd series index n cn = 2/(j*n*wo); %
Fourier Series Coefficient stem(n*wo,angle(cn)*180/pi); % plot |cn|
vsnwoend
forn = -N+1:2:N-1, % loop over even series index ncn = 0; % Fourier
Series Coefficient stem(n*wo,angle(cn)*180/pi); % plot |cn| vsnwo
end
xlabel('w (rad/s)') ylabel('angle(cn)
(degrees)')
ttle = ['EE341.01: Phase Spectrum with N = ',num2str(N)];title(ttle);
grid;
hold;
OUTPUT WAVEFORMS:
RESULT:
Trigonometric & exponential Fourier series coefficients of a rectangular periodic signals are
plotted
DSD Lab using VHDL ECE DEPT 82