1

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)
            q <= 5'd1;
        else
            q <= {q[0],din3,q[2],q[1],q[0]};
    end
endmodule

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

时序图

我也不断收到此错误:

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

Testbench 代码对我不可用,因为它是在HDLBits 网站的幕后完成的。

4

1 回答 1

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;.

于 2020-09-29T00:26:47.837 回答