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
相关推荐
FPGA小迷弟2 天前
FPGA工程师面试题汇总(二十五)
网络协议·tcp/ip·fpga开发·verilog·fpga
FPGA小迷弟4 天前
FPGA工程师面试题汇总(二十四)
网络协议·tcp/ip·fpga开发·verilog·fpga
FPGA小迷弟10 天前
FPGA工程师面试题汇总(九)
网络协议·tcp/ip·fpga开发·面试·verilog·fpga
星华云12 天前
[FPGA]Spartan6 Uart可变波特率读写JY901P惯导模块
fpga开发·verilog·jy901p·spartan6·惯导
星华云14 天前
[FPGA]Spartan6 Uart固定波特率读写JY901P惯导模块
fpga开发·verilog·jy901p·惯导模块
FPGA小迷弟14 天前
FPGA面试题汇总整理(一)
学习·fpga开发·verilog·fpga
FPGA小迷弟15 天前
FPGA工程师面试题汇总(二)
学习·fpga开发·verilog·fpga
FPGA小迷弟16 天前
FPGA 时序约束基础:从时钟定义到输入输出延迟的完整设置
前端·学习·fpga开发·verilog·fpga
FPGA小迷弟17 天前
高频时钟设计:FPGA 多时钟域同步与时序收敛实战方案
前端·学习·fpga开发·verilog·fpga
FPGA小迷弟1 个月前
FPGA工业常用接口:FPGA 的 SPI 总线多从机通信设计与时序优化
学习·fpga开发·verilog·fpga·modelsim