Mum, I’m Building a CPU – Performing Subtraction

Andrei’s 8-bit full (ripple) adder is now complete (see below), so Charlie and I have been able to look at subtraction.

Full Adder and Negator

Bottom: Full adder (4 bits on each board) – Top: Negator (now replaced).

To support subtraction, Charlie and I have build a negation board. When a data-value is sent to the addition board, one copy of it will go through a series of not gates whilst the other does not. Both then go through a multiplexer (74245) which selects which one to send on to the adder board. We did realise on Saturday however that the whole thing can be re-built with eight XOR gates, where we can choose whether to invert each bit by putting either a 0 or 1 on one of the inputs.

One thing that has taken some thinking about with this board is how we accurately perform subtractions – the problem lays with Binary. Lets take a simple example (most-significant-bit is a sign bit, b = binary):

00010011b = 19
now let’s swap the 0’s and 1’s
11101100b = 236
236-(2^8) = -20 (since we have 8 bits)

So, you see our result is one less than the desired one. The solution that we are working on is a negation of the carry flag before it is sent to the adder.  Once I’ve looked more at this I’ll update this post with a Truth-Table.

Leave a Reply

Your email address will not be published. Required fields are marked *