Hackaday 10th Anniversary: Non-Binary Computing

When [Thundersqueak] was looking for a project for The Hackaday Prize, she knew it needed to be a special project. IoT devices and microcontrollers are one thing, but it’s not really something that will set you of from the pack. No, her project needed to be exceptional, and she turned to logic and balanced ternary computing.

[Thundersqueak] was inspired to design her ternary computer from a few very interesting and nearly unknown historical computing devices. The first was the [Thomas Fowler] machine, designed all the way back in 1838. It could count to several thousand using a balanced ternary mechanical mechanism. The [Fowler] machine was used to calculate logs, and the usual boring mathematical tasks of the time.

A bit more research turned up the Setun, an electronic computer constructed out of vacuum tubes in 1958. This computer could count up to 387,000,000 with eighteen ternary digits. On the binary machine you’re using right now, representing that would take twenty-nine binary digits. It’s about a 2.5 times more efficient way of constructing a computer, and when you’re looking for the right vacuum tubes in 1950s USSR, that’s a great idea.

[Thundersqueak] isn’t dealing with vacuum tubes – she has a world of semiconductors at her fingertips. After constructing a few truth tables for ternary logic, she began designing circuits to satisfy the requirements of what this computer should do. The design uses split rails – a negative voltage, a positive voltage, and ground, with the first prototype power supply made from a 741 Op-amp. From there, it was just breadboarding stuff and checking her gates, transistors, and truth tables to begin creating her ternary computer.

With the basic building blocks of a ternary computer done, [Thundersqueak] then started to design a basic ALU. Starting with a half adder, the design then expanded to a full adder with ripple carry. We’re sure there are plans for multiplying, rotating, and everything else that would turn this project into a CPU.

39 thoughts on “Hackaday 10th Anniversary: Non-Binary Computing

  1. “On the binary machine you’re using right now, representing that would take twenty-nine binary digits.” So? Bits are cheap. A raspberry pi has 32, the machine I’m writing this on, 64. A 32 bit machine can count to 4,294,967,295. That’s ~11 times greater than the 18-trit value. Pardon my ignorance, I must be missing something here.

    Here’s something to consider: Why isn’t/wasn’t quaternary a thing? I would posit that quaternary being 4-some, didn’t (or can’t) offer anything over binary since 4 is a module (modulus?) of 2.

    Still it’s cool! Hat’s off to Thundersqueak for getting far enough with it to do a presentation of that quality and detail. I understand trinary a bit better now.

    1. Ternary is more efficient than either binary or quaternary (or any other *nary) for one very simple reason. It is the nearest whole number to the most efficient based that exists… which is e (2.71828…). Since e is an irrational number that cannot be represented in computational hardware, 3 is the next best thing because it is the nearest whole number.

  2. Apparently, Setun used an interesting combination of vacuum tube, diode-transistor and magnetic logic. http://tinyurl.com/l4fwuso is a PDF which has some accounts of the machine.

    Specifically, on page 6, “The machine contains 4,000 magnetic cores, 4,000
    germanium diodes, approximately 100 transistors, and 40 vacuum tubes.” And on page 9, “However, whereas the SETUN uses magnetic circuitry in its arithmetic unit…”

    I’d like to see how or if a ternary magnetic logic gate works.

  3. “We’re sure there are plans for multiplying, rotating, and everything else that would turn this project into a CPU.”

    Sorry to nitpick, but while bit shift and rotation are rather easy to do (a right shift being particularly useful), I wouldn’t hold my breath on multiplication. Doing multiplication in a single shot takes large numbers of ANDs and adders, regardless of what tricks you use. A single adder could be used if [Thundersqueak] was going the microcode route, but I imagine she’ll just leave out a multiplication instruction and have the programmer use a multiplication subroutine, like in most early CPUs and some microcontrollers.

    Of course I have no experience in ternary logic, so I’m working off my binary experience here. This makes me curious: are 3-operand functions (ex. 3 input add) easier in ternary because of the three states?

  4. Would booleans be different in a ternary computer? Would they be called trooleans? There’d be some wasted space (or at least extra logic needed) to store it efficiently, think of 24-bit color (8 bits for each of the r, g, and b) not really fitting into the 32-bit path. A boolean is true and false, if it’s true, false and something else (half truth??) then we don’t really have a boolean anymore. Think of how important booleans are in computer science. That could answer some question of why ternary never made it– I’m not really buying the notion that binary “just caught on quicker”. There are fundamentals, I believe.

      1. Yup, it’s a troolean! Having a third state in a boolean, at best, taints the meaning of true (or false!) and reminds me of PHP’s wretched way of dealing with booleans with all its triple operators, having to use isset() and other programming malpractices. Just one example of the “extra logic” I hinted at. I’m not saying ternary can’t deal with booleans–just not as efficiently as binary.

    1. Booleans are already represented extremely inefficiently most of the time in binary computers; in C and most languages inspired by it sizeof(bool) == sizeof(char) == 1 (i.e. 8 bits). Which is part of the reason for the horror of C++’s std::vector. Fortunately std::bitset eventually came along.

      1. That was supposed to refer to std::vector’s bool specialization.

        HaD: Please don’t silently strip out anything that happens to look like an SGML tag. It’s really not that hard to convert >< to ><

  5. A negative voltage could work, I’ve pondered this before. But for those suggesting multiple voltage levels, that won’t really work and here’s why:
    When you ramp this up to max frequency, that data stream doesn’t look like square waves anymore, you lose the edges. And the data is flying so quickly that you don’t see a full voltage flat spot unless it’s more than ‘1’ in a row. Practically on the verge of ADC conversions happening. This is highly exaggerated with HDD platter reading, they actually do straight up analog to digital signal processing. So you would have to slow things down enough that 1/2 V could be determined as an actual intermediate voltage level vs alternating ‘1’ and ‘0’ bits.
    If the only other value to consider is ‘-1’ then this problem doesn’t actually get worse. Probably easier.. but any input capacitance will cause about twice the switching loss, among the myriad of other issues in rethinking conventional logic circuits to accept negative voltages.

  6. I just realized while reading the overview why ternary computing never took off. In a binary system you call each significant place a bit, shortened from binary digit. You’d run into a problem shortening ternary digit in the same way, and no one would take the time to say it the long way.

      1. Can you imagine problems with the Computer Architecture classes though? “Alright everyone, your assignment is to design a 16-tit ALU. Any questions?” “Can I bring a friend?”

  7. I think its a huge conspiracy–and all computers are really ternary machines. After all, the ATX power supplies all have a -12v rail that supplies an amp or less. It’s powering the real, ternary computer in there. All them other 5 volt, 3.3 volt rails are just in there drawing power to dissipate through the heat sinks, to cause climate change and help make the power companies more money. It’s repression, man.

  8. Wait… how are you going to output data? Blinkenlights are binary (on/off) and you’ll run into a lot of trouble trying to hook it up to a terminal -unless of course the data is translated back into binary

        1. That’s how I was doing it on the breadboard, just 2 LEDs setup so that if it was negative one lit and if positive, the other lit. You could also just use a dual color LED, but since I had lots of single color ones that is what I used. I have also made use of an analog multimeter and just watched the needle swing.

          1. I built a ternary computer in 2012 as a 4th year project in my engineering degree. I used an FPGA, which was the enabling technology as well as its limitation.
            Despite the academics saying it couldn’t be done, I did.
            In the early stages I had studied the Setun, and found it confusing, translated by people who did not understand it.
            I reviewed the SETUN again at the end, and it all made sense. We had in fact followed very similar paths.
            There has been some misinformation about the SETUN in hackaday pages. It did not used valves. Its memory used two magnetic rings per trit, meaning it ignored the fourth state.
            In the early stages where I tested modules, I used LEDs to show states. Off meant N (or -1), Dim meant 0, and full on meant 1.
            The completed 12-trit processor ran at 2.5MIPS, and included multiply & divide instructions. I wrote a ternary BIOS for it and used a serial terminal for communicating with it and sending it programs to run.
            After graduating I continued with development because it was so interesting.
            Currently on the shelf while I work on other projects. I still think ternary is awesome!

  9. Logic takes up very little total die space in our modern computers. Memory consumes most of it. We already have multi-level flash; DRAM and SRAM will probably turn that direction as our silicon process reaches its limits in a couple years.

  10. Ternary logic may well have advantages for multiplication. A ternary encoding called Canonical Signed Digit (CSD) is sometimes used even now on binary computers to speed up multiplication because it minimises the number of non-zero bits. Each digit can have values -1, 0 or 1.

  11. The next step in this project is putting everything together, the parts are on order for this. I am switching over to the DG403 from vishay as it has a similar internal schematic and after playing with some, I think I can make it work. :)

    I was looking at old tech a while back and was musing that a magnetic core memory could have been possibly used to store a ternary value, given that you could orient the magnetic field, or simply have it “off” allowing for 3 possible states. As cool as tinkering with recreating a magnetic core ram module would be, I will probably go the transistor route.

  12. Just watched the presentation. Interesting stuff! Your trinary gates have a very “CMOS” look. I’d expect the gates to have a trade off between power consumption with zero inputs, and the stability of zero outputs. Have you considered moving to more ECL style gates? ECL is based around the “long tailed pair” differential amplifier and I’d expect it to be stable with +, -, and 0 voltages. ECL can be blindingly fast, but usually uses a lot of power. Though I have seen one article on using ECL like circuits at low voltages to save power.

  13. i think it’s a great idea, maybe you can make a project on kickstarter,
    but i’m thinking about a thing: in theory when you transmit ternary signal you will have probably have some troubles with error propagation, to solve this you can develope a ternary/binary and a binary/ternary converters, or you can just adapt hamming code to the ternary math

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.