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
相关推荐
日晨难再5 天前
Verilog基础:$display系统函数和C语言中的库函数printf的区别
c语言·硬件工程·verilog·数字ic
日晨难再8 天前
Verilog基础:时序调度中的竞争(四)(描述时序逻辑时使用非阻塞赋值)
fpga开发·硬件工程·verilog·fpga·数字ic
FPGA狂飙11 天前
FPGA IP 和 开源 HDL 一般去哪找?
fpga开发·verilog·fpga·vivado·xilinx
小桶qa13 天前
握手传输 & 状态机序列检测(记忆科技笔试题)_2024年9月2日
verilog
看未来捏18 天前
【数字集成电路与系统设计】Chisel/Scala简介与Verilog介绍
scala·verilog·chisel
小桶qa19 天前
音频左右声道数据传输_2024年9月6日
音频·verilog
吉孟雷21 天前
ZYNQ FPGA自学笔记
fpga开发·verilog·led·仿真·vivado·zynq
热爱学习地派大星1 个月前
BRAM IP Native模式使用
fpga开发·ip·verilog·fpga·存储器·bram
FPGA狂飙1 个月前
1分钟 快速掌握 双向信号(inout信号)
fpga开发·verilog·fpga·xilinx
米联客(milianke)1 个月前
[米联客-XILINX-H3_CZ08_7100] FPGA程序设计基础实验连载-24 TPG图像测试数据发生器设计
fpga开发·verilog