YURIX


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.

image of the cpu I built

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.

sketch of a TTA architecture showing how function units are connected over a 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:

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:

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.