I am building a 4-bit adder/subtractor circuit using only logic gates on a breadboard. The following IC chips are being used:
XOR- 7486, AND - 7408, OR - 7432.

I have the full adders working fine. However, I can't seem to get my subtractor working, using an XOR gate - 7486. I understand the math, 2s complement, truth table, and concepts. I attached a schematic.

Problem: I don't understand where to connect the first carry-in. Since there is no carry-in on the first adder, I tied it to ground. That makes the adder work.

However, in order for the subtractor to work, I am confused about where to connect the first carry-in. The schematic shows it to be connected to both the mode switch and the first B input for the first full adder. I did that. It just makes the circuit light up random values. Even when all the inputs are low. I have the first input of B (LSB, B0) connected to the XOR, along with the first carry-in. The output is connected to the B input of the full adder.

I get the feeling that I am making this more difficult than it should be. If I can get the first carry-in connected correctly, I believe I will be fine from there.


As soon as I flip on subtractor (¬ADD/SUB) to high, the value 4 comes on, without any inputs (A = 0, B = 0).
When A = 0 and B = 1, the value is 3.
When A = 1 and B = 1, the value is 4.
When A = 3 and B = 1, the value is 6.
When A = 2 and B = 3, the value is 3.
Also, the adders were working fine until I hooked up the subtractor. The adders are not giving correct values either.
It has to be my first carry-in is wrong.
However, I have it connected to the mode and the carry-in, as well as the XOR.

  • \$\begingroup\$ The schematics looks fine. Carry-in is set to one when subtracting using two's complement : A - B = (A + /B + 1) \$\endgroup\$
    – Grabul
    Apr 30, 2023 at 21:00
  • \$\begingroup\$ Yes. However, when I set the carry-in to one, it immediately displays random outputs, even when the inputs are 0. Does the first carry-in need to be disconnected from the adder? \$\endgroup\$ Apr 30, 2023 at 21:13
  • \$\begingroup\$ Please specify some test cases (A, B and S) for what you are calling "random values". \$\endgroup\$
    – devnull
    Apr 30, 2023 at 21:23
  • 1
    \$\begingroup\$ Ad soon as I flip on subtractor to high, the value 4 comes on, without any inputs ( A = 0, B = 0). \$\endgroup\$ Apr 30, 2023 at 21:33
  • 1
    \$\begingroup\$ When A = 0 and B = 1, it gives the value 3. A = 1 and B = 1, the value is 4. When A = 3 and B = 1, the value is 6. When A = 2 and B = 3, the output is 3. \$\endgroup\$ Apr 30, 2023 at 21:35

1 Answer 1


The schematic is correct: with SUB set to 1 the 4 XOR gates invert all the bits in B and add one (carry in), thus computing the two's complement.

Besides any a errors at the breadboard connections, or damaged ICs, what may explain the "random values" is a wrong conversion for negative values, which may actually be correct.

These are the expected values for the test cases you provided (with SUB = 1):

A   B  =  S   Cout
0   0  =  0   1
0   1  =  F   0
1   1  =  0   1
3   1  =  2   1
2   3  =  F   0

I'd suggest that you check the intermediate values with a multimeter or a "LED probe" to find the error.

  • 1
    \$\begingroup\$ Thank you @devnull. I never got F. I did notice that the voltage dropped by .5V when I switched from the adder to SUB. I must be grounding something that shouldn't be grounded. \$\endgroup\$ Apr 30, 2023 at 22:04
  • 1
    \$\begingroup\$ @MichaelPaxinos if the schematic looks right, the error may be in the breadboard. I'd not short an input to a power rail, but use a 100 Ω resistor. I've suggested to consolidate several comments into the question body, information about the voltage drop should go there too, and possibly an image of the breadboard. \$\endgroup\$
    – greybeard
    May 1, 2023 at 6:47

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.