Lab File Dlca
Lab File Dlca
Lab Experiments
CSA2003 - Digital Logic and Computer Architecture
Slot - C12+C13+F11+F12+F13
Faculty Name - Dr. Daood Saleem
1
Table of Content
1. Design and verify the truth table of all 8 basic logic gates. 4 - 13 12-07-24
4. To realize 28 - 35 13-07-24
a. Half Adder and Full Adder
b. Half Subtractor and Full Subtractor
by using Basic gates and NAND gates
10. Design and verify the 4-bit asynchronous down counter. 25-07-24
2
3
Experiment No-1
Aim: Design and verify the truth table of all 8 basic logic gates.
Theory:
A logic gate is a digital gate that allows data to be manipulated. Logic gates, use
logic to determine whether or not to pass a signal. Logic gates, on the other hand,
govern the flow of information based on a set of rules.
The logic gates can be classified into the following major types:
1. Basic Logic Gates
There are three basic logic gates:
1. AND Gate
2. OR Gate
3. NOT Gate
2. Universal Logic Gates
In digital electronics, the following two logic gates are considered as universal
logic gates:
1. NOR Gate
2. NAND Gate
4
3. Derived Logic Gates
The following two are the derived logic gates used in digital systems:
1. XOR Gate
2. XNOR Gate
AND Gate :
The AND gate is an electronic circuit which gives a high output only if all its inputs
are high. The AND operation is represented by a dot (.) sign.
OR GATE :
The OR gate is an electronic circuit which gives a high output if one or more of its
inputs are high. The operation performed by an OR gate is represented by a plus
(+) sign.
5
NOT GATE:
The NOT gate is an electronic circuit which produces an inverted version of the
input at its output. It is also known as an Inverter.
NAND GATE:
The NOT-AND (NAND) gate which is equal to an AND gate followed by a NOT gate.
The NAND gate gives a high output if any of the inputs are low. The NAND gate is
represented by a AND gate with a small circle on the output. The small circle
represents inversion.
6
NOR GATE
The NOT-OR (NOR) gate which is equal to an OR gate followed by a NOT gate. The
NOR gate gives a low output if any of the inputs are high. The NOR gate is
represented by an OR gate with a small circle on the output. The small circle
represents inversion.
The 'Exclusive-OR' gate is a circuit which will give a high output if one of its inputs
is high but not both of them. The XOR operation is represented by an encircled
plus sign.
7
EXCLUSIVE-NOR/Equivalence GATE:
The 'Exclusive-NOR' gate is a circuit that does the inverse operation to the XOR
gate. It will give a low output if one of its inputs is high but not both of them. The
small circle represents inversion.
BUFFFER GATE :
A buffer gate is a special type of logic gate that serves as a signal amplifier. Its
primary purpose is to strengthen a weak input signal so that it can drive a load
effectively.
8
Simulation Diagrams:
1. AND GATE
2. OR GATE
9
3. NOT GATE (INVERTER)
4. NOR GATE
10
5. XNOR GATE
11
6. XOR GATE
7. NAND GATE
12
8. BUFFER
Conclusion:
In this experiment, we explored basic logic gates and their behavior using Logisim
.The truth table of all 8 basic logic gates have been verified using Logisim.
13
Experiment No-2
Aim: To simplify the given expression and to realize it using basic gates and
Universal gate.
Boolean Algebra simplification is not that difficult to understand if you realise that
the use of the symbols or signs of: “+” and “.” represent the operation of logical
functions.
Logical functions test whether a condition or state is either TRUE or FALSE but not
both at the same time. So depending on the result of that test, a digital circuit can
then decide to do one thing or another.
As we saw in the Laws of Boolean Algebra tutorial, that Boolean algebra is the
mathematics of logic and that the application of various switching theory rules
can be applied to simplify long or complex switching algebra notation, and which
can also be applied to logic gates and basic digital circuits.
14
Having established the switching operation of the AND, OR, and NOT functions.
We can now look at simplifying some basic Boolean Algebra expressions to obtain
a final expression that has the minimum number of terms.
First let us start with something simple such as:
The Boolean Expression: A.(A + B)
Multiplying out the brackets gives us:
15
Then we can see that the Boolean expression of A.(A + B) can be reduced to just
“A” which follows Boole’s Absorption Law.
16
hus the complex Boolean expression of: (A + B’ + C’)(A +B’ + C)(A + B + C’) has
been reduced down to the smaller expression of: A + (B’ C’)
A Boolean function is an algebraic expression formed using the AND, OR, and
NOT operators.
The Boolean variables of A, B, and C are known as the literals of the function and
although we have used the captial letters A, B, and C, literals can take on and
symbolic value. For example, X,Y,Z, or a, b, c. Thus any symbol can be used to
represent a logical variable that can have a value of 1 or 0.
There are several Boolean Algebra laws, rules and theorems available which
provides us with a means of reducing any long or complex expression or
combinational logic circuit into a much smaller one with the most common laws
presented in the following Boolean algebra simplification table.
While some of these laws and rules may seem self-evident, and others less so. It is
important to learn and understand them and their application when working on
combinational logic circuit reduction or simplification.
17
Then Boolean algebra can be used to reduce any logic circuit to a simpler
equivalent circuit that functions identically to the original circuit, and in order to
prove the equality of the original and final Boolean expressions, truth tables could
be created for each to compare. If the truth tables match, then the final reduced
expression is correct.
18
Simulation Diagrams:
Conclusion:
The given expression has been simplified using basic postulates and the simplified
expression has been realized using Logisim . By simplifying expressions and
realizing them with logic gates, we gained practical insights into digital circuit
design.
19
Experiment-03
Aim: To Design and implement the circuit for the following 4-bit Code
conversion.
Theory:
What is a Binary Code?
The Binary code is the numerical system used in digital electronics. It only consists of two
Symbols which are 0 and 1.In binary code each digit is represented by power of 2 with the
starting bit (right most bit) as 20 and bit as 21 and so on. The binary code is serves as the basis
for encoding text, number and various other types of data in the digital devices.
Gray Code system is a binary number system in which every successive pair of numbers differs
by only one bit. It is used in applications in which the normal sequence of binary numbers
generated by the hardware ,is read while the system changes from the initial state to the final
state. This could have serious consequences for the machine using the information. The Gray
code eliminates this problem since only one bit changes its value during any transition between
two numbers.
Let 𝑏0,𝑏1,𝑏2,𝑎𝑛𝑑 𝑏3 b0,b1,b2,and b3 be the bits representing the binary numbers, where 𝑏0b0
is the LSB and 𝑏3b3 is the MSB, and Let 𝑔0,𝑔1,𝑔2,𝑎𝑛𝑑𝑔3g0,g1,g2,andg3 be the bits
representing the gray code of the binary numbers, where 𝑔0g0 is the LSB and 𝑔3g3 is the MSB.
20
K-map for g0 K-map for g1
21
Corresponding Minimized Boolean Expressions and Digital Circuit for Gray Code Bits
𝑔0=𝑏0𝑏1′+𝑏1𝑏0′=𝑏0⊕𝑏1
𝑔1=𝑏2𝑏1′+𝑏1𝑏2′=𝑏1⊕𝑏2
𝑔2=𝑏2𝑏3′+𝑏3𝑏2′=𝑏2⊕𝑏3
𝑔3=𝑏3
Logic Diagram
22
Stimulated Diagram
Let 𝑔0,𝑔1,𝑔2,𝑎𝑛𝑑𝑔3g0,g1,g2,andg3 be the bits representing the gray code of the binary
numbers, where 𝑔0g0 is the LSB and g3 is the MSB.
23
Truth Table for Gray code to binary code
24
K-map for 𝑏2 K-map for𝑏3
Corresponding Minimized Boolean Expressions and Digital Circuit for binary Code Bits
b0=G0⊕G1⊕G2⊕G3
b1=G1⊕[G2⊕G3]
b2=G2⊕G3
b3=G3
25
Corresponding Digital Circuit
Stimulated Diagram:
26
Rotary Encoders: The Rotary encoders are device which is used to convey rotary
motions into digital signals. The code converters use to convert the Gray code output of
rotary encodes into binary.
Control Systems: The Gray code converters are used in the Control system to integrate
between system using binary and gray code.
Signal Processing: The Code converters are used in the signal processing to translate
between binary and Gray coded signals.
Conclusion
In this Experiment we have gone through Code Converters – Binary to/from Gray
Code, we have gone through the definition of the Code converters, Binary code
and gray code, then we have gone through Code conversion between Binary to
Gray code and vice versa.
27
Experiment - 04
Aim: To realize
a. Half Adder and Full Adder
Inputs are called Augend and Added bits and Outputs are called Sum and
Carry.
28
Simulation Diagrams:
Full Adder:
To overcome the above limitation faced with Half adders, Full Adders are
implemented.
29
It is a arithmetic combinational logic circuit that performs addition of three
single bits.
It contains three inputs (A, B, Cin) and produces two outputs (Sum and Cout).
30
Cout = BCin + AB + ACin
Stimulated Diagram
Half Subtractor
It contains two inputs (A and B) and produces two outputs (Difference and
Borrow-output).
31
Truth Table of Half Subtractor:
32
Stimulated Diagram:
Full Subtractor:
It contains three inputs(A, B, Bin) and produces two outputs (D, Bout).
33
Truth Table of Full Subtractor:
34
Stimulated Diagram:
Conclusion:
Half and full adders/subtractors are fundamental digital circuits. Half
adders/subtractors handle single-bit operations, producing sum/difference and
carry/borrow. Full adders/subtractors extend this to include carry-in/borrow-in for
multi-bit operations. Implementable using basic gates or NAND gates, they form
the basis for arithmetic in digital systems.
35
Experiment-05
Aim: a.) Truth Table verification of
The flip-flop is a circuit that maintains a state until directed by input to change the
state. A basic flip-flop can be constructed using four-NAND or four-NOR gates. Flip-
flop is popularly known as the basic digital memory circuit. It has its two states as
logic 1(High) and logic 0(low) states. A flip flop is a sequential circuit which consist
of single binary state of information or data. The digital circuit is a flip flop which
has two outputs and are of opposite states. It is also known as a Bistable
Multivibrator.
Types of Flip-Flops
SR Flip Flop
JK Flip Flop
D Flip Flop
T Flip Flop
In the flip flop, with the help of preset and clear when the power is switched ON,
the states of the circuit keeps on changing, that is it is uncertain. It may come to
set(Q=1) or reset(Q’=0) state. In many applications, it is desired to initially set or
36
reset the flip flop that is the initial state of the flip flop that needs to be assigned.
This thing is accomplished by the preset(PR) and the clear(CLR).
37
Operations of S-R Flip Flop
Case 1(PR=CLR=1): The asynchronous inputs are inactive and the flip flop
responds freely to the S,R and the CLK inputs in the normal way.
38
Characteristics Equation for SR Flip Flop
Stimulated Diagram
In JK flip flops, The basic structure of the flip flop which consists of Clock (CLK),
Clear (CLR), Preset (PR).
39
Circuit Diagram and Truth Table of J-K Flip Flop
Given Below is the Diagram of J-K Flip Flop with its Truth Table
40
Stimulated Diagram
Case 2 (PR=0 and CLR=1):The PR is activated which means the output in the
Q is set to 1. Therefore, the flip flop is in the set state.
Case 3 (PR=1 and CLR=0):The CLR is activated which means the output in the
Q’ is set to 1. Therefore, the flip flop is in the reset state.
Case 4 (PR=CLR=1):In this condition the flip flop works in its normal way
whereas the PR and CLR gets deactivated.
When the J and K both are set to 1, the input remains high for a longer duration of
time, then the output keeps on toggling. Toggle means that switching in the output
instantly i.e. Q=0, Q’=1 will immediately change to Q=1 and Q’=0 and this
continuation keeps on changing. This change in output leads to race around
condition.
D Flip Flop
The D Flip Flop Consists a single data input(D), a clock input(CLK),and two outputs:
Q and Q’ (the complement of Q).
Given Below is the Diagram of D Flip Flop with its Truth Table
42
Operation of the D Flip-Flop
Case 2 (PR=0 and CLR=1):This state is set state in which PR is inactive (0) and
CLR is active(1) and the output Q is set to 1.
Case 3 (PR=1 and CLR=0):This state is reset state in which PR is active (1) and
CLR is inactive (0) and the complementary output Q’ is set to 1.
Case 4 (PR=CLR=1):In This state the flip flop behaves as normal, both PR and
CLR inputs are active(1).
QN+1 = D
Stimulated Diagram
43
T Flip Flop
The T Flip Flop consists of data input (T), a clock input (CLK), and two outputs: Q
and Q’ (the complement of Q).
44
Case 1 (T=0):In this condition the flip-flop remains in its current state
regardless of clock input,Also the Output Q will remain unchanged unit the
value of T will not change.
Case 2 (T=1):In this condition the flip flop will change when T input is 1,At
each rising or falling edge of the clock signal the output Q will be in
complementary state.
Stimulated Diagram:
45
b) Conversion of Flip Flop to another
Step 1 - he excitation table for the conversion of SR flip-flop into JK flip-flop is given
below –
46
Step 2 - Simplify the excitation for input expressions by using K-Map
47
Step 3- Finally, draw the logic diagram of JK flip flop by using SR flip flop, which is
shown in figure-3 below.
Stimulated Diagram:
Following is the characteristics table of T flip-flop and excitation table of S-R flip-
flop.
48
Now, using K-map we get the expression for of S & R in terms of T.
Therefore, the circuit diagram for conversion of S-R flip-flop into T flip-flop is:
49
Stimulated Diagram:
Step-1:
We construct the characteristic table of D flip-flop and excitation table of S-R flip-
flop.
50
Step-2
S=D
R = D'
We construct the circuit diagram of the conversion of S-R flip-flop into D flip-flop.
51
Stimulated Diagram
52
Logic Diagram
Stimulated Diagram
J and K are the actual inputs of the flip flop and T is taken as the external input for
conversion. Four combinations are produced with T and Qp. J and K are expressed
in terms of T and Qp. The conversion table, K-maps, and the logic diagram are
given below.
53
Stimulated Diagram
D is the external input and J and K are the actual inputs of the flip flop. D and Qp
make four combinations. J and K are expressed in terms of D and Qp. The four
combination conversion table, the K-maps for J and K in terms of D and Qp, and
the logic diagram showing the conversion from JK to D are given below.
54
Stimulated Diagram
D is the actual input of the flip flop and S and R are the external inputs. Eight
possible combinations are achieved from the external inputs S, R and Qp. But,
since the combination of S=1 and R=1 are invalid, the values of Qp+1 and D are
considered as “don’t cares”. The logic diagram showing the conversion from D to
SR, and the K-map for D in terms of S, R and Qp are shown below.
55
Stimulated Diagram:
56
In this conversion, D is the actual input to the flip flop and J and K are the external
inputs. J, K and Qp make eight possible combinations, as shown in the conversion
table below. D is expressed in terms of J, K and Qp.
The conversion table, the K-map for D in terms of J, K and Qp and the logic diagram
showing the conversion from D to JK are given in the figure below.
Stimulated Diagram:
57
D flip flop to T flip flop
In order to convert the given D flip-flop into a T-type, we need to obtain the
corresponding conversion table, as shown in Figure 9. Here, the information in the
excitation table of the D flip-flop is inserted as a part of the T flip-flop's truth table.
Having obtained the conversion table, the next step is to express the input, D, in
terms of T and Qn.
From Figure 10, we see that in order to convert the given D flip-flop into a T-type,
we need to drive its input pin (D) by the output of an XOR gate whose inputs are T
and Qn. This would lead to the new digital system which is shown in Figure 11(a).
If we must confine ourselves to only NOT, OR, and AND gates, we will need to
follow these steps:
58
1. Use an AND gate to AND the user-defined input, T, and the negation of the
flip-flop's present-state Qn.
2. Use another AND gate to AND the present-state of the flip-flop with the
negation of T (obtained as an output of a NOT gate).
3. OR together the outputs of the two AND gates using a two-input OR gate.
Stimulated Diagram
59
T flip flop to SR flip flop
Notice the don't care (X) entries in the last two rows of the conversion table's "T
input" column. These indicate that when both inputs (S and R) are driven high, the
output of the SR flip-flop is unpredictable (owing to the "race around condition").
Next, we should express the input of the given flip-flop in terms of the present-
state, Qn, and the input(s) of the desired flip-flop. This can be done by using a
suitable simplification technique, such as the K-map
60
Diagram
Stimulated Diagram
61
T flip flop to JK flip flop
We begin with the T-to-JK conversion table (see Figure 5), which combines the
information in the JK flip-flop's truth table and the T flip-flop's excitation table.
Next, we need to obtain the simplified Boolean expression for the T input in terms
of J, K, and Qn.
Figure 6 shows the expression for the T input as JQn + KQn. This means that to
convert the T flip-flop into a JK flip-flop, the T input is driven by the output of a
two-input OR gate which has as inputs
62
Thus, we will need two AND gates and one OR gate, as shown in Figure 7.
Stimulated Diagram:
63
Once this is done, we need to express the input, T, in terms of the user-defined
input, D, and the flip-flop's present-state, Qn. We will again use the K-map
simplification technique.
Figure 10 shows that, in order to make the given T flip-flop functionally equivalent
to a D flip-flop, we need to drive its input pin, T, with the output of an XOR gate
whose inputs are D and Qn. This will lead to the new digital system shown in Figure
11(a). Figure 11(b) shows a system which is functionally equivalent to that of
Figure 11(a) but is designed using only NOT, AND, and OR gates.
64
Stimulated Diagram:
Conclusion
In this experiment we have gone through definition of the flip flop in brief with its
different types, we have also gone through conversion of flip and the Application
of the Flip Flop.
65
Experiment No-6 (a)
Aim:
A. To design and set up a 4:1 Multiplexer (MUX) using only NAND gates.
B.
Inputs:
Output:
o 1 Output: YYY
The output YYY is determined by the select inputs S0S_0S0 and S1S_1S1 as
follows:
o The NAND gate output is the negation of the AND function. For
inputs A and B, the output Is ( A⋅B)’
o NOT(A)=A NAND
66
AND Gate Using NAND:
NOT Gate: Connect both inputs of a NAND gate to the same signal.
AND Gate: First use a NAND gate to get the NAND of the inputs, then use
a NOT gate (another NAND gate) to invert the result.
Combine the inverted select lines with the data inputs using
NAND gates to form the required AND and OR logic.
67
Simulation Diagrams:
Conclusion:
The process begins with implementing the NOT operation, followed by creating
AND gates and combining them to realize the MUX’s functionality. This design
approach not only demonstrates the versatility of NAND gates but also provides a
deeper insight into how complex digital systems can be constructed from simpler
components.
68
Experiment No-6(b)
Aim: To design and set up a 1:4 Demultiplexer (DE-MUX) using only NAND
gates.
o Input:
o Outputs:
4 Outputs: Y0,Y1,Y2,Y3
o Behaviour:
2. Demultiplexer Logic:
69
Y0 = D . S1’ . S0
Y1 = D1. S1’ . S0
Y2 = D.S1.S0’
Y3 = S.S1.S0
Use NAND gates to build AND gates for each of the four
demux output expressions.
Simulation Diagrams:
70
Conclusion:
Designing a 1:4 Demultiplexer (DE-MUX) using only NAND gates illustrates the
fundamental versatility and power of NAND gates in digital logic design. Through
this process, we have demonstrated how complex digital functions can be
constructed from simple building blocks.
71
Experiment No-7
Aim: Implementation of a 3 bit SIPO and SISO shift register using Flip Flops.
2. Add Components:
o Connect the Input Pin (serial input) to the D input of the first D Flip-
Flop.
1. Open Logisim: Start Logisim and create a new project if you haven't
already.
2. Add Components:
o Connect the Input Pin (serial input) to the D input of the first D Flip-
Flop.
o Connect the Q output of the third D Flip-Flop to the Output Pin (serial
output).
73
Simulation Diagrams:
SIPO
SISO
Conclusion:
74
By following the steps outlined:
This exercise provides practical experience with basic digital electronics concepts
and prepares one for more complex designs. It also demonstrates the versatility of
Logisim as an educational tool for visualizing and testing digital circuits.
75
Experiment No-8
Aim: To simplify the given expression and to realize it using basic gates and
Universal gate.
2. Place D flip-flops:
o Place an input pin on the workspace and label it as the clock (CLK).
o Connect the CLK input to the clock input of all three D flip-flops.
This will synchronize the flip-flops to the same clock signal.
o Place three input pins on the workspace and label them as D0, D1, and
D2.
o Connect D0 to the data input (D) of the first flip-flop, D1 to the data
input of the second flip-flop, and D2 to the data input of the third flip-
flop.
o Place three output pins on the workspace and label them as Q0, Q1,
and Q2.
76
o Connect the output (Q) of the first flip-flop to Q0, the output of the
second flip-flop to Q1, and the output of the third flip-flop to Q2.
6. Enable control:
o If you want to have an enable signal, place an input pin and label it as
EN.
o Use AND gates to control the data inputs to the flip-flops, so the data
is only loaded when EN is high.
Your 3-bit PIPO shift register is now complete. The data at D0, D1, and D2 will be
loaded into the flip-flops on a clock edge and will be available at Q0, Q1, and Q2,
respectively.
2. Place D flip-flops:
o Connect the CLK input to the clock input of all three D flip-flops.
o Place three input pins and label them as D0, D1, and D2.
o Connect D0 to the data input (D) of the first flip-flop, D1 to the data
input of the second flip-flop, and D2 to the data input of the third flip-
flop.
o Connect the output (Q) of the first flip-flop to the data input (D) of the
second flip-flop.
77
o Connect the output of the second flip-flop to the data input of the third
flip-flop.
o For each flip-flop, place a 2-to-1 MUX with inputs connected to D0,
D1, and D2 for the load operation and the previous flip-flop's Q
output for the shift operation.
Your 3-bit PISO shift register is now complete. The parallel data at D0, D1, and
D2 can be loaded into the flip-flops, and the data will shift out serially through
Qout on each clock pulse.
78
Simulation Diagrams: (PIPO)
PISO
Conclusion:
In this guide, we have successfully implemented both a 3-bit Parallel-In Parallel-
Out (PIPO) and a 3-bit Parallel-In Serial-Out (PISO) shift register using D flip-
flops in Logisim. The PIPO shift register allows data to be loaded in parallel and
read out in parallel, providing a straightforward means of data storage and
79
retrieval. Conversely, the PISO shift register enables parallel data loading with a
serial output, making it useful for converting parallel data to serial form for
transmission or processing.
By following the detailed steps for placing and connecting D flip-flops, input pins,
output pins, and additional control logic like enable and load signals, you should
now have a clear understanding of how to design these essential digital circuits.
Testing the circuits with clock pulses ensures their functionality, providing
valuable hands-on experience in digital design.
These shift registers are foundational components in many digital systems, and
mastering their implementation in Logisim will aid in understanding more complex
digital circuits and systems in future projects
80