Case Study: Implementing a 5-1 MUX

© 2003 by Charles C. Lin. All rights reserved.

Introduction

Recall that a MUX (multiplexer) is an input selector. That is, it selects from one of N different data inputs, and directs the input selected to the output.

Given N data inputs, there are ceil( lg ( N ) ) control bits.

When N = 5, ceil( lg ( N ) ) = 3. Thus, there are 3 control bits. With 3 control bits, you can specify one of 8 different bitstring patterns. However, you only need 5 for a 5-1 MUX. What do you do with the other 3?

There are two choices:

Even though the don't care approach seems unsatisfying, we see this happen a lot. Think about string functions in C. For example, strcpy() takes two char * arguments. Neither argument must be NULL. However, strcpy() doesn't check for the error (and how would it inform the user, even if it did check?). Thus, your program core dumps if either argument is NULL.

Thus, strcpy() takes a "don't care" approach to invalid input. That approach leads to core dumps when the input is invalid. It's the "user beware" approach.

We'll take this approach as well, mainly to illustrate that this "don't care" approach is commonly used. It may be, when you're at a job, you won't be able to take such an approach, but at least, you'll know it exists.

Specifying the Behavior of a 5-1 MUX

We wish to specify the behavior of a 5-1 MUX. We usually specify the behavior of a MUX if the first number is not a power of 2. Thus, we don't specify 4-1 MUX behavior of 8-1 MUX, since 4 and 8 are powers of 2.

Here's the standard way to specify a 5-1 MUX. Recall that we treat c2c1c0 as a 3-bit UB number, and this 3-bit control input selects an input numbered 0 though 4.

In fact, the row number also refers to the input being selected. The row number is the base 10 value of c2c1c0.

Row c2 c1 c0 Operation
0 0 0 0 z = x0
1 0 0 1 z = x1
2 0 1 0 z = x2
3 0 1 1 z = x3
4 1 0 0 z = x4
5 1 0 1 z = don't care
6 0 1 0 z = don't care
7 0 1 1 z = don't care

So if you're asked to specify the behavior of a MUX in a truth table, you should draw a table similar to the one shown above.

Specifying a Different Behavior of a 5-1 MUX

If you have N inputs where N is not a power of 2, the usual inputs to allow are from 0 to N - 1. However, there may be unusual circumstances where you might prefer to allow a different range of values. Perhaps you want to allow 1 to N as valid inputs and make the others don't cares.

Here's how to specify a 5-1 MUX where the don't cares are different values.

Row c2 c1 c0 Operation
0 0 0 0 z = don't care
1 0 0 1 z = x1
2 0 1 0 z = x2
3 0 1 1 z = x3
4 1 0 0 z = x4
5 1 0 1 z = x5
6 0 1 0 z = don't care
7 0 1 1 z = don't care

Implementing a 5-1 MUX

We can either implement a 5-1 MUX using AND, OR, and NOT gates, by implementing the sum-of-products expression using the condensed truth table, as described in the earlier discussion on MUXes.

Another approach is to build the 5-1 MUX using other, smaller MUXes.

For example, we can implement a 5-1 MUX using using a 4-1 MUX and a 2-1 MUX.

Web Accessibility

If c2 is 0, then we know the MSb of the value is 0, thus the choices are 000, 010, 010, and 011, which is exactly what we hooked up to the top.

If c2 is 1, then we know we must have selected 100two (i.e., x4, since that's the only input index has the MSb equal to 1.

To convince yourself this works, try tracing out what happens when the input is: c2c1c0 = 000 all the way up to c2c1c0 = 100.

Also, see what the circuit does for the don't care values, i.e., c2c1c0 = 101 up to c2c1c0 = 111.

Clearly, the 5-1 MUX still outputs something even when the index is not between 000 and 100, inclusive. (What does it output?)

As an aside, notice I circle x0, x1, x2, x3, and x4 to indicate they're data inputs that are sent from the "outside world".

Notice I triangle c0, c1, and c2 to indicate they're control inputs that are sent from the "outside world".

Finally, I square z to indicate it's an output going to the outside world.

The above 5-1 MUX implements the following truth table.

Row c2 c1 c0 Operation
0 0 0 0 z = x0
1 0 0 1 z = x1
2 0 1 0 z = x2
3 0 1 1 z = x3
4 1 0 0 z = x4
5 1 0 1 z = don't care
6 0 1 0 z = don't care
7 0 1 1 z = don't care

Summary

Implementing a 5-1 MUX gets us to think about several things: Both are good lessons. Ask yourself how you'd implement a 1-5 DeMUX, and think of other, unusual configurations for MUXes.