A simple project to visualize LFSR output
Find a file
2024-07-14 09:08:19 -04:00
LICENSE Initial commit of project! 2024-07-14 08:51:06 -04:00
main.c Initial commit of project! 2024-07-14 08:51:06 -04:00
Makefile Initial commit of project! 2024-07-14 08:51:06 -04:00
plottemplate Initial commit of project! 2024-07-14 08:51:06 -04:00
README.md Added a README 2024-07-14 09:08:19 -04:00

Linear feedback shift register Plotting

What is this?

This is a project that allows you to explore different LFSR polynomials/"taps" for, at the moment, 16-bit LFSRs. It sort of abuses make to do this. For example, to try the polynomial

x^15 + x^13 + x^8 + x^1 + 1

you simply invoke the Makefile like this, remembering to use bit positions instead of the exponents direction:

make TAPS='14 12 7 0' all

The code will build, run your chosen taps (a full cycle if it's valid, or until it repeats/gets to 70000 values otherwise), output the values to a text file, and then run gnuplot to make a plot of the numbers. This can reveal differences between different LFSR polynomials and how "random" they are. Some polynomials have obvious groupings of digits, whereas some are more uniform and fuzzy and therefore a bit more useful as pseudo-random number generators or procedural generation seeds.

I'm sure there are probably other reasons to plot the outputs of LFSRs, but that's what I've been using them for.

Prerequisites

  • gcc supporting C11
  • awk
  • gnuplot with PNG support built-in
  • make

Currently this will only run on Linux, though it wouldn't be difficult to get it to run under mingw or similar systems for Window$.

Limitations

At the moment it only supports 16-bit LFSRs as well as only supporting 4-term polynomials. Depending on how much time I want to spend on this, it may or may not be improved to support arbitrary LFSR widths and 2-term polynomials.

License

Usually I license stuff under the MPL v2 but this was such a random, questionably useful effort that I decided to release it under the more permissive MIT license. Please let me know if you actually use this program for anything useful!