Control Unit: Part 1

What we need now is an orchestrator that can control all the pieces, say who writes on the bus and who reads from it and so on. But most importantly, we need to make it in such a way, so that it, itself, is controlled by the very things it is controlling.

First we will build it, and then I will show you the infinite loop in it.

We will build a 4 bit computer that can only execute one instruction: SUBLEQ.

So that we will be able to run our favorite program:

7 6 9
8 8 0
3 1 0
8 8 9

The whole purpose of this exercise is to see the IF and the ADDRESS.

We will attempt to reduce everything into its essence. Infinite loops and feed forward transformations.

This is a Digital (https://github.com/hneemann/Digital) schematic I made, and how it looks in the real world.

Before we continue I will say that I had never done this, and it was an amazing experience. I got the simulation running fairly quickly, but then when I had to do the real world thing, I had to endure failure after failure. I was about to give up so many times... I stopped counting. Every night I spent 5-6 hours with the oscilloscope and multimeter debugging. I burned many chips, and I started from scratch many times. Some days I had no progress at all. But after I got it working I was so happy, I would recommend the experience.

The way I designed the computer must be terribly inefficient, but it works, and I can use it to teach you. It is enough for you to see the if and the address.

We will need the following components:

2x 555     - timers
2x 28at64c - EEPROM
4x 74LS04  - 6 hex inverters
1x 74LS32  - 4 OR gates
1x 74LS181 - ALU
4x 74LS245 - transceivers
2x 74LS161 - counters
5x 74LS373 - 8 bit register

a bunch of LEDs, some capacitors, 1k, 4.7k, 10k and 1m resistors and wires.

Quick explanation of the 74LS161 counter, and 74LS245 transceiver.

The counter is basically a register that can count, we pulse a clock to it and it increments its value. It can also load a specific value, and continue counting from there.

https://www.ti.com/lit/ds/symlink/sn74ls163a.pdf

74LS245 is a transceiver, its purpose is to separate two buses and allow you to control when data should go from one to the other, or they will be disconnected. You control the direction and if there should be output or not.

https://www.ti.com/lit/ds/symlink/sn54ls245.pdf

We need it to separate and control the ALU's output and the program counter's input and output, and the RAM's output.


BTW, If you really want to build a useful computer, get Ben Eater's kit and watch his videos, they are absolute art. Building it is an amazing meditating experience (.. I broke mine halfway through the build ...), even if you are not going to build it, just watch his YouTube channel, he explains everything much much better.

The actual reason of the whole first part of the book is to have an idea of how computers work, what does 'oh it's just ones and zeros' actually mean. I want you to know what does int a = 8; if (a > 5) a = 5; do, and to understand deeply what is an address.

I want you to challenge everything, for example: do we need a clock? What is a programming language? Why do we use only 1 and 0, high and low voltage?


There are a few things there that I have not discussed, let's start with what resistors and capacitors are, and then we will explain the EEPROM.