code wiki / _hdl_build / nx_mr_lagprobe.nx

nx_mr_lagprobe.nx source

↩ module page · 54 lines · 2027 B

1// nx_mr_lagprobe.nx -- DIAGNOSTIC: why is the constant-velocity steady lag 171 q8 and not the 2// closed-form C*v*Q8/K = 426? The MR gate measured 171 with min==max==171 over 96 ticks, i.e. a 3// TRUE fixed point, which my hand analysis says is impossible (it predicts a residual acc of -15). 4// One of the two is wrong; this dumps the raw solver state per tick so the runtime adjudicates. 5// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 6import "nx_syscalls.nx" 7import "nx_softbind.nx" 8import "nx_gate_verdict.nx" 9 10const LP_STRIDE: i64 = 6 11const LP_Q8: i64 = 256 12const LP_G: i64 = 1024 13const LP_K: i64 = 60 14const LP_C: i64 = 100 15const LP_MAXD: i64 = 64 16const LP_SETTLE: i64 = 600 17const LP_SHOW: i64 = 8 18 19func main() -> i64 { 20 gv_head("nx_mr_lagprobe -- raw per-tick state under a constant-velocity anchor" as *u8) 21 let st: *i64 = sb_alloc(1) 22 sb_seat_mob(st, 0, 0, 0, 0) 23 let b: i64 = SB_CHEST*LP_STRIDE 24 var x: i64 = 0 25 var t: i64 = 0 26 while t < LP_SETTLE { 27 x = x + 1 28 sb_tick_pt(st, 0, SB_CHEST, x, 0, 0, LP_K, LP_C, LP_MAXD) 29 t = t + 1 30 } 31 gv_puts(" after " as *u8); gv_num(LP_SETTLE); gv_puts(" ticks at 1 model-unit/tick:\n" as *u8) 32 t = 0 33 while t < LP_SHOW { 34 x = x + 1 35 sb_tick_pt(st, 0, SB_CHEST, x, 0, 0, LP_K, LP_C, LP_MAXD) 36 let q: i64 = x*LP_Q8 37 let p: i64 = st[b] 38 let v: i64 = st[b+3] 39 let e: i64 = q - p 40 let spring: i64 = (e*LP_K)/LP_G 41 let damp: i64 = (v*LP_C)/LP_G 42 gv_puts(" q=" as *u8); gv_num(q) 43 gv_puts(" p=" as *u8); gv_num(p) 44 gv_puts(" e=q-p=" as *u8); gv_num(e) 45 gv_puts(" v=" as *u8); gv_num(v) 46 gv_puts(" spring=(e*K)/G=" as *u8); gv_num(spring) 47 gv_puts(" damp=(v*C)/G=" as *u8); gv_num(damp) 48 gv_puts(" acc=" as *u8); gv_num(spring - damp) 49 gv_puts("\n" as *u8) 50 t = t + 1 51 } 52 gv_puts("\n EXPECTED at a fixed point: v == 256 (the anchor speed in q8) and acc == 0.\n" as *u8) 53 return 0 54}