Hello World!

Hello everyone and welcome to my newest blog adventure: a blog about how to build a custom CPU – transistor by transistor! Yes you have read that correctly: the goal of this blog is to show you how an actual CPU is designed and implemented at the transistor level.

Maybe you are asking now yourself, why on earth would you want to accomplish such a thing? Well, the reason for this project was very simple: I wanted to get a better understanding of how a CPU actually works. I have quite a good understanding of operating systems, and the applications that run on top of them, but the CPU was always a big mystery to me. It just works and executes with some „magic“ assembly instructions. But the question that I had always in my mind was about the "how" – how the CPU works internally.

A few years ago I discovered the Relay Computer from Harry Porter. It is quite an amazing project that Harry has accomplished here: he built an actual CPU out of relays. Based on his excellent documentation I was finally able to understand the inner workings of a simple CPU. We have exchanged a lot of emails and finally I have taken his initial design and over the last 12 months I have created a fully functional CPU based on simple, primitive transistor gates: AND, OR, XOR, and NOT – the most fundamental things that you can do with binary numbers!

I have also soldered some parts of my CPU and used some simple TTL gates for the various transistors – and it worked!. In addition the CPU design was also written with the simulation language VHDL, and currently runs within a FPGA simulator from Xilinx.

A fully functional 8-bit wide ALU

To give you an idea of what my CPU can currently perform, look at the following assembly code that reads a bit value from an input port and writes the read value into an output port.

Yes, such an assembly code can be executed by my CPU – just based on primitive transistors! Sounds awesome, doesn't it? To make it more awesome, here is the instruction set that is currently supported:

  • ADC
  • ADD
  • AND
  • CALL
  • CMP
  • DEC
  • DIV
  • IN
  • OUT
  • INC
  • JMP
  • JNC
  • JNZ
  • JZ
  • MOV
  • NEG
  • NOP
  • NOT
  • OR
  • POP
  • POPF
  • PUSH
  • RCL
  • RET
  • SAR
  • SBB
  • SHL
  • SHR
  • SUB
  • XOR

Internally the CPU uses a RISC based instruction set, and based on – let’s call them "Macros" - it mimics a CISC based instruction set that you can see in the above list. The CPU implements an 8-bit wide ALU, which performs the "number cranking" and uses a 16-bit wide address bus that gives me 64K main memory. In addition the CPU uses 7 8-bit wide registers, and 8 16-bit wide registers. For the communication with the outside world the CPU uses 2 dedicated input and output ports.

Sounds cool to you? If yes, please subscribe to my blog and follow me over the following months as I show you step by step how to implement such a CPU at the transistor level.

Stay tuned and thanks for your time,


Comments are closed.