nx_codon.nx
buildroot/runtime/nx_codon.nx
about
nx_codon.nx -- smallest re-targetable IR atom (silicon emission unit).
Biology: codons are 3-nucleotide units that ribosomes translate
into amino acids. Nishi codon is the smallest unit nx_ribosome
(and the existing nxc2 codegen backends) translate into target
machine code. ONE codon = ONE primitive operation emittable to any
of the 14 nxc2 backends + the future SILICON_HDL backend.
Per [[feedback-pathway-tropism-block-composition-location-agnostic]]
vision: same .nx pathway runs on Cortex-M0+ (Thumb), x86_64,
PTX (NVIDIA GPU), and Nishi silicon HDL -- because the underlying
codons are the substrate's invariant. Codons compose into the
rest of the cell's behavior.
V1 ships:
- sealed enum NxCodonOp (13 ops sufficient to express any cell)
- struct NxCodon (op + operand_a + operand_b + target_hint)
- struct NxCodonStream (ordered sequence of codons)
- append + iterate + validate verbs
Per Captain Moroni doctrine: codons are PURE DATA. They describe
what to compute, not how -- the ribosome translates per-target.
Substrate cannot embed offensive ops in codons because the op set
is sealed (no DRONE_STRIKE / FIRMWARE_INJECT / etc).
dependencies 3 imports · 2 importers
imports: nx_syscalls.nxnx_tier.nxnx_ribosome.nx
imported by: nx_cell_anatomy_compose_test.nxnx_codon_test.nx
structs
| 53 | struct NxCodon |
| 60 | struct NxCodonStream |
consts
| 32 | const NX_OP_NOP: nx_int = 0 |
| 33 | const NX_OP_ADD: nx_int = 1 |
| 34 | const NX_OP_SUB: nx_int = 2 |
| 35 | const NX_OP_MUL: nx_int = 3 |
| 36 | const NX_OP_SHL: nx_int = 4 |
| 37 | const NX_OP_SHR: nx_int = 5 |
| 38 | const NX_OP_AND: nx_int = 6 |
| 39 | const NX_OP_OR: nx_int = 7 |
| 40 | const NX_OP_XOR: nx_int = 8 |
| 41 | const NX_OP_LOAD: nx_int = 9 |
| 42 | const NX_OP_STORE: nx_int = 10 |
| 43 | const NX_OP_BRANCH: nx_int = 11 |
| 44 | const NX_OP_CALL: nx_int = 12 |
| 45 | const NX_OP_RET: nx_int = 13 |
| 46 | const NX_OP_N_OPS: nx_int = 14 |
| 48 | const NX_CODON_OK: nx_int = 0 |
| 49 | const NX_CODON_ERR_FULL: nx_int = 1 |
| 50 | const NX_CODON_ERR_BAD_OP: nx_int = 2 |
| 51 | const NX_CODON_ERR_BAD_TARG: nx_int = 3 |
| 66 | const NX_CODON_BYTES: nx_size = 32 |
functions
| 68 | func nx_op_is_valid(o: nx_int) -> nx_int |
| 74 | func nx_codon_stream_new(capacity: nx_size) -> *NxCodonStream |
| 83 | func _codon_at(s: *NxCodonStream, idx: nx_size) -> *NxCodon |
| 92 | func nx_codon_emit(s: *NxCodonStream, |
| 111 | func nx_codon_at(s: *NxCodonStream, idx: nx_size) -> *NxCodon |
| 116 | func nx_codon_stream_length(s: *NxCodonStream) -> nx_size |
| 125 | func nx_codon_count_by_op(s: *NxCodonStream, op: nx_int) -> nx_int |
| 143 | func nx_codon_resolve_target(s: *NxCodonStream, |