Building a Computer

← home

What I hear, I forget; What I see, I remember; What I do, I Understand. - Confucius

One of the most famous programming books ‘The C Programming Language’ by Kernighan and Ritchie starts with the following few lines.

‘The only way to learn a new programming language is by writing programs in it. The first program to write is the same for all languages: Print the words’

hello, world

‘This is the big hurdle, to leap over it you have to be able to create the program text somewhere, compile it successfully, load it, and find out where your output went. With these mechanical details mastered, everything else is comparatively easy.’

‘In C, the program to print “hello, world” is’

#include <stdio.h>

main ()
{
    printf("hello, world\n");
}

Mechanical Details

What do Kernighan and Ritchie mean by mechanical details? What does a compiler actually do? How does it read the text in the C code above? How does it instruct the CPU to print ‘hello, world’. How does the CPU execute those instructions? Where are the 0s and 1s? How are these binary states stored? What physics makes these binary states possible? It is a rabbit hole. The only way to truly understand what a computer is - is by building one.

I am inspired by a few projects online where an 8 bit computer is constructed on breadboards, but what really motivates me is the book ‘The Elements of Computing Systems’ (2nd ed.) by Noam Nisan and Shimon Schocken. They have wonderful content on their website called Nand to Tetris.

In this project, which I expect to last many months, perhaps years I intend to build a computer in real hardware just like Nand to Tetris book does but they do in a simulated environment. I honestly do not have all the specifics as I type this at the start but have two approaches in mind. First, use Integrated Circuits (ICs) such as SN7400 chips, and the other being use NPN transistors such as 2N3904. With the ICs I can aim for an 8 bit computer maybe even a 16 bit computer, which would be a real challenge, but with the transistors a 4 bit computer is more realistic. Currently I am undecided. Second, I will build the computer exactly as mentioned in the Nand to Tetris book in software so my learning is complete.

In Summary:
1. Hardware:
- Option 1: Use Transistors NPN 2N3904 to build a 4 bit computer (realistic goal)
- Option 2: Use IC SN7400 to build an 8 bit computer (realistic goal)
2. A 16 bit computer in a simulated software environment

Abstraction

The key principle with which I will be working with is that when I have built a certain piece of hardware and moved on to the next step I will not focus on how the layer beneath works. I would have extracted away that underlying layer. It is valid even for theoretical physics concepts where we hold some axioms as true and work with that.

Progress

I will use this blog post to publish every step of building this computer. As I complete each section, I will update this post:

  1. Particle Physics

  2. Solid State Physics

  3. Transistors

  4. Logic Gates