pub fn rotate_left_dynamic(
b: &CircuitBuilder,
words: &[Wire],
shift: Wire,
n_out: usize,
) -> Vec<Wire>Expand description
Rotates words left by a dynamic word count, returning the first n_out positions.
out[i] is words[(shift + i) % words.len()]. A caller that only needs a prefix reads the
wrap-around at positions past its own validity bound, so it must treat those as unconstrained.
§Arguments
b- Circuit builderwords- The array to rotateshift- Rotate amount in words (onlyceil(log2(len))LSB bits are used)n_out- Number of leading positions to return
§Implementation Details
One barrel stage per bit of shift, largest stage first so the working window shrinks as the
stages are applied. That costs one select per position per stage, where a multiplexer per
output position would instead cost words.len() - 1 selects each.
§Panics
- If
wordsis empty - If
n_outexceedswords.len()