code wiki / _hdl_build / nx_research_chipfab_test.nx

nx_research_chipfab_test.nx source

↩ module page · 42 lines · 2073 B

1// nx_research_chipfab_test.nx -- ACCEPTANCE GATE for the Researcher's chip-fab arc. 2// Proves the corroboration discipline: facts with >=2 sources AND cataloged are admitted; 3// 1-source / uncataloged are NOT (no hearsay into the spec). Exact counts. 4import "nx_research_chipfab.nx" 5import "nx_syscalls.nx" 6 7func rt_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 8func rt_putn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;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(1,bb,k); return 0 } 9 10func main() -> i64 { 11 var pass: i64 = 0 12 var total: i64 = 0 13 14 // T1: facts 0-5 (>=2 sources, cataloged) admitted; facts 6,7 (1 source / uncataloged) NOT 15 total = total + 1 16 var t1: i64 = 1 17 var i: i64 = 0 18 while i < 6 { if rc_fact_admitted(i) != 1 { t1 = 0 } i = i + 1 } 19 if rc_fact_admitted(6) != 0 { t1 = 0 } 20 if rc_fact_admitted(7) != 0 { t1 = 0 } 21 if t1 == 1 { pass = pass + 1 } else { rt_puts("T1 FAIL admit pattern\n" as *u8) } 22 23 // T2: admitted total = 6 of 8 24 total = total + 1 25 if rc_admitted_total() == 6 { pass = pass + 1 } else { rt_puts("T2 FAIL admitted=" as *u8); rt_putn(rc_admitted_total()); rt_puts("\n" as *u8) } 26 27 // T3: spec is grounded (6/8 admitted clears the researcher's grounding gate) 28 total = total + 1 29 if rc_grounded() == 1 { pass = pass + 1 } else { rt_puts("T3 FAIL not grounded\n" as *u8) } 30 31 // T4: the CORE honest fact (fully-printed CPUs infeasible -> litho path) is admitted (3 sources) 32 total = total + 1 33 if rc_fact_admitted(4) == 1 { pass = pass + 1 } else { rt_puts("T4 FAIL core fact\n" as *u8) } 34 35 // emit the report (visible deliverable) 36 rc_report() 37 38 rt_puts("CHIPFAB-RESEARCH " as *u8); rt_putn(pass); rt_puts("/" as *u8); rt_putn(total); rt_puts("\n" as *u8) 39 if pass == total { rt_puts("CHIPFAB-RESEARCH ALL-PASS\n" as *u8); sys_exit(0) } 40 sys_exit(1) 41 return 1 42}