74HC138 3-to-8 decoder

Three address inputs choose one of eight outputs, and that output goes low while the other seven stay high.

It is how a microcontroller picks one chip out of eight on a shared bus, and how a counter lights one LED out of eight. Aliases: 74138, SN74HC138, 3-to-8 line decoder, demultiplexer, demux, chip select decoder.

Pins

Pin Name What it does
1, 2, 3 A0, A1, A2 The address, A0 the 1s bit.
15 to 9, 7 Y0 to Y7 The outputs, active low. Y7 is on pin 7, beside GND.
4, 5 E1, E2 Enables, active low. Both must be low.
6 E3 Enable, active high. Must be high.
8 GND Ground.
16 VCC Supply, 2 V to 6 V.

Truth table

E1 E2 E3 A2 A1 A0 Output that is low
1 x x x None
x 1 x x None
x x 0 x None
0 0 1 000 Y0
0 0 1 001 Y1
0 0 1 ... ...
0 0 1 111 Y7

Having enables of both senses is what lets two 138s make a 4-to-16 decoder with no extra gate: the fourth address bit goes to E1 of one chip and E3 of the other.

Properties

None.

What the model gets right

Every output is worked out separately, so an unknown input only makes an output unknown when it could change that output: a disabled chip is all high whatever the address is doing, and with A0 and A1 high and A2 floating only Y3 and Y7 are unknown. Propagation delay is the SN74HC138 typical, 18 ns at 4.5 V, from an address or an enable.

What it does not model

One delay for every path, with no glitches between addresses: when the address moves from 3 to 4, a real 138 can flash another output for a few nanoseconds while its three inputs change at slightly different times. Here the change is clean.

Common mistakes

Wiring an LED from an output to ground: the outputs are active low, so the LED goes from VCC through a resistor to the output, and lights when that output is selected. Forgetting the enables, especially E3, which has to be high.

See it in action

Decoder chaser counts with a 74HC161 and lights one LED of eight through a 138. Open it at /templates.