## At the end of this lesson-

- 1. You will be able to explain encoder.
- 2. You will be able to describe the uses of encoder.
- 3. You will be able to explain decoder.
- 4. You will be able to describe the uses of decoder.
- 5. You will be able to differentiate encoder and decoder.

## Go for Bangla Version

An **Encoder** is a combinational circuit that produces a binary code equivalent to the input, which is active High. In other words, Encoder is a circuit which converts the analog signal into the digital signal. Encoders are digital circuit used for encoding.

**Characteristics of Encoder:**

- It has maximum of 2
^{n}input lines and ‘n’ output lines. - It encodes 2
^{n}input lines with ‘n’ bits. - It performs the reverse operation of Decoder.
- At any time, only one of inputs can be ‘1’ in order to get the respective binary code at the output and rest of the inputs are zero(0).
- It is used in input system like Keyboards.

**Fig: Block diagram of Encoder**

## 4 to 2 Encoder:

Let 4 to 2 Encoder has four inputs D_{0}, D_{1}, D_{2} & D_{3} and two outputs X & Y. The **block diagram** of 4 to 2 Encoder is shown in the following figure-

**Fig: Block diagram of 4 to 2 Line Encoder**

At any time, only one of these 4 inputs can be ‘1’ in order to get the respective binary code at the output. The **Truth table** of 4 to 2 encoder is shown below.

**Fig: Truth table of 4 to 2 Line Encoder**

From Truth table, we can write the **Boolean functions** for each output as

**X=D**

_{2}+D_{3}**Y=D**

_{1}+D_{3}We can implement the above two Boolean functions by using two input OR gates. The **circuit diagram** of 4 to 2 encoder is shown in the following figure-

**Fig: Circuit of 4 to 2 Line Encoder**

The above circuit diagram contains two OR gates. These OR gates encode the four inputs with two bits.

## Octal to Binary Encoder or 8 to 3 encoder:

Octal to binary Encoder has eight inputs, D_{0} to D_{7} and three outputs X, Y & Z. Octal to binary encoder is nothing but 8 to 3 encoder. The **block diagram** of octal to binary Encoder is shown in the following figure.

**Fig: Block diagram of 8 to 3 Line Encoder**

At any time, only one of these eight inputs can be ‘1’ in order to get the respective binary code. The **Truth table** of octal to binary encoder is shown below.

**Fig: Truth table of 8 to 3 Line Encoder**

From Truth table, we can write the **Boolean functions** for each output as

**X = D**_{4}**+D**_{5}**+D**_{6}**+D**_{7}** **

**Y ****= D**_{2}**+D**_{3}**+D**_{6}**+D**_{7}** **

**Z ****= D**_{1}**+D**_{3}**+D**_{5}**+D**_{7}** **

We can implement the above Boolean functions by using four input OR gates. The **circuit diagram** of octal to binary encoder is shown in the following figure-

**Fig: Circuit of 8 to 3 Line Encoder**

The above circuit diagram contains three 4-input OR gates. These OR gates encode the eight inputs with three bits.

### Drawbacks of Encoder

- There is an ambiguity, when all inputs of encoder are equal to zero.
- If more than one input is active High, then the encoder produces an output, which may not be the correct code.

So, to overcome these difficulties, we should assign priorities to each input of encoder. Then, the output of encoder will be the code corresponding to the active High inputs, which has higher priority.

**Uses 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 the binary functions such as addition, subtraction, multiplication, etc.
- Other applications especially for Priority Encoders may include detecting interrupts in microprocessor applications.

**Decoder:**

**Decoder** is a combinational circuit that converts binary code or binary information into human understandable format.

In other word, Decoder is a combinational circuit which converts the digital signal into analog signal. Its input will be in digital form while the output will be a continuous sine wave or analog wave. Decoders are digital circuit which are used for decoding.

**Characteristics of Decoder:**

- It has ‘n’ input lines and maximum of 2
^{n}output lines. - It performs the reverse operation of Encoder.
- At any time, only one of outputs can be ‘1’ and rest of the outputs are zero(0).
- It is used in output system like display units.

**Fig: Block diagram of Decoder**

## 2 to 4 Decoder

Let 2 to 4 Decoder has two inputs X & Y and four outputs D_{0}, D_{1}, D_{2} & D_{3}. The **block diagram** of 2 to 4 decoder is shown in the following figure-

**Fig: Block diagram of 2 to 4 Line Decoder**

One of these four outputs will be ‘1’ for each combination of inputs.The **Truth table** of 2 to 4 decoder is shown below-

**Fig: Truth table of 2 to 4 Line Decoder**

From Truth table, we can write the** **Boolean functions using** SOP **method for each output as-

**circuit diagram**of 2 to 4 line decoder is shown in the following figure-

**Fig: Circuit of 2 to 4 Line Decoder**

**min terms**of two input variables X & Y.

## 3-to-8 line decoder

Let 3 to 8 Decoder has three inputs X , Y & Z and eight outputs D_{0} to D_{7}. The **block diagram** of 3 to 8 decoder is shown in the following figure-

**Fig: Block diagram of 3 to 8 Line Decoder**

One of these eight outputs will be ‘1’ for each combination of inputs.The **Truth table** of 3 to 8 decoder is shown below-

**Fig: Truth table of 3 to 8 Line Decoder**

From Truth table, we can write the **Boolean functions** for each output as-

The **circuit diagram** of 3 to 8 decoder is shown in the following figure-

**Fig: Circuit of 3 to 8 Line Decoder**

**Uses of Decoders:**

- They are used in a wide variety of applications, including data multiplexing and data demultiplexing
- It is used in seven segment displays
- It is used as address decoders for memory and port-mapped I/O.
- Used for converting binary number into equivalent decimal number.

## Encoder Vs Decoder:

## Lesson Evaluation-

__Knowledge Based Questions:__

- a. What is Encoder?
- a. What is Decoder?

__Comprehension Based Questions:__

- b. Explain the circuit that converts human comprehensible language into machine comprehensible language.
- b. Why Encoder is used in input devices? explain
- b. Explain the circuit that converts machine comprehensible language into human comprehensible language.
- b. Why Decoder is used in output devices? explain.
- b. “Encoder is the inverse of the decoder”- Explain.

__Creative Questions:__

**According to the stem answer the following questions:**

**c)** Identify the fig-1 and draw the truth table and logic circuit.

**d)** Which figure is very essential to convert machine code into human understandable symbol? Analyze.

**According to the stem answer the following questions:**

**c)** Explain fig-2 for n=2.

**d)** Draw the truth table and logic circuit of fig-1 for n=3 and analyze that it can convert maximum 8 symbols into machine code.

__Multiple Choice Questions:__

**1.** How many minimum output lines are in en Encoder of 40 input lines?

a) 3 b) 4 c) 5 d) 6

**2.** How many basic logic gates are needed to implement a 4 to 2 line encoder?

a) 2 b) 4 c) 6 d) 8

**3.** How many basic logic gates are needed to implement a 8 to 3 line encoder?

a) 2 b) 4 c) 6 d) 8

**4.** Which one is encoder circuit?

a) 8 to 3 line b) 3 to 8 line c) 3 to 9 line d) 2 to 16 line

**5.** The basic gates used in encoder circuit are-

i. AND ii. OR iii. NOT

Which one is correct?

a) i & ii b) i & iii c) ii & iii d) i, ii & iii

**6.** Encoder is one kind of circuit which has-

i. n output lines ii. 2n input lines iii. 2^{n} input lines

Which one is correct?

a) i & ii b) i & iii c) ii & iii d) i, ii & iii

**7.** Which one is inverse of encoder?

a) Multiplexer b) Adder c) Register d) Decoder

**8.** How many minimum input lines are in a decoder of 48 output lines?

a) 3 b) 4 c) 5 d) 6

**9.** How many basic logic gates are needed to implement a 2 to 4 line decoder?

a) 2 b) 4 c) 6 d) 8

**10.** Which one is decoder circuit?

a) 3 to 8 line b) 8 to 3 line c) 1 to 9 line d) 2 to 16 line

**11.** The basic gates used in decoder circuit are-

i. AND ii. OR iii. NOT

Which one is correct?

a) i & ii b) i & iii c) ii & iii d) i, ii & iii

**12.** Decoder ia a kind of circuit which has-

i. n input lines ii. 2n output lines iii. 2^{n} output lines

Which one is correct?

a) i & ii b) i & iii c) ii & iii d) i, ii & iii

**Written by,**

- Mizanur Rahman (Mizan)
- Lecturer of ICT, Shaheed Bir Uttam Lt. Anwar Girls’ College , Dhaka Cantonment
- Author at www.edupointbd.com
- Software Engineer at mands IT
- Former Lecturer of ICT, Cambrian College, Dhaka
- Email: mizanjust@gmail.com
- Cell:
**01724351470**