2. A 16-bit LFSR:
Here we will repeat what we did in section 1, but with 16 bits. The locations of the XOR gates will also
be different. If you look at section 1, the gates were at bit locations 6,5, and 4. You can encode this as
a binary number where those bits are 1, and others are zero. So the XOR pattern was 0x70. Here, we
will try several options of configuring the 16-bit LFSR and observe the cyclic behavior of generating
random numbers. Ideally, we would expect a good 16-bit LFSR to cycle every 65535 samples (meaning
return to generating the initial seed value).
For this part, please complete the following:
• Start with a register seed value of 0xA315, and a feedback pattern of 0x2012. Implement the
16-bit LFSR. Print the result of just 400 iterations. Does the pattern cycle? Explain what
happens and after how many iterations.
• Now, let us loop over the feedback values while keeping the seed value constant at 0xA315. We
can have 32767 different feedback values (excluding zero and excluding odd numbers since we
don't use an XOR at location 0). For the first 100 feedback values (2,4,6, etc), cycle the full
65536 times as above and record the iteration number when the PRNG fails or cycles (stop the
loop when you hit this, such that for each feedback value, you have the cycle count). Print this
number as a function of the feedback value. For how many different feedback values does the cycle
go through all 65535 outputs? What are these feedback values? (tip: use a comma-separated
pair when printing so you have a column that is the feedback value, and another column that is
the cycle size).
• Use the first feedback value and cycle through all the 65535 generated numbers. Plot these
numbers and zoom in and look at the behavior of the random numbers as they approach very
high (close to 65535) and very low (close to 0) values. What do you notice here? Is there any
predictability in the pattern ?
• Now, use this particular feedback value 0x36C3 and repeat the previous step. Compare the
behavior of this PRNG with that of the previous step and state your findings