I need to plan a circuit that will square a 3 bit binary number:

$$\{Y_2, Y_1, Y_0\} \rightarrow \{S_5,S_4,S_3,S_2,S_1,S_0\} $$

I thought of the common way we multiply numbers and used it to plan the circuit (as you can see in the top left of the attached picture)

What do you think? Is there a better way to do the following using the basic gates, FA, HA and MUX?

## Best Answer

Of course there is.

First we write out the truth table:

We notice right away that S0 = Y0, S1 = 0, and S5 = Y1 * Y2. Let's remove those.

And now we see that S2 = Y1 * !Y0, S3 = Y0 * (Y1 ^ Y2), and S4 = Y2 * (!Y1 + Y0) = Y2 * !S2. Since you now have all 6 equations for the bits in S, building a logic circuit for it is easy, and left as an exercise for the reader.