8-bit breadboard CPU

[ pt_BR ]

8 bit cpu

A long time ago I read CODE: The Hidden Language of Computer Hardware and Software and was really impressed. It's a great trip through all the layers of abstractions in a computer. Petzold starts with very simple building blocks and brings you step by step closer to understanding how computers work.

Years later I stumbled upon Ben eater's 8-bit breadboard computer. In this video series, Ben Eater follows a similar path, and builds an entire functioning computer from simple 74 series ICs.

I obviously decided to build one.

I basically only followed Ben's amazing videos and schematics.

The basic structure of the computer is the following:

Functional block diagram of the 8 bit computer
Functional block diagram of the 8 bit computer. Screenshot taken from one of Ben Eater's videos

Needless to say, it's a very simple computer. In fact, it's apparently based on the SAP-1 computer described by Albert Paul Malvino in his book Digital Computer Electronics. In Ben Eater's implementation (and in mine), the instruction set is minimal. The are only instructions to manipulate data in one of the registers, and there are only two conditional jumps: jump if carry and jump if zero.

NOP    0000
LDA    0001
ADD    0010
SUB    0011
STA    0100
LDI    0101
JMP    0110
JC     0111
JZ     1000
OUT    1110
HLT    1111
Instruction set for the 8bit breadboard computer

The design uses a couple of EEPROMs to replace the combinational logic necessary to decode the instructions into the necessary signals to operate them. The opcode and the instruction cycle counter are used to address the EEPROM, and the outputs (basically the data at that specific address) are the control signal. This means we can update the microcode for the computer by changing the contents of those EEPROMs.

With only 4 bits of memory address space, you have to fit the program and data in 16 bytes. A simple program to calculate the Fibonacci sequence uses up almost the entire memory:

| Opcode |  arg  |   mem pos.  |   content   |
+--------+-------+-------------+-------------+
LDI        1        0000        0101 0001
STA       14        0001        0100 1110
LDI        0        0010        0101 0000
ADD       14        0011        0010 1110
STA       15        0100        0100 1111
LDA       14        0101        0001 1110
STA       13        0110        0100 1101
LDA       15        0111        0001 1111
STA       14        1000        0100 1110
LDA       13        1001        0001 1101
OUT                 1010        1110 0000
JC         0        1011        0111 0000
JMP        3        1100        0110 0011
Simple program to calculate the Fibonacci sequence

One small place where my circuit diverges from Ben Eater's is in the reset circuit. I didn't have any more NAND gates at hand when I wanted to build it, but I had NOR gates. So adapted his reset logic to use only NOR gates.

Reset circuit using NOR gates
Reset circuit using NOR gates

Another issue I found is that sometimes RAM got overwritten when switching between programming and run mode. The solution is to pull up the write enable pin on the RAM IC so it doesn't float when the "write" button is not pressed.

There is a subreddit dedicated to Ben Eater's channel, where people post a lot of different programs and modifications to the hardware. There's people who built programmers, expanded the memory of the computer, and other modifications. It's a great source of information on the project and a good place to look when you find problems.