# Electronic – Is there a better way to plan a circuit to square a 3 bits binary number

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?

Of course there is.

First we write out the truth table:

 Y    S
000 000000
001 000001
010 000100
011 001001
100 010000
101 011001
110 100100
111 110001


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

 Y   S
210 432
000 000
001 000
010 001
011 010
100 100
101 110
110 001
111 100


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.