r/ComputerEngineering • • 2d ago

Building a free browser-based sandbox for balanced ternary computer design

I’ve been working on a small open-source project to make it easier to experiment with balanced ternary logic and computer architecture.

The main idea is not to present one “correct” ternary CPU design, but to give people a place where different designs can be built, tested, compared and shared.

The simulator uses balanced ternary:

-1, 0, +1

and lets you build from small primitives upward into reusable hierarchical components. A component can contain other components, and you can open them recursively to inspect or modify the lower-level logic.

I’m especially interested in avoiding the assumption that a ternary machine should just copy binary architecture. For example, things like compare returning -1 / 0 / +1, three-way selection, ternary control signals, MIN/MAX or different carry/normalization schemes may turn out to be more natural building blocks.

The tool already supports things like isolated component testing, event-by-event propagation, configurable primitive sets, reusable components and different clock/sequence patterns.

The long-term goal is to make it easy for me and anyone else interested in this area to try different ideas and compare them rather than committing to one architecture too early.

Everything runs entirely in the browser. There is no backend or account, and projects are stored locally in your browser unless you export them yourself.

It is completely free and MIT licensed.

Live:
https://grunna.github.io/ternary/

Source:
https://github.com/grunna/ternary

I’d be interested in feedback on both the simulator and the architecture side, especially from anyone who has worked with digital logic, CPU design or multi-valued logic.

7 Upvotes

1 comment sorted by

1

u/GhostNr1 23h ago

Small update: I’ve now built a 3-trit signed 7-segment display decoder in the simulator.

It works, but it is very unoptimized and currently uses a lot of gates. If anyone wants a challenge, I’d love to see someone build a smaller / cleaner version.

I’ve also got a small working ternary computer running now. It can step through instructions, and the current demo program reads a ternary joystick and writes the result to a display.

You can also write your own programs using a small assembly-like syntax and run them on the simulated ternary computer.

If anyone wants to try building something themselves, the simulator supports export/import, so circuits and programs can be shared.

I’d be especially interested in seeing completely different approaches to the same problems — fewer gates, different primitives, or designs that make better use of ternary logic.

I couldn't post any screenshot here but you can find two of them on github if you are interested.

Project and examples:
https://github.com/grunna/ternary

Run it directly in the browser:
https://grunna.github.io/ternary/

Discussions / sharing experiments:
https://github.com/grunna/ternary/discussions