Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
36 views82 pages

Digital Design & Signal Simulation Lab 23 Regulation

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

Digital Design & Signal Simulation Lab 23 Regulation

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

JNTUA College Code: 2U

GEETHANJALI INSTITUTE OF SCIENCE & TECHNOLOGY


Unit of USHODAYA EDUCATIONAL SOCIETY
(Approved by AICTE, New Delhi & Permanently Affiliated to JNTUA, Anantapur)
Accredited By NBA & NAAC With A Grade
An ISO 9001:2015 certified Institution: Recognized under Sec. 2(f) of UGC Act, 1956
3rd Mile, Bombay Highway, Gangavaram (V)Kovur(M), SPSR Nellore (Dt), Andhra Pradesh,
India- 524137
Ph. No. 08622-212769, E-Mail: [email protected], Website: www.gist.edu.in

DEPARTMENT OF
Electronics and communication Engineering
DIGITAL DESIGN & SIGNAL SIMULATION LAB
OBSERVATION

Name of the student : ____________________________________________________


Roll no : ____________________________________________________
Year/ Sem : ____________________________________________________
Branch : ____________________________________________________

No. of Experiments Conducted: No. of Experiments Performed:

Lab In charge
ABOUT THE DEPARTMENT:

Department of Electronics and Communication Engineering


The Department of Electronics and Communication Engineering (ECE) was
established in the year 2008 and offers an under graduate program inElectronics and
Communication Engineering, with an initial intake of 60, and progressively increased to
180 by the year 2012. To accomplish the mission and vision of the Department, it has
adequate infrastructural support with well-equipped laboratories and Licensed softwares
comprises Xilinx, Code Composer Studio, MATLAB, LABTEK, MASM etc., .
The Department aims at imparting the students with the latest technologies
through NPTEL online resources, Webinars by Texas Instruments, Spoken tutorials,
SWAYAM and FOSSEE by IIT Bombay, Lab VIEW in association with National Instruments
(NI), Workshops and internships in association with Andhra Pradesh State Skill
Development Corporation (APSSDC) etc.,
The Department also employs training programmes such as ‘College to Corporate' (C2C)
Program by IIT Bombay and supports to build skills of entrepreneurship through
International Institute of Entrepreneurship (i2E) .The Department of ECE has membership
in professional societies like IEEE andIETE.
Adequate encouragement and technical scaffolding are extended to the students to
participate and excel in the national Level challenges organized by National Instruments,
Texas Instruments, TerrasicInc, DST, Intel, AICTE, IIT Bombayand the like. The department
organizes industrial visits to the apparent organizations as NARL (National Atmospheric
Research Laboratory), Shatish Dawn Space Centre (SDSC SHAR), to make students aware
with Industry Practices and acquaint with Newer Technologies.
The department of ECE bagged gold medalfrom JNTU Anantapur, anathapuramufor
securing highest percentage of marks in the University examinations for the batch 2013-
17.
Endowed with a cluster of well qualified, proficient and highly stimulating faculty
including 8 Doctorates and 23 M.Tech graduates in the specialized areas of VLSI Desin,
Digital Electronics and Computer systems, and Embedded systems adopting some of the
best academic practices like Smart Classrooms and ICT methods. The regular Faculty
Development programmes (FDP) through NMEICT, Workshops and Conferences help them
to update their skill set and to publish their work in conferences and reputed national and
international journals..

VISION OF THE DEPARTMENT:

 To progress as an effective learning centre producing competent professionals

MISSION OF THE DEPARTMENT:

 Quality education through interactive teaching-learning practices


 Technology-enabled environment to improve core competencies
 Industry-Collaboration to hone professional skills
 Fostering social skills and ethical values
List of Experiments as Per the Curriculum:

DIGITAL DESIGN & SIGNAL SIMULATION LAB

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

S.No Name of the experiment Date Page No. Marks Signature

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:

1. SOP Digital IC Trainer Kit


2. Patch Chords

LOGIC DIAGRAM:-

Fig:2.1 SOP

PROCEDURE:-

 Connect the circuit as for the circuit diagram.

 Connect the supply to the Digital IC Trainer System.

 Apply logic inputs to any 4variable equation example

A’B’C’D’ + A’BC’D’ + ABC’D’ + AB’C’D’ and observe the output


TRUTH TABLE:

STATE ABCD F =A’B’C’D’ + A’BC’D’ + ABC’D’ + AB’C’D’

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:

AIM: To verify operation of the 3 to 8 decoder using Ic 74138.


APPARATUS :
1. 3 to 8 decoder Ic 74138 kit.
2 .Patch chords .
THEORY:

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:

1. What are the applications of decoder?


2. What is the difference between decoder & encoder?
3. For n- 2n decoder how many i/p lines & how many o/p lines?
4. What are the different codes & their applications?
5. What Are Code Converters?
6. What Is The Difference Between Decoder And Demux?
Expt.No: 3
8x1 MULTIPLEXER-IC 74X151
Date:

AIM: To verify the truth table of a given 8 to 1 Multiplexer using IC 74151.


APPARATUS:
1. 8 to 1 Multiplexer Trainer kit .
2. Connecting patch chords
THEORY:

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.

IC 74151A is an 8: 1 multiplexer which provides two complementary outputs Y & Y. The


o/p Y is same as the selected i/p & Y is its complement. The n: 1 multiplexer can be used to realize
a m variable function. (2m= n, m is no. of select inputs)

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 :

Fig 4.1:Pin diagram of 74x151


Fig:4.1: 8 to 1 Multiplexer
TRUTH TABLE:

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:

1. Write the behavioral code for the IC 74x151.


2. What is meant by multiplexer?
3. What does demultiplexer mean?
4. How many 8X1 multiplexers are needed to construct 16X1 multiplexer?
5. Compare decoder with demultiplexer?
Expt.No: 4
Full ADDER and Full SUBTRACTOR
Date:

AIM: To Verify the Truth Table of Full Adder and Full Subtractor using IC 7483

APPARATUS:

1.Adder and Subtractor trainer

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.

Logic/Connection diagram of adder/subtractor

Fig 5.1: Adder/Subtractor


Truth Table of FULL ADDER:

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

Truth Table of FULL SUBTRACTOR:

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:

1.What is a full subtractor?


2.What is half adder full adder half subtractor and full subtractor?
3.What is a full adder explain?
4.What does a full adder do?
5.What is the major difference between half adders and full adders?
6.What is the difference between adder and subtractor circuits?
7.What is the major difference between half adders and full adders Mcq?
Expt.No: 5
4bit Ring Counter using D Flip Flop and JK Flip Flop
Date:

AIM:

Design 4bit Ring Counter using D Flip Flop and JK Flip Flop

EQUIPMENT REQUIRED:

 Trainer Kit
 Patch Chords

Logic Diagram of Ring Counter using D FLIP- FLOP

Fig 7.1: Ring Counter using D FLIP- FLOP


Logic Diagram of Ring Counter using JK FLIP-
FLOP

Fig:7.2: Ring Counter using JK FLIP- FLOP


THEORY: A ring counter is a special type of application of the Serial IN Serial OUT Shift
register. The only difference between the shift register and the ring counter is that the last flip flop
outcome is taken as the output in the shift register. But in the ring counter, this outcome is passed to
the first flip flop as an input. All of the remaining things in the ring counter are the same as the shift
register. Here, we use 4 D flip flops. The same clock pulse is passed to the clock input of all the flip
flops as a synchronous counter. The Overriding input(ORI) is used to design this circuit.

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:

1. Connect the circuit as for the circuit diagram.

2. Connect the supply to the Digital IC Trainer System.

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:

1.What is the purpose of a ring counter?


2.Which signal is essential in ring counter?
3.Which type of flip-flop is used for designing twisted ring counter?
4.How many flip flops are required for ring counter using JK flip flops?
Expt.No: 6
Johnson Counter using D Flip Flop and JK Flip Flop
Date:

AIM: Design Johnson Counter using D Flip Flop and JK Flip Flop

APPARATUS:

1. Johnson Counter Trainer kit


2. Patch Chords

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

Logic Diagram of Johnson Counter using D FLIP- FLOP:

Fig 8.1: Johnson Counter using D FLIP- FLOP


Logic Diagram of Johnson Counter using JK FLIP-
FLOP:

Fig 8.2: Johnson Counter using JK FLIP- FLOP

PROCEDURE:

1. Connect the circuit as for the circuit diagram.

2. Connect the supply to the Digital IC Trainer System.

3. Apply Clock inputs and Observe the truth table of Ring Counter and Johnson counter

TRUTH TABLE :

RESULT:

VIVA-VOCE QUESTIONS:

1.Which flip flop is used in Johnson counter?


2.Why Johnson counter is used?
3.What is Johnson counter explain its advantages and disadvantages?
4.Why Johnson counter is called modulo 2N counter
2.Verification of Functional table of 3 to 8 –Line Decoder/De-
Multiplexer
AIM: To verify the functional table of 3 to 8-line Decoder /De-multiplexer

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
);

wire w1,w2,w3,w4;//Internal connections

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
);

//what are the input ports and their sizes.


input Clock;
input Reset;
//what are the output ports and their sizes.
output [3:0] Count_out;
//Internal variables
reg [3:0] Count_temp;

//Whenever the Clock changes from 0 to 1(positive edge) or


//a change in Reset, execute the always block.
always @(posedge(Clock),Reset)
begin
if(Reset == 1'b1) begin //when Reset is high
Count_temp = 4'b0001; end //The Count value is reset to "0001".
else if(Clock == 1'b1) begin //When the Clock is high
//Left shift the Count value.
Count_temp = {Count_temp[2:0],Count_temp[3]}; end
end

//The Count value is assigned to final output port.


assign Count_out = Count_temp;

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
);

//what are the input ports and their sizes.


input Clock;
input Reset;
//what are the output ports and their sizes.
output [3:0] Count_out;
//Internal variables
reg [3:0] Count_temp;

//Whenever the Clock changes from 0 to 1(positive edge) or


//a change in Reset, execute the always block.
always @(posedge(Clock) or Reset)
begin
if(Reset == 1'b1) begin //when Reset is high
Count_temp = 4'b0000; end //The Count value is reset to "0000".
else if(Clock == 1'b1) begin //When the Clock is high
//Left shift the Count value and at the same time
//negate the least significant bit.
Count_temp = {Count_temp[2:0],~Count_temp[3]}; end
end

//The Count value is assigned to final output port.


assign Count_out = Count_temp;

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;

// initiate 3 T-FF to update the count


tff tf1(q[0],clk,rst);
tff tf2(q[1],q[0],rst);
tff tf3(q[2],q[1],rst);
Endmodule

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

APPARATUS: PC with HDL


Theory:
The 8-Bit Synchronous Counter using T Flip-Flops and AND Gates Consider the circuit in Figure
1. It is a 4-bit synchronous counter which utilizes four T-type flipflops.
The counter increases its value on each positive edge of the Clock signal if the Enable signal is
high, since it is an active-high signal. The counter is immediately cleared to 0 by setting the
asynchronous Clear signal low, since it is an active-low signal. The output of the leftmost flip-flop
in the diagram is considered to represent the LSB of the
counter.

module lab4part1(SW, KEY, HEX1, HEX0);


input [1:0] SW;
input [0:0] KEY;
output [0:6] HEX1,HEX0;

wire [6:0] W;
wire [7:0] S;

assign W[0] = SW[1] & S[7];


assign W[1] = W[0] & S[6];
assign W[2] = W[1] & S[5];
assign W[3] = W[2] & S[4];
assign W[4] = W[3] & S[3];
assign W[5] = W[4] & S[2];
assign W[6] = W[5] & S[1];

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]);

seg7 (S[3:0] , HEX0 );


seg7 (S[7:4] , HEX1 );

endmodule

module tff0(T, Clock, ClearN, Q);


input T, Clock, ClearN;
outputreg Q;

always @ ( posedge Clock, negedgeClearN)


if ( ~ClearN )begin
Q <=0;
end
else if ( T ) begin
Q <= !Q;
end

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

APPARATUS: PC with HDL


Theory:
A comparator used to compare two bits, i.e., two numbers each of single bit is called a single bit
comparator. It consists of two inputs for allowing two single bit numbers and three outputs to
generate less than, equal and greater than comparison outputs.

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

module b_comp1 (a, b, L, E,G);


input a, b; output L, E, G;
wire s1, s2;
not X1(s1, a);
not X2 (s2, b);
and X3 (L,s1, b);
and X4 (G,s2, a);
xnor X5 (E, a, b);
end module
Expected waveforms

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 ...::

2.Generate Sawtooth Waveform


clc; clear
all;close
all;
N = input('Enter the number of cycles ...:: ');
t1 = 0:25;
t = [];
for i = 1:N,
t = [t,t1];
end;
subplot(2,1,1);
plot(t);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Sawtooth waveform');
subplot(2,1,2);
stem(t);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Sawtooth waveform');

OUTPUT
Enter the number of cycles ..... ::

3.Generate Triangular Waveform


clc; clear
all;close
all;
N = input('Enter the number of cycles .......:: ');
M = input('Enter the period ......:: ');
t1 = 0:0.1:M/2;
t2 = M/2:-0.1:0;t
= [];
for i = 1:N,
t = [t,t1,t2];
end;
subplot(1,2,1);
plot(t);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Triangular waveform');
subplot(1,2,2);
stem(t);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Triangular waveform');

OUTPUT
Enter the number of cycles ....... ::
Enter the period ...... ::

4.Generate Square waveform


clc; clear
all;close
all;
fs=500;
t=0:1/fs:4;
x=square(2*pi*t,50);
subplot(2,1,1)
plot(t,x);
xlabel(' ---- > t');
ylabel(' ---- > x(t)');
title('Square signal');
fs=10;
n=0:1/fs:4;
x=square(2*pi*n,50);
subplot(2,1,2)
stem(n,x);
xlabel(' ---- > n');
ylabel(' ---- > x(n)');
title('Square sequence');

5.Generate Unit Impulse function


clc; clear
all;close
all;
x = ones(1,1);
y = zeros(1,2);
z = [y, x, y];
stem(z);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Unit Impulse');

6.Generate Unit Step function


clc; clear
all;close
all;
x = ones(100);
subplot(2,1,1);
plot(x);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Step signal');
subplot(2,1,2);
stem(x);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Step signal');
7.Generate Ramp function
clc; clear
all;close
all;t =
0:25;
y = t;
subplot(1,2,1);
plot(t,y);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Ramp function');
subplot(1,2,2);
stem(t,y);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Ramp function');

8.Generate Sinc function


clc; clear
all;close
all;
t = -3:0.1:3;
x = sin(pi*t)./(pi*t);
subplot(1,2,1); plot(x);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Sinc function');
axis([0,100,-0.5,1.0]);
subplot(1,2,2); stem(x);
xlabel(' ---------- > Time');
ylabel(' ---------- > Amplitude');
title('Sinc function');
axis([0,100,-0.5,1.0]);
OUTPUT WAVEFORMS:
RESULT:
Various signals & sequences generated using MATLAB software.

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:

1. What are the various mathematical operations on signals?


2. Define the various mathematical operations like addition, multiplication, division and average
with respect to signals.
3. Define scaling of a signal.
4. What is the difference between frequency scaling and amplitude scaling?
3.Fourier Transform of a given signal

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.

2. What is the difference between sequence and signal?


5.Auto Correlation and Cross Correlation between Signals
and Sequences

AIM: To compute Auto correlation and Cross correlation between signals and 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:
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.

2. Define auto correlation.

3. Define cross correlation.

4. What is the difference between auto and cross correlations?


6.Verification of Linearity and Time Invariance of a given
Continuous/Discrete system

AIM: Write a MATLAB program to verify the linearity and time invariance of the system.

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:
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:

%To write a Program to check Linearity Property of given Function


%Program1:%
clc; clearall;
closeall;
n=0:40;
a=2;
b=1;
x1=cos(2*pi*0.1*n);
x2=cos(2*pi*0.4*n);
x=a*x1+b*x2; y=n.*x;
y1=n.*x1;
y2=n.*x2;
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;

%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;

%To write a Program to check Time Invariance Property of given Functionclc;


closeall;
clearall;
n=0:40;
D=10;
x=3*cos(2*pi*0.1*n)-2*cos(2*pi*0.4*n);
xd=[zeros(1,D) x];
y=n.*xd(n+D);
n1=n+D;
yd=n1.*x;
d=y-yd; ifd
disp('Given system is not satisfy time shifting property');else

disp('Given system is satisfy time shifting property');end


subplot(3,1,1),
stem(y),
grid; subplot(3,1,2),
stem(yd),
grid; subplot(3,1,3),
stem(d),
grid;
OUTPUT WAVEFORMS:
RESULT:
The Linearity of a given Discrete System is verified and the Time Invariance of a given
Discrete System is verified.

VIVA-VOICE:

1. Define Linear System.


2. Define LTI system.
3. How can we characterize an LTI system?
7. 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

AIM: Verify the sampling theorem.

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:
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:

RESULT:Sampling theorem is verified.


VIVA VOICE:
1. Define sampling theorem in both frequency and time domain.

2. What is the sampling rate?

3. What is the multiple sampling rate?

4. What is the Nyquist Sampling Rate?


8.Magnitude and Phase Response of First order Low pass and
High pass Filter

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:

The magnitude and phase response of LPF plotted.


9.To Generate Complex Gaussian Noise And Find Its Mean,
Variance, Probability Density Function (PDF) And Power Spectral
Density (PSD).
AIM: Write the program for generation of Gaussian noise and computation of its mean,
mean square value, standard deviation, variance, and skewness.
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:
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;

un=-5 + rand(1,10000); % A = a + (b-a)*rand(m,n); un1=10 +


5*randn(1,10000); % A = mu + sigma*rand(m,n);

disp('mean of uniform noise')m=mean(un)


disp('variance of uniform noise')v=var(un)
disp('standard deviation of uniform noise')sd=std(un)
disp('mean of gaussian noise')
m1=mean(un1)
disp('variance of gaussian noise')v1=var(un1)
disp('standard deviation of gaussian noise')
sd1=std(un1)
subplot(2,2,1);
plot(un)
title('uinform random noise')xlabel('n--->');
ylabel('amplitude'); subplot(2,2,2);
hist(un,100);
title('distribution of uinform noise')xlabel('random
variable X'); ylabel('probability of occurance');
subplot(2,2,3);
plot(un1)
title('gaussian random noise')xlabel('n--->');
ylabel('amplitude'); subplot(2,2,4);
hist(un1,100);
title('distribution of gaussian noise')xlabel('random
variable X'); ylabel('probability of occurance');

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:

1.Mention the details of ztrans( ) and iztrans( )


functions. 2.What are poles and zeros?
3. How you specify the stability based on poles and zeros?

4. Define S-plane and Z-plane.


11.Trigonometric & Exponential Fourier Series Coefficients of a
Rectangular Periodic Signal
AIM: 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.
APPARATUS: PC with MATLAB
PROCEDURE:
7. Open MATLAB
8. Open new M-file
9. Type the program
10. Save in current directory
11. Compile and run the program
12. For the output see command window\Figure window
THEORY:
To compute the Trigonometric Fourier series coefficients of a periodic square wave
time signal that has a value of 2 from time 0 to 3 and a value of -12 from time 3 to.
It then repeats itself. I am trying to calculate in MATLAB the Fourier series
coefficients of this time signal and am having trouble on where to begin.
The equation is x(t)=a0+sum(bk*cos(2*pi*f*k*t)+ck*sin(2*pi*f*k*t))The
sum is obviously from k=1tok=infinity.
a0, bk, and ck are the coefficients

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

You might also like