Skip to main content

Theory

1. Decoder

In general, decoder is a combinatorial device that has n input ports and m output ports such that n <= m <= 2n. A decoder is commonly prefixed with the phrase n-to-m, where n and m are the number of input and output ports respectively.

Decoders are used for decoding, which is a process of converting or “translating” an input code which is hard to deal with, to an output code which is easier to deal with. For example, a binary decoder is a type of decoder that converts an n-bit binary number to its corresponding minterm index or a one-hot representation of the number. So, a 3-to-8 binary decoder would have the truth table:

Explanation : If we’re looking for the number 5 (101), we just need to check port D5. If D5 is 0, then the number A is definitely not 5. If, however, D5 is 1, then it is certain that the number A is 5. Checking the output port D5 is easier than checking straight from the undecoded input. We would need to check if A2=1 AND A1=0 AND A0=1, which is tedious, especially for larger numbers with more bits.

Another type of decoder is the 7-segment decoder. It converts a one-digit BCD (4-bit) input to a 7-bit output. Each output line correspond to a segment on a 7-segment display and when connected would result in a digit showing up in the display. For example, when the input is the number 5 (0101 in BCD), the output would light up appropriate segments of the display so that the actual “5” appears in it. Two such 7-segment decoders are IC 7447 and IC 7448

Feature IC 7447 IC 7448
Display Type Common Anode Common Cathode
Output Polarity Active Low Active High
Display Control Turns on segments with logic 0 Turns on segments with logic 1
Usage For displays with connected anodes For displays with connected cathodes

2. Encoder

Encoder is the counterpart to the decoder; it does the inverse of what the decoder does, which is encoding. An encoder has m input lines and n output lines n <= m <= 2n. Like the decoder, encoder is usually prefixed with the phrase m-to-n, where m and n are the number of input and output ports respectively.

Generally, to encode means to take an input which has more lines/bits, to an output which has less lines/bits. This is done so that the resulting output could be transferred or transmitted to another location easily because it’s more packed and require less bits. For example, a binary encoder would output a binary number that correspond to the minterm index or one-hot representation of the input. So, an 8-to-3 binary encoder would have the truth table :

But, there’s a problem: not every input combination is defined in the truth table. For example, what would the output of the encoder be if 00000011 is given as the input? To solve that issue, we introduce a special type of encoder, called the priority encoder. It has the truth table :

A priority encoder “prioritizes” input lines so that one line takes precedence over another. In this case, the input line with a bigger index takes precedence over the ones with a smaller index. If we take the example from before, when we give the priority encoder 00000011 as input, it “ignores” D0 and outputs 001. If we take another number: 10101010, then it would only “care” about D7 and ignore the rest. The resulting output would be 111.

Priority encoders are available in standard IC form and the TTL 74LS148 is an 8-to-3 bit priority encoder which has eight active LOW (logic “0”) inputs and provides a 3-bit code of the highest ranked input at its output.

Additional Explanation

In addition to standard encoders like the priority encoder or decoders such as the BCD-to-7-segment decoder, we can create custom encoders and decoders based on specific application needs. These custom designs allow us to define unique encoding or decoding schemes that go beyond the limitations of previous standard examples & components (IC such as 7447,7448,74148) offering flexibility for various digital systems. Your Case Study or Additional Task and Final Project of this subject (Digital Systems Basics) will most likely need you to design these other than using the examples of decoder & encoder mentioned above.