3
\$\begingroup\$

I am new at digital design and I have a problem. I need to get the number of zeros. There must be 4 inputs and I must use only half-adders. I tried everything I know but I could not solve this. Do you have an idea?

\$\endgroup\$
3
  • \$\begingroup\$ I have trouble understanding this question, can you be more informative? are you building a digital circuit with 4 inputs, purely made out of half adders? \$\endgroup\$
    – Iancovici
    Commented Oct 4, 2013 at 14:21
  • \$\begingroup\$ Yes, I have 4 inputs and as an output I need to get the number of 0's \$\endgroup\$
    – g3d
    Commented Oct 4, 2013 at 14:22
  • \$\begingroup\$ So you can't use inverters or any other gates individually? \$\endgroup\$
    – Iancovici
    Commented Oct 4, 2013 at 17:19

2 Answers 2

8
\$\begingroup\$

Phase 1, invert all inputs.

  • That way we can identify zeros as logic 1. and Logic 1 can be quantified easily with a half adder as oppose to logic 0.

Phase 2, Combine half-adders to make a 4-bit adder.

  • Half-Adder can add 2-bits
  • Full-Adder can add 3-bits
  • Hald-Adders + Full-Adders + Ripple Carry can add n-bits

What Half Adder and Full Adder look like enter image description here


How to build an inverter with a half-adder:

  • keep one of the exclusive-or inputs high. Then the exclusive-or gate acts like an inverter

schematic

simulate this circuit – Schematic created using CircuitLab

NOT gate using a single Half-Adder


How to build an or gate with only half-adders, in case you need it to build the full-adder and n-bit adder:

First, build a nand gate using a half adder. Second, build an or gate from nand gates.

  • You can do it by attaching the input of the not gate to the and gate.

schematic

simulate this circuit

NAND gate using 2 half-adders

enter image description here

OR gate using 3 NANDs

\$\endgroup\$
1
  • 1
    \$\begingroup\$ It might help to explain how a half-adder (the only allowed component) can be used to invert the input. \$\endgroup\$
    – The Photon
    Commented Oct 4, 2013 at 17:12
4
\$\begingroup\$

It is pretty easy. Invert these inputs and then add them all. This way you will add 1 for every zero and 0 for every 1. Don't forget for the carry.

If the half adder is the only allowed component, you can use it to invert the signals, setting the one of the inputs to 1, because the 1+1=0 and 0+1=1. The carry output will be not used in this case.

\$\endgroup\$
6
  • \$\begingroup\$ Can you add a schema? \$\endgroup\$
    – g3d
    Commented Oct 4, 2013 at 13:52
  • 3
    \$\begingroup\$ Now you're just being lazy. \$\endgroup\$
    – John U
    Commented Oct 4, 2013 at 14:12
  • \$\begingroup\$ It is not about being lazy,I didnt get it. \$\endgroup\$
    – g3d
    Commented Oct 4, 2013 at 14:26
  • 2
    \$\begingroup\$ It might help to explain how a half-adder (the only allowed component) can be used to invert the input. \$\endgroup\$
    – The Photon
    Commented Oct 4, 2013 at 17:12
  • \$\begingroup\$ @g3d - then counts the 1s and subtract from 15 \$\endgroup\$
    – Andy aka
    Commented Oct 4, 2013 at 17:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.