2
\$\begingroup\$

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 .

\$\endgroup\$
12
  • 2
    \$\begingroup\$ As with any logic function - start with truth table. \$\endgroup\$
    – Eugene Sh.
    Commented Nov 4, 2019 at 16:32
  • \$\begingroup\$ @EugeneSh. I made truth table consisting of 8 rows and 6 columns .First 3 columns correspong to 3-bit number and next 3 column is 2's complement .Then i solved the K - map but i am unable to proceed. \$\endgroup\$
    – user235492
    Commented Nov 4, 2019 at 16:40
  • \$\begingroup\$ Let me give you a boost of sorts. The only way any of the 3-bit number bits can be anything other than 0 is if the lowest order output line from the 3-to-8 decoder is a "1". So you know in advance that you will AND this line to each and every output bit. But symmetry (in my mind) is what almost makes the result too obvious. I don't need paper and pencil. \$\endgroup\$
    – jonk
    Commented Nov 4, 2019 at 16:46
  • \$\begingroup\$ @Mike I see a cube, each vertex holding one of the 3-bit outputs and also ear-marked with the obvious Dn that's LOW. Movement along an edge, left to right, changes a0. Movement along an edge, front to back, changes a1. Movement along an edge, top to bottom, changes a2. There there three dividing plane orientations to cut the cube in mutually perpendicular ways. Simple observation of the separated Dn lines immediately tells you the answer (and also that you will need 4 AND'd lines for each output.) But are you required to use a different approach, not just get an easy answer? \$\endgroup\$
    – jonk
    Commented Nov 4, 2019 at 17:06
  • \$\begingroup\$ @jonk I can use any approach but only using active low decoder and AND gates \$\endgroup\$
    – user235492
    Commented Nov 4, 2019 at 17:07

1 Answer 1

0
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ That successfully inverts each input bit. However, a0 can go straight to the output y0 unmodified. You do need to carry if a0 is 0, so you can use the above product D0D2D4D6 (in conjunction with its complement, a0) to select between a1 and ~a1 for the y1 output. Replicate that trick to select between a2 and ~a2 for the y2 output. \$\endgroup\$ Commented Nov 4, 2019 at 21:32
  • \$\begingroup\$ @Crist I had no intention on optimizing. I merely wanted to pass on a way to visualize well enough to solve the problem without even paper. The above can be worked in the head, entirely. \$\endgroup\$
    – jonk
    Commented Nov 4, 2019 at 21:39
  • \$\begingroup\$ Won't ANDing any two outputs of a 3-to-8 decoder always give 0? Or is this a decoder with active low outputs? \$\endgroup\$
    – The Photon
    Commented Nov 4, 2019 at 23:33
  • \$\begingroup\$ @ThePhoton It's active-low. I think. Double check me by reading the OP. But I think it is there. \$\endgroup\$
    – jonk
    Commented Nov 5, 2019 at 0:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.