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.

They share one function so they cannot drift: a guard written into one copy and not the other would make the engines disagree about the same program.

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.