Last verified · v1.0
Calculator
Linear Feedback Shift Register (Lfsr) Period Calculator
Calculate Linear Feedback Shift Register maximum period (2^n-1), required bits for target period, and pseudo-random sequence properties.
Inputs
Maximum Period
—
Explain my result
Get a plain-English breakdown of your result with practical next steps.
The formula
How the
result is
computed.
Understanding Linear Feedback Shift Registers
A Linear Feedback Shift Register (LFSR) is a sequential shift register circuit that generates pseudo-random sequences through linear feedback functions. The maximum period formula Pmax = 2n - 1 determines the longest possible sequence length before repetition, where n represents the number of bits in the register. This maximum period occurs only when the LFSR uses a primitive polynomial as its feedback function.
The Maximum Period Formula Derivation
The formula 2n - 1 derives from fundamental principles of finite field theory. An n-bit LFSR has 2n possible states, but the all-zeros state creates a locked condition where the register cannot produce meaningful output. Subtracting this invalid state yields 2n - 1 as the theoretical maximum period. According to Wikipedia's comprehensive LFSR documentation, achieving this maximum requires selecting feedback tap positions corresponding to a primitive polynomial over GF(2).
Primitive Polynomials and Maximal-Length Sequences
Not all tap configurations produce maximum-length sequences. The feedback polynomial must be primitive, meaning it cannot be factored into smaller polynomials over the Galois Field GF(2). For example, a 4-bit LFSR has a maximum period of 24 - 1 = 15 cycles. The polynomial x4 + x + 1 is primitive and generates this full sequence, while x4 + x2 + 1 is not primitive and produces shorter cycles. Research from Koc Lab at UC Santa Barbara provides comprehensive tables of primitive polynomials for registers up to 168 bits.
Calculating Required Register Size
When designing systems requiring specific sequence lengths, engineers calculate the minimum register size using the inverse formula: n = ⌈log2(P + 1)⌉, where P is the target period. For instance, generating a pseudo-random sequence with period 1,000,000 requires n = ⌈log2(1,000,001)⌉ = ⌈19.93⌉ = 20 bits, yielding an actual maximum period of 220 - 1 = 1,048,575 cycles.
Practical Applications and Examples
Cryptographic Stream Ciphers: The A5/1 algorithm used in GSM encryption employs three LFSRs with 19, 22, and 23 bits, producing combined periods of 524,287, 4,194,303, and 8,388,607 respectively. Though A5/1 has known vulnerabilities, it demonstrates LFSR implementation in security protocols.
Error Detection: Cyclic Redundancy Check (CRC) algorithms utilize LFSR architectures. A CRC-32 implementation uses a 32-bit register with maximum period 232 - 1 = 4,294,967,295, enabling detection of burst errors up to 32 bits in length.
GNSS Gold Codes: GPS satellites generate unique identification codes using pairs of 10-bit LFSRs (period 1,023 chips) combined through exclusive-OR operations. Each satellite transmits a distinct Gold code sequence for signal acquisition and tracking.
Non-Maximal Period Sequences
LFSRs using non-primitive polynomials exhibit shorter periods. A 5-bit register theoretically achieves 31 cycles maximum, but with polynomial x5 + x2 + 1 (non-primitive), the actual period drops to 5 cycles. This behavior results from the polynomial factoring into irreducible components, creating multiple shorter cycles instead of one maximal sequence.
Implementation Considerations
Hardware implementations prefer Fibonacci (external XOR) or Galois (internal XOR) configurations. Fibonacci LFSRs apply feedback externally, requiring a single multi-input XOR gate but introducing propagation delay. Galois configurations distribute XOR operations throughout the register, enabling higher clock speeds at the cost of additional gates. For an 8-bit maximal-length LFSR with period 255, the Galois architecture typically operates 30-40% faster in FPGA implementations.
System designers must balance speed requirements against implementation complexity. The Galois configuration's speed advantage becomes critical in real-time systems processing high-bandwidth data streams, such as satellite communications or radar signal processing. Conversely, power-constrained applications in battery-powered devices may prefer the simpler Fibonacci approach despite lower clock speeds, as the reduced gate count directly reduces power consumption and heat generation.
Sequence Quality and Statistical Properties
Maximal-length LFSRs satisfy three randomness properties: (1) balance property - the number of ones exceeds zeros by exactly one; (2) run property - specific distributions of consecutive identical bits; (3) correlation property - shifted versions appear uncorrelated. An 8-bit maximal LFSR producing 255 outputs contains 128 ones and 127 zeros, with autocorrelation values approaching ideal random sequences.
Reference