- Data inputs: 3 (labeled
**x**,_{2}**x**,_{1}**x**)_{0} - Control inputs: 0
- Outputs: 8 (labeled
**z**, ...,_{7}**z**)_{0}

In general, you have a **k-ceil(lg(k))** decoder.

- Data inputs:: ceil( lg k ) (labeled
**x**, ...,_{ceil(lg k)}**x**)_{0} - Control inputs: 0
- Outputs: k (labeled
**z**, ...,_{k-1}**z**)_{0}

What does a 3-8 decoder do? A decoder assumes the inputs
**x _{2}x_{1}x_{0}** represent a 3-bit
bitstring represented in UB. Thus, if

For each of the 8 possible inputs, exactly one of the outputs is
set to 1. The rest have a value of 0. Thus, if
**x _{2}x_{1}x_{0}** = 011, then

Here's a table describing the behavior of an 8-3 decoder.

x_{2}x_{1}x_{0} |
Operation |

000 |
z _{0} = 1 |

001 |
z _{1} = 1 |

010 |
z _{2} = 1 |

011 |
z _{3} = 1 |

100 |
z _{4} = 1 |

101 |
z _{5} = 1 |

110 |
z _{6} = 1 |

111 |
z _{7} = 1 |

To see what this is doing, let's look at one of the rows of the
table above. In particular, look at the last row. When
**x _{2}x_{1}x_{0}** = 111 (that is,

Thus, we make **z _{7}** = 1. All other outputs are
set to 0.

x_{1} |
x_{0} |
z_{3} |
z_{2} |
z_{1} |
z_{0} |

0 | 0 | 0 |
0 |
0 |
1 |

0 | 1 | 0 |
0 |
1 |
0 |

1 | 0 | 0 |
1 |
0 |
0 |

1 | 0 | 1 |
0 |
0 |
0 |

We can write the Boolean expression for each of the outputs. Since this is a conventional truth table, we can write sum-of-products for each output. Since each output only has one row with an output of 1, this results in a minterm.

z_{3}= x_{1}x_{0}z_{2}= x_{1}\x_{0}z_{1}= \x_{1}x_{0}z_{0}= \x_{1}\x_{0}

Thus, **x _{2}x_{1}x_{0}** = 100.
That is,

In order to make the decoder and DeMUX essentially the same, we need to add an additional feature to the decoder.

The enable control bit for the decoder acts somewhat like the chip enable.

Here's how the enable bit works:

Enable | Operation |

e = 0 | All outputs are 0 |

e = 1 | Acts like regular decoder without enable |

If the enable is active, it behaves as a regular decoder. If it's not active, then all outputs are 0.

This is equivalent to the following condensed truth table.

x_{1} |
x_{0} |
z_{3} |
z_{2} |
z_{1} |
z_{0} |

0 | 0 | 0 |
0 |
0 |
e |

0 | 1 | 0 |
0 |
e |
0 |

1 | 0 | 0 |
e |
0 |
0 |

1 | 0 | e |
0 |
0 |
0 |

There is now a direct correspondence between a 1-8 DeMUX and a 3-8 decoder with enable.

- The data inputs of a decoder correspond to the control bits of a DeMUX.
- The enable input of a decoder correspond to the data bit of a DeMUX.

In other words, the only difference is that interpretation of what is a control bit and what is a data bit. The two circuits are identical.

It stands to reason that this is the difference between an encoder and a decoder. For example, a 3-8 decoder has 8 outputs, of which exactly one output is 1.

If we convert the output to input, we get 8 inputs, where exactly one input is 1. This is the constraint of a regular encoder.

Consider this assumption. Normally, we have 8 inputs, which means we haveAssumptionA regular encoder assumes that exactly one input is 1 (while all other inputs are 0).

With the 3-8 decoder, the inputs were a 3 bit UB bitstring which
told us which output to set high. So, now that inputs are outputs,
the output of an 8-3 decoder has 3 bits as output. This should
indicate which input was set to 1, and output the binary representation
(in UB) of the input. THus, if **x _{5} = 1** (and all
other inputs are 0), then the output is

Thus, we can write a simplified truth table with only those 8 rows.

Input Variable Has Value 1 | z_{2} |
z_{1} |
z_{0} |

x_{0} |
0 |
0 |
0 |

x_{1} |
0 |
0 |
1 |

x_{2} |
0 |
1 |
0 |

x_{3} |
0 |
1 |
1 |

x_{4} |
1 |
0 |
0 |

x_{5} |
1 |
0 |
1 |

x_{6} |
1 |
1 |
0 |

x_{7} |
1 |
1 |
1 |

Thus, if **x _{3} = 1**, then the 3 output bits,

Suppose we wanted to write the Boolean expression for **z _{2}**.
As before, we identify the rows with 1's as outputs, and create
a minterm.

If we do this, we will have very large minterms.

zThe terms need not be this large. We've assumed that exactly one input is a 1. This is a strong assumption that allows us to simply the expression greatly._{2}= \x_{0}\x_{1}\x_{2}\x_{3}x\x_{4}_{5}\x_{6}\x_{7}+ \x_{0}\x_{1}\x_{2}\x_{3}\x_{4}x\x_{5}_{6}\x_{7}+ \x_{0}\x_{1}\x_{2}\x_{3}\x_{4}x_{\5}x\x_{6}_{7}+ \x_{0}\x_{1}\x_{2}\x_{3}\x_{4}\x_{5}\x_{6}x_{7}

zLet's see how this works. Suppose we know that_{2}= x_{4}+ x_{5}+ x_{6}+ x_{7}z_{1}= x_{2}+ x_{3}+ x_{6}+ x_{7}z_{0}= x_{1}+ x_{3}+ x_{5}+ x_{7}

Therefore, **x _{2}x_{1}x_{0}** = 011, which
is UB for 3, so that's what we expected. Again, this Boolean
expression can be simplified because we assume exactly one input is
1.

This only excludes one possible input. The input where all bits are 0. We'll talk about what to do in that case.AssumptionA priority encoder assumes that at least one input is 1

There are two common ways to do come up with a *priority scheme*.

- Larger subscripts have higher priorities. Thus, 0 has the lowest priority, and 7 has the highest.
- Smaller subscripts have higher priorities. Thus, 7 has the lowest priority, and 0 has the highest.

For now, let's assume that larger subscripts have higher priorities.

The Boolean expressions we came up with for the regular encoder are no longer valid.

zTo make it a little easier to modify, I've written the expressions with the highest priority input variable first._{2}= x_{7}+ x_{6}+ x_{5}+ x_{4}z_{1}= x_{7}+ x_{6}+ x_{3}+ x_{2}z_{0}= x_{7}+ x_{5}+ x_{3}+ x_{1}

So why doesn't this work? Suppose **x _{4}** = 1, and

However, if we plug into the Boolean expressions, we get an output of 111, which is clearly incorrect. The problem? Our assumption that exactly one input is 1 no longer holds.

For example, **x _{4}** appears in the Boolean expression
for

How can we modify these formulas so that we know that, say,
**x _{4}** has the highest priority?

How can we come up with a Boolean expression to convey this? This looks very much like creating a minterm, except we don't use all input variables. In fact, that's what it is:

\xWe negate all literals with higher priority than the input, and we leave out all literals with smaller priorities._{7}\x_{6}\x_{5}x_{4}

z_{2}=x+ \x_{7}_{7}x+ \x_{6}_{7}\x_{6}x+ \x_{5}_{7}\x_{6}\x_{5}xz_{4}_{1}=x+ \x_{7}_{7}x+ \x_{6}_{7}\x_{6}\x_{5}\x_{4}x+ \x_{3}_{7}\x_{6}\x_{5}\x_{4}\x_{3}xz_{2}_{0}=x+ \x_{7}_{7}\x_{6}x+ \x_{5}_{7}\x_{6}\x_{5}\x_{4}x+ \x_{3}_{7}\x_{6}\x_{5}\x_{4}\x_{3}\x_{2}x_{1}

To discuss this more, let's rewrite **z _{1}** as:

zwhere_{1}= P_{7}+ P_{6}+ P_{3}+ P_{2}

PThis is the same Boolean expression as before, but it makes it easier to identify the product terms._{7}=xP_{7}_{6}= \x_{7}xP_{6}_{3}= \x_{7}\x_{6}\x_{5}\x_{4}xP_{3}_{2}= \x_{7}\x_{6}\x_{5}\x_{4}\x_{3}x_{2}

When we rewrite the Boolean expression this way, we expect the
following to happen. If **x _{7}** has the highest
priority, then

In particular, if one of the four priorities (7, 6, 3, 2) are
the highest priority, then the corresponding **P _{i}** is 1,
while the other priorities are 0.

Let's look at **P _{6}** more closely.

We can analyze this by cases. Either **x _{7}** = 1,
or

Suppose **x _{7}** = 1. That means that

The other case is when **x _{7}** = 0. That means that

This leads us to the following strategy. If there is already a
product term handling a higher priority, we can leave the negated literal
out. For example, look at \x_{7}\x_{6}x_{5}
in the Boolean expression for **z _{2}**. We don't need to
keep either \x

This leads to the following simplified expression:StrategyTo simplify the product terms in the Boolean expressions for a priority encoder, leave out any negated literal that has higher priority than the term, and is already taken care of by a different term.

zLet's look at one term more closely. Let's look at \x_{2}=x+_{7}x+_{6}x+_{5}xz_{4}_{1}=x+_{7}x+ \x_{6}_{5}\x_{4}x+ \x_{3}_{5}\x_{4}xz_{2}_{0}=x+ \x_{7}_{6}x+ \x_{5}_{6}\x_{4}x+ \x_{3}_{6}\x_{4}\x_{2}x_{1}

We had to keep **\x _{4}** and

One way to solve this problem is to create a *status bit*. This
bit is an output. We could say that this bit is 1 if the input is valid,
and 0 if not. Thus, this bit is only 0 when all inputs are 0. Other
hardware devices could look at the status bit to determine whether
a proper encoding was performed.

Priority encoders allow us to encode values based on a *priority
scheme*. Of all the combinational logic devices, understanding
priority encoders is perhaps the most challenging. Even encoders
take a little time to fully comprehend.