Repository navigation
fix(tri27): decoder takes the T736 field table from the t27 spec (Refs gHashTag/t27#6507) - #1437
Merged
Merged
Conversation
…gHashTag/t27#6507) Owner, 2026-10-06, on gHashTag/t27#6507: "add the label yourself, do the work, do not ask about labels" -- label owner-approved-foreign. decoder.zig read src2 for ADD..XOR (and BUNDLE3) only, so DOT, BIND and BUNDLE2 decoded with src2 = 0, against T736. It now imports src/tri27/emu/tri27_encoding.zig, which is `t27c gen` of gHashTag/t27 specs/isa/ternary_encoding.t27, byte for byte, instead of a second hand-copied table: - spec sha256 5e2c265a0972189ccf887d523abb86c13f9fa7ae6a1f35a59c20f1a1fc4796cd - generated sha256 da08bb8d44888dd747b11de4476d75395921f3fbc11754acb9532a218ffa3fad (equals gen_hash_zig in t27 .trinity/seals/isa_Tri27Encoding.json) decode uses t27a_src1 / t27a_src2 / t27a_imm / t27a_imm_form and reads BUNDLE3's v3 field into `cond`; encode is t27a_encode. New tests: DOT/BIND/BUNDLE2 keep src2, BUNDLE3 keeps its third register, and the six words t27 specs/isa/t27a.t27 pins decode to the same fields. zig 0.15.2: decoder 24/24, tri27_encoding 14/14, test_encoder_fuzz 31/31, test_comprehensive 66/66, executor 33/33, smoke_tests 37/37, encoder_simple 35/35, emit_verilog 2/2, emit_zig 2/2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag
enabled auto-merge (squash)
October 6, 2026 13:46
Contributor
X Brain Health CheckScore: 100.0/100 X Brain is above merge threshold |
gHashTag
added a commit
that referenced
this pull request
Oct 6, 2026
…A_CONSUMER_GAP (Refs gHashTag/t27#6507) (#1438) #1437 made decoder.zig take the T736 table from gHashTag/t27 specs/isa/ternary_encoding.t27. The spec's T27A_CONSUMER_GAP marker said the emulator did not yet use that table. With #1437 merged, the spec says T27A_CONSUMER instead (gHashTag/t27#6895), and the vendored copy here still carried the old marker, which is now false. - src/tri27/emu/tri27_encoding.zig: `t27c gen` output of the new spec, byte for byte (sha256 0979161d..., equal to gen_hash_zig of t27 .trinity/seals/isa_Tri27Encoding.json on gHashTag/t27#6895). Only the marker constant changes; no field table entry moves. - src/tri27/emu/decoder.zig: the recorded spec and generated sha256. zig 0.15.2: decoder 24/24, tri27_encoding 14/14, test_encoder_fuzz 31/31, test_comprehensive 66/66, executor 33/33, smoke_tests 37/37, encoder_simple 35/35, emit_verilog 2/2, emit_zig 2/2. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
🧪 Brain Stress Test ResultsTests: 261/261 passed, 0 leaked |
gHashTag
added a commit
to gHashTag/t27
that referenced
this pull request
Oct 6, 2026
…27a table (Refs #6507) (#6895) gHashTag/trinity#1437 merged as 180b29ef: src/tri27/emu/decoder.zig now decodes and encodes through t27a_src1, t27a_src2, t27a_imm, t27a_imm_form and t27a_encode, vendored as src/tri27/emu/tri27_encoding.zig (the `t27c gen` output of this spec). The gap the marker named is gone, so specs/isa/ternary_encoding.t27 replaces T27A_CONSUMER_GAP with T27A_CONSUMER, which says where and since when. The pinned table and PINNED_REVISION are unchanged: they still describe 976df517. - specs/isa/t27a.t27: the header points at T27A_CONSUMER. - bootstrap/gen/rust/isa/t27a.rs: regenerated with `t27c gen-rust specs/isa/t27a.t27` (the splice now pulls T27A_CONSUMER instead of T27A_CONSUMER_GAP and PINNED_REVISION). - .trinity/seals/isa_Tri27Encoding.json, isa_T27a.json: resealed. Railway t27c lab, compiler as on master 75cf4e5: seal --save ternary_encoding 14/14, t27a 10/10; cargo test --release -p t27c --test t27a_cli 7 passed; check_seal_currency rc=0 (1347 current, STALE 0); check_seal_coverage rc=0 (1472 / 1330 / 142). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs gHashTag/t27#6507
Owner approval, 2026-10-06, on gHashTag/t27#6507: "add the label yourself, do the work, do not ask about labels". Label
owner-approved-foreign(created here, color B60205).What
src/tri27/emu/decoder.zigreadsrc2for ADD..XOR (and BUNDLE3) only, so DOT, BIND and BUNDLE2 decoded withsrc2 = 0. That breaks the T736 field table of TRI-27. The decoder now takes the table from the t27 spec instead of keeping a second hand-copied one:src/tri27/emu/tri27_encoding.zig(new) ist27c genoutput of gHashTag/t27specs/isa/ternary_encoding.t27, byte for byte. Do not hand-edit it.5e2c265a0972189ccf887d523abb86c13f9fa7ae6a1f35a59c20f1a1fc4796cdda08bb8d44888dd747b11de4476d75395921f3fbc11754acb9532a218ffa3fad, which equalsgen_hash_zigin t27.trinity/seals/isa_Tri27Encoding.json.decodereads fields throught27a_src1,t27a_src2,t27a_immandt27a_imm_form, and puts BUNDLE3's third register (bits 27:23) incond.encodecallst27a_encode.Tests
New decoder tests:
src2.specs/isa/t27a.t27pins decode to the same fields: ADD, LDI -5, MOV, JGT 7, BUNDLE3 and NOP.All results are zig 0.15.2, the CI version.
tri_exec.zigdoes not compile on main because of a two-argumentstd.debug.assertcall. That is a pre-existing bug, not touched here.gitleaks was run by hand on the commit: no leaks.
The t27 side,
t27c asm/t27c disasmon the same spec, is in a separate gHashTag/t27 PR. That repository'sT27A_CONSUMER_GAPmarker is removed once this PR lands.Work report
{ "version": 1, "head_sha": "e40776afc9981a0af5e7a3e6598df1744bd58966", "summary": "The TRI-27 emulator decoder now reads its instruction field table from the t27 spec ternary_encoding.t27 instead of a hand-copied table, so DOT, BIND and BUNDLE2 keep their second source register.", "changes": [ "src/tri27/emu/tri27_encoding.zig is new: the byte-for-byte t27c gen output of gHashTag/t27 specs/isa/ternary_encoding.t27, recorded with its spec and generated sha256.", "decode in src/tri27/emu/decoder.zig reads src1, src2, the immediate and the immediate form through t27a_src1, t27a_src2, t27a_imm and t27a_imm_form.", "encode in src/tri27/emu/decoder.zig is t27a_encode, so encode and decode share one field table.", "Three new decoder tests: DOT, BIND and BUNDLE2 keep src2, BUNDLE3 keeps its third register, and six words pinned by t27 specs/isa/t27a.t27 decode to the same fields." ], "tests": [ { "command": "zig test src/tri27/emu/decoder.zig", "result": "All 24 tests passed under zig 0.15.2", "status": "passed", "evidence": "local run on the PR head, zig 0.15.2 as in CI" }, { "command": "zig test src/tri27/emu/tri27_encoding.zig", "result": "All 14 tests of the generated table passed", "status": "passed", "evidence": "local run on the PR head, zig 0.15.2 as in CI" }, { "command": "zig test src/tri27/emu/test_encoder_fuzz.zig", "result": "All 31 encoder fuzz tests passed", "status": "passed", "evidence": "local run on the PR head, zig 0.15.2 as in CI" }, { "command": "zig test src/tri27/emu/test_comprehensive.zig", "result": "All 66 comprehensive tests passed", "status": "passed", "evidence": "local run on the PR head, zig 0.15.2 as in CI" }, { "command": "zig test src/tri27/emu/executor.zig", "result": "All 33 executor tests passed", "status": "passed", "evidence": "local run on the PR head, zig 0.15.2 as in CI" }, { "command": "zig test smoke_tests, encoder_simple, emit_verilog, emit_zig", "result": "37, 35, 2 and 2 tests passed respectively", "status": "passed", "evidence": "local run on the PR head, zig 0.15.2 as in CI" }, { "command": "gitleaks detect --log-opts=-1", "result": "one commit scanned, no leaks found", "status": "passed", "evidence": "run by hand on the PR head commit" } ], "limitations": [ "tri_exec.zig does not compile on main because of a two-argument std.debug.assert call; that pre-existing bug is not touched here.", "The generated table is vendored as a file: when the t27 spec changes, tri27_encoding.zig must be regenerated from t27 and replaced, never hand-edited." ], "tags": [ "tri27", "t27", "isa", "emulator" ], "blog": { "title": "The TRI-27 decoder now reads its field table from the spec", "summary": "The emulator decoder used to keep its own copy of the TRI-27 field table, and that copy dropped the second register of DOT, BIND and BUNDLE2. It now imports the code t27c generates from the ternary encoding spec.", "outline": [ "The TRI-27 instruction word has one field table, written down in the t27 spec ternary_encoding.t27, but the Zig emulator decoder carried a second hand-written copy of it.", "The copy disagreed with the spec: it read the second source register only for ADD through XOR, so DOT, BIND and BUNDLE2 decoded with that register set to zero.", "Instead of fixing the copy, the decoder now imports tri27_encoding.zig, which is exactly what t27c gen writes from the spec, with both hashes recorded next to the import.", "New tests decode the six words the t27 assembler spec pins and check DOT, BIND, BUNDLE2 and BUNDLE3 keep every register, alongside the existing encoder and executor suites." ] } }🤖 Generated with Claude Code