COA (2021/22) Chapter II
Logic Gates & Digital Components
Logic gates
Logic gates are the basic building blocks of a digital computer. We are going to study how gates
can be used to build useful circuits. I.C circuits such as micro-processors, RAMs, interface chips
and so…on are manufactured by putting hundreds and thousands of simple logic gates on a
silicon chip. This chip is again packaged to provide pins for connecting the circuit to the rest of
the system.
Logic gates are digital circuits that have two or more logic inputs (except for NOT gate) and
produce a single output with a logic level based on the input. The input and output logic levels
applied to these gates are represented as Boolean variables.
Basic Logic Gates
AND
An AND gate is an electronic circuit that generates an output signal of 1 only if all input signals
are 1. An AND gate is the physical realization of logical multiplication. AND gate can have
more than two inputs. The output of the AND gate with inputs A, B, and C is 1 only if A, B and
C are 1. Two or more switches connected in series behave as an AND gate.
Truth table and the block diagram for an AND gate
INPUT OUTPUT
A B Q= A.B
0 0 0
1 0 0
0 1 0
1 1 1
Prepared by: Sisay Z. 1 G2-SE-FCSE
COA (2021/22) Chapter II
OR
An OR gate is an electronic circuit that generates an output signal of 1 if any of the input signals
is 1. An OR gate is the physical realization of logical addition. OR gate can have more than two
inputs. The output of the OR gate with inputs A, B, and C is a 1 if A or B or C is a 1. Two or
more switches connected in parallel behave as an OR gate.
Truth table and the block diagram for an OR gate
INPUT OUTPUT
A B Q = A+B
0 0 0
1 0 1
0 1 1
1 1 1
NOT
NOT gate is an electronic circuit that generates an output signal which is the reverse of the input
signal. A NOT gate is the physical realization of the complementation or logical inversion. A
NOT gate is also known as an inverter because it inverts the input. A NOT gate always has a
single input. Connecting two NOT gates in series gives an output equal to the input.
Truth table and the block diagram for a NOT gate
INPUT OUTPUT
A Q = A
0 1
1 0
NOR (Combines OR and NOT gates)
A NOR gate is an electronic circuit that generates an output signal of 1 when all input signals are
0 and it will be a 0 if any input represents a 1. NOR gate is a complemented OR gate. The
symbol is used to represent NOR operation in Boolean expression.
Thus, A B = (A+B)= A.B
The NOR gate can then be seen to be an OR gate followed by a NOT gate.
Truth table and the block diagram for a NOR gate
INPUT OUTPUT
A B Q= A.B
0 0 1
1 0 0
0 1 0
1 1 0
Prepared by: Sisay Z. 2 G2-SE-FCSE
COA (2021/22) Chapter II
NAND (Combines AND & NOT)
A NAND gate is an electronic circuit that generates an output signal of 1 if any one of the input
is a 0 and will be a 0 when all input signals are 1. NAND gate is a complemented AND gate. The
symbol is used to represent NAND operation in Boolean expression.
Thus A B = (A.B)= A+B
The NAND gate can then be seen to be an AND gate followed by a NOT gate.
Truth table and the block diagram for a NAND gate
INPUT OUTPUT
A B Q= A+B
0 0 1
1 0 1
0 1 1
1 1 0
Exclusive-OR
Ex-OR gate is a combinational Logic circuit. Ex-OR gate is an electronic circuit that generates
an output signal of 0 if both the inputs are same. The symbol is used to represent Ex-OR
operation in Boolean expression. Thus A B = A.B + A.B
Truth table and the block diagram for an Ex-OR gate
INPUT OUTPUT
A B Q= A.B+A.B
0 0 0
1 0 1
0 1 1
1 1 0
Prepared by: Sisay Z. 3 G2-SE-FCSE
COA (2021/22) Chapter II
Boolean algebra
Example 2:
Example 3:
Example 4: Draw the logic circuit for the Boolean expression, xy + xc + yc with three inputs
x, y and c only.
Prepared by: Sisay Z. 4 G2-SE-FCSE
COA (2021/22) Chapter II
Combinational Circuits
Half adder
A combinational circuit that performs the addition of two bits is called a half adder. This circuit
needs 2 inputs and 2 outputs. The input variables designate the augends and addend bits whereas
the output variable produce the sum (S) and carry (C) bits.
That is S=A`.B + A.B` and C= A.B
Prepared by: Sisay Z. 5 G2-SE-FCSE
COA (2021/22) Chapter II
The half adder is limited in the sense that it can add only 2 single bits. All though it generates a
carry for the next higher pair of significant bits, it cannot accept a carry generated from the
previous pair of lower significant bits.
A full adder solves this problem.
Full Adder
One that performs the addition of 3 bits (2 significant bits and previous carry) is called a full
adder. A full adder forms arithmetic sum of 3 input bits thus it consists of 3 inputs and 2 outputs.
Two of the input variables (A and B) represent the augend and addend bits and the third input
variable input (D) represents the carry from the previous lower significant position. These two
outputs are designated by the symbol S (Sum) and C (Carry). When all input variables are zero,
the output is zero for both C and S. the output S=1 when only one input is 1 or all 3 inputs are
equal to one. The output C is 1 if 2 or 3 input is equal to one.
Logic circuit Symbol
Binary adder
Parallel binary adders are used to add to binary numbers. To add 2 four bit binary numbers we
need to construct a parallel 4 bit binary adder. Such an adder requires one half adder (denoted by
HA) and 3 full adders (denoted by FA).
Addition of two 4-bit numbers (with binary adder)
Eg:- Add 910 and 1110
910 = 10012 and 1110 = 10112
Prepared by: Sisay Z. 6 G2-SE-FCSE
COA (2021/22) Chapter II
The circuit shown below depicts the method of addition for the above Using 1 H.A and 3 F.As
Sequential Circuits
Sequential Circuits are more complex form of digital logic circuits. Sequential circuits make use
of combinational circuits. The simplest form of sequential circuit is the flip-flop.
The flip-flop is a bistable device (the circuit can exist in one of two stable states by the virtue of
the fact that i ts outputs are cross coupled to its inputs. For this reason we call this type of circuit
a bistable). Flip-flop exists in one of the two states and in the absence of input, remains in that
state. The flip-flop has 2 outputs, which are always complement of each other. These are
generally labeled as Q and Q`.
S-R flip-flop (logical circuit)
Clocked S-R flip-flop
Events in the digital computer are synchronized to a clock pulse so that changes in the output of
a latch (flip-flop) will occur only when a clock pulse occurs.
Clocked S-R flip-flop (logical circuit)
D-flip flop
Problem with S-R flip flop is that the condition R=1, S=1 must be avoided. One way to do this is
to allow just a single input. The D-flip flop accomplishes this by using an inverter in the circuit.
Prepared by: Sisay Z. 7 G2-SE-FCSE
COA (2021/22) Chapter II
Logical circuit of D-flip flops
J-K flip-flop
The JK is a refinement of the SR flip-flop in that the indeterminate state of the SR is defined in
the JK type. It has two inputs J and K. When J=K=1, flip-flop switch to complement state. So,
for a value of Q = 1, it switches to Q = 0 & for a value of Q = 0, it switches to Q = 1.
All possible combinations of input values are valid.
Integrated Circuits (IC)
An integrated circuit (IC) is a small chip that can function as an amplifier, oscillator, timer,
microprocessor, or even computer memory. An IC is usually made of silicon, that can hold
anywhere from hundreds to millions of transistors, resistors, and capacitors. These extremely
small electronics can perform calculations and store data using
either digital or analog technology.
Digital ICs use logic gates, which work only with values of ones and zeros. A low signal sent to
a component on a digital IC will result in a value of 0, while a high signal creates a value of 1.
Digital ICs are the kind you will usually find in computers, networking equipment, and most
consumer electronics.
Integrated Circuits play a very important part in electronics. Most are specially made for a
specific task and contain up to thousands of transistors, diodes and resistors. Special purposes
IC's such as audio-amplifiers, FM radios, logic blocks, regulators and even a whole micro
computer in the form of a micro controller can be fitted inside a tiny package. Most integrated
Circuits are in a DIL package - Dual In Line, meaning there are two rows of pins.
Prepared by: Sisay Z. 8 G2-SE-FCSE
COA (2021/22) Chapter II
The Digital Buffer
A Digital Buffer is another single input device that does no inversion or performs any type of
logical operation on its input signal as its output exactly matches that of its input. In other words,
the digital buffer is a "non-inverting" device as it does nothing as its output state equals its input
state.
Digital Buffers can be used to drive high current loads such as transistor switches because their
output drive capability is much higher than their input signal requirements. In other words
buffers can be used for power amplification of a digital signal as they have high "fan-out"
capability.
The fan-out is the number of parallel loads that can be driven simultaneously by one digital
buffer of logic gate.
The Tri-State Buffer
As the standard Digital Buffer seen above, there is another type of digital buffer circuit whose
output can be "electronically" disconnected as and when required. A tri-state buffer, also known
as a 3-State Buffer, is a useful device that allows passing the input to output through the device,
and blocks when it doesn't require.
A Tri-state Buffer can be thought of as an input controlled switch which has an output that can
be electronically turned "ON" or "OFF" by means of an external "Control" or "Enable" signal
input. This control signal can be either logic "0" or a logic "1" type signal, resulting in the Tri-
state Buffer being in one state.
There are two different types of Tri-state Buffers, one whose output is controlled by an "Active-
HIGH" control signal and the other which is controlled by an "Active-LOW" control signal.
Prepared by: Sisay Z. 9 G2-SE-FCSE
COA (2021/22) Chapter II
Active- High Tri-state buffer
When the control/Enable input is active-high, the output is the input. That is, it behaves just like
a normal buffer. The "valve" is open. The Hi-Z represents a High impedance state (which is the
third state)
Active-Low Tri-state buffer
The circle marked on the enable signal represents it is active-low
Multiplexers, De-multiplexers, Encoders & Decoders
Multiplexers (MUX)
A multiplexer is a circuit that accepts many inputs but give only one output. It is a device that
allows several analog or digital input signals which are to be selected and transmits the selected
input into a single medium. Multiplexer is also known as Data Selector. A multiplexer of 2n
inputs has n select lines that will be used to select input line to send to the output. Multiplexer
handle two types of data that is analog and digital. For analog application, multiplexer are built
of relays and transistor switches. For digital application, they are built from standard logic gates.
Multiplexer allow the process of transmitting different type of data such as audio, video at the
same time using a single transmission line. Multiplexers are used to implement huge amount of
memory into the computer, at the same time reduces the number of copper lines required to
connect the memory to other parts of the computer circuit.
Prepared by: Sisay Z. 10 G2-SE-FCSE
COA (2021/22) Chapter II
4 – to - 1 Multiplexer
8 – to - 1 Multiplexer
De-Multiplexers (De MUX)
Conversely, a demultiplexer (or demux) is a device taking a single input signal and selecting
one of many data-output-lines. A demultiplexer functions exactly in the reverse of a multiplexer,
that it accepts only one input and gives many outputs. In an ALU circuit, the output of ALU can
be stored in multiple registers or storage units with the help of demultiplexer. Each output of
demultiplexer is connected to multiple register which can be stored in the registers.
1– to - 4 DeMultiplexer
Communication through MUX and DeMUX
Generally multiplexer and demultiplexer are used together since most of the communication
systems are bidirectional.
Prepared by: Sisay Z. 11 G2-SE-FCSE
COA (2021/22) Chapter II
Encoders
An encoder is a device, circuit, software program, algorithm or person that converts information
from one format/code to another, for the purposes of standardization, speed, secrecy, security or
compressions.
4 – to – 2 Encoder
Here Y0 , Y1, Y2, Y3 are given value 1.
It indicates they are active high on those situations.
8 – to – 3 Encoder
Exercise : Do the truth table for the above mentioned 8 – to – 3 Encoder.
Decoders
2 – to – 4 Decoder
Here Z0 , Z1, Z2, Z3 are given value 1.
It indicates that they are active high on those situations.
Prepared by: Sisay Z. 12 G2-SE-FCSE
COA (2021/22) Chapter II
3 – to – 8 Decoder
Here Y0, Y1, Y2, Y3….. Y7 are given value 1.
It indicates they are active high on those situations.
Difference between an Encoder and Decoder
BCD to 7 Segment Decoder
Because cathode displays require a high voltage drive, they have mostly been replaced by low
voltage LED or LCD displays using 7 segment displays, therefore the BCD-to-7-segment
decoder has become one of the most commonly available decoders.
Address Decoders
Decoders may also be used in computer systems for address decoding. It is used to enable the
microprocessor to communicate with many locations in its memory system.
Prepared by: Sisay Z. 13 G2-SE-FCSE
COA (2021/22) Chapter II
Counters
Counting is frequently required in digital computers and other digital systems to record the
number of events occurring in a specified interval of time. Normally an electronic counter is used
for counting the number of clock pulses coming at the input line in a specified time period. The
counter must possess memory since it has to remember its past states. In electronics, counters
can be implemented quite easily by using flip-flops. A counter that follows the binary number
sequence is a binary counter. n-bit binary counter is a register of n flip-flops and gates that
follow a sequence of states.
E.g., 0000, 0001, 0010, 0011, 1000, …1111
The LSB is complemented each count. Every other bit is complemented if and only if all its
lower-order bits are equal to 1.
T Flip flop
The T or "toggle" flip-flop changes its output on each clock edge, giving an output which is half
the frequency of the signal to the T input.
It is useful for constructing binary counters, frequency dividers, and general binary addition
devices. It can be made from a J-K flip-flop by tying both of its inputs high.
Construction of T flip flop from a J-K flip flop
As with other sequential logic circuits counters can be synchronous or asynchronous.
Asynchronous (ripple) counter
Asynchronous counters: the flip-flops do not change states at exactly the same as they do not
have a common clock pulse. Input clock is only connected to one flip-flop only. Clocks for other
flip-flops are (or are derived from) the outputs of the previous flip-flops. Also known as ripple
counters, as the input clock pulse “ripples” through the counter.
An Asynchronous counter created from two JK flip-flops is shown below.
You can continue to add additional flip-flops, always using the output from the previous flip-flop
as the clock signal for the newly added flip-flop.
Prepared by: Sisay Z. 14 G2-SE-FCSE
COA (2021/22) Chapter II
Binary Counter (4 stage)
A binary counter can be constructed from JK flip flops by taking the output of one cell to the
clock input of the next. The J and K inputs of each flip-flop are set to 1 to produce a toggle at
each cycle of the clock input. For each two toggles of the first cell, a single toggle is produced in
the second cell, and so on down to the fourth cell. This produces a binary number equal to the
number of cycles of the input clock signal. This device is sometimes called a “ripple through”
counter.
Synchronous (parallel) counter
Synchronous counters have a regular pattern with a common clock. To eliminate the “ripple”
effects, use a common clock for each flip-flop and a combinational circuit to generate the next
state. The flip-flops are clocked at the same time by a common clock pulse (with a single
clocking source). Synchronous counters give faster response than asynchronous counters since
the clock pulses are applied to all the flip-flops simultaneously.
In synchronous counters, the clock inputs of all the flip-flops are connected together and are
triggered by the input pulses. Thus, all the flip-flops change state simultaneously (in parallel).
Prepared by: Sisay Z. 15 G2-SE-FCSE
COA (2021/22) Chapter II
The circuit below is a 4-bit synchronous counter using JK flip flops.
Initially, let both the FFs (FFA and FFB) be in the reset state. That means Q A=0 & QB=0. As
soon as the first clock pulse is applied, FFA will toggle and QA will change from 0 to 1. But at
the instant of application of clock pulse, the J and K input of FFB will become 0. Hence FFB
will not change its state. So QB will remain 0.
On the arrival of second clock pulse, FFA toggles again and QA changes from 1 to 0. But at this
instant QA was 1. So J and K of FFB will be = 1 and FFB will toggle. Hence QB changes from 0
to 1.
On the third clock edge, FFA will toggle from 0 to 1 but there is no change of state for FFB.
Hence, QB =1 and QA = 1 after the third clock pulse.
Like these ways, 4-bit synchronous counter counts from 0 to 15.
As the name suggests, counters are circuit which counts. Counters are useful for digital clocks
and timers. The main purpose of the counter is to record the number of occurrence of some
input.
Prepared by: Sisay Z. 16 G2-SE-FCSE
COA (2021/22) Chapter II
Assignment # 1
There are many types of counter both binary and decimal. Each is useful for different
applications. Usually, counter circuits are digital in nature, and count in natural binary.
1) Write where all places counters are found and the usage of counters in each area
2) Write detailed notes on the following commonly used counters with their circuits:
1. Frequency Counter
2. Ring Counter
3. BCD Counter
4. Decade counter
5. UP Counter
6. Down Counter
7. Up down Counter
Submission date: December 5-2022(Monday)
Time: before 12 pm (local time 6)
Prepared by: Sisay Z. 17 G2-SE-FCSE