# 线性反馈移位寄存器

**线性反馈移位寄存器**（LFSR）是一种移位寄存器，其输入位是此前两个或多个状态位的线性函数——实际中即异或（XOR）——因此它在每个时钟周期都会产生一个确定性的、重复的二进制值序列，而该序列看上去可以是随机的。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup><sup> • </sup><sup>[2](https://www.ece.ualberta.ca/~elliott/ee552/studentAppNotes/1999f/Drivers_Ed/lfsr.html)</sup> LFSR 属于数字逻辑中最早被研究、也研究得最透彻的结构之列，是流密码、内建自测试电路和扩频通信系统的基础。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup>

| 关键事实 | 详情 |
|---|---|
| 结构 | 一个 n 级 LFSR 由链式相连的 n 个触发器组成；每个时钟周期，每一级都把自身的值传给下一级，而第一级接收的新位由反馈多项式所指定的抽头异或而成。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> |
| 反馈多项式 | 每一条反馈连接都对应寄存器在 GF(2)（二元域）上的特征多项式中的一项。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> |
| 最大长度 | 当特征多项式在 GF(2) 上为本原多项式时，寄存器在重复之前会遍历全部 2^n − 1 个非零状态，产生周期为 2^n − 1 的最大长度序列（m 序列）。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> |
| 密码学弱点 | 仅凭 2n 位密钥流输出，Berlekamp-Massey 算法就能精确重建寄存器及其多项式，因此实际密码中的原始 LFSR 要以非线性方式组合使用。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> |
| 硬件成本 | 一个 n 级寄存器只需 n 个触发器、一个反馈异或门和一个时钟即可实现；级数不超过 32 级的紧凑 LFSR 电路所需门数不到一打。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> |
| 抽头集示例 | 8 位时，抽头 1、2、3、7 给出长度为 255 的循环；16 位时，抽头 1、2、4、15 给出 65,535；32 位时，抽头 1、5、6、31 给出 4,294,967,295。<sup>[2](https://www.ece.ualberta.ca/~elliott/ee552/studentAppNotes/1999f/Drivers_Ed/lfsr.html)</sup> |
| CRC 用途 | 循环冗余校验硬件即以 LFSR 实现；广泛使用的 CRC-CCITT 16 位多项式为 X16 + X12 + X5 + 1。<sup>[3](https://www.infineon.com/assets/row/public/documents/cross-divisions/396/infineon-component-crc-v2.40-software-module-datasheets-en.pdf?fileId=8ac78c8c7d0d8da4017d0e85774a164a)</sup> |

## 工作原理

长度为 L 的 LFSR 由 L 个级（延迟元件）组成，每一级存储一位，另有一个控制数据流动的时钟。<sup>[4](https://ebrary.net/134500/computer_science/feedback_shift_registers)</sup> 反馈取自寄存器链上若干选定的点，称为抽头，这些抽头异或后送回寄存器；没有输入抽头的寄存器位则表现得如同标准移位寄存器。抽头的选择决定了序列在重复之前会出现多少个值。<sup>[2](https://www.ece.ualberta.ca/~elliott/ee552/studentAppNotes/1999f/Drivers_Ed/lfsr.html)</sup>

反馈连接由 GF(2) 上的特征多项式以代数方式描述。若该多项式为本原多项式，寄存器在每个周期内恰好遍历每一个非零状态一次，从而给出可能的最长序列，即 n 级时周期为 2^n − 1 的 m 序列；全零状态被排除在外，因为处于该状态的寄存器将永远无法离开。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> 对任意自然数 n 都存在本原多项式。<sup>[5](https://www.utupub.fi/bitstream/handle/10024/45076/TUCSDISS118Dudkov.pdf?isAllowed=y&sequence=1)</sup> 由长度为 L、反馈多项式为本原多项式的 LFSR 生成的序列具有可能达到的最高线性复杂度，等于 L，并具有可能达到的最大周期。<sup>[6](https://www.rocq.inria.fr/secret/Pascale.Charpin/encyclopedia-tout.pdf)</sup>

**两种电路形式。** 实现形式有[斐波那契](https://www.edgepedia.org/zh/fibonacci)结构和伽罗瓦结构，反馈门可用异或门或同或门；FPGA 厂商库同时支持这两种结构，并允许通过可重载输入随时改变寄存器的值。<sup>[7](https://docs.amd.com/r/en-US/ug958-vivado-sysgen-ref/LFSR)</sup> 在 FPGA 设计中，一对多（伽罗瓦式）布线往往更受青睐，因为它给出的时钟到时钟延迟路径最短。<sup>[2](https://www.ece.ualberta.ca/~elliott/ee552/studentAppNotes/1999f/Drivers_Ed/lfsr.html)</sup>

## m 序列的统计特性

最大长度序列具有三种特性，使其在一切需要确定性、可复现的白噪声式信号之处都有用武之地：0 与 1 的数目几乎相等、自相关函数只有一个峰、游程长度分布均衡。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> 这些特性在二十世纪中叶通过有限域代数和线性递推序列理论得以确立，[南加州大学](https://www.edgepedia.org/zh/university-of-southern-california)数学家[所罗门·W·戈隆布](https://www.edgepedia.org/zh/solomon-w-golomb)（Solomon W. Golomb）在二十世纪五十年代和六十年代发展了移位寄存器序列理论；他的著作《移位寄存器序列》（*Shift Register Sequences*）于 1967 年首次出版、1982 年修订，是该主题的开创性论著。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup><sup> • </sup><sup>[8](https://www.cambridge.org/core/books/abs/signal-design-for-good-correlation/feedback-shift-register-sequences/BAAF89EFBC7F6C28843120D84D3166CE)</sup>

## 密码学用途与局限

流密码长期以来一直用 LFSR 作为密钥流生成器，因为它在硬件上很经济：密钥初始化寄存器状态，寄存器输出密钥流，与明文异或。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> 其根本弱点在于线性。Berlekamp-Massey 算法是一个 O(n^2) 的过程，能恢复出产生任何观测到的二进制序列的最小 LFSR；仅凭 2n 位密钥流，攻击者就能精确重建寄存器及其多项式，从而完全攻破密码。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> 为对抗这一弱点，密码要么用非线性组合函数合并多个 LFSR——GSM 语音加密所用的 [A5/1](https://www.edgepedia.org/zh/a5-1) 密码即采用此法——要么让寄存器的输出经过一个非线性滤波器。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> 对密码学伪随机数生成器的实证测试发现，基于 LFSR 的生成器属于表现较弱者之列，因此单靠它们并不太适合密码学用途的随机数生成。<sup>[9](https://www.mdpi.com/2227-7390/11/23/4812)</sup>

## 硬件与测试应用

**内建自测试。** 在内建自测试（BIST）方法中，LFSR 产生确定性的测试向量来驱动被测电路，另有一个独立的签名寄存器把该电路的响应压缩成一个短签名，用于比较。LFSR 电路的紧凑性使其适合直接用于被测芯片内部。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> 面向低功耗 BIST 的 LFSR 功耗优化是一个活跃的工程课题。<sup>[10](https://ieeexplore.ieee.org/document/5942075/)</sup>

**循环冗余校验。** 硬件中的 CRC 计算是一个多项式除法过程，用长度等于生成多项式次数的移位寄存器实现，在相应多项式系数为 1 的位置放置异或门。串行实现每比特需要一个时钟，因此高速网络应用改用并行实现。<sup>[11](https://www.xilinx.com/publications/archives/xcell/Xcell60.pdf)</sup> 例如英飞凌（Infineon）的 CRC 组件把 CRC 实现为带有独立多项式寄存器和种子寄存器的 LFSR，每输入一个字节需要八个时钟。<sup>[3](https://www.infineon.com/assets/row/public/documents/cross-divisions/396/infineon-component-crc-v2.40-software-module-datasheets-en.pdf?fileId=8ac78c8c7d0d8da4017d0e85774a164a)</sup>

**扩频及其他用途。** 在直接序列扩频中，由 LFSR 生成的扩频码把窄带信号扩展到宽带宽上。<sup>[1](https://technav.ieee.org/topic/linear-feedback-shift-registers/)</sup> 更广泛地说，反馈移位寄存器序列可用作同步码、掩码和扰码，CDMA 通信中的信号集，密钥流生成器，随机数生成器，以及硬件设计中的测试向量。<sup>[8](https://www.cambridge.org/core/books/abs/signal-design-for-good-correlation/feedback-shift-register-sequences/BAAF89EFBC7F6C28843120D84D3166CE)</sup> 其他有文献记载的应用包括数据加扰与解扰、数据完整性校验和、数据压缩、数字信号处理以及优化计数器。<sup>[2](https://www.ece.ualberta.ca/~elliott/ee552/studentAppNotes/1999f/Drivers_Ed/lfsr.html)</sup>

## 变体与相关生成器

广义反馈移位寄存器生成器增加了反馈抽头的数量，与双抽头设计相比可大大削弱相关性。<sup>[13](https://arxiv.org/abs/cond-mat/9710104)</sup> 非线性反馈移位寄存器取消了线性限制，而德布鲁因序列可通过循环拼接法由 LFSR 构造出来。<sup>[14](https://arxiv.org/abs/1611.10088)</sup> LFSR 也可以定义在扩域 GF(2^n) 而非二元域上，软件实现会利用这一点来提升性能。<sup>[15](https://www.sciencedirect.com/science/article/abs/pii/S0045790611000401)</sup>

## References

1. [Linear feedback shift registers, IEEE Technology Navigator](https://technav.ieee.org/topic/linear-feedback-shift-registers/)
2. [Linear Feedback Shift Register, University of Alberta EE 552 student application notes (Sung, Sung, Chan, Mah)](https://www.ece.ualberta.ca/~elliott/ee552/studentAppNotes/1999f/Drivers_Ed/lfsr.html)
3. [CRC V2.40 Component Datasheet, Infineon/Cypress PSoC Creator](https://www.infineon.com/assets/row/public/documents/cross-divisions/396/infineon-component-crc-v2.40-software-module-datasheets-en.pdf?fileId=8ac78c8c7d0d8da4017d0e85774a164a)
4. [Feedback shift registers, Linear feedback shift registers, ebrary.net](https://ebrary.net/134500/computer_science/feedback_shift_registers)
5. [Alexey Dudkov, dissertation, University of Turku](https://www.utupub.fi/bitstream/handle/10024/45076/TUCSDISS118Dudkov.pdf?isAllowed=y&sequence=1)
6. [Encyclopedia of sequences, Pascale Charpin, INRIA](https://www.rocq.inria.fr/secret/Pascale.Charpin/encyclopedia-tout.pdf)
7. [LFSR block, Vivado Design Suite Reference Guide UG958, AMD/Xilinx](https://docs.amd.com/r/en-US/ug958-vivado-sysgen-ref/LFSR)
8. [Solomon W. Golomb and Guang Gong, Feedback Shift Register Sequences, Chapter 4 of Signal Design for Good Correlation, Cambridge University Press](https://www.cambridge.org/core/books/abs/signal-design-for-good-correlation/feedback-shift-register-sequences/BAAF89EFBC7F6C28843120D84D3166CE)
9. [Cryptographically Secured Pseudo-Random Number Generators: Analysis and Testing with NIST Statistical Test Suite, Mathematics (MDPI)](https://www.mdpi.com/2227-7390/11/23/4812)
10. [A review on power optimization of linear feedback shift register (LFSR) for low power built-in self-test (BIST), IEEE Xplore](https://ieeexplore.ieee.org/document/5942075/)
11. [CRC hard block implementation, Xcell Journal issue 60, Xilinx](https://www.xilinx.com/publications/archives/xcell/Xcell60.pdf)
12. [A search for good pseudo-random number generators: Survey and empirical studies, ScienceDirect](https://www.sciencedirect.com/science/article/pii/S1574013722000144)
13. [Four-tap shift-register-sequence random-number generators, arXiv](https://arxiv.org/abs/cond-mat/9710104)
14. [On Binary de Bruijn Sequences from LFSRs with Arbitrary Characteristic Polynomials, arXiv](https://arxiv.org/abs/1611.10088)
15. [Performance evaluation of highly efficient techniques for software implementation of LFSR, ScienceDirect](https://www.sciencedirect.com/science/article/abs/pii/S0045790611000401)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Algorithms and computational methods › Numerical, string, and geometric algorithms › Pseudorandomness and hashing algorithms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/linear-feedback-shift-register

English original: https://www.edgepedia.org/linear-feedback-shift-register
