Electronic – How to generate 2’s complement of a 3-bit number using 3:8 active low decoder

decoderdigital-logic

This is previous year problem of a competitive exam. I tried by self but i was unable to solve it.

Exact wordings of the problem:

Generate 2’s complement of a 3-bit number (a2a1a0) using a single 3 to 8 active low decoder IC and
AND gates.

My work till now : (Maybe my approach is wrong)

a2 a1 ao  y2 y1 yo
0  0  0   0   0  0
0  0  1   1   1  1
0  1  0   1   1  0
0  1  1   1   0  1
1  0  0   1   0  0
1  0  1   0   1  1
1  1  0   0   1  0
1  1  1   0   0  1

y2y1yo is required output .Now solve K map for each y2 , y1 , yo and write y2 , y1 , yo in product of sum forms .Notice that output of the decoder will be one of the max terms so we can some how solve using this approach .

Best Answer

Hypercubes are really useful for symbol/code work. In this case, it's just a cube:

enter image description here

On the left is the cube and I've placed the binary codes at appropriate vertices. (It's not the only way, but one of several possible permutations, of course.) Black print for the binary used to drive the 3-to-8 decoder and red print for the two's complement version at the same vertex. In the center of the cube I've placed a small, centered axis system to help orient things. On the right is represented the transition bit axes. If you inspect the cube on the left and the axis associated with some transitioning bit, I think you will find I didn't make any mistakes. (I can hope, anyway. I'd hate to have to re-draw it.)

Now, there are three planes possible that cut the cube in half and are perpendicular to each other. There's a plane that cuts the cube so that half has \$a_0=0\$ and the other half has \$a_0=1\$. There's another plane that cuts the cube so that half has \$a_1=0\$ and the other half has \$a_1=1\$. The last plane should now be obvious.

In doing so, we always divide up four vertices vs four opposite-side vertices. So we'll need to AND four signals coming out of the 3-to-8 decoder to generate each bit.

  1. \$a_0\$ cutting plane: This divides the cube, left vs right. The binary values at the vertices tell you which of \$D_n\$ is low, of course. Now look closely at the left side for a moment. You can see that \$D_0\$, \$D_2\$, \$D_4\$, and \$D_6\$ are low on the left (for \$a_0=0\$.) Since you want AND logic, the idea here is to simply say, "If any of these are low, then \$a_0=0\$." This obviously is performed by a 4-in AND gate, yes?? So \$a_0=D_0\:D_2\:D_4\:D_6\$ and through similar reasoning \$y_0=D_0\:D_2\:D_4\:D_6\$ (the only difference being that two values swapped vertices.)
  2. \$a_1\$ cutting plane: This divides the cube, front vs back. You can see that \$D_0\$, \$D_1\$, \$D_4\$, and \$D_5\$ are low for the front (for \$a_1=0\$.) So, "If any of these are low, then \$a_1=0\$." Again, performed by a 4-in AND gate, as \$a_1=D_0\:D_1\:D_4\:D_5\$ and \$y_1=D_0\:D_3\:D_4\:D_7\$.
  3. \$a_2\$ cutting plane: This divides the cube, top vs bottom. You can see that \$D_0\$, \$D_1\$, \$D_2\$, and \$D_3\$ are low for the top (for \$a_2=0\$.) So, "If any of these are low, then \$a_2=0\$." Again, performed by a 4-in AND gate, as \$a_2=D_0\:D_1\:D_2\:D_3\$ and \$y_2=D_0\:D_5\:D_6\:D_7\$.

Symmetry is beautiful.

Result, if you were just reproducing what drove the 3-to-8 decoder, is:

$$\begin{array}{r|cccccccc} & D_7 & D_6 & D_5 & D_4 & D_3 & D_2 & D_1 & D_0\\ \hline a_2 & \, & \, & \, & \, & \cdot & \cdot & \cdot & \cdot\\ a_1 & \, & \, & \cdot & \cdot & \, & \, & \cdot & \cdot\\ a_0 & \, & \cdot & \, & \cdot & \, & \cdot & \, & \cdot\\ \end{array}$$

And for twos-complement:

$$\begin{array}{r|cccccccc} & D_7 & D_6 & D_5 & D_4 & D_3 & D_2 & D_1 & D_0\\ \hline y_2 & \cdot & \cdot & \cdot & \, & \, & \, & \, & \cdot\\ y_1 & \cdot & \, & \, & \cdot & \cdot & \, & \, & \cdot\\ y_0 & \, & \cdot & \, & \cdot & \, & \cdot & \, & \cdot\\ \end{array}$$

If you imagine a vertical axis through \$D_4\$ and reflect the left and right 3x3 squares around/through that axis then you get the opposite table (in this particular case.)

The N-cube approach works for binary, unique 1:1 replacement symbol set mapping.