code wiki / _hdl_build / nx_bootstrap.nx
nx_bootstrap.nx source
↩ module page · 36 lines · 1868 B
1// nx_bootstrap.nx -- LIB: the DOOMSDAY self-sufficiency + ROI model. Scales the digital-twin/supply-chain capability
2// from a single product up to the WHOLE fabrication bootstrap: the chain of machines/processes from the tiniest input
3// (feedstock) up to making our OWN CPUs/GPUs. Each stage carries real numbers: capital cost (cents), build time (days),
4// value produced (cents/day), and self_made (1 = we can build it from lower stages in-house, 0 = a must-buy "vitamin").
5// Computes SELF-SUFFICIENCY (permil makeable in-house), per-machine ROI/PAYBACK days, and the BOTTLENECKS (what stays
6// bought -- chips, steppers per Gershenfeld). The leverage: closing the chip bottleneck (garage litho / additive CPU
7// printing) is the biggest self-sufficiency jump. Inputs are RESEARCH-GROUNDED ESTIMATES (RepRap/OSE/Zeloof/CMU Hacker
8// Fab); the rollup MATH is exact. never-brick #26: pure arithmetic, deterministic. license_tier: ORIGINAL
9import "nx_syscalls.nx"
10
11// self-sufficiency in permil = (count self_made) * 1000 / n.
12func boot_selfsuff_permil(self_made: *i64, n: i64) -> i64 {
13 var s: i64 = 0; var i: i64 = 0
14 while i < n { s = s + self_made[i]; i = i + 1 }
15 return (s * 1000) / n
16}
17
18// payback period in days = capital / value_per_day (0-1 if it never pays back).
19func boot_payback_days(capital: i64, value_per_day: i64) -> i64 {
20 if value_per_day <= 0 { return 0 - 1 }
21 return capital / value_per_day
22}
23
24// number of must-buy bottlenecks (self_made == 0).
25func boot_bottlenecks(self_made: *i64, n: i64) -> i64 {
26 var b: i64 = 0; var i: i64 = 0
27 while i < n { if self_made[i] == 0 { b = b + 1 } i = i + 1 }
28 return b
29}
30
31// total capital (cents) to stand up the whole chain.
32func boot_total_capital(capital: *i64, n: i64) -> i64 {
33 var t: i64 = 0; var i: i64 = 0
34 while i < n { t = t + capital[i]; i = i + 1 }
35 return t
36}