
A LFSR or Linear Feedback Shift Register is a quick and easy way to generate Purpose: Load up LFSR with Seed if Data Valid (DV) pulse is detected. Signal r_LFSR : std_logic_vector(g_Num_Bits downto 1) := (others => '0') O_LFSR_Data : out std_logic_vector(g_Num_Bits-1 downto 0) I_Seed_Data : in std_logic_vector(g_Num_Bits-1 downto 0) g_Num_Bits - Set to the integer number of bits wide to create your LFSR. clock cycle that the module is enabled, which can be used if desired. will pulse every 2^5-1 = 31 clock cycles. For example, setting g_Num_Bits to 5 means that o_LFSR_Done number of clock cycles that it takes o_LFSR_Done to pulse is equal to o_LFSR_Done will pulse once all combinations of the LFSR are complete. This module creates an LFSR whose width gets set by a generic. for things like counters, test patterns, scrambling of data, and others. way to generate pseudo-random data inside of an FPGA. A LFSR or Linear Feedback Shift Register is a quick and easy Here is the full table of all LFSR patterns published by Xilinx. I based this on an XNOR implementation to allow the FPGA to start up in an all-zero state on the LFSR. Therefore, for 3 bits, it takes 2 3-1=7 clocks to run through all possible combinations, for 4 bits: 2 4-1=15, for 5 bits: 2 5-1=31, etc. It uses polynomials (which is the math behind the LFSR) to create the maximum possible LFSR length for each bit width. The VHDL and Verilog code creates any N-Bit wide LFSR that you desire. That pattern is all 0’s when using XOR gates, or all 1’s when using XNOR gates as your feedback gate. Therefore there is only one pattern that cannot be expressed using an LFSR. If you think about it, all possible patterns of something that is N-bits long is 2 N. The longest possible number of iterations for an LFSR of N-bits is 2 N-1. Longer LFSRs will take longer to run through all iterations.

The maximum possible number of iterations of any LFSR = 2 Bits-1.Since 1 XNORed with 1 will always produce 1, the LFSR will stop running. A pattern of all 1’s cannot appear when the taps use XNOR gates.Since 0 XORed with 0 will always produce 0, the LFSR will stop running. A pattern of all 0’s cannot appear when the taps use XOR gates.You can figure out the next state by knowing the position of the XOR gates as well as the current pattern.
