Lably
Skip to content

Adder–subtractor

Computing circuit

  • 3 min read
  • 2 chapters

Related on Lably

Through Adder (electronics), Binary number and Two's complement

Construction

Having an n-bit adder for A and B, then S = A + B. Then, assume the numbers are in two's complement. Then to perform B − A, two's complement theory says to invert each bit of A with a NOT gate then add one. This yields S = B + A + 1, which is easy to do with a slightly modified adder.

By preceding each A input bit on the adder with a 2-to-1 multiplexer where:

  • Input 0 (I0) is A
  • Input 1 (I1) is A

that has control input D that is also connected to the initial carry, then the modified adder performs

  • addition when D = 0, or
  • subtraction when D = 1.

This works because when D = 1 the A input to the adder is really A and the carry in is 1. Adding B to A and 1 yields the desired subtraction of B − A.

A way you can mark number A as positive or negative without using a multiplexer on each bit is to use an XOR gate to precede each bit instead.

  • The first input to the XOR gate is the actual input bit
  • The second input for each XOR gate is the control input D

This produces the same truth table for the bit arriving at the adder as the multiplexer solution does since the XOR gate output will be what the input bit is when D = 0 and the inverted input bit when D = 1.

Sign in to keep reading

One more chapter is free with a Lably account.

More in Computing and communication