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
相关推荐
greatdan3 天前
[HDL设计] 片外串行总线-IIC
fpga开发·verilog·xilinx
greatdan3 天前
[HDL设计] 片外串行总线-SPI
fpga开发·verilog·xilinx
南檐巷上学7 天前
基于FPGA的音频信号监测识别系统
fpga开发·音频·verilog·fpga·傅立叶分析·fft·快速傅里叶变换
FPGA小迷弟9 天前
基于FPGA实现HDMI接口,选型/核心技术
学习·fpga开发·verilog·fpga·modelsim
FPGA小迷弟10 天前
FPGA处理图像需要用到的主流接口详解
学习·fpga开发·verilog·fpga·modelsim
不吃橘子的橘猫14 天前
Verilog HDL基础(概念+模块)
开发语言·学习·算法·fpga开发·verilog
北方孤寂的灵魂1 个月前
systemverilog中随机std::randomize的用法
verilog·systemverilog·sv·数字验证
FPGA_小田老师1 个月前
FPGA例程(4):按键消抖实验
fpga开发·verilog·fpga demo·fpga例程
FPGA小迷弟1 个月前
京微齐力FPGA联合modelsim仿真操作
fpga开发·ic·verilog·fpga·仿真
FPGA_小田老师1 个月前
FPGA例程(3):按键检测实验
fpga开发·verilog·vivado·led灯·按键测试