Skip to main content

Module xbar

Module xbar 

Source
Expand description

Crossbar canonicalization — folding a gain/sum tree into single Kirchhoff columns.

Sum is linear, so a GainConst feeding a Sum input is the same node with the weight product (w·(k·x) = (w·k)·x in ℝ), and a Sum feeding a Sum splices its addends with distributed weights. Driven to fixpoint, an unrolled constant-weight dot product collapses to ONE Sum { inputs, weights } — one physical current-summing node whose programmed conductances ARE the weight vector: the crossbar column (I = V·G).

The fold RE-ASSOCIATES float arithmetic, so the folded netlist’s ideal evaluation is no longer bit-identical to the VM’s op order — it is equivalent in ℝ and compared through logos_approx_eq / the error budget (which carries an explicit f64-rounding term). Callers choose: the unfolded netlist for the bit-exact ideal tier, the folded one for the physical crossbar shape. Both evaluate with the same super::eval entry points.

Functions§

fold_crossbar
Fold gain-into-sum and sum-into-sum to fixpoint, then prune dead tiles. Order-preserving: spliced addends keep their producer’s addend order at the consumer’s position, so the evaluation order stays deterministic.
fold_crossbar_for
Fold to fixpoint, prune, then TREE the columns back down to the physical summing fan-in: a folded column wider than max_fanin splits into balanced sub-sums (weights ride on the leaves; the joining nodes take unit weights), because fan-in is a physical resource — the summing node’s loading, settling, and noise all grow with it.