I have to design a 1-bit binary adder/subtractor unit that can both add or subtract two input values A and B depending on a control input C (it is assumed that two's complement is used).

Also, the adder/subtractor has an additional input $C_{in}$ for a previous borrow or carry. When subtraction is to be performed and the borrow input is 1, an additional subtraction of 1 is to be done. There are two outputs, one for the borrow/carry and one for the sum.

How would the corresponding circuit look like?

I thought that (because in two's complement $A - B = A + (\bar{B} + 1)$),

$A - B - C_{in} = A + \bar{B} + 1 - C_{in} = A + \bar{B} + \overline{C_{in}}$

So is it correct that when doing subtraction, all I have to do is invert B and $C_{in}$ and feed these inverted values to the inputs of a normal full adder?

Also, how would I construct a 4-bit adder/subtractor from those single 1 bit adder-subtractor cells?

The standard adder / subtract circuit is given by the figure below.For an explanation of how it works please see my previous answer here : Subtraction using adder circuit

Now notice that if you were to change the input that is tied to '0' to Cin, then the circuit would now perform the operation: A + ~B + (Cin ^ SUB), meaning that:

1) it would be a normal Adder/Subtract circuit when Cin is 0.

2) if Cin = 1 and Sub = 1 it would evaluate to:

A + ~B + (1 ^ 1) = A + ~B = A + ~B + 1 - 1 = A + (~B + 1) - 1 = A - B - 1 ,

This means that the normal Add/Sub circuit can achieve the operation you require, all you need to do is change the input tied to '0' your Cin.

You could also design the desired circuit by using the usual method of writing all your possible inputs into a truth table, then deriving the Boolean equations for them, then simplifying them to get your final circuit equation.

• Thanks, so basically my idea to invert C_in and B was correct, right? After all, an XOR gate is like a controllable inverter. I was just a bit confused because obviously you cannot build a 4 bit adder-subtractor from those 1 bit-cells because the carry-in input is only inverted for the first full adder while the other cells are just normal FAs with inverted B input. – IronMan12 Mar 6 '14 at 10:37