Al Williams

Dr. Dobb's Bloggers

CPU Design on Paper

April 23, 2013

FPGAs are great for experimenting with CPU designs.

I've designed a few CPUs in my life from old school to actually practical. FPGAs are great for experimenting with CPU designs, since I could never get all the wiring right for something like Oneder if I were trying to build it out of regular components.

Webcasts

Even with FPGAs, though, the process is a little daunting. I've often thought that fundamental CPU concepts could be a great thing to teach aspiring computer programmers, even at the high school level. However, getting your hands around an FPGA design flow might be a bit too much.

However, as usual, my thought isn't original. Way back in 1968, Bell Labs released a "paper computer" to help teach kids about how computers work. CARDIAC was nothing more than some cardboard (there are some pictures of one at the Porticus site), but it implemented a simple CPU design that was great for teaching people how these mysterious machines actually worked.

The CPU is definitely a child of the '60s. Like the machine I learned on (another made up computer called TUTAC), CARDIAC was a decimal machine and relied on self-modifying code for things like indexing. Still, you can teach a lot about programming even with a simple machine.

It turns out, you can still find CARDIAC for sale on a few web sites (they must have made millions of them). The included book is pretty sexist for the modern generation (a flow chart about fixing a spare tire starts with a decision block to determine if you are a boy or a girl), but that was how it was back then. If you can get past that, the actual design of the computer is very clever. Of course, the student is the ALU and the control unit, but the die cut pieces direct the flow and provide step-by-step guidance for the execution of each instruction.

I have in mind trying to work with some students on something like CARDIAC and picking out a few to actually do a simple CPU on an FPGA (maybe something like mCPU). However, I didn't want to go buy a classroom full of CARDIACs.

A quick search turned up a CARDIAC emulator, although it isn't totally faithful to the original. Besides, have you tried getting a school to let you load software on their computers? Good luck with that. So I set out to write a simulated CARDIAC CPU in, of all things, Microsoft Excel.

Excel? Why not? The schools have it and it certainly can do the work of a computer made out of cardboard. You can see the result below and download the spreadsheet. I will confess that I was highly inspired by another spreadsheet-based educational simulation for The Little Man Computer. The Little Man Computer was another educational (and fictional) computer from that same time period. If you aren't old enough to remember, things like CARDIAC, Little Man, TUTAC, and MIX were important, because computer time was too expensive in those days to let students just run code on them all the time. Times have certainly changed.

What's this got to do with FPGA CPU design? Well, you have to understand how a CPU works before you can design one in an FPGA or otherwise. Granted, this one has some bad habits (like decimal numbers and self-modifying code). On the other hand, you don't confuse kids with number bases (yet), and you can use those very flaws to point them out and show how modern machines fix them.

If you've ever designed a CPU or other significant FPGA design, how did you get started? I'll have some more thoughts on CARDIAC, the CARDIAC spreadsheet, and learning CPU design next time. Even if you don't actually want to design your own CPU, there are a lot of lessons you can learn from delving under the hood.

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task.
However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Video

This month's Dr. Dobb's Journal

This month,
Dr. Dobb's Journal is devoted to mobile programming. We introduce you to Apple's new Swift programming language, discuss the perils of being the third-most-popular mobile platform, revisit SQLite on Android
, and much more!