首页 > 解决方案 > 如何修复在verilog中分配多个值错误?

问题描述

以下是研究verilog分层设计的尝试。这是我正在实现的电路:

在此处输入图像描述

电路的顶层模块是:

 module D_Filiflop_Hierarchal_top_level (clock, reset, i_d, q);

    input clock;
    input reset;
    input i_d;
    output [1:0] q;


    D_Flipflop u0 (.clk(clock), .rst(reset), .q(q[0]), .d(i_d));
    D_Flipflop u1 (.clk(clock), .rst(reset), .q(q[1]), .d(q[0]));

endmodule

以下是定义的 D 触发器模块:

module D_Flipflop(clk,rst, d, q);
input clk;
input rst;
output d;
output reg q;

always @ (posedge clk or posedge rst) begin

    if (rst) begin
    q <= 1'b0;
    end

    else begin
    q <= d;
    end

end 

endmodule

但是,这是控制台显示的错误消息:

Error (12014): Net "q[0]", which fans out to "q[0]", cannot be assigned more than one value
    Error (12015): Net is fed by "D_Flipflop:u0|q"
    Error (12015): Net is fed by "D_Flipflop:u1|d"

在此处输入图像描述

我该如何解决这个错误?

标签: veriloghierarchical

解决方案


更改output为:input_d

module D_Flipflop(clk,rst, d, q);
input clk;
input rst;
input d;
output reg q;

推荐阅读