CE221L - Digital Logic Design Lab Manual
CE221L - Digital Logic Design Lab Manual
Lab Manual
Version History
Engr. Zaheer
Dr. Waqar
2.0 Fall 2023 Ahmed
Ahmad
Engr. Irfanullah
Table of contents
Instructions for Students ..…………………………………………………….…
3
2. The introductory lab provides working guidelines for the entire course of lab. Students
are advised to study it thoroughly before coming to the lab. Actual experiments which
will be graded start from lab 1, “Introduction to Digital Experiments”.
3. All labs have a section named Summary of Theory which provides necessary theory
related to the experiments. Since the purpose of a lab manual is to compliment a text
book, students should not rely completely on this manual.
4. Almost every lab is divided into two main parts, with each section having its own set of
5. Labs will be graded in double entry fashion; one entry in an assessment sheet given at
the end of every lab and another entry in the instructor’s record. This system of
keeping records will keep students aware of their performance throughout the lab.
7. The assessment sheet at the end of every lab looks like this:
Lab Rubrics
3 2 1 0
Can setup, and Can setup, and
Can independently Cannot setup or
Apparatus handle the handle the
setup, operate and handle the
Handling apparatus with apparatus with
handle the apparatus apparatus
minimal help some help
Can assemble
Assembly/ according to the Can assemble Can assemble but Cannot
Apparatus design according to design inaccurately assemble
design within least time
Achieving Design objectives Design objectives Design objectives Design
have been
have been achieved have been achieved
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Measurements
Measurements are Measurements are Measurements are
are made and
Presentation made and results are made and results are made and results
results are not
of Results presented presented more are presented
presented
most accurately accurately much accurately
accurately
Much of the Most of the
Most of the
All the questions are questions are questions are not
questions are
answered correctly answered but answered and
Viva answered with
with information with minimal information is
almost information
relevant to topic. information not relevant to
relevant to topic
relevant to topic topic
Date: ______________________
Lab-1
Introduction to the Lab
1.2 Overview:
This section describes the procedure for wiring logic circuits with any general-purpose
white prototype board for your breadboard. One of these is contained in each lab kit.
2. Every time you add a wire or component to the physical circuit, mark off the
corresponding part of the wiring diagram with a colored pencil or marker. This makes it
easy to see what parts of the circuit have been built so far. If you make any circuit
changes, draw these on your wiring diagram.
3. Insert IC packages into the appropriate breadboard area before inserting any wires. You
will usually need to bend the IC leads (pins) slightly inward so that the spacing closely
matches the spacing of sockets on the breadboard. Be careful to check that all IC leads
actually make it into the correct sockets.
5. Use only solid-conductor wire in the size range of AWG 20 to AWG 26. Wire with larger
diameter may damage the socket spring clips of the breadboard. Wire strippers should
be used to cut wires to appropriate lengths and to check wires that are suspected of
having a larger diameter than permitted. Trim and re-strip the end of any jumper wire
that appears badly nicked or overly flexed.
6. It is possible to insert most wires by hand. In tight places, using the forceps from the
tool kit can make the job much easier. In either case, wires are easier to insert if they
have been cut at an angle of approximately 45 degrees with respect to the axis of the
wire.
7. When removing wires, be sure to pull at a right angle to the socket to avoid damage.
8. Route wires around IC packages, not over them. Occasionally an IC turns out to be
defective. If wires have been placed over the IC, you will have to remove them so that
the IC can be replaced. It is best to wire a circuit in stages, beginning with power and
ground connections. Add wires with the power switch OFF. Before turning power ON,
remove all hand jewelry and make sure that no foreign metal objects are near the
circuit. Check every IC to make sure it is not overheating. If any IC is too hot to touch
immediately shut the power off and check all leads. (Be careful because shorted ICs can
become very hot and leave a brand on your finger!) Also make sure that no IC has been
inserted backwards.
9. IC devices can be damaged if the power level exceeds 5.5V. Damage may also occur if
the supply voltage connection is removed from the IC pin while power is still being
applied to the circuit.
10. To debug a circuit, use a Oscilloscope to check logic levels. Start at a position in the
circuit where the logic level is known to be correct and work outward from there. If an
IC does not appear to produce the correct signal, check that power and ground are
correctly connected to the IC; also check all inputs to the component. Finally, check
that the output of the IC is not incorrectly connected to some other signal.
11. If you cannot get your circuit to work, bring it and a current circuit diagram or
schematic to Engineer for help.
• Old wire can break inside the insulation, causing incorrect circuit behavior that is
difficult to troubleshoot.
• Old wire should be recycled; place old wires in the wire recycling box next to the
new wire box in Lab.
2. Strip for breadboard squares worth of insulation off the ends of a wire when using it
in the breadboard. This is approximately 5/16 inch or 8 mm.
• If you strip too much, the wires in adjacent breadboard columns can touch,
causing a short circuit and most likely incorrect behavior.
• If you don’t strip enough, the insulation can prevent the spring clips in the
breadboard holes from closing properly around the non-insulated part of the wire
that is inserted into the hole.
3. Create power and ground busses at the top and bottom of your breadboard.
• The connection pattern used in the breadboard is shown in figure (to follow
shortly).
• The top and bottom rows can be used to distribute +5VDC and ground to the ICs,
• Note that the top and bottom “bus” rows have a break in the very middle! If you
want a power or ground bus to run the length of the breadboard, you must insert
a jumper in the middle of the row to join the two half rows together. This makes
your wiring less crowded, and makes it easy to see power and ground connections.
4. The top and bottom rows can be used to distribute +5VDC and ground to the ICs.
Run all power signals in red wire and all ground signals in black wire.
• Do not use red or black wire for any other signals. This makes it easy to tell which
wires are power and ground wires, and which are actual signal wires.
• Use a single power or ground wire from the bus to the chip. Do not daisy chain
power or ground connections. Think parallel, not serial.
• You may wire from the bus to the breadboard hole next to the chip. This makes it
easy to see that the power and ground wires are connected to the correct pin.
• You may wire from the bus to the breadboard column that connects to the chip.
This allows more room for signal wires, without covering the power and ground
wires.
5. Color codes your wiring in some way. Here are some suggestions that are meant to
make it easier to trace your wiring:
• Use the same color for all the wires of a signal that runs to multiple gates.
• Use different colors for different inputs of a gate.
• If you have a bus, make all the wires of the bus the same color. However, if you have
long runs of parallel wires that are the same color, it will be more difficult to trace
individual bits of the bus.
6. Wires should be routed no more than ½” (12 mm) above the breadboard.
• If the wires are too high, it will be difficult to trace signals through your circuit.
• If the wires are low, be sure the stripped wire ends are seated firmly in the
breadboard. Careful routing is essential for efficient troubleshooting. Tight wiring
can create sharp bends, which can cause trouble.
7. Avoid sharp bends in the wires. Sharp bends in the wire can cause the wire to break
inside the insulation.
• Your chips may be defective or be damaged while in use, and it is much easier to
remove chips for testing/replacement if you do not have to remove your wiring in
order to remove your chips.
• When possible, leave 2 or 3 rows of the breadboard between chips, to allow signals
to pass from one side of the IC to the other.
10. Wire from a complete schematic diagram. The chip’s pin numbers should match the
pin numbers in the diagram.
Description:
Features:
Bread Board Based
Power Supplies Included
Technical Features:
Supplies:
Fixed DC: +5V, -5V, +12V, -12V
Dual DC Power Supply: 0 ~ +15V and 0 ~ -15V adjustable
FIX Supply AC: 2V-0-2V, 12V-0-12V, 15V-0-15V
Function Generator:
Output Waveform: Sine, Square, Triangle and TTL
Output Frequency: up to 100KHz in five steps
Data Switch:
16-bit switch with TTL Output
Push Switch
Two independent Switches
Each with Q, Q’ output
De-Bounce Switch
Logic Indicator
24 independent LEDs indicate high and low logic state
Digital Display
3 independent 7-segment LED display with BCD to 7-segment decoder/driver
input with 8-4-2-1 code
Potentiometer:
Carbon Track 1K and 100K
Interface Connectors
2X BNC Connectors interfaced to 2mm gold plated pins
1X Banana Connector interfaced to 2mm gold plated pin
DB-9 Connector with all pins interfaced to 2mm gold plated pins
DB-25 Connector with all pins interfaced to 2mm gold plated pins
Solderless Breadboard:
2 Terminal Strips, Tie-point 1680
4 Distribution Strips, Tie-point 400
Audio Output
0.5W Speaker with Audio Amplifier and Volume Control
Accessories:
2mm-1mm patch cords, Power Cord, User Manual
A digital multimeter is a test tool used to measure two or more electrical values—
principally voltage (volts), current (amps) and resistance (ohms). It is a standard
diagnostic tool for technicians in the electrical/electronic industries.
Digital Multimeter
Specification:
Special Functions:
Diode
Continuity buzzer
Data Hold
Icon display
Sleep mode
Low battery display
Input impedance for DC voltage: 10 MOhm
Display backlight - auto sensor
Max. display 1999 (59 x 25mm)
General Characteristics:
Channels 2
Bandwidth 100MHz
Waveform Acquisition
≥2000wfms/s
Rate
Storage Setup,Wave,Bitmap
General Characteristic
Standard Individual
Gift Box, English Manual
Packing
Standard Carton
450mm× 420mm × 280mm
Measurement (L×W×H)
Lab-2
Logic Gates & Truth Table
2.1 Lab Objectives:
Learn to construct basic logic gates on a breadboard.
Verify logic gate functionality through testing and truth tables.
Gain proficiency in breadboard usage for electronic circuits.
bipolar transistor technology or the much faster and low power CMOS based MOSFET
transistor logic used in the 74Cxxx, 74HCxxx, 74ACxxx and the 4000 series logic chips.
IC Circuit Diagram:
74266 IC 4077 IC
0 0 0 1 0 1 0 1
0 1 0 1 1 0 1 0
1 0 0 1 1 0 1 0
1 1 1 0 1 0 0 1
2.5 Procedure:
1. Get the ICs and other required apparatus/equipment from the lab staff.
2. Plug in the IC in the breadboard of the Trainer board and while doing so; try to
avoid touching the IC pins for safety reasons.
4. The IC used has four gates each having two inputs (quad 2- in). PIN 1 and 2 are
inputs whereas pin 3 is the output of the gate. Similarly, the input pair for other
gates are (4, 5) & (8, 9) & (10, 11) and the output is obtained from PIN 6, 10, and 13
respectively.
5. Once you have wired the circuit, check it with your instructor. If approved, power up
your circuit.
6. The output should be connected to the LED on the Logic Trainer for monitoring
purposes.
7. Apply different input combinations at the input note down the corresponding output
and fill in the following truth table.
A B A.B
A B A+B
A B (A.B)’
A B (A+B)’
A B (A ⊕ B)
A B (A ⊕ B)’
A A’
Lab Rubrics
3 2 1 0
Can set, and Can set, up and
Can independently Cannot set or
Apparatus handle the handle the
set, operate, and handle the
Handling apparatus with apparatus with
handle the apparatus apparatus
minimal help some help
Can assemble
Assembly/ according to the Can assemble It can assemble Cannot
Apparatus design according to design but inaccurately assemble
design within least time
Design objectives
Design objectives Design objectives
have been
Achieving have been achieved have been achieved Design
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Measurements are Measurements
Measurements are Measurements are
made and results are made and
Presentation made and results are made and results are
are presented results are not
of Results presented presented more
much more presented
most accurately accurately
accurately accurately
Date: ______________________
Lab-3
Boolean Algebra & Demorgan’s Law
3.1 Lab Objectives:
Understand the fundamentals of Boolean Algebra.
Learn the principles of DeMorgan's Laws and their significance in simplifying logical
expressions.
Build circuits that represent given Boolean expressions.
Apply De Morgan's Laws to simplify complex logic expressions and construct equivalent
circuits.
Verify the correctness of constructed circuits by comparing their truth tables to the
expected results.
In parallel with
Annulment
A+1=1 closed = “CLOSED”
In parallel with
A+0=A Identity
open = “A”
An in series with
A.1=A Identity
closed = “A”
An in series with
A.0=0 Annulment
open = “OPEN”
In parallel with
A+A=A Idempotent
A = “A”
An in series with
A.A=A Idempotent
A = “A”
NOT NOT A
NOT A’ = A Double Negation
(double negative) = “A”
In parallel with
A + A’ = 1 Complement
NOT A = “CLOSED”
An in series with
A . A’ = 0 Complement
NOT A = “OPEN”
A in parallel with B =
A+B = B+A Commutative
B in parallel with A
An in series with B =
A.B = B.A Commutative
B in series with A
A brief description of the various Laws of Boolean are given below with A representing a
variable input.
A term AND´ed with a “0” equals 0 or OR´ed with a “1” will equal 1.
Identity Law –
A term OR´ed with a “0” or AND´ed with a “1” will always equal that term.
Idempotent Law –
Complement Law –
A term AND´ed with its complement equals “0” and a term OR´ed with its complement
equals “1”.
Commutative Law –
Task-1:
Consider an example for the following Boolean function: F1 = x+y’z
Design a circuit for the given Function (i.e., F1 = x+y’z) on the Trainer Board.
Verify the given Truth table.
Truth table for F1:
X Y Z Y’ Y’Z F1
0 0 0 1 0 0
0 0 1 1 1 1
0 1 0 0 0 0
0 1 1 0 0 0
1 0 0 1 0 1
1 0 1 1 1 1
1 1 0 0 0 1
1 1 1 0 0 1
Task-2:
Consider the following equation: F2 = x’y + y’z
Design a circuit for the given equation (i.e., F2 = x’y + y’z) on the Trainer Board.
Complete and Verify the given Truth table.
X X’ Y Y’ Z X’Y Y’Z F2
Task-3:
Design a circuit on the trainer board for DeMorgan’s first theorem.
Verify the given Truth table
Inputs Outputs
A B A.B (A.B)’ A’ B’ A’ + B’
0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0
Task-4:
Design a circuit on the trainer board for DeMorgan’s second theorem.
Complete and Verify the given Truth table.
Draw a logic diagram for DeMorgan’s second theorem.
Inputs Outputs
A B A+B (A+B)’ A’ B’ A’ . B’
Lab Rubrics
3 2 1 0
Can setup, and Can setup, and
Can independently Cannot setup or
Apparatus handle the handle the
setup, operate and handle the
Handling apparatus with apparatus with
handle the apparatus apparatus
minimal help some help
Can assemble
Assembly/ according to the Can assemble Can assemble but Cannot
Apparatus design according to design inaccurately assemble
design within least time
Design objectives
Design objectives Design objectives
have been
Achieving have been achieved have been achieved Design
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Measurements
Measurements are Measurements are Measurements are
are made and
Presentation made and results are made and results are made and results
results are not
of Results presented presented more are presented
presented
most accurately accurately much accurately
accurately
Much of the Most of the
Most of the
All the questions are questions are questions are not
questions are
answered correctly answered but answered and
Viva answered with
with information with minimal information is
almost information
relevant to topic. information not relevant to
relevant to topic
relevant to topic topic
Date: ______________________
Lab-4
Combinational Logic Circuits (CLC)
Adders and Subtractors
4.1 Lab Objectives:
Understand the concept of binary addition and subtraction.
Design and construct a half adder and half subtractor circuit on a breadboard to perform
binary addition and subtraction.
Design and construct full adder and full subtractor circuits by combining two half adders
and subtractors.
Understand the concept of n-bit addition/subtraction by combining multiple
adders/subtractors.
In the combinational circuits, different logic gates are used to design encoder,
multiplexer, decoder & de-multiplexer. These circuits have some characteristics like the
output of this circuit mainly depends on the levels which are there at input terminals at
any time. This circuit doesn’t include any memory. The earlier state of the input doesn’t
have any influence on the current state of this circuit. The inputs and outputs of a
combinational circuit are ‘n’ no. of inputs & ‘m’ no. of outputs. Some of the
combinational circuits are half adder and full adder, subtractor, encoder, decoder,
multiplexer, and demultiplexer.
Unlike Sequential Logic Circuits whose outputs are dependent on both their present
inputs and their previous output state giving them some form of Memory. The outputs
of Combinational Logic Circuits are only determined by the logical function of their
current input state, logic “0” or logic “1”, at any given instant in time.
The result is that combinational logic circuits have no feedback, and any changes to the
signals being applied to their inputs will immediately have an effect at the output. In
other words, in a Combinational Logic Circuit, the output is dependent at all times on
the combination of its inputs. Thus, a combinational circuit is memoryless.
So, if one of its inputs condition changes state, from 0-1 or 1-0, so too will the resulting
output as by default combinational logic circuits have “no memory”, “timing” or
“feedback loops” within their design.
Combinational Logic Circuits are made up from basic logic NAND, NOR or NOT gates
that are “combined” or connected together to produce more complicated switching
circuits. These logic gates are the building blocks of combinational logic circuits. An
example of a combinational circuit is a decoder, which converts the binary code data
present at its input into a number of different output lines, one at a time producing an
equivalent decimal code at its output.
addend and the result will be two outputs one is the sum and the other is carry. To
perform the sum operation, XOR is applied to both the inputs, and AND gate is applied
to both inputs to produce carry.
The block diagram of a half adder is shown below.
Task-1:
Design a combinational logic circuit that performs arithmetic operation for adding two
bits.
Truth Table:
Boolean Expression:
Sum = S = A’B+AB’ = A ⊕ B
Carry = C = A.B
Logic Diagram:
Task-2:
Design a combinational logic circuit that performs arithmetic operation for adding
three bits.
Complete and verify the given truth table and Boolean expressions.
Draw the Logic Diagram for Full Adder circuit.
Truth Table:
Total number of inputs = n = 3
Total number of outputs = 2^n = 2^3 = 8
Inputs Outputs
Boolean Expression:
Logic Diagram:
Task-3:
Design a combinational logic circuit that performs arithmetic operation for subtracting
two bits.
Verify the given Truth table and Boolean expressions.
Truth Table:
Input Output
0 1 1 1
1 0 1 0
1 1 0 0
Boolean Expression:
Difference = D = X’Y+XY’ = X ⊕ Y
Borrow = B = X’.Y
Logic Diagram:
Task-4:
Design a combinational logic circuit that performs arithmetic operation for
subtracting three bits.
Complete and verify the given Truth table and Boolean expressions.
Draw the Logic diagram for Full Subtractor circuit.
Truth Table:
Input Output
Boolean Expression:
Difference = D = (X’.Y’.BIN) + (X’.Y.B’IN) + (X.Y’.B’IN) + (X.Y.BIN)
= X ⊕ Y ⊕ BIN
Logic Diagram:
Schematic diagram of a 2-bit adder: (a) 2-bit half adder is implemented by joining 1-bit half
adder and 1-bit full adder; (b) 2-bit full adder is implemented by joining two 1-bit full adders.
Task-5:
Design a combinational logic circuit that performs addition of two, 2-
bit numbers.
Truth Table:
Inputs Outputs
A1 A0 B1 B0 C1 S1 S0
Logic Diagram:
Lab Rubrics
3 2 1 0
Can setup, and Can setup, and
Can independently Cannot setup or
Apparatus handle the handle the
setup, operate and handle the
Handling apparatus with apparatus with
handle the apparatus apparatus
minimal help some help
Can assemble
Assembly/ according to the Can assemble Can assemble but Cannot
Apparatus design according to design inaccurately assemble
design within least time
Design objectives
Design objectives Design objectives
have been
Achieving have been achieved have been achieved Design
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Measurements
Measurements are Measurements are Measurements are
are made and
Presentation made and results are made and results are made and results
results are not
of Results presented presented more are presented
presented
most accurately accurately much accurately
accurately
Date: ______________________
Lab # 05
Combinational Logic Circuits (CLC)
Encoders & Decoders
5.1 Lab Objectives:
Understand the fundamental concepts of encoding and decoding in digital systems.
Learn the purpose and applications of encoders and decoders.
Design and construct simple encoder and decoder circuits.
Create a more advanced encoder (Decimal to BCD encoder).
5.3 Decoders:
The name “Decoder” means to translate or decode coded information from one format
into another, so a binary decoder transforms “n” binary input signals into an equivalent
code using 2n outputs.
Binary Decoders are another type of digital logic device that has inputs of 2-bit, 3-bit or
4-bit codes depending upon the number of data input lines, so a decoder that has a set
of two or more bits will be defined as having an n-bit code, and therefore it will be
possible to represent 2n possible values. Thus, a decoder generally decodes a binary
value into a non-binary one by setting exactly one of its n outputs to logic “1”.
If a binary decoder receives n inputs (usually grouped as a single Binary or Boolean
number) it activates one and only one of its 2n outputs based on that input with all other
outputs deactivated.
A Binary Decoder converts coded inputs into coded outputs, where the input and output
codes are different, and decoders are available to “decode” either a Binary or BCD (8421
code) input pattern to typically a Decimal output code. Commonly available BCD-to-
Decimal decoders include the TTL 7442 or the CMOS 4028. Generally, a decoders output
code normally has more bits than its input code and practical “binary decoder” circuits
include, 2-to-4, 3-to-8 and 4-to-16 line configurations.
Task-1:
Design a circuit for 2-to-4 Line DECODER with E=1 (i.e., enable is HIGH) on the trainer
board.
Verify the given truth table and the Boolean expression.
Draw the Logic Diagram for 2-to-4 line decoder circuit.
Truth Table:
0 X X 0 0 0 0
1 0 0 0 0 0 1
1 0 1 0 0 1 0
1 1 0 0 1 0 0
1 1 1 1 0 0 0
Boolean Expression:
Y0 = E.A1’.A0’
Y1 = E.A1’.A0
Y2 = E.A1.A0’
Y3 = E.A1.A0
Logic Diagram:
Task-2:
Design a circuit for 3-to-8 Line DECODER with E=1 (i.e., enable is HIGH) on the trainer
board.
Complete and verify the given truth table.
Write down the Boolean expression for the Output terms.
Draw the Logic Diagram for 3-to-8 line decoder circuit.
Truth Table:
E A2 A1 A0 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
0 X X X
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
Boolean Expression:
Y0 = _________________________________
Y1 = _________________________________
Y2 = _________________________________
Y3 = _________________________________
Y4 = _________________________________
Y5 = _________________________________
Y6 = _________________________________
Y7 = _________________________________
Logic Diagram:
5.4 Encoders:
An Encoder is a combinational circuit that performs the reverse operation of Decoder. It
has maximum of 2n input lines and ‘n’ output lines. It will produce a binary code
equivalent to the input, which is active High. Therefore, the encoder encodes 2 n input
lines with ‘n’ bits. It is optional to represent the enable signal in encoders.
Digital Encoder more commonly called a Binary Encoder takes ALL its data inputs one at
a time and then converts them into a single encoded output. So we can say that a binary
encoder, is a multi-input combinational logic circuit that converts the logic level “1” data
at its inputs into an equivalent binary code at its output.
Generally, digital encoders produce outputs of 2-bit, 3-bit or 4-bit codes depending
upon the number of data input lines. An “n-bit” binary encoder has 2n input lines and n-
bit output lines with common types that include 4-to-2, 8-to-3 and 16-to-4 line
configurations.
The output lines of a digital encoder generate the binary equivalent of the input line
whose value is equal to “1” and are available to encode either a decimal or hexadecimal
input pattern to typically a binary or “B.C.D” (binary coded decimal) output code.
Task-3:
Design a circuit for 4-to-2 Line ENCODER on the trainer board.
Verify the given truth table and the Boolean expression.
Draw the Logic Diagram for 4-to-2 Line decoder circuit.
Truth Table:
Inputs Outputs
Y3 Y2 Y1 Y0 A1 A0
0 0 0 1 0 0
0 0 1 0 0 1
0 1 0 0 1 0
1 0 0 0 1 1
Boolean Expression:
A1 = Y3 + Y2 ; A0 = Y3 + Y1
Logic Diagram:
Task-4:
Design a circuit 8-to-3 Line ENCODER on the trainer board.
Complete and verify the given truth table.
Write down the Boolean expression for the Output terms.
Draw the Logic Diagram for 8-to-3 Line ENCODER circuit.
Truth Table:
Inputs Outputs
Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 A2 A1 A0
Boolean Expression:
A2 = ______________________________ ; A0 = _________________________
A1 = ______________________________
Logic Diagram:
Task-5:
Design a circuit for Decimal to BCD Encoder on the trainer board.
Complete and verify the given truth table.
Write down the Boolean expression for the Output terms.
Draw the Logic Diagram for Decimal to BCD ENCODER circuit.
Truth Table:
No. Inputs Outputs
I9 I8 I7 I6 I5 I4 I3 I2 I1 I0 Y3 Y2 Y1 Y0
0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1 0
2 0 0 0 0 0 0 0 1 0 0
3 0 0 0 0 0 0 1 0 0 0
4 0 0 0 0 0 1 0 0 0 0
5 0 0 0 0 1 0 0 0 0 0
6 0 0 0 1 0 0 0 0 0 0
7 0 0 1 0 0 0 0 0 0 0
8 0 1 0 0 0 0 0 0 0 0
9 1 0 0 0 0 0 0 0 0 0
Boolean Expression:
A3 = _________________________________
A2 = _________________________________
A1 = _________________________________
A0 = _________________________________
Logic Diagram:
Lab Rubrics
3 2 1 0
Can setup, and Can setup, and
Can independently Cannot setup or
Apparatus handle the handle the
setup, operate and handle the
Handling apparatus with apparatus with
handle the apparatus apparatus
minimal help some help
Can assemble
Assembly/ according to the Can assemble Can assemble but Cannot
Apparatus design according to design inaccurately assemble
design within least time
Design objectives
Design objectives Design objectives
have been
Achieving have been achieved have been achieved Design
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Measurements
Measurements are Measurements are Measurements are
are made and
Presentation made and results are made and results are made and results
results are not
of Results presented presented more are presented
presented
most accurately accurately much accurately
accurately
Much of the Most of the
Most of the
All the questions are questions are questions are not
questions are
answered correctly answered but answered and
Viva answered with
with information with minimal information is
almost information
relevant to topic. information not relevant to
relevant to topic
relevant to topic topic
Date: ______________________
Lab # 06
Combinational Logic Circuits (CLC)
Multiplexers & Demultiplexers
6.1 Lab Objectives:
Understand the fundamental concepts of multiplexers and demultiplexers in digital
systems.
Learn the purpose and applications of multiplexers and demultiplexers.
Design and construct different multiplexers and demultiplexers on breadboard.
MOSFET’s or relays to switch one of the voltage or current inputs through to a single
output.
The most basic type of multiplexer device is that of a one-way rotary switch as shown.
4 x 1 Multiplexer
Task-1:
Design a circuit for 4x1 MUX on the trainer board.
Verify the given truth table and the Boolean expression.
Draw the Logic Diagram for 4x1 MUX circuit.
Truth Table:
1 0 0 0 1 1 I3
Boolean Expression:
Y = I0 + I 1 + I 2 + I 3
Y = S1’.S0’.I0 + S1’.S0.I1 + S1’.S0.I2 + S1.S0.I3
Logic Diagram:
8 x 1 Multiplexer
The same selection lines, s1 & s0 are applied to both 4x1 Multiplexers. The data inputs of
upper 4x1 Multiplexer are I7 to I4 and the data inputs of lower 4x1 Multiplexer are I 3 to I0.
Therefore, each 4x1 Multiplexer produces an output based on the values of selection lines,
s1 & s 0.
The outputs of first stage 4x1 Multiplexers are applied as inputs of 2x1 Multiplexer that is
present in second stage. The other selection line, s2 is applied to 2x1 Multiplexer.
If s2 is zero, then the output of 2x1 Multiplexer will be one of the 4 inputs I 3 to
I0 based on the values of selection lines s1 & s0.
If s2 is one, then the output of 2x1 Multiplexer will be one of the 4 inputs I 7 to
I4 based on the values of selection lines s1 & s0.
Therefore, the overall combination of two 4x1 Multiplexers and one 2x1 Multiplexer
performs as one 8x1 Multiplexer.
Similarly, we can implement 16x1 Multiplexer using 8x1 Multiplexers and 2x1 Multiplexer.
We know that 8x1 Multiplexer has 8 data inputs, 3 selection lines and one output. Whereas,
16x1 Multiplexer has 16 data inputs, 4 selection lines and one output.
So, we require two 8x1 Multiplexers in first stage in order to get the 16 data inputs. Since,
each 8x1 Multiplexer produces one output, we require a 2x1 Multiplexer in second stage by
considering the outputs of first stage as inputs and to produce the final output.
Task-2:
Design a circuit for 8x1 MUX on the trainer board.
Complete and verify the given truth table.
Write down the Boolean expression for the Output terms.
Draw the Logic Diagram for 8x1 MUX circuit.
Truth Table:
Boolean Expression:
Y = _____________________________
Y = __________________________________________________
Logic Diagram:
1 x 4 De-Multiplexer
Task-3:
Design a circuit for 1x4 De-Mux on the trainer board.
Verify the given truth table and the Boolean expression.
Draw the Logic Diagram for 1x4 De-Mux circuit.
Truth Table:
I/p S1 S0 Y3 Y2 Y1 Y0
I 0 0 0 0 0 I
I 0 1 0 0 I 0
I 1 0 0 I 0 0
I 1 1 I 0 0 0
Boolean Expression:
Y3 = S1.S0.I
Y2 = S1.S0’.I
Y1 = S1’.S0.I
Y0 = S1’.S0’.I
Logic Diagram:
1 x 8 De-Multiplexer
The common selection lines, s1 & s0 are applied to both 1x4 De-Multiplexers. The outputs of
upper 1x4 De-Multiplexer are Y7 to Y4 and the outputs of lower 1x4 De-Multiplexer are Y 3 to
Y0 .
The other selection line, s2 is applied to 1x2 De-Multiplexer. If s 2 is zero, then one of the
four outputs of lower 1x4 De-Multiplexer will be equal to input, I based on the values of
selection lines s1 & s0. Similarly, if s2 is one, then one of the four outputs of upper 1x4 De-
Multiplexer will be equal to input, I based on the values of selection lines s1 & s0.
Similarly, we can implement 1x16 De-Multiplexer using 1x8 De-Multiplexers and 1x2 De-
Multiplexer. We know that 1x8 De-Multiplexer has single input, three selection lines and
eight outputs. Whereas, 1x16 De-Multiplexer has single input, four selection lines and
sixteen outputs.
So, we require two 1x8 De-Multiplexers in second stage in order to get the final sixteen
outputs. Since, the number of inputs in second stage is two, we require 1x2 De-
Multiplexer in first stage so that the outputs of first stage will be the inputs of second stage.
Input of this 1x2 De-Multiplexer will be the overall input of 1x16 De-Multiplexer.
Task-4:
Design a circuit for 1x8 De-Mux on the trainer board.
Complete and verify the given truth table.
Write down the Boolean expression for the Output terms.
Draw the Logic Diagram for 1x8 De-Mux circuit.
Truth Table:
Boolean Expression:
Y7 = _____________________________________ ; Y3 = ________________________________
Y6 = _____________________________________ ; Y2 = ________________________________
Y5 =______________________________________ ; Y1 = ________________________________
Y4 = _____________________________________ ; Y0 = ________________________________
Logic Diagram:
Lab Rubrics
3 2 1 0
Can setup, and Can setup, and
Can independently Cannot setup or
Apparatus handle the handle the
setup, operate and handle the
Handling apparatus with apparatus with
handle the apparatus apparatus
minimal help some help
Can assemble
Assembly/ according to the Can assemble Can assemble but Cannot
Apparatus design according to design inaccurately assemble
design within least time
Design objectives
Design objectives Design objectives
have been
Achieving have been achieved have been achieved Design
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Measurements
Measurements are Measurements are Measurements are
are made and
Presentation made and results are made and results are made and results
results are not
of Results presented presented more are presented
presented
most accurately accurately much accurately
accurately
Much of the Most of the
Most of the
All the questions are questions are questions are not
questions are
answered correctly answered but answered and
Viva answered with
with information with minimal information is
almost information
relevant to topic. information not relevant to
relevant to topic
relevant to topic topic
Date: ______________________
Lab-7
Sequential Logic Circuits (SLC)
Flip Flops
7.1 Lab Objectives:
Understand the principles of sequential logic circuits.
Understand the concept of feedback in flip-flop operation.
Construct SR and D flip-flop circuit on a breadboard.
Verify the functionality of the flip-flop by applying different input scenarios.
Understand the working of JK and T flip-flop.
Construct JK and T flip-flop circuit on a breadboard.
Verify the functionality of the flip-flop by applying different input scenarios.
This sequential circuit contains a set of inputs and outputs. The outputs of sequential
circuit depend not only on the combination of present inputs but also on the previous
outputs. Previous output is nothing but the present state. Therefore, sequential circuits
contain combinational circuits along with memory storage elements. Some sequential
circuits may not contain combinational circuits, but only memory elements.
The following table shows the differences between combinational circuits and
sequential circuits.
In the above figure, square wave is considered as clock signal. This signal stays at logic
High 5V for some time and stays at logic Low 0V for equal amount of time. This pattern
repeats with some time period. In this case, the time period will be equal to either twice
of ON time or twice of OFF time.
The reciprocal of the time period of clock signal is known as the frequency of the clock
signal. All sequential circuits are operated with clock signal. So, the frequency at which
the sequential circuits can be operated accordingly the clock signal frequency has to be
chosen.
Triggering:
While applying the clock pulse to the flip flop, it gets triggered by two ways, Level
triggering and edge triggering.
Level Triggering:
In this, the flip flop is triggered only during the high-level or the low level of the clock
pulse. In other words, the output changes its state, when active low or high level is
maintained at the clock signal. Based on the level of triggering, it is of two types:-
Positive Level Triggering — If the sequential circuit is operated with the clock
signal when it is in Logic High, then that type of triggering is known as Positive
level triggering. It is highlighted in below figure.
Negative Level Triggering — If the sequential circuit is operated with the clock
signal when it is in Logic Low, then that type of triggering is known as Negative
level triggering. It is highlighted in the following figure.
Edge Triggering:
In edge triggering, the flip flop changes its state during the positive edge or negative
edge of the clock pulse. There are two types of edge triggering.
Positive Edge Triggering — If the sequential circuit is operated with the clock
signal that is transitioning from Logic Low to Logic High, then that type of
triggering is known as Positive edge triggering. It is also called as rising edge
triggering. It is shown in the following figure.
Negative Edge Triggering — If the sequential circuit is operated with the clock
signal that is transitioning from Logic High to Logic Low, then that type of
triggering is known as Negative edge triggering. It is also called as falling edge
triggering. It is shown in the following figure.
7.5 Latches:
There are two types of memory elements based on the type of triggering that is suitable
to operate it.
Latches
Flip-flops
Latches operate with enable signal, which is level sensitive. Whereas flip-flops are edge
sensitive. Let us discuss about SR Latch & D Latch one by one.
SR Latch:
SR Latch is also called as Set Reset Latch. This latch affects the outputs as long as the
enable, E is maintained at ‘1’. The circuit diagram of SR Latch is shown in the following
figure.
This circuit has two inputs S & R and two outputs Q(t) & Q(t)’. The upper NOR gate has
two inputs R & complement of present state, Q(t)’ and produces next state, Q(t+1)
when enable, E is ‘1’.
Similarly, the lower NOR gate has two inputs S & present state, Q t and produces
complement of next state, Qt+1t+1’ when enable, E is ‘1’.
We know that a 2-input NOR gate produces an output, which is the complement of
another input when one of the input is ‘0’. Similarly, it produces ‘0’ output, when one of
the input is ‘1’.
If S = 1, then next state Q(t+1) will be equal to ‘1’ irrespective of present state,
Q(t) values.
If R = 1, then next state Q(t+1) will be equal to ‘0’ irrespective of present state,
Q(t) values.
At any time, only of those two inputs should be ‘1’. If both inputs are ‘1’, then the next
state Q(t+1) value is undefined.
The following table shows the state table of SR latch.
S R Q(t+1)
0 0 Q(t)
0 1 0
1 0 1
1 1 -
Therefore, SR Latch performs three types of functions such as Hold, Set & Reset based
on the input conditions.
D Latch:
There is one drawback of SR Latch. That is the next state value can’t be predicted when
both the inputs S & R are one. So, we can overcome this difficulty by D Latch. It is also
called as Data Latch. The circuit diagram of D Latch is shown in the following figure.
This circuit has single input D and two outputs Q(t) & Q(t)’. D Latch is obtained from SR
Latch by placing an inverter between S and R inputs and connect D input to S. That
means we eliminated the combinations of S & R are of same value.
If D = 0 → S = 0 & R = 1, then next state Q(t+1) will be equal to ‘0’ irrespective of
present state, Q(t) values. This is corresponding to the second row of SR Latch
state table.
If D = 1 → S = 1 & R = 0, then next state Q(t+1) will be equal to ‘1’ irrespective of
present state, Q(t) values. This is corresponding to the third row of SR Latch state
table.
The following table shows the state table of D latch.
D Q(t+1)
0 0
1 1
Therefore, D Latch Hold the information that is available on data input, D. That means
the output of D Latch is sensitive to the changes in the input, D as long as the enable is
High.
In this chapter, we implemented various Latches by providing the cross coupling
between NOR gates. Similarly, you can implement these Latches using NAND gates.
SR Flip-Flop:
SR flip-flop operates with only positive clock transitions or negative clock transitions.
Whereas SR latch operates with enable signal. The block diagram of SR flip-flop is shown
in the following figure.
The simplest way to make any basic single bit set-reset SR flip-flop is to connect
together a pair of cross-coupled 2-input NAND gates as shown, to form a Set-Reset
Bistable also known as an active LOW SR NAND Gate Latch, so that there is feedback
from each output to one of the other NAND gate inputs. This device consists of two
inputs, one called the Set, S and the other called the Reset, R with two corresponding
outputs Q and its inverse or complement Q (not-Q). The circuit diagram of SR flip-flop is
shown below:
This circuit has two inputs S & R and two outputs Q(t) & Q(t)’. The operation of SR
flipflop is similar to SR Latch. But, this flip-flop affects the outputs only when positive
transition of the clock signal is applied instead of active enable.
Task-1:
Design a circuit for SR Flip-Flop (using NAND Gates only) on the trainer board.
Verify the given State & Characteristics table.
State Table:
The following table shows the state table of SR flip-flop.
S R Q(t+1)
0 0 Q(t) No Change/
Present State
0 1 0 Reset
1 0 1 Set
1 1 - Undetermined
Here, Q(t) & Q(t+1) are present state & next state respectively. So, SR flip-flop can be
used for one of these three functions such as Hold, Reset & Set based on the input
conditions, when positive transition of clock signal is applied. The following table shows
the characteristic table of SR flip-flop.
S R Q(t) Q(t+1)
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 x
1 1 1 x
D Flip-Flop:
D flip-flop is a better alternative that is very popular with digital electronics. They are
commonly used for counters and shift-registers and input synchronization. The logic
symbol of D flip-flop is shown in the following figure.
D flip-flop operates with only positive clock transitions or negative clock transitions.
Whereas D latch operates with enable signal. That means, the output of D flip-flop is
insensitive to the changes in the input, D except for active transition of the clock signal.
The circuit diagram of D flip-flop is shown below:
Task-2:
Design a circuit for D Flip-Flop (using NAND Gates only) on the trainer board.
Verify the given State table.
State Table:
The following table shows the state table of D flip-flop.
D Q(t + 1)
0 0
1 1
JK Flip-Flop:
JK flip-flop is the modified version of SR flip-flop. It operates with only positive clock
transitions or negative clock transitions. Due to the undefined state in the SR flip-flop,
another flip-flop is required in electronics. The JK flip-flop is an improvement on the SR
flip-flop where S=R=1 is not a problem. The logic symbol of D flip-flop is shown in the
following figure.
A gated S R flip flop with the addition of a clock input circuitry is basically the J k flip flop.
This circuit prevents the invalid output condition which occurs when both inputs are
high. The new addition here gives us four possible outputs of the flip flop. The output
may be – No Change, Logic 0, Logic 1 & Toggle. The circuit diagram of JK flip-flop is
shown in the following figure.
In simple words, If J and K data input are different (i.e. high and low) then the output Q
takes the value of J at the next clock edge. If J and K are both low then no change
occurs. If J and K are both high at the clock edge then the output will toggle from one
state to the other. JK Flip-Flops can function as Set or Reset Flip-flops.
Task-3:
Design a circuit for JK Flip-Flop (using NAND Gates only) on the trainer board.
Verify the given State & Characteristics table.
State Table:
The following table shows the state table of JK flip-flop.
J K Q(t+1)
0 0 Q(t) Present State
0 1 0 0
1 0 1 1
1 1 Q(t)' Q(t)’
Here, Q(t) & Q(t+1) are present state & next state respectively. So, JK flip-flop can be
used for one of these four functions such as Hold, Reset, Set & Complement of present
state based on the input conditions, when positive transition of clock signal is applied.
The following table shows the characteristic table of JK flip-flop.
T Flip-Flop:
T flip-flop is the simplified version of JK flip-flop. It is obtained by connecting the same
input ‘T’ to both inputs of JK flip-flop. It operates with only positive clock transitions or
negative clock transitions. The logic symbol of T flip-flop is shown in the following figure.
A T flip-flop is like a JK flip-flop. These are basically a single input version of JK flip-flops.
This modified form of JK flip-flop is obtained by connecting both inputs J and K together.
It has only one input along with the clock input.
Task-4:
Design a circuit for T Flip-Flop (using NAND Gates only) on the trainer board.
Verify the given State table.
State Table:
The following table shows the state table of T flip-flop.
D Q(t+1)
0 Q(t)
1 Q(t)’
Here, Q(t) & Q(t+1) are present state & next state respectively. So, T flip-flop can be
used for one of these two functions such as Hold, & Complement of present state based
on the input conditions, when positive transition of clock signal is applied. The following
table shows the characteristic table of T flip-flop.
T Q(t) Q(t+1)
0 0 0
0 1 1
1 0 1
1 1 0
The output of T flip-flop always toggles for every positive transition of the clock signal
when input T remains at logic High 1. Hence, T flip-flop can be used in counters.
Lab Rubrics
3 2 1 0
Can setup, and Can setup, and
Can independently Cannot setup or
Apparatus handle the handle the
setup, operate and handle the
Handling apparatus with apparatus with
handle the apparatus apparatus
minimal help some help
Can assemble
Assembly/ according to the Can assemble Can assemble but Cannot
Apparatus design according to design inaccurately assemble
design within least time
Design objectives
Design objectives Design objectives
have been
Achieving have been achieved have been achieved Design
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Measurements
Measurements are Measurements are Measurements are
are made and
Presentation made and results are made and results are made and results
results are not
of Results presented presented more are presented
presented
most accurately accurately much accurately
accurately
Much of the Most of the
Most of the
All the questions are questions are questions are not
questions are
answered correctly answered but answered and
Viva answered with
with information with minimal information is
almost information
relevant to topic. information not relevant to
relevant to topic
relevant to topic topic
Date: ______________________
Lab-8
Sequential Logic Circuits (SLC)
Counters
8.1 Lab Objectives:
Understand the concept of binary counters and their significance in digital circuits.
Learn the difference between binary up counters and binary down counters.
Comprehend the concept of toggle or "T" flip-flops and their role in binary counting.
Design a 2-bit asynchronous binary up/down counter and verify its operation.
Asynchronous Counters:
If the flip-flops do not receive the same clock signal, then that counter is called
as Asynchronous counter. The output of system clock is applied as clock signal only to
first flip-flop. The remaining flip-flops receive the clock signal from output of its previous
stage flip-flop. Hence, the outputs of all flip-flops do not change affect at the same time.
The 3-bit Asynchronous binary up counter contains three T flip-flops and the T-input of
all the flip-flops are connected to ‘1’. All these flip-flops are negative edge triggered but
the outputs change asynchronously. The clock signal is directly applied to the first T flip-
flop. So, the output of first T flip-flop toggles for every negative edge of clock signal.
The output of first T flip-flop is applied as clock signal for second T flip-flop. So, the
output of second T flip-flop toggles for every negative edge of output of first T flip-flop.
Similarly, the output of third T flip-flop toggles for every negative edge of output of
second T flip-flop, since the output of second T flip-flop acts as the clock signal for third
T flip-flop.
Assume the initial status of T flip-flops from rightmost to leftmost is Q2Q1Q0 = 000.
Here, Q2 & Q0 are MSB & LSB respectively. We can understand the working of 3-bit
asynchronous binary counter from the following table.
0 0 0 0
1 1 0 0
2 0 1 0
3 1 1 0
4 0 0 1
5 1 0 1
6 0 1 1
7 1 1 1
Here Q0 toggled for every negative edge of clock signal. Q1 toggled for every Q0 that
goes from 0 to 1, otherwise remained in the previous state. Similarly, Q2 toggled for
every Q1 that goes from 0 to 1, otherwise remained in the previous state.
The initial status of the T flip-flops in the absence of clock signal is Q2Q1Q0=000. This is
decremented by one for every negative edge of clock signal and reaches to the same
value at 8th negative edge of clock signal. This pattern repeats when further negative
edges of clock signal are applied.
An ‘N’ bit Asynchronous binary down counter consists of ‘N’ T flip-flops. It counts from
2𝑁 − 1 to 0. The block diagram of 3-bit Asynchronous binary down counter is shown in
the following figure.
The block diagram of 3-bit Asynchronous binary down counter is similar to the block
diagram of 3-bit Asynchronous binary up counter. But, the only difference is that instead
of connecting the normal outputs of one stage flip-flop as clock signal for next stage flip-
flop, connect the complemented outputs of one stage flip-flop as clock signal for next
stage flip-flop. Complemented output goes from 1 to 0 is same as the normal output
goes from 0 to 1.
Assume the initial status of T flip-flops from rightmost to leftmost is Q2Q1Q0=0000.
Here, Q2 & Q0 are MSB & LSB respectively. We can understand the working of 3-bit
asynchronous binary down counter from the following table.
No of negative Q0 Q1 Q2
edge of Clock LSB MSB
0 0 0 0
1 1 1 1
2 0 1 1
3 1 0 1
4 0 0 1
5 1 1 0
6 0 1 0
7 1 0 0
Here Q0 toggled for every negative edge of clock signal. Q1 toggled for every Q0 that
goes from 0 to 1, otherwise remained in the previous state. Similarly, Q2 toggled for
every Q1 that goes from 0 to 1, otherwise remained in the previous state.
The initial status of the T flip-flops in the absence of clock signal is Q2Q1Q0 = 000. This is
decremented by one for every negative edge of clock signal and reaches to the same
value at 8th negative edge of clock signal. This pattern repeats when further negative
edges of clock signal are applied.
Synchronous Counters:
If all the flip-flops receive the same clock signal, then that counter is called
as Synchronous counter. Hence, the outputs of all flip-flops change affect at the same
time.
The 3-bit Synchronous binary up counter contains three T flip-flops & one 2-input AND
gate. All these flip-flops are negative edge triggered and the outputs of flip-flops
change affect synchronously. The T inputs of first, second and third flip-flops are 1, Q0
& Q1Q0 respectively.
The output of first T flip-flop toggles for every negative edge of clock signal. The output
of second T flip-flop toggles for every negative edge of clock signal if Q0 is 1. The output
of third T flip-flop toggles for every negative edge of clock signal if both Q0 & Q1 are 1.
The 3-bit Synchronous binary down counter contains three T flip-flops & one 2-input
AND gate. All these flip-flops are negative edge triggered and the outputs of flip-flops
change affect synchronously. The T inputs of first, second and third flip-flops are 1, Q0’
& Q1′ Q0′ respectively.
The output of first T flip-flop toggles for every negative edge of clock signal. The output
of second T flip-flop toggles for every negative edge of clock signal if Q0′ is 1. The output
of third T flip-flop toggles for every negative edge of clock signal if both Q1′ & ′Q0′ are
1.
Task-1:
Design a circuit for 2-bit UP/DOWN Counter on the Trainer Board such that:
When UP/DOWN = 0, the counter counts down &
When UP/DOWN = 1, the counter counts up
Circuit Diagram:
State Diagram:
Task-2:
Design a circuit for 3-bit Johnson Counter on the Trainer Board:
A Johnson counter is a counter where the inverted output from the last flip-flop is connected
to the input of the first flip-flop. Generally, it is implemented by using D flip-flops or JK flip-
flops. It is also known as an inverse feedback counter or twisted ring counter. This follows
the sequence of bit patterns. When compared to the ring counter, it uses only half of the
number of flip-flops.
Lab Rubrics
3 2 1 0
Can setup, and Can setup, and
Can independently Cannot setup or
Apparatus handle the handle the
setup, operate and handle the
Handling apparatus with apparatus with
handle the apparatus apparatus
minimal help some help
Can assemble
Assembly/ according to the Can assemble Can assemble but Cannot
Apparatus design according to design inaccurately assemble
design within least time
Design objectives
Design objectives Design objectives
have been
Achieving have been achieved have been achieved Design
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Measurements
Measurements are Measurements are Measurements are
are made and
Presentation made and results are made and results are made and results
results are not
of Results presented presented more are presented
presented
most accurately accurately much accurately
accurately
Much of the Most of the
Most of the
All the questions are questions are questions are not
questions are
answered correctly answered but answered and
Viva answered with
with information with minimal information is
almost information
relevant to topic. information not relevant to
relevant to topic
relevant to topic topic
Date: ______________________
Lab-9
Shift Registers
9.1 Lab Objectives:
Understand the concept of shift registers and their significance in digital circuits.
Design a 2-bit shift register and demonstrate its functionality in shifting data left or right.
Task-1:
Design a circuit for 2-bit Shift Register on the Trainer Board such that:
At the first clock signal, the value Data is stored and displayed at Q1.
At the second clock signal, the value of Q1 is stored at the second flip-flop and
displayed at Q0. At the same time a new value Data is stored and displayed
at Q1.
By doing this, you have "shifted" the stored value by one flip-flop to the right.
Circuit Diagram:
Task-2:
Design a circuit for 4-bit Bidirectional Shift Register on the Trainer Board:
Circuit Diagram:
Lab Rubrics
3 2 1 0
Can setup, and Can setup, and
Can independently Cannot setup or
Apparatus handle the handle the
setup, operate and handle the
Handling apparatus with apparatus with
handle the apparatus apparatus
minimal help some help
Can assemble
Assembly/ according to the Can assemble Can assemble but Cannot
Apparatus design according to design inaccurately assemble
design within least time
Design objectives
Design objectives Design objectives
have been
Achieving have been achieved have been achieved Design
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Measurements
Measurements are Measurements are Measurements are
are made and
Presentation made and results are made and results are made and results
results are not
of Results presented presented more are presented
presented
most accurately accurately much accurately
accurately
Much of the Most of the
Most of the
All the questions are questions are questions are not
questions are
answered correctly answered but answered and
Viva answered with
with information with minimal information is
almost information
relevant to topic. information not relevant to
relevant to topic
relevant to topic topic
Date: ______________________
Lab-10
Introduction to Verilog HDL
Combinational circuits in Verilog
HDL
10.1 Lab Objectives:
Understand the fundamental concepts of Verilog Hardware Description Language
(HDL).
Learn the syntax and structure of Verilog code for designing digital circuits.
Implement basic logic gates (AND, OR, NOT) using Verilog and simulate their behavior.
Design and simulate combinational circuits such as multiplexers, decoders, and encoders
in Verilog.
Gain proficiency in using Verilog modeling techniques for sequential circuits.
Develop skills in writing testbenches to verify the functionality of Verilog designs.
Understand the concept of waveform simulation and analyze simulation results.
Learn how to use Verilog for simple arithmetic and data manipulation tasks.
Explore the concept of gate-level modeling and its applications in Verilog.
Practice documenting Verilog code and creating clear design descriptions for future
reference and collaboration.
10.2 Verilog:
Verilog is the combination of the terms “Verification” and “Logic”. It is hardware description
language or a special type of programming language which describes the hardware
implementations of digital systems and circuits. It is most commonly used in the design and
verification of digital circuits at the register-transfer level of abstraction. It is also used in the
verification of analog circuits and mixed-signal circuits.
Verilog module:
Verilog provides the concept of a module. A module is the basic building block in Verilog. A
module can be an element or a collection of lower-level design blocks.
which is the identifier for the module, and a module_terminal_list, which describes the input
and output terminals of the module.
...
...
endmodule
Purpose of a module:
A module represents a design unit that implements certain behavioral characteristics and well
get converted into a digital circuit during synthesis. Any combination of the inputs can be given
to the module, and it will provide a corresponding output. This allows the same module to be
reused to form bigger modules that implement more complex hardware.
For example –
/* Example
Of Verilog multiple
Line comment*/
Verilog Operators:
Verilog has three fundamental operators for Verilog HDL. They are given below.
Unary Verilog operators: These types of Verilog operators come first of the operands.
Binary Verilog operators: These types of Verilog operators come in between two operands.
Ternary Verilog operators: These types of Verilog operators use two different operators to
differentiate three operators.
Verilog HDL’s categorical operators are – arithmetical, logical, relational, bitwise, shift,
concatenation, and equality. Different types of Verilog operators and their symbols are given in
the below table.
10.6 Dataflow Modeling: Dataflow modeling provides the means of describing combinational
circuits by their function rather than by their gate structure. Dataflow modeling uses several
operators that act on operands to produce the desired results. Verilog HDL provides about 30
operator types.
/ Division Two
+ Addition Two
– Subtraction Two
% Modulus Two
! Negation One
Logical
&& AND Two
|| OR Two
== Equals to Two
~ Negation One
Bitwise
& Bitwise AND Two
| Bitwise OR Two
| Reduction OR One
Reduction
~| Reduction NOR One
Verilog numbers are of two types, sized numbers and unsized numbers.
Sized Verilog numbers: The general structure for representing sized numbers in Verilog HDL is
given below.
<size>’<base format><numbers>
size: Size is the number of digits the main number has. Size is described using decimal values.
base format: Base format suggests which type of number it would be. There are several types –
binary (given by – ‘b’), decimal (given by – ‘d’), octal (given by – ‘o’), hexadecimal (given by –
‘h’). If there is no specification for base format, then by default it is a decimal number.
Unsized Verilog numbers: These numbers do not require any specified size.
The general structure for representing unsized numbers in Verilog HDL is given below.
’<base format><numbers>
Negative Numbers: If you want to declare a number as a negative number, then put a minus
symbol (-) before the number.
Start > Programs > Xilinx ISE Design Suite 11 > ISE > Project Navigator. In Project Navigator,
Select the New Project option from the Getting Started menu (or by selecting Select File > New
Project).
This brings up a Dialog box where you can enter the desired project name and project location.
Choose a meaningful name for easy reference. Here we call this project “example1-Verilog” and
save it in a local directory. You can place comments for your project in the Description text box.
We use HDL for our top-level source type in this tutorial.
Choose the location to create a New Project. Always choose something other than User folder
as it is read only. The best way is to create a folder on desktop, name it and copy its url and
paste it in the “location” of the “new project wizard”.
2. The next step is to select the proper Family, Device, and Package for your project. This
depends on the chip you are targeting for this project. The appropriate settings for a project
suited for the Nexys2 500k board are as follows:
Since this lab does not require physically burn the logic on a chip so we will leave this window
as it is. Just click Next.
3. Once the appropriate settings have been entered, click Next. The next two dialog boxes give
you the option of adding new or existing source files to your project. Since we will fulfill these
steps later, click Next without adding any source files.
Once the new project has been created, ISE opens the project in Project Navigator. Click the
Design tab to show the Design panel and click the Console tab to show the Console panel.
The Design panel (1) contains two windows: a Sources window that displays all source files
associated with the current design and a Process window that displays all available processes
that can be run on a selected source file.
The Console panel (2) displays status messages including error and warning messages.
The HDL editor window (3) displays source code from files selected in the Design panel.
You can add a new or existing source file to the project. To do this, right-click the target device
and select one of the three options for adding source files.
We create a new source file, so select New Source from the list. This starts the New Source
Wizard, which prompts you for the Source type and file name. Select Verilog Module and give it
a meaningful name e.g. circuit1.
When you click Next, you have the option of defining top-level ports for the new Verilog
module. We chose A, B, and C as input ports and Y as an output port.
The Xilinx tools automatically generate lines of code in the file to get you started with circuit
development. This generated code includes:
1. a module statement
The actual behavioral or structural description of the given circuit is to be placed between the
“module” and “endmodule” statements in the file. Between these statements, you can define
any Verilog circuit you wish. In this tutorial, we use a simple combinational logic example, and
then show how it can be used as a structural component in another Verilog module. We start
with the basic logic equation: Y= (A·B) + C.
If there are any syntax errors in the source file, ISE can help you find them. For example, the
parentheses around the A and B inputs are crucial to this implementation; without them, ISE
would return an error during synthesis info.
The RTL schematics can be viewed using the following set of steps, the example used here is
that of a Nand gate. Double click on synthesize-XST, on the left-hand side.
To create a Test bench, create New Source. Select Verilog Test Fixture. Template of Test bench
will be created instantiating the Nand gate module.
Stimulus/Testbench
Code
module nand1_stimulas;
reg a;
reg b;
wire c;
Initial block: Initial blocks cause particular instructions to be performed at the beginning of the
simulation before any other instructions operate. Initial blocks only operate once.
Verilog test benches are used for the verification of the digital hardware design. Verification is
required to ensure the design meets the timing and functionality requirements. Verilog Test
benches are used to simulate and analyze designs without the need for any physical hardware
or any hardware device.
RTL
OUTPUT
This is the simulation window. You can verify the working using waveforms.
Gate level modeling is virtually the lowest level of abstraction because switch-level abstraction
is rarely used. Gate level modeling is used to implement the lowest-level modules in a design,
such as multiplexers, full-adder, etc. Verilog has gate primitives for all basic gates.
Gate Types
A logic circuit can be designed using logic gates. Verilog supports basic logic gates as predefined
primitives. These primitives are instantiated like modules except that they are predefined in
Verilog and do not need a module definition. All logic circuits can be designed by using basic
gates. There are two classes of basic gates: and/or gates and buf /not gates.
And/ Or Gates
And/or gates have one scalar output and multiple scalar inputs. The first terminal in the list of
gate terminals is an output and the other terminals are inputs. The output of a gate is evaluated
as soon as one of the inputs changes. And /or gates available in Verilog are shown below.
Buf/not gates have one scalar input and one or more scalar outputs. The last terminal in the
port list is connected to the input. Other terminals are connected to the outputs. We will
discuss gates that have one input and one output.
Syntax
module and_gate (z,x,y);
input x,y;
output z;
and a1 (z,x,y);
endmodule
Code
module all_gates(
input a,
input b,
output x1,
output x2,
output x3,
output x4,
output x5,
output x6
);
and (x1,a,b);
or (x2,a,b);
nand (x3,a,b);
xor (x4,a,b);
xnor (x5,a,b);
nor (x6,a,b);
endmodule
RTL
Waveform
Example # 2
Implement 4x1 MUX (gate level designing) in Xilinx ISE. Implement test benches to verify their
working. Visualize their behavior in waveforms.
Code
module mux_4x1(op,i0,i1,i2,i3,s0,s1);
input i0,i1,i2,i3;
input s1,s0;
output op;
wire s1bar,s0bar;
wire w1,w2,w3,w4;
not n1(s1bar,s1);
not n2 (s0bar,s0);
and a1(w1,i0,s1bar,s0bar);
and a2 (w2,i1,s1bar,s0);
and a3(w3,i2,s1,s0bar);
and a4(w4,i3,s1,s0);
or o1 (op,w1,w2,w3,w4);
endmodule
RTL
Schematics
Waveform
Lab Tasks:
A) Implement the following logic gates in Xilinx ISE and implement test benches to verify their
working. Visualize their behavior in waveforms.
1. AND
2. OR
3. XOR
4. NOT
B) F = (AB) + (CD)
C) G = (A|B) & (C|D)
D) Implement full adder and implement test benches to verify their working. Visualize their
behavior in waveforms.
E) Implement the following in Xilinx (Gate Level Designing). implement test benches to verify
their working. Visualize their behavior in waveforms.
I. Full adder
II. Full subtractor
III. 8 X 1 multiplexer
IV. 4 to 2 encoders
V. 4 to 1 demultiplexer
Lab Rubrics
3 2 1 0
Satisfactory
Coding Exceptional coding Good coding with with noticeable Struggles with
Skills with minimal errors minor errors errors frequent errors
Effectively
Struggles with Frequently
Problem identifies and solves Capably identifies
significant fails to identify
Solving complex problems and resolves issues
assistance or solve
Design objectives
Design objectives Design objectives
have been
Achieving have been achieved have been achieved Design
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Date: ______________________
Lab-11
Sequential Circuits in Verilog HDL
11.1 Lab Objectives:
Gain a deep understanding of implementing sequential circuits in Verilog.
Learn to use high-level abstractions and Verilog constructs for digital system
descriptions.
Represent algorithms and functions behaviorally using Verilog.
Simulate behavioral models written in Verilog and verify their accuracy.
initial begin
#10 x = 1'b0;
#25 y = 1'b1;
end
initial
#50 $finish;
Endmodule
In the above example, the three initial statements start to execute in parallel at time 0.
If a delay #<delay> is seen before a statement, the statement is executed <delay> time
units after the current simulation time. Thus, the execution sequence of the statements
inside the initial blocks will be as follows.
time statement executed
0 m = 1'b0;
5 a = 1'b1;
10 x = 1'b0;
30 b = 1'b0;
#50 $finish;
35 y = 1'b1;
Always Statement:
All behavioral statements inside an always statement constitute an always block. The
always statement starts at time 0 and executes the statements in the always block
continuously in a looping fashion. This statement is used to model a block of activity
that is repeated continuously in a digital circuit. An example is a clock generator module
that toggles the clock signal every half cycle. In real circuits, the clock generator is active
from time 0 to as long as the circuit is powered on. Example illustrates one method to
model a clock generator in Verilog
In Example, the always statement starts at time 0 and executes the statement clock =
~clock every 10 time units. Notice that the initialization of clock has to be done inside a
separate initial statement. If we put the initialization of clock inside the always block,
clock will be initialized every time the always is entered. Also, the simulation must be
halted inside an initial statement. If there is no $stop or $finish statement to halt the
simulation, the clock generator will run forever. The activity is stopped only by power off
($finish) or by an interrupt ($stop).
Blocking Assignments:
Blocking assignment statements are executed in the order they are specified in a
sequential block. A blocking assignment will not block execution of statements that
follow in a parallel block., The = operator is used to specify blocking assignments.
Example of Blocking Statement:
reg x, y, z;
Non-Blocking Assignments:
In this example, the statements x = 0 through reg_b = reg_a are executed sequentially at
time 0.
Then the three nonblocking assignments are processed at the same simulation time:
1. reg_a[2] = 0 is scheduled to execute after 15 units (i.e., time = 15)
2. reg_b[15:13] = {x, y, z} is scheduled to execute after 10 time units (i.e., time =
10)
3. count = count + 1 is scheduled to be executed without any delay (i.e., time =
0)
11.4 Examples:
4-bit Counter:
//4-bit Binary counter module counter(Q , clock, clear);
// I/O ports
output [3:0] Q; //output defined as register reg [3:0] Q
input clock, clear;
always @( posedge clear or negedge clock)
begin
if (clear)
Q <= 4'd0;
//Nonblocking assignments are recommended for creating sequential logic such
as flipflops else
Q <= Q + 1;// Modulo 16 is not necessary because Q is a 4-bit value and wraps
around.
end
endmodule
D Flip Flop:
module d_FF(Clock,Data,Q,Reset);
input Clock,Data,Reset;
output Q; reg Q;
always@(posedge clock)
begin
if (reset==1) Q<=0;
else Q<=Data;
end
endmodule
J K Q(t+1)
0 0 Q(t)(No change)
0 1 0 (Set)
1 0 1 (Reset)
1 1 Q’(t) (Toggle)
Task-2:
Implement T Flip flop using behavioral modeling, Truth table is given below.
T Q(t+1)
0 Q(t)(No change)
1 Q’(t) (Toggle)
Task-3:
Implement 4 bit ripple counter, Figure is given below
Lab Rubrics
3 2 1 0
Satisfactory
Coding Exceptional coding Good coding with with noticeable Struggles with
Skills with minimal errors minor errors errors frequent errors
Effectively
Struggles with Frequently
Problem identifies and solves Capably identifies
significant fails to identify
Solving complex problems and resolves issues
assistance or solve
Design objectives
Design objectives Design objectives
have been
Achieving have been achieved have been achieved Design
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Date: ______________________
Lab-12
FCSE, GIK Institute 148
CE-221L – Digital Logic Design Lab
A finite state machine is a mathematical model used to describe and analyze the behavior of
systems that have a finite number of states. It consists of a set of states, a set of inputs or
events that cause state transitions, and a set of rules that determine how the system transitions
from one state to another in response to these events.
F: final state
δ: Transition function
The behavior of an FSM can be visualized using a state transition diagram, which is a directed
graph where the nodes represent the states, and the edges represent the transitions between
them. The FSM can be in only one state at a time, and the current state determines how the
system will respond to the next input or event.
This lab introduces the concept of two types of FSMs, Moore and Mealy, and the modeling
styles to develop such machines.
In a Moore machine, the output is a function of the current state, and does not depend on the
input received. The output is generated when the machine transitions from one state to
another.
In a Mealy machine, the output is associated with the transition from one state to another,
rather than with the state itself. This means that the output can change as the machine
transitions from one state to another, depending on the input received.
Parameter: In Verilog, a parameter is a value that is declared at the module level and is used to
define constants or default values for a module's inputs, outputs, or internal signals.
Parameters are like constants in other programming languages and can be used to make a
module more flexible and reusable. A parameter is declared using the parameter keyword,
followed by the parameter name and value.
Note: A Mealy machine typically has one less state than a Moore machine is because Mealy
machines can encode some of the output information in the transitions between states, rather
than requiring a separate state for each possible output. This means that fewer states are
needed to represent the same behavior.
Example# 1: Design a Moore (FSM) circuit to detect a sequence (101) if the input signal is:
Input signal = 10100101010010101010
First, we need to create a state diagram that represents the states and transitions of the Moore
machine. In this case, we need to design a Moore machine that recognizes the input sequence
"110". We can do this by creating three states: S0, S1, and S2.
State S0 is the starting state, which means the machine has not yet detected any part of the
sequence "101". State S1 represents that the machine has detected the first "1" in the
sequence, while state S2 represents that the machine has detected both "1" and "0" in the
sequence. state S3 represents that the machine has detected all the corresponding inputs that
is “1", "0” and “1” in the sequence.
Next, we need to determine the output of each state. In state S0, the output will be 0. In state
S1, the output will also be 0. In state S2, the output will be 1 and State 3 the output is also 1.
Finally, we can create a state transition table and a state transition.
State Diagram
S0 0 S0 0
S0 1 S1 0
S1 0 S2 0
S1 1 S1 0
S2 0 S0 0
S2 1 S3 1
S3 0 S2 1
S3 1 S1 1
CODE
parameter s0 = 2'b00;
parameter s1 = 2'b01;
parameter s2 = 2'b10;
parameter s3 = 2'b11;
always @ (crntstate or x)
begin
case(crntstate)
s0: begin
//y = 0;
if (x==1)
nxtstate = s1;
else
nxtstate = crntstate;
end
s1: begin
//y = 0;
if (x==0)
nxtstate = s2;
else
nxtstate = crntstate;
end
s2: begin
//y = 0;
if (x==1)
nxtstate = s3;
else
nxtstate = s0;
end
s3: begin
//y = 1;
if (x==1)
nxtstate = s1;
else
nxtstate = s2;
end
default:nxtstate = s0;
endcase
end
always @ (posedge Clk)
begin
if (Rst)
crntstate = s0;
else
crntstate = nxtstate;
end
assign y = (crntstate == s3);
endmodule
Test-Bench
`timescale 1ns / 1ps
module moore_tb;
// Inputs
reg Clk;
reg Rst;
reg x;
// Outputs
wire y;
#5;
Clk = ~Clk;
end
end
always @(posedge Clk) begin
x = data>>k;
k = k+1;
end
endmodule
RTL
Technology Schematics
Example # 2 : Design a Mealy (FSM ) circuit to detect a sequence (101) if the input signal is
Input signal = 10100101010010101010
State Diagram
S0 0 S0 0
S0 1 S1 0
S1 0 S2 0
S1 1 S1 0
S2 0 S0 0
S2 1 S1 1
CODE
`timescale 1ns / 1ps
module mealy_machine_sequence_detector(y,Clk,Rst,x);
input Clk,Rst,x;
output y;
reg [1:0] crntstate,nxtstate;
parameter s0 = 2'b00;
parameter s1 = 2'b01;
parameter s2 = 2'b10;
always @ (crntstate or x)
begin
case(crntstate)
s0: begin
if (x==1)
nxtstate = s1;
else
nxtstate = crntstate;
end
s1: begin
if (x==0)
nxtstate = s2;
else
nxtstate = crntstate;
end
s2: begin
if (x==1)
nxtstate = s2;
else
nxtstate = s0;
end
default:nxtstate = s0;
endcase
end
always @ (posedge Clk)
begin
if (Rst)
crntstate <= s0;
else
crntstate <= nxtstate;
end
assign y = (crntstate == s2)&x;
endmodule
Test-Bench
`timescale 1ns / 1ps
module mealy_tb;
// Inputs
reg Clk;
reg Rst;
reg x;
// Outputs
wire y;
initial begin
Clk = 0;
forever begin
#5;
Clk = ~Clk;
end
end
always @(posedge Clk) begin
x = data>>k;
k = k+1;
end
endmodule
RTL
Technology Schematics
Task # 1:
Write a Verilog code for a Moore (FSM) that detects the sequence (X) from given input
Signal in Xilinx ISE and implement test benches to verify their working. Visualize their
behavior in waveforms.
Task # 2:
Write a Verilog code for a Mealy (FSM) that detects the sequence (X) from given input
Signal in Xilinx and implement test benches to verify their working. Visualize their
behavior in waveforms.
Draw State diagram and make a state transition table for above tasks.
Lab Rubrics
3 2 1 0
Satisfactory
Coding Exceptional coding Good coding with with noticeable Struggles with
Skills with minimal errors minor errors errors frequent errors
Effectively
Struggles with Frequently
Problem identifies and solves Capably identifies
significant fails to identify
Solving complex problems and resolves issues
assistance or solve
Design objectives
Design objectives Design objectives
have been
Achieving have been achieved have been achieved Design
achieved within
Design within 10% of the within 25% of the objectives are
40% of the
Objectives desired desired not met
specifications desired
specifications
specifications
Date: ______________________
Lab-13
FCSE, GIK Institute 162
CE-221L – Digital Logic Design Lab
13.3 Exercise:
To be announced on the spot or in previous lab.