### Comment on

 ( #3333=superdoc: print w/ replies, xml ) Need Help??

Here is a bit more on what an LFSR is.

A LFSR is a register of N bits. Two or more positions are designated as "taps" and the bit values from those positions are XOR'd together to produce a new bit. This bit is placed to the left of the register and all bits are then shifted to the right with the previous right-most bit being returned as the output.

```       4   3   2   1   0   <- tap location numbers
+---+---+---+---+---+
,->| 0 | 1 | 0 | 1 | 0 | -> Output
|  +---+---+---+---+---+
|        |           |
|        |           |
|        `->--XOR--<-'
|              |
`-------<------'
```

You repeat this process forever, producing a somewhat random stream of bits as a result.

A good LFSR will repeat the pattern of bits produced only after (2**N)-1 interations. For each size of LFSR, there are positions for the taps that result in such a "good" LFSR. Unless, of course, you seed it with a value of 0, which will always stay 0 since the XOR of any number of 0 bits is another 0 bit. Note, that is why the period can't be larger than (2**N)-1 since there are 2**N possible states and one of them (the value 0) can't be part of the loop.

You can go to http://www.google.com/ and search for LFSR to get more information on these. The person who pointed these out to me also pointed me to the book Applied Cryptography.

From my quick introduction to these, I'm starting to think that most of the material on them is a bit sloppy. (:

It seems to me that if you have an odd number of taps, then either a seed of 0 or of all 1 bits would never change (the XOR of an odd number of 1 bits is another 1 bit). But most of the "good" arrangements of taps have an odd number of taps [ which means that the maximum period for an odd number of taps would be (2**N)-2 ].

So I think we should really be using XNOR instead of XOR. Though I'm reluctant to jump to many conclusions since I've just barely learned of them. :)

- tye (but my friends call me "Tye")

In reply to (tye)Re: LFSR golf by tye
in thread LFSR golf by tye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
As of 2016-07-23 20:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
What is your favorite alternate name for a (specific) keyboard key?

Results (221 votes). Check out past polls.