0
\$\begingroup\$

I have constructed a half-adder that looks like this:

enter image description here

And a half-subtractor like this:

enter image description here

It's basically the same circuit except the AND gate at the bottom has a NOT before it for one of the inputs. I would like to combine the two so that I can perform (half-) addition or subtraction based upon a third boolean input. Zero would mean Add and One would mean Subtraction. What would be an example of how I could 'route' the input into an optional NOT gate based upon the type of operation being performed?

One idea I had was to put the operation input into an XOR gate before the AND input.

\$\endgroup\$
  • \$\begingroup\$ @jsotola I already did, and it worked. I'm seeing what other solutions there might be. \$\endgroup\$ – David542 Mar 26 at 0:59
  • \$\begingroup\$ @jsotola agreed, thanks for the feedback. \$\endgroup\$ – David542 Mar 26 at 5:00
0
\$\begingroup\$

This would work. You could also use a tristate-inverter. However, the XOR gate idea would work better because XOR gates are more common to have. On a side note, I used to think of XOR gates as controllable inverters.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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