Building a Computer from Electronic Components
December 2023
Note: This is a newer version of this article. The old article written in the middle of the project can be found here.
Computer architecture is an interesting topic. While you can learn quite a lot about it by reading books and articles, doing something practical is a bit difficult. Besides the TinyTapeout project, it is basically impossible to get integrated circuits manufactured as a private customer.
However, as for example Ben Eater and James Sharman have shown, it is possible to build a computer out of glue logic chips. They are a group of simple ICs that implement functionalities like logic gates, registers or even adders. While they are not typically used to build CPUs anymore, around the 1970s there have been many CPUs made with them. Today, it is still possible to build a simple computer using glue logic.
Over the last half year, I've been building my own version of a glue logic CPU. It is a 16-bit computer using 16-bit words. In total, it has 64 KB of memory organized as 32k 16-bit words. Communication to a "big computer" (e.g. a laptop) can be done over SPI. An Arduino acts as a USB translator. This is also the primary way of loading programs onto the computer.

Architecture
This computer is based on a transport-triggered architecture(TTA) very similar to the one described by Douglas W. Jones on his website. A transport-triggered architecture means there is one instruction: Move data. All other operations are memory-mapped. Because there is just one instruction, an opcode can be omitted and an instruction only consists of a source and destination.
A group of memory-mapped registers, for example, the operands of the subtraction device, are called a function unit since they help with performing an action, and form one unit.
The function units are all connected over the so-called data-bus. This is one long bus that connects all function units. All data movements go through the data bus.

In the picture of the finished CPU, the blue wires are the data bus. As it can be seen, it stretches over the whole CPU and connects many regions.
Memory-Mapped Function Units
The computer has the following function units memory-mapped:
- subtraction
- unconditional branches
- conditional branches (conditions: all bits set or is negative)
- SPI input and output
- main memory
- swapping the high part of a 16-bit word into the low parts
- breakpoints
With these features, the CPU isn't very powerful and difficult to program, but it is more than enough to e.g. find prime numbers using the sieve algorithm.
Construction
The computer is built out of 74-series chips mounted on breadboards. It is wired using hook-up wire and in parts using wire wrap because I ran out of hook-up wire. The breadboards are mounted on a piece of wood. This allows me to move the computer around.
I've included a few LEDs to visualize important parts of the CPU state. They have proven to be invaluable for debugging together with a single-step mode.
Programming
I've created a custom assembler for programming. An example program that can search for primes using the sieve algorithm can be found here.
Writing the assembler was my first big project using the zig programming language, and you notice it while reading its code. Therefore, I won't share it. It isn't particularly interesting though. It parses the file, converts it to an intermediate representation, optimizes immediate values, resolves the labels and emits a binary.
Additionally, I started work on a cross-assembler that takes in RISC-V assembly and translates it to assembly for my CPU. However, since there is no function unit for binary operations like AND, I doubt I will ever finish it.
Advice
It was an interesting experience, and I learned a lot from building this CPU. Here are a few points I want to share with anyone attempting a similar project:
- Keep it simple. It will take you long enough to finish the project, so don't make it needlessly complicated. You can always do a second build/upgrade your current one.
- Build small: in retrospect, building it 16-bit wasn't worth it. Going 16-bit means you have to lay twice as many wires per function unit, and laying wires is what took the most time.
- Investing some time to test the computer properly is very much worth it.
- Use program-counter-relative jumps
-
Don't forget the power supply. You will need to supply your project with power. Ideally, your power
supply is short-circuit proven. Because I didn't have anything better, I
usedfried and arduino as a USB adapter. Don't do it. Get a lab power supply, resettable fuses, or just anything to protect you. While I haven't managed to destroy my CPU with short circuits yet, I managed to create plenty of them. - A modular architecture like a transport-triggered architecture is worth it. With TTAs, you can always add and remove function units. This allows for some flexibility at the start, not all function units have to be planned completely, or you can even add completely new function units you didn't think about before.
More Information
I started this project as my matura project. This is a project I had to do in my final year of high school. Besides actually building the computer, I also had to write a report about it. It is way more detailed than this article ever can be. Check it out here.