Tunguska – Ternary, 6502-like processor emulation

This project isn’t particularly new (2008), however, besides its merits of having conquered the Hacker News front page (which brought this to my attention), it combines two topics some of us seem to like here: the mostly unfulfilled promises of ternary computing and the simplicity and accessibility of the 6502 processor:

Tunguska is a ternary computer emulator. On a good day, it’s performance it is roughly equivalent with that of a personal computer from the 1980’s, with peak speeds around 1,000,000 operations per second, on a more normal day roughly 250,000 ops/sec.

It is loosely based on the excellent design of the (binary) 6502-processor by MOS Technology, but entirely ternary. So instead of having two memory cell states (0, 1), it has three (-1, 0, 1).

The machine uses tryte-width (tryte = ternary analog to “byte”) 6, with 3⁶=729 states per tryte.

The name is both a tip of the hat to the predominantly russian heritage of ternary computing, and an (obsolete) in-joke about the stability of an earlier version.

Apparently, it isn’t just an emulator, but an entire suite consisting of, besides of the emulator itself, of an assembler, a C-compiler and an operating system providing core functionality like IO. About everything required in order to provide a playground for exploring ternary computing:

“I wonder how it would be if my computer was ternary?”, I asked myself a while back. I googled around, and found a few stub-ish wikipedia articles, a few pages explaining why ternary computing is vastly superior to everything, and some documents discussing russian experiments in the 1950’s.

Obviously, this wouldn’t do. I wanted a hands-on computer I could play with. So I got to work, and a few months later, this is the result.

So, the purpose is to provide a simple and accessible, yet powerful playground for ternary computing for the man in the street (with a decent understanding of assembly programming and general computer infrastructure).

Also, the design goals listed on the pages are rather attractive:

The goal of the project is primarily enjoyment, but undirected programming won’t really produce anything useful, so some sort of priorities and goals need to be defined. In descending order of importance:

  1. Simplicity / usability
  2. Speed
  3. Beautiful code
  4. Experimentation

Is “charming” an appropriate attribute for a software project?

Tunguska is available for GNU/Linux, FreeBSD, and MS Windows.
(A proper build requires SDL, zlib, bison and flex.)

HN discussion: https://news.ycombinator.com/item?id=25616994

4 Likes

Why must ternary have more logic functions than binary?
0 is 0 -1 or 1 is true. -1 could be maybe. If cloudy sun 0
snow -1 rain -1.

Nice project - perhaps an educational demonstrator rather than a practical proposition. A bit like a relay computer. Fun to have one (I imagine.) But in this case, a stalled project - at least there’s a trace of it which might inspire a successor.

As for ternary logic, I think the way to look at it is what kind of truth tables can you build, and how useful they are. I wouldn’t worry too much about the possible meanings of 3 states. After all, we commonly use a byte to represent a small number of selections, not necessarily all 256 possibilities.

Interesting about the ‘balanced nonary’ as a notation though: A, B, C, D are negative values, to be used in a set with 0, 1, 2, 3, 4.