Skip to content

Nyvyme/modern-lfsr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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