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
相关推荐
北方孤寂的灵魂2 天前
systemverilog中随机std::randomize的用法
verilog·systemverilog·sv·数字验证
FPGA_小田老师4 天前
FPGA例程(4):按键消抖实验
fpga开发·verilog·fpga demo·fpga例程
FPGA小迷弟10 天前
京微齐力FPGA联合modelsim仿真操作
fpga开发·ic·verilog·fpga·仿真
FPGA_小田老师11 天前
FPGA例程(3):按键检测实验
fpga开发·verilog·vivado·led灯·按键测试
FPGA小迷弟14 天前
modelsim使用教程,仿真技巧,精华帖
fpga开发·verilog·fpga·modelsim
才鲸嵌入式22 天前
香山CPU(国产开源)的 SoC SDK底层程序编写,以及其它开源SoC芯片介绍
c语言·单片机·嵌入式·arm·cpu·verilog·fpga
莫问前程_满城风雨24 天前
verilog 可变范围的bit选择
运维·服务器·verilog
啄缘之间25 天前
10.基于 MARCH C+ 算法的SRAM BIST
经验分享·笔记·学习·verilog
s09071361 个月前
FPGA中同步与异步复位
fpga开发·verilog·xilinx·zynq
民乐团扒谱机1 个月前
十字路口交通信号灯控制器设计(Multisim 电路 + Vivado 仿真)
单片机·fpga开发·verilog·状态机·仿真·时序逻辑·multism