code wiki / _hdl_build / nx_eff_conv.nx

nx_eff_conv.nx

buildroot/runtime/_hdl_build/nx_eff_conv.nx

3946 B62 linesdepth 0pulls 0 transitivereach 4 importersview sourcekind librarytopic eff
docsdependenciesstructsconstsfunctions

about

nx_eff_conv.nx -- pure spend->money/energy conversion core (eff lane). SYSCALL-FREE integer math, so it compiles anywhere (NAS buildroot incl older toolchains) -- decoupled from the getdents/fstatat SCAN code in nx_eff_lib so the board (a plane READER) never drags scan syscalls into its compile. Shared by nx_eff_lib (scan CLI) AND nx_eff_board_lib (ROI board) = DRY (rule 15). Coefficients DECLARED + emitted transparently by every consumer (rule 11, operator "non-fake numbers"). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 0 imports · 2 importers

nx_eff_conv.nx nx_eff_board_lib.nx nx_eff_probe.nx

imports: none

imported by: nx_eff_board_lib.nxnx_eff_probe.nx

structs

none

consts

9const EFL_W_IN: i64 = 100
10const EFL_W_OUT: i64 = 500
11const EFL_W_CR: i64 = 10
12const EFL_W_CW: i64 = 125
13const EFL_CENTS_PER_MTOK_IN: i64 = 1500 // uncached input $15.00/Mtok (Opus-class UPPER-BOUND default; editable)
14const EFL_MONEY_DIV: i64 = 100000000 // bp(x100) x per-Mtok(1e6) normalizer
22const EFL_WH_ENERGY_DIV: i64 = 1000000
40const EFL_T_FABLE: i64 = 0
41const EFL_T_OPUS: i64 = 1
42const EFL_T_SONNET: i64 = 2
43const EFL_T_HAIKU: i64 = 3
44const EFL_T_OTHER: i64 = 4
45const EFL_NTIER: i64 = 5
46const EFL_RATE_FABLE: i64 = 1000 // Fable 5 / Mythos 5 base input $10.00/Mtok
47const EFL_RATE_OPUS: i64 = 500 // Opus 4.5-4.8 base input $5.00/Mtok
48const EFL_RATE_SONNET: i64 = 300 // Sonnet 4.5/4.6 $3 (Sonnet 5 intro $2 is lower -> conservative-high)
49const EFL_RATE_HAIKU: i64 = 100 // Haiku 4.5 base input $1.00/Mtok
50const EFL_RATE_OTHER: i64 = 500 // unknown model -> Opus-ish conservative

functions

24func efl_weighted_bp(ti: i64, to_: i64, cr: i64, cw: i64) -> i64 { return ti*EFL_W_IN + to_*EFL_W_OUT + cr*EFL_W_CR + cw*EFL_W_CW }
26func efl_cost_cents(ti: i64, to_: i64, cr: i64, cw: i64) -> i64
31func efl_energy_wh(ti: i64, to_: i64, cr: i64, cw: i64) -> i64
51func efl_tier_rate(tier: i64) -> i64
called by 1: efl_cost_tier
59func efl_cost_tier(tier: i64, ti: i64, to_: i64, cr: i64, cw: i64) -> i64