code wiki / (root) / nx_codon.nx

nx_codon.nx

buildroot/runtime/nx_codon.nx

5082 B152 linesdepth 4pulls 4 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tier.nx nx_ribosome.nx nx_codon.nx nx_cell_anatomy_compose_test.nx nx_codon_test.nx

imports: nx_syscalls.nxnx_tier.nxnx_ribosome.nx

imported by: nx_cell_anatomy_compose_test.nxnx_codon_test.nx

structs

53struct NxCodon
60struct NxCodonStream

consts

32const NX_OP_NOP: nx_int = 0
33const NX_OP_ADD: nx_int = 1
34const NX_OP_SUB: nx_int = 2
35const NX_OP_MUL: nx_int = 3
36const NX_OP_SHL: nx_int = 4
37const NX_OP_SHR: nx_int = 5
38const NX_OP_AND: nx_int = 6
39const NX_OP_OR: nx_int = 7
40const NX_OP_XOR: nx_int = 8
41const NX_OP_LOAD: nx_int = 9
42const NX_OP_STORE: nx_int = 10
43const NX_OP_BRANCH: nx_int = 11
44const NX_OP_CALL: nx_int = 12
45const NX_OP_RET: nx_int = 13
46const NX_OP_N_OPS: nx_int = 14
48const NX_CODON_OK: nx_int = 0
49const NX_CODON_ERR_FULL: nx_int = 1
50const NX_CODON_ERR_BAD_OP: nx_int = 2
51const NX_CODON_ERR_BAD_TARG: nx_int = 3
66const NX_CODON_BYTES: nx_size = 32

functions

68func nx_op_is_valid(o: nx_int) -> nx_int
called by 2: nx_codon_emitmain
74func nx_codon_stream_new(capacity: nx_size) -> *NxCodonStream
called by 2: mainmain calls 1: sys_mmap
83func _codon_at(s: *NxCodonStream, idx: nx_size) -> *NxCodon
92func nx_codon_emit(s: *NxCodonStream,
111func nx_codon_at(s: *NxCodonStream, idx: nx_size) -> *NxCodon
called by 1: main calls 1: _codon_at
116func nx_codon_stream_length(s: *NxCodonStream) -> nx_size
called by 2: mainmain
125func nx_codon_count_by_op(s: *NxCodonStream, op: nx_int) -> nx_int
called by 2: mainmain calls 1: _codon_at
143func nx_codon_resolve_target(s: *NxCodonStream,