An Excel-lent Microcode Compiler

Bob Alexander built a microcode compiler into a Google Sheets spreadsheet to simplify the process of designing a custom CPU.

Nick Bild
11 days ago β€’ Retro Tech
Compiling custom microcode with Google Sheets (πŸ“·: Bob Alexander)

The path to becoming a knowledgeable electronics hobbyist can be long and arduous, but it is also very rewarding. It always starts out innocently enough, perhaps with an Arduino or Raspberry Pi development board, a few resistors, an LED, and a bit of Python coding. After learning about forward voltages, Ohm's law, and GPIO pins, the beginner will be rewarded with their first blinking lights. The initial excitement this stirs up will inevitably lead to curiosity β€” but how does it all work? β€” and off down the rabbit hole they go!

For many, that journey ultimately leads them to build a computer, probably based on an older processor like a 6502 or Z80 for simplicity. Designing and building the complex circuit to make a functional computer is a tremendously valuable learning experience. But for a relatively small number of hardware hackers, that is not enough to satisfy their curiosity. There is still the question of what exactly is happening inside those integrated circuits β€” especially the CPU.

Most people are content to stop before that, and consider machine code or assembly language to be the lowest level of computer engineering. Of course that is not true, however. This view ignores everything that actually happens inside the CPU. So brave souls, like Bob Alexander, set out to build their own CPUs to gain more understanding.

As you might expect, this is some pretty challenging work. In particular, CPU design will bring you face-to-face with microcode. Consider an assembly language instruction like ADD. Even if we do not know all of the details, we can easily recognize that there must be a lot happening inside the CPU to carry out this simple instruction. Data may have to be loaded from memory into registers, and of course that data must pass through specialized addition circuits, before the result winds up in another register. That is where microcode comes in β€” it specifies in great detail exactly what needs to happen to carry out an instruction.

Typically this microcode is stored in ROM chips. A number of inputs, like the opcode, the system clock, and a variety of processor flags are supplied to the address pins of these chips. Stored at the specified address is a value, which will be written to the data pins, that is used to switch components inside the CPU on and off to control the flow of data and perform the requested computation.

So to build a CPU, one needs to define and implement the microcode instructions. Alexander came up with a clever hack to make this process just a bit less painful. By creating a microcode compiler within a Google Sheet, Alexander made it possible to define the inputs and outputs, then generate binaries that can be written to ROM chips.

Not only does this make the development process simpler and less prone to error, but it also makes for a nice piece of documentation that can be referenced later. If you happen to be going through the process of designing your own CPU, it would be well worth taking a look at this spreadsheet-based microcode compiler.

Nick Bild
R&D, creativity, and building the next big thing you never knew you wanted are my specialties.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles