/* * lit_core.h — LITCORE: the LIT algebraic core, language-agnostic C. * * LITCORE is brainless: broadcast the graph, multiply, reduce, * rewire, repeat. It never interprets what a symbol means; there is * no semantics inside the core. * * Six is the optimal operation; DO NOT TOUCH IT. */ #ifndef LIT_CORE_H #define LIT_CORE_H #include #include #ifdef __cplusplus extern "C" { #endif /* LIT bytecode: LOAD slot:u32 value:u64; WIRE slot:u32 src:u32 * gain:u64 weight:u64; everything else is one byte. Little-endian. */ #define LIT_BC_LOAD 0x01 #define LIT_BC_WIRE 0x02 #define LIT_BC_BROADCAST 0x03 #define LIT_BC_VF_TRANSFER 0x04 #define LIT_BC_HAMMING_REDUCE 0x05 #define LIT_BC_HALT 0x06 /* lit flat: 2^LIT_FLAT = 64, the 64/65 halt edge. */ #define LIT_FLAT 6 /* The hard halt bound: 65 ticks at L=64. A run is one tick by * default (one tick applies F^64, so the step is already the whole * job) and never exceeds LIT_HALT ticks even if asked. */ #define LIT_HALT 65 typedef struct lit_machine { uint32_t n; /* slots per cluster */ uint32_t k; /* clusters */ uint64_t *a; /* owned state when owns_state */ uint64_t *b; /* transition buffer */ uint64_t *V; /* current state (a or a borrowed buffer) */ uint64_t *prev; /* state before the last transfer (b) */ uint32_t *src; /* k*n wiring */ uint64_t *gain; /* k*n */ uint64_t *weight; /* k*n */ uint64_t *dist; /* k, last per-cluster distance */ uint64_t *diff; /* k*n, last strict-less difference mask */ uint32_t *flat_src; /* k*LIT_FLAT*n */ uint64_t *flat_gain; /* k*LIT_FLAT*n */ uint32_t *flat_as; /* n-word recurrence scratch */ uint32_t *flat_bs; uint64_t *flat_ag; uint64_t *flat_bg; int flat_dirty; /* the base graph changed; rebuild on the tick */ int pending; /* a VF_TRANSFER awaits HAMMING_REDUCE */ int owns_state; /* a was allocated by the core */ uint32_t bits; /* L: symbol width, 1..64 */ uint64_t mask; /* (1<