code wiki / _hdl_build / nx_phys_units.nx

nx_phys_units.nx

buildroot/runtime/_hdl_build/nx_phys_units.nx

6978 B159 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_phys_units.nx -- the SOVEREIGN INTEGER-EXACT dimensional-analysis engine (science-exceed arc, rung PHYS-UNITS). A physical quantity's DIMENSION is the vector of 7 INTEGER SI-base exponents [L,M,T,I,TH,N,J]. Dimensional algebra is therefore PURE INTEGER -- multiply = ADD exponent vectors, divide = SUBTRACT, power = SCALE, "compatible for +/compare" = EXACT vector equality. No float anywhere -> exact, deterministic, reproducible, attestable. EXCEED THESIS vs Mathematica Quantity/UnitConvert (the top-down incumbent): Mathematica is float- magnitude + proprietary + cloud-tethered; Nishi tracks dimensions as exact integer vectors, sovereign + offline + bit-attestable. We do NOT out-breadth Wolfram -- we win on EXACTNESS + SOVEREIGNTY. Data-driven (rule-11): the unit->dimension map is knowledge/registry/sci_units.tsv (no magic numbers in code). BAKED GATE proves the algebra on real physics identities (F=ma, E=F*d, P=E/t exact) + a NEGATIVE control (force != energy -> rejected) before emitting verdict=GREEN. module: nishi-core.science.phys_units depends: nishi-core.sys.syscalls capability: INTEGER_EXACT_DIMENSIONAL_ANALYSIS license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_phys_units.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap pu_read sys_openat_rd sys_read sys_close pu_w sys_write sys_exit pu_lookup sys_mmap ↻ pu_field pu_streq pu_atoi pu_mul pu_eq pu_div sys_openat_append pu_wn sys_mmap ↻ sys_write ↻ sys_close ↻

structs

none

consts

20const PU_MAGIC_65536: i64 = 65536
22const PU_REF: *u8 = "knowledge/registry/sci_units.tsv"
23const PU_LOG: *u8 = "knowledge/status/phys_units.log"

functions

25func pu_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 1: main calls 1: sys_write
26func pu_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
28func pu_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
39func pu_field(buf: *u8, ls: i64, le: i64, f: i64, dst: *u8, cap: i64) -> i64
called by 1: pu_lookup
53func pu_atoi(s: *u8, len: i64) -> i64
called by 1: pu_lookup
61func pu_streq(a: *u8, b: *u8) -> i64
called by 1: pu_lookup
69func pu_mul(out: *i64, a: *i64, b: *i64) -> i64 { var k: i64=0; while k<7 { out[k]=a[k]+b[k]; k=k+1 } return 0 }
called by 1: main
70func pu_div(out: *i64, a: *i64, b: *i64) -> i64 { var k: i64=0; while k<7 { out[k]=a[k]-b[k]; k=k+1 } return 0 }
called by 1: main
71func pu_eq(a: *i64, b: *i64) -> i64 { var k: i64=0; while k<7 { if a[k]!=b[k] { return 0 } k=k+1 } return 1 }
called by 1: main
74func pu_lookup(rbuf: *u8, rn: i64, name: *u8, dim: *i64) -> i64
102func main() -> i64