Home / Learn Verilog / LFSR: Pseudo-Random Numbers
LFSR: Pseudo-Random Numbers
Shift register with XOR feedback.
In shortShift register with XOR feedback.
What's actually going on
The basic idea
An LFSR shifts and feeds back XOR of selected taps, cycling through 2^N - 1 states.
Why this comes up
Test patterns, scrambling, CRC.
The mechanics
Taps for 4 bits: x^4 + x^3 + 1.
Where it is used
- Everyday RTL design
- FPGA and ASIC projects
- Testbenches and debugging
Try it
4-bit LFSRVerilog: edit and run
Visits all 15 non-zero values, then repeats. Zero is a lock-up state.
Quick check
1. 4-bit LFSR period?
2^4 - 1.