I am trying to understand how the galois LFSR code works. On the wikipedia page there is a figure with an example. There is a C snippet code.
#include <stdint.h>
uint16_t lfsr = 0xACE1u;
unsigned period = 0;
do {
unsigned lsb = lfsr & 1; /* Get lsb (i.e., the output bit). */
lfsr >>= 1; /* Shift register */
if (lsb == 1) /* Only apply toggle mask if output bit is 1. */
lfsr ^= 0xB400u; /* Apply toggle mask, value has 1 at bits corresponding
* to taps, 0 elsewhere. */
++period;
} while(lfsr != 0xACE1u);
I am unable to understand figure given on wikipedia and correlate with the code. what is the toggle mask doing? Can anybody explain as to how the operation is working with example bit sequence and it's shifted versions. I am not aware of fields and am not understanding code. I checked online but couldnot find any good explanations of the algorithm without going into the fields terminology. Kindly help.