【问题标题】:How do I build a 5-bit maximal-length Galois LFSR in Verilog?如何在 Verilog 中构建 5 位最大长度的 Galois LFSR?
【发布时间】:2020-09-28 23:59:03
【问题描述】:

我无法获得所需的输出。

这是我的代码:

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

这是我的输出与正确输出的时序图。

我也不断收到此错误:

警告 (13024):输出引脚卡在 VCC 或 GND

我无法使用 Testbench 代码,因为它是在 HDLBits website 的幕后完成的。

【问题讨论】:

    标签: verilog lfsr


    【解决方案1】:

    你有接线错误。

    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
    

    注意:如果您在网站上进行尝试,您可以看到 HDLBits 解决方案。例如,我输入了合法(但错误)的解决方案:assign q=0;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 2017-12-25
      • 2021-03-09
      • 2019-04-13
      相关资源
      最近更新 更多