Boilerplate Part 1 - History
So I sort of made a simulator for a new kind of CPU...
A few years ago another UNSW student (David Collien) wanted a way to teach hardware design to students. Breadboards and wires are sort of annoying, but there's lots of other ways you can make a logic gate. And once you have NAND, you can of course make anything.
Here's an early prototype of logic gates using string:
Before long David started exploring the idea of using air pressure instead. The idea was that air pressure could push a little piece of plastic (a shuttle) which could block off perpendicular air tunnels. You could use pressure to make logic gates, and from there you could build everything. Dougall Johnson made a prototype of the idea using laser cut acrylic:
David Collien then made a simple simulator in Java for it to plot out circuitry. He called it SteamOS. They wanted to make a CPU using it - but I don't think that ever worked out.
This is what the first simulator looked like in late 2010 - this is a diode:
Pressure can come from the left and travel down - it'll push the shuttle out of the way and travel. But if pressure comes from the bottom pipe, it'll get stopped by the shuttle.
This is a NAND gate:
If positive pressure hits both of the shuttles from the left (purple), it'll connect the negative pressure (red) through to the output on the left. If they aren't both pressurized, at least one green will be connected.
I don't know what the blue cells are - I think this simulator had some way to ground out pressure to the environment.
These world files were originally stored as BMPs - which makes a lot of sense, and you edited them using a paint tool.
In early 2012 Jeremy Apthorp and I were hacking and ended up talking about steamos. I hadn't seen any of the picture at this point - but it was a great concept. We decided to whack together a simple simulator in coffeescript. The original simulator was 100 lines. We didn't even have any programs to use as reference - I'd never seen the original, but that didn't really matter. We just wanted a toy.
The thing we ended up building is impossible to build physically - we dumped some realism in favor of having a simple simulator that is easy to reason about. There's no concept of a vaccuum in our world - air isn't displaced, it merely has a pressure integer and walls default to a pressure of 0. But it looks like this:
This is a ceiling function - it simply takes positive or negative pressure as an input, and outputs positive or negative pressure. Because of a quirk of how the simulator works, if a shuttle has twice the surface area, pressure will have twice the effect - hence the larger plate on the left.
After spending a few hours making the simulator, Jeremy and I got horribly distracted simply making stuff with it - What does a multiplexer look like? Can you make a shuttle move back and forth along a tunnel? Oscillators are easy, but whats the smallest binary counter you can make? Our implementation is called Boilerplate, and the code is here.
This is 16 bits of addressable memory. The giant shuttles on the left wire a bit of memory into the output (which you can barely see) on the left. The cells themselves are on the right. A pressure value of two is used to write (using the same tunnel you can read from).
Over christmas I started making a CPU:
The main bus is on the top left, and the program counter on the top. I haven't finished it - so I don't think anybody has built a CPU with steam yet. I'm not sure that I will finish though - making a Von Neumann machine feels like its going against the grain of steam somehow. I might start from scratch and build a Forth machine or something like that.
I showed it publically for the first time in Jan 2014 to a standing ovation at SydJS. I keep getting a fantastic reception when I show people. There's now a haskell implementation of the simulator. I also wired it up to arduinos at nodeconf last weekend - I'm really tempted to attach it to some lego robots. And Jeremy and I started making a little safe crasking game using it, although its pretty broken at the moment.
I'm going to make a visual walkthrough / tutorial soon - I finished cleaning up the code today, so now its a lot easier to embed in a page or do whatever you want with (it hasn't been 100 lines for a long time now).
As of today, the boilerplate simulator is now its own npm module. I'm hoping to re-launch it in a week or so. I basically just need to host it somewhere now and I'm done! :D
Update: Boilerplate is hosted at josephg.com/boilerplate.