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
相关推荐
tiantianuser19 天前
RDMA简介7之RoCE v2可靠传输
服务器·fpga开发·verilog·xilinx·rdma·可编程逻辑
9527华安24 天前
国产安路FPGA纯verilog图像缩放,工程项目解决方案,提供5套TD工程源码和技术支持
fpga开发·verilog·图像缩放·双线性插值·安路fpga
tiantianuser1 个月前
RDMA简介5之RoCE v2队列
fpga开发·verilog·fpga·rdma·高速传输·rocev2
迎风打盹儿1 个月前
FPGA仿真中阻塞赋值(=)和非阻塞赋值(<=)区别
verilog·fpga·阻塞赋值·非阻塞赋值·testbench仿真
tiantianuser1 个月前
RDMA简介3之四种子协议对比
verilog·fpga·vivado·rdma·高速传输
可编程芯片开发1 个月前
基于FPGA的DES加解密系统verilog实现,包含testbench和开发板硬件测试
fpga开发·des·verilog·加解密
可编程芯片开发2 个月前
基于FPGA的PID控制器verilog实现,包含simulink对比模型
fpga开发·verilog·simulink·pid控制器
__pop_2 个月前
SV 仿真的常识
verilog
nanxl12 个月前
FPGA-DDS信号发生器
fpga开发·verilog·vivado
nanxl12 个月前
FPGA-数字时钟
fpga开发·verilog·vivado