# Tutorial: Linear Feedback Shift Registers (LFSRs) - Part 1

**More taps than you know what to do with**

Each LFSR supports a number of tap combinations that will generate maximal-length sequences. The problem is weeding out the ones that do from the ones that don't, because badly chosen taps can result in the register entering a loop comprising only a limited number of states.

The author created a simple C program to determine the taps for maximal-length LFSRs with 2 to 32 bits. These values are presented for your delectation and delight in *Fig 4* (the * annotations indicate sequences whose length is a prime number).

*4. Taps for maximal length LFSRs with 2 to 32 bits.*

The taps are identical for both XOR-based and XNOR-based LFSRs, although the resulting sequence will of course differ. As was previously noted, alternative tap combinations may also yield maximum-length LFSRs, although the resulting sequences will vary. For example, in the case of a 10-bit LFSR, there are two 2-tap combinations that result in a maximal-length sequence: [2,9] and [6,9]. There are also twenty 4-tap combinations, twenty-eight 6-tap combinations, and ten 8-tap combinations that satisfy the maximal-length criteria.

**One-to-many versus many-to-one implementations**

Consider the case of an 8-bit LFSR, for which the minimum number of taps that will generate a maximal-length sequence is four. In the real world, XOR gates only have two inputs, so a four-input XOR function has to be created using three XOR gates arranged as two levels of logic. Even in those cases where an LFSR does support a minimum of two taps, you may actually wish to use a greater number of taps such as eight (which would result in three levels of XOR logic).

The problem is that increasing the levels of logic in the combinational feedback path can negatively impact the maximum clocking frequency of the function. One solution is to transpose the *many-to-one implementations* discussed above into their *one-to-many counterparts* (*Fig 5*).

*5. One-to-many versus many-to-one implementations.*

The traditional many-to-one implementation for the eight-bit LFSR has taps at [7,3,2,1]. To convert this into its one-to-many counterpart, the most-significant tap (which is always the most significant bit) is fed back directly into the least significant bit, and is also individually XORed with the other original taps (bits [3,2,1] in this example). Note that although both styles result in maximal-length LFSRs, the actual sequences of values will differ between them. But the main point is that using the one-to-many style means that there is never more than one level of combinational logic in the feedback path, irrespective of the number of taps being employed.

In parts 2 and 3 we will ... but no, I'm not going to spoil the anticipation ...

* Clive "Max" Maxfield is president of *TechBites Interactive

*, a marketing consultancy firm specializing in high technology. Max is the author and co-author of a number of books, including*Bebop to the Boolean Boogie (An Unconventional Guide to Electronics)

*,*The Design Warrior's Guide to FPGAs (Devices, Tools, and Flows)

*, and*How Computers Do Math

*featuring the pedagogical and phantasmagorical virtual*DIY Calculator

*.*

*
Widely regarded as being an expert in all aspects of computing and electronics (at least by his mother), Max was once referred to as "an industry notable" and a "semiconductor design expert" by someone famous who wasn't prompted, coerced, or remunerated in any way. Max can be reached at *max@techbites.com.