Lfsr5

A linear feedback shift register is a shift register usually with a few XOR gates to produce the next state of the shift register. A Galois LFSR is one particular arrangement where bit positions with a "tap" are XORed with the output bit to produce its next value, while bit positions without a tap shift. If the taps positions are carefully chosen, the LFSR can be made to be "maximum-length". A maximum-length LFSR of n bits cycles through 2n-1 states before repeating (the all-zero state is never reached).

The following diagram shows a 5-bit maximal-length Galois LFSR with taps at bit positions 5 and 3. (Tap positions are usually numbered starting from 1). Note that I drew the XOR gate at position 5 for consistency, but one of the XOR gate inputs is 0.

module top_module(
    input clk,
    input reset,    // Active-high synchronous reset to 5'h1
    output [4:0] q
); 

    
    always@ (posedge clk)
        if(reset)
            q <= 5'h1;
    	else begin
            q[0] <= q[1];
            q[1] <= q[2];
            q[2] <= q[0] ^ q[3];
            q[3] <= q[4];
            q[4] <= 0 ^ q[0];
        end
endmodule
相关推荐
超级大咸鱼3 天前
CW信号的正交解调
matlab·verilog·fpga·数字信号·解调·正交解调·cw
fei_sun8 天前
【计组】实验三 ORI指令设计实验
fpga开发·verilog·计组
热爱学习地派大星11 天前
FPGA在线升级 -- Multiboot
fpga开发·verilog·fpga·远程升级·升级程序
杨德杰12 天前
Verilog实现图像处理的行缓存Line Buffer
图像处理·verilog·fpga·isp·行缓存linebuffer
杨德杰20 天前
异步FIFO的实现
fpga开发·verilog
fei_sun22 天前
【Verilog】实验六 移位寄存器的设计
fpga开发·verilog
fei_sun1 个月前
【Verilog】第三章作业
fpga开发·verilog
Astron_fjh1 个月前
数字IC知识点:处理多个时钟
verilog
fei_sun1 个月前
【Verilog】第一章作业
fpga开发·verilog
fei_sun1 个月前
【Verilog】第二章作业
fpga开发·verilog