Circuit Design With Quartz Composer

You didn’t think it would be done, did you? You didn’t think one person would have enough free time, boredom, and sheer ingenuity to do it, but I did.

The other day I sat down to write an entry to the esteemed contest, ironcoder. This was short lived however, because I got sucked in by a virtually unknown gem of 10.4: Quartz Composer. I was browsing around dragging random ‘patches’ into the canvas, when I saw an innocuous line in the patch library.

This little patch holds the same power that started the computer revolution. Armed with my limited digital design knowledge, I set out to create some well known circuits from within Quartz Composer. I started out building a full adder. This takes three inputs and produces two outputs. When you chain these together, you can make an N bit adder. You have one in your CPU right now, chugging away at thousands of operations a second.

This allowed me to string them together to create a 4 bit adder.

This produces the following output:

After this I knew what I had to do. I had to create the foundation of modern computer storage…the flip flop. This little guy holds a bit (binary digit) indefinitely. If you want a fast way to store data close to a processor…this is the way to do it.

CPUs have things called registers that are basically a bank of flip flops with some logic to do different operations. So my next task was to create something like that. Because of a limitation with Quartz Composer (it can’t do recursion), I had to not implement some features I wanted to. I ended up with a parallel load register that could ‘hold’, ‘load’, and ‘clear’.

I then plugged that register into a small test flow that would print out the contents.

And it produces the following output when you hold the load line high on the next rising edge of the clock:

So there you have it. The escapades of a bored college student. Mess around with the following stuff and email me (zacwhite at gmail.com) or IM me (cubeman) if you make some modifications.

4bit.zip
flipflop.zip

10 responses to “Circuit Design With Quartz Composer”

  1. Justin Blanton | Circuit design with Quartz Composer

    [...] Circuit design with Quartz Composer. [...]

  2. Rhonabwy - logic circuits with Quartz Composer

    [...] This is just too good – Zac White created a logic circuit simulator with Quartz Composer. That’s just awesome. Completely useless for me, but boy does it bring back memories (the UI is a hell of a lot nicer than what I used to use with spice too!) [...]

  3. Scott

    Very neat.

    You can also do similar things with OmniGraffle. One of the sample documents for that application is a half-adder built using AppleScript actions attached to shapes within a document.

  4. Daniel McLaury

    A ripple-carry adder in 2006? Pssh.

  5. Scott Bayes

    “chugging away at thousands of operations a second.”
    Tens of thousands, even :-)
    I figure the program counter has to increment for each fetch, plus the code will contain numerous branch computations, add instructions (and subtracts, multiplies, divides, etc will all undoubtedly use additions somewhere deep in their bowels), plus register indexing and oyher stuff. Probably adds up to more than hundreds of thousands of adds per seconds, especially with my PBook’s 1.5 GHz clock. Lots more :-)
    This effort reminds me of back in the 80s when one of our hardware teams implemented our first hardware assist for the frame buffer (till then, all pixels were computed and placed in the fb by the CPU). I immediately suggested using it to do simple “parallel” arithmetic (more like SIMD, since the graphics h/w cycled sequentially through the pixels rather than swell fooping it in true parallel fashion). One of the guys took me up on it and implemented a visual adder, with the frame buffer displaying inputs and outputs while they were being computed. Totally worthless, but fun, in that twisted geek fun way.

  6. Jeff Lindsay

    You realize this is the key to a potential world of mainstream programming, where normal people are able to program. The idea of graphical programming has been around for a long time, but I really think it should start to be taken seriously.

    In the game industry they’ve been battling with some of the most complicated systems, both as far as software and overall production. They’ve been trying to empower content creators with the ability to easily embed logic in the content and make it easier for designers to work on gameplay without becoming programmers. The new Unreal tech is all about these graphical programming environments with several tools that look exactly like Quartz Composer.

    Work like DabbleDB and some of the things you’ve been doing with editable UIs and realtime environment manipulation have been really inspiring me in this area. This is the kind of stuff that I’m really interested in.

  7. Jeff Lindsay

    Doh, thought you were somebody else! :P

  8. John

    The idea of graphical programming has been around for a long time, but I really think it should start to be taken seriously.

    But this, like every graphical programming system before it, suffers from the problem of being much more complicated than writing code. I don’t want to say we’ll never program complex systems graphically, but the odds aren’t very good. There’s a reason why we stick to writing stories instead of drawing pictures, and those reasons extend into the programming domain.

  9. willlow

    If you are interested quartz composer visit http://www.quartzcompositions.com and get hundreds of samples, documentation wiki and forum.

  10. Red Sweater Links » Blog Archive » Quartz Composer Circuit Design

    [...] Link. [...]