Tern is a self-hosting language experiment for the MHX-T2 ternary SoC. Version 1 has one target: MHX-T2.
Its seed compiler is deliberately written by hand in MHX assembly. Host-side Python is used only as mechanical test glue to assemble MHX code and drive the CPU simulator; it is not part of the Tern language implementation.
The repository contains the hand-written Subset S seed compiler, bootstrap data, and an end-to-end harness. The seed assembles and compiles programs on the simulated chip: arithmetic (+ - & | ^ << >>), comparisons (== != < > <= >=), if/else, while, for, user functions with value returns, nested calls, recursion, arrays, const/globals/locals, brk and asm("..."). See stdlib/std.tn (division, print_u32) and examples/*.tn.
-
Python 3.11+
-
Access to the private MHX-T2 reference toolchain (assembler + simulator), pointed to by
TERN_CHIP:set TERN_CHIP=C:\path\to\toolchain python -m unittest discover -s tests -p "test_*.py" -v
The bootstrap tests assemble seed/seed.asm through the reference assembler
and execute it in the reference simulator. Without the toolchain they skip
gracefully; tests/test_static.py (source sanity, no toolchain) always runs.
seed/ hand-written MHX assembly seed compiler and bootstrap artifacts
tests/ host-only bootstrap and end-to-end verification glue
docs/ frozen Subset S and bootstrap contract
examples/ small verified Subset S programs (.tn)
.github/ public CI workflow
Tern is source-available under the Tern/Triad Source-Available License. Non-commercial use, study, and modification are permitted; commercial deployment, resale, and hosted commercial use require a separate written license.
See the language and bootstrap contract, the contribution guide, and the security policy.