Generating a pseudo-random bitstream in Rust using a Linear Feedback Shift Register

Dec 10, 2017
2 minute read

In a previous article, we saw how easy it was to get up and running
with Rust on the TI Tiva/Stellaris launchpad development boards. In this post, we will write a small Rust program which generates
a random stream of 1’s and 0’s and use it to randomly blink an LED.

The Linear Feedback Shift Register

An LFSR is a shift register whose input bit is a function of some of the bits already present in the register. This wikipedia
article describes the idea in detail. A common use of the LFSR
is to generate pseudo-random bit sequences.

Here is a C program for a 16 bit Fibonacci LFSR (taken from the Wikipedia article):