Learning from 0 – Part 1 Half Adder

Learning from 0 – Part 1 Half Adder

I’ve been meaning for a long time to start learning about some of the fundamentals of Computer Science and have recently got very interested in Computing history. Whether it is the story of J. Presper Eckert and John Mauchly and their work on ENIAC or Alan Turing and his life, I am really interested in where all of this amazing technology that we mostly take for granted started. I want to learn about the people and the technology.

To start with I wanted to learn about digital circuits and how they work. I started with a simple idea, creating a binary calculator using logic gates.

First step was to create an adder. To do this, I needed to make a half-adder circuit. I decided it create it in Python as this is the language I use most often but I plan to re-create it in Javascript to go on the main projects page of www.paulwill.co.uk

The Half Adder

The logic for a half adder goes like this:

Try it here.

This logic led to me writing the same thing in Python. Python has bitwise Exclusive OR capabilities but I am implementing my half-adder in boolean logic, using only True or False. Here is the code:

The truth table for this was:

A B Carry-In Sum Carry-Out
0 0 0 0 0
0 0 1 1 0
0 1 1 0
1 1 0 1

This works, and the inputs for the truth table looks like this in Python:

The outputs produced are correct:

So far so good, next post a Full Adder.

Reader Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.