Source

Adapted from my own handwritten and hand-typed notes from Year 1 to Year 3 of my EEE degree

Binary Decoder

An n-to- decoder has inputs and outputs. For each input combination exactly one output is active, so each output is one minterm of the inputs.

3-to-8 decoder (inputs ):

Enable Input

An enable () gates every output. For a 2-to-4 decoder:

When all outputs are 0 whatever are.

Implementing Functions With a Decoder

Since the outputs are all the minterms, any function can be built by ORing the minterm outputs where the function is 1.

Example: , so .

74LS138

The 74LS138 is an MSI 3-to-8 decoder with:

  • three enable pins: active high, and active low, so it is enabled only when , ,
  • active-low outputs, so the selected output goes to 0 and all others stay at 1

With active-low outputs, use a NAND instead of an OR. By DeMorgan, , so a 3-input NAND of the active-low lines gives .

A 4-to-16 decoder can be built from two 74LS138s: input drives of the top chip and of the bottom chip, so enables the top decoder ( to ) and enables the bottom one ( to ). A separate active-low enable line goes to one active-low enable pin on each chip, so enables the whole 4-to-16 decoder.

Non-Binary Decoders

A decoder can be any custom code converter where not every input combination is used and more than one output can be active (e.g. a 3-to-4 decoder or BCD to 7-segment decoder). Each output is still a sum of minterms, so it can be built from a binary decoder plus OR gates.

Binary Encoder

An encoder does the reverse: inputs, outputs, built from OR gates. For a 4-to-2 encoder with one-hot inputs :

Problem: if more than one input is active, the output is wrong (e.g. and together give 11, which looks like ). Also, no input and both give 00.

Priority Encoder

A priority encoder fixes this by giving each input a priority and encoding only the highest active one.

1xxx11
01xx10
001x01
000100

Here has the highest priority and the lowest. A decoder with an enable also works as a demultiplexer, see Multiplexers and Demultiplexers.