Skip to content

Latest commit

 

History

History
22 lines (19 loc) · 699 Bytes

README.md

File metadata and controls

22 lines (19 loc) · 699 Bytes

Modern LFSR

LFSR is a very old random number generation algorithm.

It works like this:

  • Shift seed by 1 bit to right
  • If first bit before shifting was 1, xor seed by mask, otherwise do nothing

Available functions

void mlfsrSetSeedAndMask(); // sets seed and mask based on their addresses in memory
                            // also, this must be called before mlfsrRand() and mlfsrRandInRange()
int mlfsrRand(); // generate a random 32 bit number
int mlfsrRandInRange(int min, int max); // generate a random 32 bit number in range

Manual Build

$ git clone https://github.com/NoWare-Development/modern-lfsr.git
$ cd mlfsr
$ meson setup build
$ ninja -C build