Building a general-purpose computer means that you’ll have to take a lot of use cases into consideration, and while the end product might be useful for a lot of situations, it will inherently contain a lot of inefficiencies. On the other hand, if you want your computer to do one thing and do it very well, you can optimize to extremes and still get results. This computer, built from RAM, is just such an example.
The single task in this case was to build a computer that can compute the Fibonacci sequence. Since it only does one thing, another part of the computer that can be simplified (besides the parts list) is the instruction set. In this case, the computer uses a single instruction: byte-byte-jump. Essentially all this computer does is copy one byte to another, and then perform an unconditional jump. Doing this single task properly is enough to build every other operation from, so this was chosen for simplicity even though the science behind why this works is a little less intuitive.
Of course, a single instruction set requires a lot of clock cycles to work (around 200 for a single operation). The hardware used in this build is also interesting and although it uses a Raspberry Pi to handle some of the minutiae, it’s still mostly done entirely in RAM chips, only cost around $15, and is a fascinating illustration of some of the more interesting fundamentals of computer science. If you’re interested, you can build similar computers out of 74-series chips as well.
16 thoughts on “A Turing-Complete CPU From RAM”
I left out a tremendous amount of detail about how the CPU works, because it’s extremely dry. Still, if anyone wants to know the dirty details, shoot me an email.
It was interesting until reaching that. Now I regret every second wasted on it.
Retract this article until schematics and other essential details are available.
It’s extremely rough, but my previous version of the writeup had much more detail, along with some schematic files.
I rewrote the entire thing, because I got bored reading it, and that was a bad sign, given that it was my project.
The older version is still in the Github here: https://github.com/mysterymath/simple_cpu/commit/8df3958e1d992b8424a58e8161bff96a9f45e076
I collected some of this from my notes and added a details page. The wording is a bit rough, but it should all be there!
i second this
Or you know, shoot him an email and publish it yourself if you feel it’s so important. It’s his article, he can do whatever he wants in it, like you can write whatever you want in your comment, and I can reply to you than I think you’re being a little prick, free speech is indeed wonderful :)
It is good he doesn’t interleave the article with arbitrary details. It keeps the story flowing. He tells more than enough that anybody who has seen a CPU before can build something very similar. And he offers to fill in the gaps to those who need it. Such a toxic comment is absolutely unnecessary.
Any other tips or demands?
There’s plenty of space to store lots of useful look-up tables if they’re for 4-bit operations.
the only instruction is “copy source byte to destination byte then unconditionally jump”, and that’s pretty cool that is all that is needed. I’ve toyed with some more luxurious one-instruction architectures like “subtract and branch if negative” or “reverse subtract and skip if borrow”
I am always fascinated with one instruction architecture. Very cool indeed.
There was an article in Byte about a Turing machine, no later than 1985, and likely closer to 1980. It certainky explained them, but I think there was examples.
Not so useful without a date, but maybe someone remembers. It would be great to have master indexes of the old magazines now online. That americanradiohistory site has a search engine, but every time I try to use it, I get way too many results, so I’ve given up.
It was easier to find than expected.
Byte for December 1976 page 114. A hardware Turing Machine, no special parts.
Byte for Dec 1978, page 26, a Turing machine in software
I thought “Wow, cool!” until I found that this is another in a long line of “throw a Pi or Arduino into it” articles.
Or a 555. :-)
What difference would it have made if he toggled the program into SRAM and not using some other machine as a glorified RAM he can easily manipulate with modern tools?
The feat of building such a CPU still stands.
In other words this is a teeny tiny homebrew FPGA.
Please be kind and respectful to help make the comments section excellent. (Comment Policy)