如何修复 verilog 中分配多个值的错误?
How can I fix assigning more than one value error in 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"
我该如何解决这个错误?
将 output
更改为 input
for d
:
module D_Flipflop(clk,rst, d, q);
input clk;
input rst;
input d;
output reg q;
以下是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"
我该如何解决这个错误?
将 output
更改为 input
for d
:
module D_Flipflop(clk,rst, d, q);
input clk;
input rst;
input d;
output reg q;