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
相关推荐
tiantianuser2 天前
RDMA简介5之RoCE v2队列
fpga开发·verilog·fpga·rdma·高速传输·rocev2
迎风打盹儿3 天前
FPGA仿真中阻塞赋值(=)和非阻塞赋值(<=)区别
verilog·fpga·阻塞赋值·非阻塞赋值·testbench仿真
tiantianuser4 天前
RDMA简介3之四种子协议对比
verilog·fpga·vivado·rdma·高速传输
可编程芯片开发11 天前
基于FPGA的DES加解密系统verilog实现,包含testbench和开发板硬件测试
fpga开发·des·verilog·加解密
可编程芯片开发1 个月前
基于FPGA的PID控制器verilog实现,包含simulink对比模型
fpga开发·verilog·simulink·pid控制器
__pop_1 个月前
SV 仿真的常识
verilog
nanxl11 个月前
FPGA-DDS信号发生器
fpga开发·verilog·vivado
nanxl11 个月前
FPGA-数字时钟
fpga开发·verilog·vivado
__pop_2 个月前
system verilog 语句 耗时规则
verilog
0基础学习者2 个月前
按键消抖(用状态机实现)
前端·笔记·fpga开发·verilog·fpga