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
相关推荐
Js_cold17 小时前
Verilog局部参数localparam
开发语言·fpga开发·verilog
Js_cold2 天前
Verilog宏define
fpga开发·verilog
迎风打盹儿2 天前
一种无需IP核的FPGA RAM初始化方法:基于源码定义与赋值实现
fpga开发·verilog·vivado·ram·rom
bnsarocket4 天前
Verilog和FPGA的自学笔记8——按键消抖与模块化设计
笔记·fpga开发·verilog·自学·硬件编程
bnsarocket6 天前
Verilog和FPGA的自学笔记9——呼吸灯
笔记·fpga开发·verilog·自学·硬件编程
云雾J视界9 天前
RISC-V开源处理器实战:从Verilog RTL设计到FPGA原型验证
fpga开发·开源·verilog·risc-v·rtl·数字系统
FPGA_小田老师17 天前
FPGA开发入门:深入理解计数器——数字逻辑的时序基石
fpga开发·verilog·状态机·计数器·计数器设计
FPGA狂飙20 天前
传统FPGA开发流程的9大步骤是哪些?
fpga开发·verilog·fpga·vivado·xilinx
bnsarocket23 天前
Verilog和FPGA的自学笔记6——计数器(D触发器同步+异步方案)
笔记·fpga开发·verilog·自学·硬件编程
bnsarocket25 天前
Verilog和FPGA的自学笔记2——点亮LED
笔记·fpga开发·verilog·自学