Binary Subtraction using Logic Gates

In our previous blog post “from transistors to processors” we found out that the CPU consists of logic gates, which are made using transistors.

In this blog post we are looking at how these logic gates can be combined to create an integrated circuit used by the ALU (Arithmetic and Logic Unit of the CPU) to perform a binary subtraction of two 8-bits binary numbers.

Half-Subtractor Circuit


A half-subtractor circuit is used to perform a binary subtraction of two bits of data. It is based on the following Truth Table.
half-subtractor-truth-table

A half-subtractor circuit consists of three logic gates as follows:
half-subtractor-logic-gates-diagram

Full-Subtractor Circuit


A full-subtractor circuit is used to perform a binary subtraction using three bits of data and is based on the following Truth Table:
full-subtractor-truth-table

A full-subtractor circuit consists of two half-subtractor circuits and an OR gate connected as follows:
full-subtractor-logic-gates-diagram

Full Binary Subtraction


By connecting one half-subtractor circuit with seven full-subtractor circuits we can create a circuit to implement a full binary subtraction of two 8-bits binary numbers:
8-bit-subtractor-block-diagram

Alternative Approach


An alternative approach is to design a circuit that can be used to complete both full binary additions and full binary subtractions of two 8-bit inputs.

This can be achieved using 8 full-adder circuits and 8 XOR gates connected as follows: On this “2-in-1 circuit” the Mode input is used to decide if an addition (Mode=0) or a subtraction (Mode=1) is performed.
8-bit-subtractor-block-diagram-using-full-adders

Did you like this challenge?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 53

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: