This is the eleventh article in a twelve-part series that discusses the twelve finalists and their calculator submissions for the OMGWTF Programming Contest. The entries are being presented in the order submitted, and the winner will be announced on June 18, 2007.


NPN TransistorVirtualization was not an uncommon theme among several of the OMGWTF entries. It only makes sense: why stop at abstracting layers of software when the entire hardware platform might need to be changed later on? Sure, some might argue that the “operating system” or “compiler” can handle all those changes, but why risk it? Entry #100336 (Randolpho St. John’s VICE, Virtual Integrated Circuit Engine) sure didn’t: it took the concept of a virtual machine way too far.

Some of the virtualization-themed entries focused a “high-level” approach: a virtual CPU that implemented a custom assembly code. Others went “low-level,” implementing logic gates, adders, etc. Although no entry was able to do it all (everything from transistors to CPUs), VICE was the cleanest, closest, and had a very clear path to full implementation.

At the core of VICE lies the VirtualTransistor. It is essentially a switch (modeled after an NPN transistor) that sends current to its output (“Emitter”) only if it receives current from both its input (“Collector”) and its switch input (“Base”). Of course, a transistor is useless without current flowing to and from, so the VirtualConnection was built: it is a virtual wire with a single Boolean indicating whether there’s current or no current flowing through.

But even with VirtualTransistors and VirtualConnections, something is still needed to simulate the “flow” of electricity from wire to transistor to wire, and so on. This is where the VirtualComponent abstract class comes in: it has a single method (Update()) that instructs the implementing class to read its inputs and update its outputs.

Once the VirtualTransistor, VirtualConnection, and VirtualComponenet classes were built, it was merely a matter of dusting off some old digital electronics books and “wiring together” the rest: VirtualJunctions, VirtualFlipFlops, VirtualMultiplexers, VirtualBinaryAdders, and so on. Randolpho’s original design included a Turing-complete VirtualCPU (complete with its own instruction set), a VirtualALU, a VirtualFPU, and VirtualMemory, all entirely through VirtualConnections and VirtualTransistors.

Unfortunately, time constraints made that impossible. As it turns out, with three kids and a fulltime job, “every spare moment” over fifteen days is only enough to build full 32-bit integer addition, subtraction, and multiplication. Despite that, we were still very impressed by not only the cleverness, but the sheer elegance of the VirtualTransistor/VirtualConnector architecture. It was the ultimate inner-platform effect: developing software to run on hardware that was built with software that runs on hardware.

The code is certainly worth downloading and reading through. It’s not buggy or “WTF-y,” but is more an example of the ultimate in over-engineering. What’s really interesting about all of this (or, more of a testament to how fast computers are), is that, as an end user of VICE, you’d never notice the difference in speed.

As for VICE’s author, Randolpho is currently an ASP.NET developer at a financial services company in Nashville, Tennessee. He was awarded a bachelors degree in Computer Science from Tennessee Tech. And he still wouldn’t use VICE for himself…

Although VICE works and is surprisingly performant thanks to fast CPUs and a decent optimizing compiler, no, I wouldn't replace calc.exe. Windows Calculator is a very versatile program, especially the scientific view.

Download Entry #100336, VICE, Virtual Integrated Circuit Engine (ZIP File)