Skip to main content

Module permute

Module permute 

Source
Expand description

The Galois LFSR permutation: one body for the shuffle node and for jit_shuffle, the helper native code calls.

The two carried a copy each until 2026-09-22, and the copies drifted the way copies do — a zero size divided by zero in both, and a guard written into one would have made the engines disagree about the same program. They are one function now, which is what this module is for.

The feedback polynomials come with it. A shuffle whose polynomial does not match its register width is not a permutation, so the table and the body are one thing to keep honest, not two; splitting them across the crates is what let the bodies diverge in the first place. polydat-nodes re-exports the selection helpers under their old paths.

Functions§

feedback_for_size
Convenience: derive a bank-0 feedback polynomial directly from a shuffle size. Callers building a Shuffle node from an outer “size” parameter use this rather than tracking width / bank manually.
feedback_for_width
Return the default (bank 0) feedback polynomial for a given width.
feedback_for_width_and_bank
Return the feedback polynomial for a given register width and bank.
lfsr_step
One step of the Galois LFSR: shift right, and fold in the feedback polynomial when the bit shifted out was set.
shuffle_bounded
Map input into [min, min + size), visiting every value of that range exactly once per cycle.
width_for_period
Return the minimum register width needed to represent period values.