pub fn bounded_fanout_select(
prefix: &str,
suffix: &str,
sel_expr: &str,
data_wire: &str,
width: usize,
slice: usize,
) -> (String, String)Expand description
Emit a fan-out-bounded image of the one-bit select sel_expr ? data_wire : 0 over width
bits, sliced into slice groups.
Returns (decls, pp_expr):
decls— theslice(* keep *)select-bit copies, one per line, each named{prefix}{s}{suffix}and driven bysel_expr. The(* keep *)attribute stops synthesis (yosys) from merging the copies back into one high-fan-out net; iverilog ignores it, so simulation is unchanged.pp_expr— the concatenation{ {G{prefix_{slice-1}_suffix}} & data[hi:lo] , ... , {G{prefix_0_suffix}} & data[hi:lo] }whereG = width / slice. Groups are concatenated high→low so group 0 lands at the LSB. No net in this expression drives more thanGmux bits — the fan-out is bounded bywidth / slice, never the full datapath (the met1-antenna root cause).
prefix/suffix frame the select-copy family so copy s is named {prefix}{s}{suffix} (the
suffix carries any per-instance tag, e.g. a lane suffix _l3 — pass "" when there is none).
data_wire is the wire being gated (e.g. "mc"). Panics unless slice > 0 && width % slice == 0, so the byte-groups tile data_wire exactly with no dropped or misaligned bit.