0% found this document useful (0 votes)
3 views

comparator_encoder

The document discusses comparators, encoders, and decoders in digital electronics, explaining their functions and types. Comparators compare the magnitudes of binary numbers, while encoders convert multiple inputs into a unique binary code, and decoders convert binary input codes into output channels. It also highlights the advantages and disadvantages of encoders and provides examples of different types of each circuit.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

comparator_encoder

The document discusses comparators, encoders, and decoders in digital electronics, explaining their functions and types. Comparators compare the magnitudes of binary numbers, while encoders convert multiple inputs into a unique binary code, and decoders convert binary input codes into output channels. It also highlights the advantages and disadvantages of encoders and provides examples of different types of each circuit.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Digital Electronics - Comparators

In digital electronics, a comparator is a combinational logic circuit that is used to compare the
magnitudes of two binary numbers.
Comparators are used in several different electronic circuits like analog to digital converters,
voltage level detectors, zero-crossing detectors, etc.
What is a Comparator?
A digital combinational circuit used to compare the magnitude of two binary numbers to
determine the equality or non-equality is called a comparator.
Therefore, the main function of a comparator is to compare the values of input numbers and
produce an output indicating whether the numbers are equal or specifies which of the numbers
is greater.
Let us understand the working of a comparator with the help of an example.
Consider two 3-bit binary numbers A2A1A0 and B2B1B0. These two binary numbers are said to
be equal if all their corresponding bits coincide. In other words, these two binary numbers are
equal if A2 = B2, A1 = B1, and A0 = B0.

The block diagram of a typical comparator is shown in the following figure −

Here, A and B are the input bits, and L, E, and G are the output lines, where L indicates which
number is smaller, E indicates equality, and G indicates the greater number.

Types of Comparators
Depending on the number of bits, the following are some main types of comparators used in
digital circuits −
• 1-Bit Magnitude Comparator
• 2-Bit Magnitude Comparator
• 4-Bit Magnitude Comparator
1-Bit Magnitude Comparator :

• A 1-bit magnitude comparator is a logic circuit which can compare two binary
numbers of one bit each. It produces an output that indicates the relationship between
the two input numbers.
• In other words, a 1-bit magnitude comparator is one that compares two 1-bit binary
numbers and generates an output showing whether one number is equal to or greater
than or less than the other.
• The block diagram of a 1-bit magnitude comparator is shown in the following figure −

Here, A and B are the 1-bit input numbers, and L, E, and G are the output lines indicating less
than or equal to or greater than relationship between A and B respectively.
2-Bit Magnitude Comparator :
A digital combinational circuit used to compare the magnitudes of two 2-bit binary numbers
and determine the relationship between them is called a 2-bit magnitude comparator.
Hence, the 2-bit magnitude comparator compares the values represented by two 2-bit binary
numbers and then generates an output that indicates whether one number is equal to or greater
than or less than the other.
The block diagram of a typical 2-bit magnitude comparator is shown in the following figure –

Here, the lines A0A1 and B0B1 represents two 2-bit binary number inputs and the lines L, E,
and G represents the less than, equal to, and greater than output lines.
We can understand the operation of the 2-bit magnitude comparator with the help of its truth
table given below −
What is Encoder?
• An Encoder is a combinational circuit that performs the reverse operation of
a Decoder.
• It has a maximum of 2^n input lines and ‘n’ output lines, hence it encodes the
information from 2^n inputs into an n-bit code.
• 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.
The basic principle of an encoder is to assign a unique binary code to each possible input.
For example, a 2-to-4 line encoder has 2 input lines and 4 output lines and assigns a unique 4-
bit binary code to each of the 2^2 = 4 possible input combinations.
The output of an encoder is usually active low, meaning that only one output is active (low) at
any given time, and the remaining outputs are inactive (high).
The active low output is selected based on the binary code assigned to the active input.
There are different types of encoders, including priority encoders, which assign a priority to
each input, and binary-weighted encoders, which use a binary weighting system to assign
binary codes to inputs.
In summary, an encoder is a digital circuit that converts a set of binary inputs into a unique
binary code that represents the position of the input. Encoders are widely used in digital
systems to convert parallel inputs into serial codes.

Types of Encoders
There are different types of Encoders which are mentioned below.
• Octal to Binary Encoder (8 to 3 Encoder)
• Decimal to BCD Encoder
• Priority Encoder
4 to 2 Encoder
• The 4 to 2 Encoder consists of four inputs Y3, Y2, Y1 & Y0, and two outputs A1
& A0. At any time, only one of these 4 inputs can be ‘1’ in order to get the respective
binary code at the output. The figure below shows the logic symbol of the 4 to 2
encoder.

Logical expression for A1 and A0:


A1 = Y3 + Y2
A0 = Y3 + Y1
implementation using OR Gate

Octal to Binary Encoder (8 to 3 Encoder)


The 8 to 3 Encoder or octal to Binary encoder consists of 8 inputs: Y7 to Y0 and 3 outputs:
A2, A1 & A0. Each input line corresponds to each octal digit value and three outputs
generate corresponding binary code. The figure below shows the logic symbol of octal to the
binary encoder.

The truth table for the 8 to 3 encoder is as follows.


Logical expression for A2, A1, and A0.
A2 = Y7 + Y6 + Y5 + Y4
A1 = Y7 + Y6 + Y3 + Y2
A0 = Y7 + Y5 + Y3 + Y1
Implementation using OR Gate
Application of Encoders
• Encoders are very common electronic circuits used in all digital systems.
• Encoders are used to translate the decimal values to the binary in order to perform
binary functions such as addition, subtraction, multiplication, etc.
• Other applications especially for Priority Encoders may include detecting interrupts in
microprocessor applications.
Advantages of Encoders in Digital Logic
• Reduction in the number of lines: Encoders reduce the number of lines required to
transmit information from multiple inputs to a single output, which can simplify the
design of the system and reduce the cost of components.
• Improved reliability: By converting multiple inputs into a single serial code,
encoders can reduce the possibility of errors in the transmission of information.
• Improved performance: Encoders can enhance the performance of a digital system
by reducing the amount of time required to transmit information from multiple inputs
to a single output.
Disadvantages of Encoders in Digital Logic
• Increased complexity: Encoders are typically more complex circuits compared
to multiplexers , and require additional components to implement.
• Limited to specific applications: Encoders are only suitable for applications where a
parallel set of inputs must be converted into a serial code.
• Limited flexibility: Encoders are limited in their flexibility, as they can only encode a
fixed number of inputs into a fixed number of outputs.
Decoders

What is a Decoder?
• In digital electronics, a combinational logic circuit that converts an N-bit binary input
code into M output channels in such a way that only one output channel is activated for
each one of the possible combinations of inputs is known as a decoder.
• In other words, a combinational logic circuit which converts N input lines into a
maximum of 2N output lines is called a decoder.
• Therefore, a decoder is a combination logic circuit that is capable of identifying or
detecting a particular code. The operation that a decoder performs is referred to as
decoding. A general block diagram of a decoder is shown in Figure-1.

Here, the decoder has N input lines and M (2N) output lines. In a decoder, each of the N input
lines can be a 0 or a 1, hence the number of possible input combinations or codes be equal to
2N. For each of these input combinations, only one of the M output lines will be active, and
all other output lines will remain inactive.
Types of Decoders
There are several types of decoders present. But, based on the input and output lines present,
decoders may be classified into the following three types −
• 2 to 4 Decoder
• 3 to 8 Decoder
• 4 to 16 Decoder
3 to 8 Decoder :
• The 3 to 8 decoder is one that has 3 input lines and 8 (23) output lines.
• The functional block diagram of the 3 to 8 decoder is shown in Figure-2.

• When this decoder is enabled with the help of enable input E, then it's one of the eight
outputs will be active for each combination of inputs.
• The operation of this 3-line to 8-line decoder can be analysed with the help of its
function table which is given below.

Using this function table, we can derive the Boolean expression for each output as follows –
As we can see, each output term contains products of input variables, hence they can be
implemented with the help of AND gates. Therefore, the logic circuit diagram of the 3 to 8
decoder is shown in Figure-5.
Operation:

The operation of logic circuit of the 3 to 8 decoder is described as follows −


• When enable input (E) is inactive, i.e. set to 0, none of the AND gates will function.
• When enable input (E) is made active by setting it to 1, then the circuit works as
described below.
• When A = 0, B = 0, and C = 0, the AND gate 1 becomes active and produces output
Y0.
• When A = 0, B = 0, and C = 1, the AND gate 2 becomes active and produces output
Y1.
• When A = 0, B = 1, and C = 0, the AND gate 3 becomes active and produces output
Y2.
• When A = 0, B = 1, and C = 1, the AND gate 4 becomes active and produces output
Y3.
• When A = 1, B = 0, and C = 0, the AND gate 5 becomes active and produces output
Y4.
• When A = 1, B = 0, and C = 1, the AND gate 6 becomes active and produces output
Y5.
• When A = 1, B = 1, and C = 0, the AND gate 7 becomes active and produces output
Y6.
• When A = 1, B = 1, and C = 1, the AND gate 8 becomes active and produces output
Y7.

You might also like