code wiki / _hdl_build / nx_viz_sankey_gate.nx
nx_viz_sankey_gate.nx source
↩ module page · 51 lines · 2209 B
1// nx_viz_sankey_gate.nx -- REFEREE for the sankey layer. Flow: node0(col0)->node2(col1) val 5; node1(col0)->
2// node2 val 3. Throughput: n0=5 n1=3 n2=8 (=5+3, conservation). Stack col0 (gap 10): n0 y=0, n1 y=15. col1: n2 y=0.
3// 2 columns. GREEN iff all. Sovereign: nx_viz_sankey + nx_syscalls. license_tier: ORIGINAL
4import "nx_viz_sankey.nx"
5import "nx_syscalls.nx"
6import "nx_gate_verdict.nx"
7
8func g_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
9func g_row(name: *u8, ok: i64) -> i64 {
10 if ok == 1 { g_w(" PASS " as *u8) }
11 if ok != 1 { g_w(" FAIL " as *u8) }
12 g_w(name); g_w("\n" as *u8)
13 return ok
14}
15
16func main() -> i64 {
17 g_w("viz-sankey gate (throughput + per-column stacking)\n" as *u8)
18 let column: *i64 = sys_mmap(64) as *i64
19 let src: *i64 = sys_mmap(64) as *i64
20 let dst: *i64 = sys_mmap(64) as *i64
21 let val: *i64 = sys_mmap(64) as *i64
22 let nh: *i64 = sys_mmap(64) as *i64
23 let ny: *i64 = sys_mmap(64) as *i64
24 column[0] = 0; column[1] = 0; column[2] = 1
25 src[0] = 0; dst[0] = 2; val[0] = 5
26 src[1] = 1; dst[1] = 2; val[1] = 3
27 var pass: i64 = 0
28
29 let cols: i64 = vsk_layout(3, column, 2, src, dst, val, 10, nh, ny)
30 var t1: i64 = 0
31 if cols == 2 { t1 = 1 }
32 pass = pass + g_row("T1 columns = 2\x00" as *u8, t1)
33
34 var t2: i64 = 0
35 if nh[0] == 5 { if nh[1] == 3 { if nh[2] == 8 { t2 = 1 } } }
36 pass = pass + g_row("T2 throughput 5/3/8 (n2 = 5+3, conserved)\x00" as *u8, t2)
37
38 var t3: i64 = 0
39 if ny[0] == 0 { if ny[1] == 15 { if ny[2] == 0 { t3 = 1 } } }
40 pass = pass + g_row("T3 stack col0: y 0,15 (gap 10); col1: y 0\x00" as *u8, t3)
41
42 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
43 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
44 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
45 let ctr__dry: *i64 = gv_ctr()
46 ctr__dry[0] = pass
47 ctr__dry[1] = 3
48 let rc__dry: i64 = gv_verdict("VIZ-SANKEY-GATE" as *u8, ctr__dry, "3/3 (flow layout, conserved + stacked)" as *u8)
49 sys_exit(rc__dry)
50 return rc__dry
51}