3-to-8 Line Decoder: How the 74138 Works
Learn how a 3 to 8 line decoder works, the 74138 enable pins and active low outputs, how to build any function from minterms, and expand to 4 to 16 lines.
What a decoder does
A decoder turns a binary code on its inputs into one active line on its outputs. A 3 to 8 decoder has three inputs and eight outputs. For each of the eight input codes, exactly one output is active and the other seven are inactive. It is the opposite of an encoder.
Decoders select things: a memory chip out of several, a row of a display, or one device out of many on a bus. Every time a computer chooses a location by its address, a decoder is at work.
The 74138
The 74138 is a 3 to 8 decoder in a 16 pin package, with the supply on pin 16 and ground on pin 8. The address inputs are A, B and C, where C is the most significant bit. There are eight outputs, Y0 to Y7. They are active low, which means the selected output goes low and the other seven stay high.
There are three enable inputs. G1 is active high, and G2A and G2B are active low. The chip works only when G1 = 1 and G2A = G2B = 0. In any other case all eight outputs stay high.
| C B A | Selected output | Outputs Y7 to Y0 |
|---|---|---|
| 0 0 0 | Y0 low | 1 1 1 1 1 1 1 0 |
| 0 0 1 | Y1 low | 1 1 1 1 1 1 0 1 |
| 0 1 0 | Y2 low | 1 1 1 1 1 0 1 1 |
| 0 1 1 | Y3 low | 1 1 1 1 0 1 1 1 |
| 1 0 0 | Y4 low | 1 1 1 0 1 1 1 1 |
| 1 0 1 | Y5 low | 1 1 0 1 1 1 1 1 |
| 1 1 0 | Y6 low | 1 0 1 1 1 1 1 1 |
| 1 1 1 | Y7 low | 0 1 1 1 1 1 1 1 |
Each output is the complement of one minterm of the three address variables. For example Y5 = (C B' A)'. This fact leads to the most useful trick with a decoder.
Building a function with a decoder
A decoder produces every minterm of its inputs. Any function of three variables is a sum of minterms. Because the outputs are active low, a NAND gate collects them: the NAND of a set of active low lines is the OR of the matching minterms.
F(A, B, C) = Σ m(a, b, c) → F = NAND( Ya', Yb', Yc' )
Example: the sum output of a full adder is 1 for the minterms 1, 2, 4 and 7. Connect Y1, Y2, Y4 and Y7 to a 4 input NAND gate. The carry out is 1 for the minterms 3, 5, 6 and 7, so a second NAND gate takes Y3, Y5, Y6 and Y7. A full adder is then one decoder and two NAND gates.
Using the enable inputs
The enable inputs make the decoder easy to expand. To make a 4 to 16 decoder, use two 74138 chips and the fourth address bit D.
- Connect A, B and C of both chips together.
- For the first chip (outputs 0 to 7), connect D to G2A. It is enabled when D = 0.
- For the second chip (outputs 8 to 15), connect D to G1. It is enabled when D = 1.
- Connect the remaining enables to the right fixed levels, high for G1 and low for G2A and G2B.
The two chips never work at the same time, so only one of the sixteen outputs is ever low.
The decoder as a demultiplexer
A decoder can send a data bit to one chosen output. Put the data on the enable pin G2A and the address on A, B and C. The selected output equals the data, going low when the data is 0 and high when the data is 1. All the other outputs stay high. This is a 1 to 8 demultiplexer.
Common faults
- No output goes low. An enable pin is in the wrong state. Check G1 high and G2A, G2B low.
- An LED on an active low output looks reversed. The LED is lit when the output is low, so it must connect from the positive supply through a resistor to the output.
- Two outputs change at once. One of the select pins is left open, and open TTL inputs float high. Wire every input.
Try it in the virtual lab
SinBench has free 3D benches and interactive demos for this topic. Open one to try the ideas above with real instruments, no sign up needed.
Questions and answers
What does a 74138 do?
It decodes a 3 bit binary input into eight active low outputs. Exactly one output goes low for each input code, when the chip is enabled.
What are the enable inputs of the 74138?
G1 is active high, and G2A and G2B are active low. The chip is enabled only when G1 is 1 and both G2A and G2B are 0.
How do you make a 4 to 16 decoder?
Use two 74138 chips with A, B and C shared. Use the fourth address bit to enable one chip when it is 0 and the other when it is 1.
How do you implement a function with a decoder?
Connect the outputs that match the minterms of the function to a NAND gate. The NAND of active low outputs gives the OR of those minterms.
Related topics
Multiplexer and Demultiplexer: The 74151 and 74138
Learn how a multiplexer selects one of many inputs, how the 74151 works, how to build a Boolean function with it, and how a demultiplexer sends data out.
Digital Logic DesignEncoders and the 74148 Priority Encoder
Learn how encoders and priority encoders work. See the 74148 inputs, active low outputs, the GS and EO signals, and how to cascade two chips to encode 16 lines.
Digital Logic DesignKarnaugh Maps: Simplify Boolean Functions Step by Step
A step by step guide to Karnaugh maps: how to fill a 4 variable map, group cells, use don't cares and write the simplest sum of products, with a worked example.