
A linear feedback shift register (LFSR) is the heart of any digital system that relies on pseudorandom bit sequences (PRBS), with applications ranging from cryptography and biterrorrate measurements, to wireless communication systems employing spread spectrum or CDMA techniques. In this article we discuss the two implementations of LFSR generators, how to determine feedback taps for generating a maximal length sequence, and the properties of maximal length sequences (msequences). We also provide tables of msequence feedback taps. LFSR Generator ImplementationsLinear feedback shift registers can be implemented in two ways. The Fibonacci implementation consists of a simple shift register in which a binaryweighted modulo2 sum of the taps is fed back to the input. (The modulo2 sum of two 1bit binary numbers yields 0 if the two numbers are identical, and 1 if the differ: 0+0=0, 0+1=1, 1+1=0.)
Figure 1. Fibonacci implementation of LFSR.
The Galois implementation consists of a shift register, the contents of which are modified at every step by a binaryweighted value of the output stage.
Figure 2. Galois implementation of LFSR.
Given identical feedback weights, the two LFSR implementations will produce the same sequence. However, the initial states of the two implementations must necessarily be different for the two sequences to have identical phase. The initial state of the Fibonacci form is called the initial fill or initial vector, and this initial fill comprises the first m bits output from the generator. The initial state of the Galois generator must be adjusted appropriately to attain the equivalent initial fill. When implemented in hardware, modulo2 addition is performed with exclusiveOR (XOR) gates. The Galois form is generally faster than the Fibonacci in hardware due to the reduced number of gates in the feedback loop, thus making it the favored form. It should be noted that, in some industries, the Fibonacci form LFSR is referred to as a simple shift register generator (SSRG), and the Galois form is referred to as a multiplereturn shift register generator (MRSRG) or modular shift register generator (MSRG). Conventions for Feedback Tap SpecificationA given set of feedback connections can be expressed in a convenient and easytouse shorthand form, with the connection numbers being listed within a pair of brackets. In doing so, connection g_{0} is implied, and not listed, since it is always connected. Although g_{m} is also always connected, it is listed in order to convey the shift register size (number of registers). A set of feedback taps for a Galois generator is denoted as [f_{1}, f_{2}, f_{3}, ..., f_{J}]_{ g} where subscript J is the total number of feedback taps (not including g_{0}), f_{1} = m is the highestorder feedback tap (and the size of the LFSR), and f_{j} are the remaining feedback taps. The g subscript signifies the Galois LFSR form. The set of feedback taps for the equivalent Fibonacci generator is denoted as [f_{1}, mf_{2}, mf_{3}, ..., mf_{J}]_{ f} where the f subscript signifies the Fibonacci LFSR form. Note that subtracting the feedback tap numbers from m is equivalent to reversing the order of the feedback taps (as they are defined in Figures 1 and 2). As an example, consider an LFSR of size m = 8 with feedback connections at g_{8}, g_{6}, g_{5}, g_{4, }and implied g_{0}. The feedback taps are specified as [8, 6, 5, 4]_{g} for the Galois form, and [8, 86, 85, 84]_{f} = [8, 2, 3, 4]_{f} = [8, 4, 3, 2]_{f} for the Fibonacci form. Note that the taps are customarily arranged in a descending order. A set of feedback taps specified in this format is called a feedback tap set, feedback set, or feedback pattern. It is important to recognize that feedback taps given in this shorthand form don't conform to the order of the weights given in Figure 1 for the Fibonacci generator. As such, it is best not to use Figures 1 and 2 in connection with this feedback convention. Rather, one should simply consider the first tap listed as being the output of the generator, the second tap being that just to the left of it, and so on, regardless of whether the generator is a Fibonacci or a Galois form. In tables of msequence feedback sets, as presented below, neither the Fibonacci nor the Galois form is specified. This is because any given set will work with either implementation. If a given feedback set is used on both the Fibonacci and Galois forms, the sequence produced by one form will be the mirror image of the sequence produced by the other. One other related convention should be mentioned: An LFSR with m shift register stages is said to be an Rm LFSR. For example, an R8 generator is one with eight stages. An alternative to this convention is PNm, or PN8 in this example. (PN is an acronym for pseudonoise, which is a term used in some industries for maximal length pseudorandom sequences, to be discussed next.) Maximal Length SequencesLFSR generators produce what are called linear recursive sequences (LRS) because all operations are linear. Generally speaking, the length of the sequence before repetition occurs depends upon two things, the feedback taps and the initial state. An LFSR of any given size m (number of registers) is capable of producing every possible state during the period N=2^{m}1, but will do so only if proper feedback taps, or terms, have been chosen. Such a sequence is called a maximal length sequence, maximal sequence, or less commonly, maximum length sequence. It is often abbreviated as msequence. In certain industries msequences are referred to as a pseudonoise (PN) or pseudorandom sequences, due to their optimal noiselike characteristics. Maximal length generators can actually produce two sequences. One is the trivial one, of length one, that occurs when the initial state of the generator is all zeros. The other one, the useful one, has a length of 2^{m}1. Together, these two sequences account for all 2^{m} states of an mbit state register. When the feedback taps of an LFSR are nonmaximal, the length of the generated sequence depends upon the initial state of the LFSR. A nonmaximal generator is capable of producing two or more unique sequences (plus the trivial allzeros one), with the initial state determining which is produced. Each of these sequences is referred to as a state space of the generator. Together, all possible nonmaximal sequences account for all 2^{m} states of an mbit state register. Properties of nonmaximal sequences are generally inferior to those of maximal sequences. So the use of nonmaximal sequences in real systems is usually avoided in favor of their maximallength counterparts. Galois Field Mathematics and MSequencesFinite (Galois) field mathematics are used to derive msequence feedback taps. Any LFSR can be represented as a polynomial of variable X, referred to as the generator polynomial: Equation 1. Generalized generator polynomial. The coefficients g_{i} represent the tap weights, as defined in Figures 1 and 2, and are 1 for taps that are connected (fed back), and 0 otherwise. The order of the polynomial, m, represents the number of LFSR stages. Rules of linear algebra apply to the polynomial, but all mathematical operations are performed in modulo2: Modulo2 addition: 0 + 0 = 0 Modulo2 multiplication: 0 * 0 = 0 As an example of polynomial representation, the generator polynomial G(X) = X^{3} + X^{1} + 1 represents an LFSR with feedback taps 3 and 1, denoted as [3, 1]_{g}:
Now, here is the key to determining msequence feedback taps: The generator polynomial of Equation 1 is said to be primitive if it cannot be factored (i.e. it is prime), and if it is a factor of (i.e. can evenly divide) X^{N}+1, where N = 2^{m}1 (the length of the msequence). It can be shown that an LFSR represented by a primitive polynomial will produce a maximal length sequence. Consider again the example of the [3, 1]_{g} LFSR just given. We wish to know if this generator will produce an msequence. First we note that m = 3 and N=2^{3}1=7. It can be shown that its polynomial, X^{3}+X^{1}+1 , cannot be factored, and it can be shown that its polynomial is a factor of X^{7}+1. Thus, we conclude that this LFSR will indeed produce a maximal length sequence. In this example, we went through the process of determining whether or not the given set of feedback taps would result in a maximal length sequence. Normally, however, we are required to do just the opposite. That is, we are normally asked to find all sets of feedback taps that will produce msequences for a given register size. For example, we may be asked to find all sets of maximallength feedback taps for an LFSR with m=3 registers. We do this as follows: The length of the msequences will be N=2^{3}1=7. We know that the solution lies in all the primitive factors of polynomial X^{7}+1. We use modulo2 linear algebra (perhaps with the aid of a computer algorithm) to find the prime factors to be The primitive polynomials are those factors whose order is the same as the register size, m = 3. Of the three prime factors, the last two meet this criterion. Thus we see that there are exactly two sets of msequence feedback taps, [3, 1]_{g} and [3, 2]_{g}. It is interesting to note that, given any shift register size, there will always be an even number of msequence feedback sets. More specifically, given any one of its msequence feedback sets, [f_{1}, f_{2}, f_{3}, ..., f_{J}]_{ g} there will be a companion set described as [f_{1}, mf_{2}, mf_{3}, ..., mf_{J}]_{ g} whose sequence will be the mirror image of the original set's sequence. Note that subtracting feedback tap numbers from m for the companion set is equivalent to reversing the order of those taps. Thus we conclude that, for any given feedback set that produces an msequence, the mirror image of the feedback set will produce the mirror image of the msequence. And, of course, the resulting sequence will also be an msequence since all possible states are exhausted. An astute reader may have noticed in the last example that the two derived sets of msequence feedback taps, [3, 1]_{g} and [3, 2]_{g}, are in fact mirror images of each other. Tables of msequence feedback taps are presented below for the reader's convenience. MSequence PropertiesProperties of msequences include the following: 1. An mbit register produces an msequence of period 2^{m}1. 2. An msequence contains exactly 2^{(m1)} ones and 2^{(m1)}1 zeros. 3. The modulo2 sum of an msequence and another phase of the same sequence yields yet a third phase of the sequence. 3a. (A corollary of 3.) Each node of an msequence generator runs through some phase of the sequence. (While this is obvious with a Fibonacci LFSR, it may not be with a Galois LFSR.) 4. A sliding window of length m, passed along an msequence for 2^{m}1 positions, will span every possible mbit number, except all zeros, once and only once. 5. Define a run of length r to be a sequence of r consecutive identical numbers, bracketed by nonequal numbers. Then in any msequence there are:
6. If an msequence is mapped to an analog timevarying waveform, by mapping each binary zero to 1 and each binary one to +1, then the autocorrelation function will be unity for zero delay, and 1/(2^{m}1) for any delay greater that one bit, either positive or negative in time. The shape of the autocorrelation function between 1 bit and +1 bit will be triangular, centered around time 0. That is, the function will rise linearly from time = (onebit) to time 0, and then declines linearly from time 0 to time = +(onebit). Other interesting facts regarding msequences and feedback sets that produce them include the following: 1. If the order of the feedback taps (as defined in Figures 1 and 2) is reversed, the resulting sequence will be the time reversal of the original sequence, and will also be an msequence. 2. The tap numbers of any given msequence LFSR will all be relatively prime. Tables of MSequence Feedback Taps The following
tables contain msequence feedback sets for LFSR
sizes R3 through R32. The tables for R3 through
R24 contain all maximal feedback sets (except for
mirror image sequences). The tables for R25
through R32 contain maximal feedback sets for 2,
4, and 6 taps only. The last table contains a
sampling of "dense feedback sets"
(those with taps for at least half the stages)
for R25 through R32 registers.




