Building a CPU from Scratch

Tanmay Khale '16

The project: Mr. Khale conducted a hands-on exploration of the internal workings of computers with the help of a Field Programmable Gate Array (FPGA), an integrated circuit that can be configured to the programmer’s own specifications. Through the process of developing the “assembly” or “machine language” that a programmer might use, he learned how to design the architecture of a basic central processing unit, the brain of a computer.

From his paper: “In May 1936, Alan Turing published a paper titled “On Computable Numbers, with an Application to the Entscheidungsproblem,” in which he introduced the idea of an abstract machine which manipulates symbols on a tape according to a set of rules, the appropriately named “Turing machine.” The idea of the Turing machine was of a general-purpose computing machine that could in theory, according to a certain set of rules, compute anything that could possibly be computed… The ideas behind Turing’s hypothetical machine led directly to the modern ideas of programming and the computer…. Inside each smartphone or laptop is essentially the realization of Turing’s abstraction, a mini Turing machine in the form of the central processing unit or “CPU”… In technical terms, the goal of my project was to create a machine with an assembly language that is Turing-complete, meaning it can act as a Turing machine. My CPU design is Turing-complete.”

Biggest challenge: “I worked out of a book and there were definitely some things that were hard to understand that took me longer to do. But what’s been my biggest challenge is I haven’t done much programming for the chip yet. It’s easier to understand things in theory than it is to actually program them and put them on the chip. I know it’s going to be a whole other piece to the challenge.”

Surprising discovery: “I was surprised that I better understood the question I was asking. They say in mathematics that a lot of the skill is in asking the right question.That’s what I feel. I understood the answer more but what was more interesting to me, and surprising, was I understood the question better. What am I doing? What is an FPGA? What is a CPU? As I got further, I understood.”

Tip for future scholars: “One of the things I’ve learned over the past year or two is that the best way to learn is to make mistakes. You have to accept that you are going to make mistakes along the way. Every time you make a mistake you have to ask yourself why did I make that mistake and what can I do next time. You learn more from your failures. This is a lesson I’ve learned from math and also this project.”