Skip to main content

multi_wire_multiplex

Function multi_wire_multiplex 

Source
pub fn multi_wire_multiplex(
    b: &CircuitBuilder,
    inputs: &[&[Wire]],
    sel: Wire,
) -> Vec<Wire>
Expand description

Creates a multiplexer circuit that selects a group of wires from multiple groups based on a selector value.

This circuit validates that the output contains the group at position sel from the input groups. Each group must have the same number of wires.

§Arguments

  • b - Circuit builder
  • inputs - Slice of wire groups, where each group has the same number of wires
  • sel - Selector value (only ceil(log2(N)) LSB bits are used, where N is the number of groups)

§Returns

A vector of wires representing the selected group

§Implementation Details

For each wire position across all groups, builds a separate multiplexer tree using select gates. If inputs is [[a1,a2], [b1,b2], [c1,c2]] and sel=1, output is [b1,b2].

§Panics

  • If inputs is empty
  • If any group is empty
  • If groups have different lengths