SETNEX  /  Open Ternary ISA  /  v0.8

Balanced ternary
instruction set

A clean-slate, open ISA for balanced ternary computing. 27-trit words. 27 registers. Fixed-length instructions. 5 configurable ternary logics via LMODE.

Apache 2.0 Balanced ternary {−1, 0, +1} v0.8 — specification RISC-inspired Patent-free Python simulator
0
+
0
+
0
0
+
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

↑ ADD r3, r1, r2 — 27-trit instruction (LST-first, t[0] left)

Core parameters

Word width
27 trits = 3³
Registers
27 general-purpose (r0–r26) + 27 vector (v0–v26)
Instruction width
Fixed — 27 trits
Instruction formats
R / I / J / U / B
Opcode
4 trits — 81 values (60 used)
Address space
±3.6 × 10¹² words
Endianness
Little-endian (t[0] = LST)
Ternary logic
5 modes — LMODE + STATUS.lx
Arithmetic flags
2 ternary — sign / carry
Floating-point
T26F — 26-trit Tekum tapered precision
Division
Symmetric Euclidean
Licence
Apache 2.0 — patent grant included

Instruction formats

Five formats share the same 27-trit fixed-length word. The opcode sits at t[0]–t[3] (LST) — the decoder starts working before the full word has arrived.

R — register–register
opcode4t
rd3t
rs13t
rs23t
funct — 14 trits
I — immediate
opcode4t
rd3t
rs13t
imm17 — ±64 million
J — conditional branch
opcode4t
rs13t
offset20 — ±1.7 billion (PC-relative)
U — unconditional jump
opcode4t
offset23 — ±4.7 × 10¹⁰ (PC-relative)
B — ternary three-way branch (new in v0.3)
opcode4t
rX3t
off_z10t ±29 524
off_n10t ±29 524

Format B encodes three outcomes in one instruction — P falls through, Z and N each carry an independent PC-relative offset. Zero wasted trits.

Five configurable ternary logics

The LMODE CSR and STATUS.lx trit select the truth tables for all logic instructions (TAND, TOR, TNOT, TIMPL) at runtime. All five IMPL tables are distinct. Same code, different epistemology, one register write.

N · N
Heyting
Intuitionistic — NOT and IMPL differ
N · Z
Łukasiewicz
Order test — IMPL(a,b) = P iff a ≤ b
N · P
RM3
Paraconsistent — contradictions don't explode
Z
Kleene
Default at reset — SQL 3VL, neutral
P
B3 (Bochvar)
Z infectious — meaningless contaminates

CONS, ACONS, and TCMP are LMODE-insensitive — they are ternary-native comparison primitives that form a complete trit-comparison toolkit.

Vector extension — trit-parallel SIMD

v0.8 adds a dedicated 27-register vector bank (v0..v26) with a trit-parallel datapath: each lane is a single trit, 27 lanes per word. Eight new opcodes (+15..+22) amortise fetch/decode over 27 simultaneous trit operations and expose ternary-native primitives that have no clean binary equivalent.

VADD · VMUL
Arithmetic
Lane-wise add and multiply over balanced trits
VLOG
Logic (fused)
TAND/TOR/TNOT/TIMPL + CONS/ACONS, sub-mode in funct
VSEL · VCMP
3-state mask & trichotomy
Native ternary mask; one VCMP returns </=/>
VRED
Reduction
Sum, min/max, Kleene-consensus across lanes
VPERM · VMOVE
Permute & bank bridge
Rotate/shift/reverse/shuffle; GPR↔v-reg moves

The format set is unchanged — vector opcodes reinterpret the existing R-format register fields as v-reg indices. Two opcodes (+23, +24) are reserved for v0.9 (fused multiply-accumulate, gather/scatter). v0.8 is purely additive: existing v0.7 binaries run unmodified.

Ternary ML at 1.58-bit (BitNet-style weights ∈ {−1, 0, +1}) maps directly onto the lane width — one v-reg holds 27 weights, one VMUL + VRED computes a dot product without packing.

Related work

Setnex is not the only balanced ternary project. A small but active community has been building ternary hardware, simulators, and documentation — some for decades. Setnex positions itself among them as an open, logic-configurable ISA, distinct in its goals but indebted to prior art.

Setnex vs. 5500FP — a side-by-side

The 5500FP is the closest living cousin of Setnex: another balanced ternary RISC ISA with real hardware behind it. The two projects answer different questions, and their differences are worth making explicit.

Word / instruction
Setnex: 27 trits · 5500FP: 24 trits
Opcode encoding
Setnex: fixed 4-trit · 5500FP: extensible by prefix (6 levels)
Instruction count
Setnex: 60 (v0.8, incl. vector ext) · 5500FP: ~120 (v1.1)
Instruction formats
Setnex: 5 (R, I, J, U, B) · 5500FP: 10 (A–F, J, J2–J4)
Logic modes
Setnex: 5 configurable (Kleene, Łukasiewicz, Heyting, RM3, B3) · 5500FP: Kleene only
3-way branch
Setnex: BRT3 (native, one instruction) · 5500FP: synthesized from binary branches
3-way select
Setnex: TSEL on FLAGS.sign · 5500FP: not present
Multi-precision carry
Setnex: ternary ADC/SBC (carry ∈ {N,Z,P}) · 5500FP: not documented
Floating-point
Setnex: T26F Tekum (tapered precision) · 5500FP: integer-only
Vector / SIMD
Setnex: 27-lane trit-parallel (v0.8, 8 opcodes) · 5500FP: scalar only
Atomics
Setnex: roadmap (v0.7+) · 5500FP: CAS, FAA native
Hardware status
Setnex: Python simulator · 5500FP: FPGA running (Efinix Trion, 20 MHz)
ISA licence
Setnex: Apache 2.0 + patent grant · 5500FP: proprietary, patent pending
Hardware licence
Setnex: n/a yet · 5500FP: CERN-OHL-P (board only)

In short: the 5500FP is a ternary processor of the engineering tradition — rich instruction set, mature tooling, atomics, and real silicon through FPGA. Setnex is a ternary ISA of the logical tradition — minimal core, configurable multi-valued logics, ternary-native control flow, and an open specification. They are complementary, not competing: if you want to run ternary code on real hardware today, look at the 5500FP. If you want to experiment with the epistemology of three-valued reasoning, Setnex is built for that.

Read more

Get started