Choosing Between Addition and Subtraction

In the next step, the circuit will be expanded to allow choosing between addition and subtraction.

First, consider the following circuit:

With the Op input, you can select whether A is inverted. It can be easily shown with truth tables that the following holds: In the case of \(Op = 0\), \(S = A\), and in the case of \(Op = 1\), \(S = \lnot A\).

This circuit uses a 4-bit wide XOR gate to invert the bit pattern:

Use this method of selective inversion of a bit pattern to choose between addition and subtraction.