如何在Verilog中构建5位最大长度Galois LFSR?

如何在Verilog中构建5位最大长度Galois LFSR?,verilog,lfsr,Verilog,Lfsr,我在获取所需输出时遇到问题 这是我的密码: module top_module( input clk, input reset, // Active-high synchronous reset to 5'h1 output reg [4:0] q ); wire din3; assign din3 = q[3] ^ q[0]; always @(posedge clk) begin if (reset)

我在获取所需输出时遇到问题

这是我的密码:

module top_module(
    input clk,
    input reset,    // Active-high synchronous reset to 5'h1
    output reg [4:0] q
); 
    wire din3;

    assign din3 = q[3] ^ q[0];
    always @(posedge clk)
    begin
        if (reset)
            q <= 5'd1;
        else
            q <= {q[0],din3,q[2],q[1],q[0]};
    end
endmodule
模块顶部\u模块(
输入时钟,
输入复位,//主动高同步复位至5'h1
输出寄存器[4:0]q
); 
钢丝din3;
分配din3=q[3]^q[0];
始终@(posedge clk)
开始
如果(重置)

q您有接线错误

module top_module(
    input clk,
    input reset,    // Active-high synchronous reset to 5'h1
    output reg [4:0] q
); 

    always @(posedge clk)
    begin
        if (reset)
            q <= 5'd1;
        else
            q <= {q[0], q[4], (q[0] ^ q[3]), q[2], q[1]};
    end
endmodule
模块顶部\u模块(
输入时钟,
输入复位,//主动高同步复位至5'h1
输出寄存器[4:0]q
); 
始终@(posedge clk)
开始
如果(重置)
Q