# An exercise on decoders

I have the following exercise:

Design a circuit that takes a 2 bit binary and makes it x^3 (x cubed), using a decoder


I thought to do it with a 3 to 8 decoder, because I have 2 bits of input, and 4 bits of output, since the largest output is 11011 (which is 27 in decimal).

I have managed to get to a truth table. Input = $x_0x_1x_2$. Output= $a,b,c,d,e$.

\begin{array}{|c|c|c|c|c|c|c|c|} \hline x_0 & x_1 & x_2 & a & b & c & d & e \\ \hline 0 & 0 &0 &0 &0 &0 &0 &0\\ \hline 0 &0 &1 &0 &0 &0 &0 &1\\ \hline 0& 1 &0 &0 & 1 &0 &0 &0\\ \hline 0 &1 &1 &1 &1 &0 &1 &1\\ \hline \end{array}

However, I am not quite sure what should I do now. I have to get to a function to represent it in gates? How can I make a karnaugh map from that table?

I am aware that I would have to add three more outputs to the 3 to 8 decoder, but they will be just "don't cares".

• If you were not using the decoder, I would say to draw 5 small Karnaugh maps, one for each output, using your 2 bits of input. Since you are using a decoder, there is no need for Karnaugh maps. Just follow Brian's advice.
– Tut
Commented Jun 26, 2014 at 11:25

With some thought you can do it with less logic ... a single 2-input gate.

I'll not give the whole game away, but one technique that may help is to treat each output bit individually, and minimise the logic for that output alone.

Start with bit c as it is the simplest.

Then put the individual solutions together.

• Actually, it looks like he needs no extra gates at all (assuming he uses the required decoder)
– Tut
Commented Jun 26, 2014 at 12:10
• Right : the trick is to use a decoder to mimic a simple gate...
– user16324
Commented Jun 26, 2014 at 12:13
• +1 This took me a moment but I see it. Very clever observation. At least the solution I see requires a single gate as Brian had suggested. I am not sure how this would be done with only a decoder and no external logic? Commented Jun 26, 2014 at 13:20
• @BrianDrummond I think I might got it. I got expressions for all the outputs: a=x1*x2, b=x1, c=0, d=x1*x2, e=x2. Now when I make the circuit I just connect the gates? I'm not exactly sure I should I treat d and a since they're equal. Please correct me if I'm wrong, and I thank you for your help.
– Alan
Commented Jun 26, 2014 at 20:09
• I never said anything about 4 bits of output : but in a sense, you DO only have 4 bits of output because a and d are equal. I would simply connect them together. (In a large design there are other considerations - read about "fanout" in TTL logic - but not here.)
– user16324
Commented Jun 26, 2014 at 20:20

To answer the question in general, from this point you would look at each output variable and construct the appropriate logic on that line.

Each of your output variables, in general, will be constructed independent of the others. However, there are often cases where there is similarity (or they are identical) and as such may be formed used into a single logic configuration and taken twice on the output. The following is taken directly from the wiki.

For instance, the truth table for a 2 to 4 decoder looks like this:

Where the output expressions are derived for each respective output variable with respect to the input states.

And from these expressions you can directly design the decoder:

• @sherrllbc I understand why the input is 2 bit long, but I don't understand why the output is 4 bit long? because 3^3 is 27 - a 5 bit outpout.
– Alan
Commented Jun 26, 2014 at 19:46
• Which output? The output of the decoder schematic I presented above? Commented Jun 26, 2014 at 19:48
• No, the output bits I have shown in the table in the original post. Thank you btw!
– Alan
Commented Jun 26, 2014 at 19:50
• I think I might got it. I got expressions for all the outputs: a=x1*x2, b=x1, c=0, d=x1*x2, e=x2. Now when I make the circuit I just connect the gates? I'm not exactly sure I should I treat d and a since they're equal. Please correct me if I'm wrong, and I thank you for your help. @sherrellbc
– Alan
Commented Jun 26, 2014 at 20:10
• Yes, that is what Brian was talking about above. For the case that a=d just have the output of x1*x2 taken to both bits a and d. No big deal there. Commented Jun 26, 2014 at 20:15