gpt4 book ai didi

verilog - 不能由原语或连续赋值驱动

转载 作者:行者123 更新时间:2023-12-02 17:52:06 25 4
gpt4 key购买 nike

我得到了

reg OUT; cannot be driven by primitives or continuous assignment.

错误。

计数器模块是:

module Counter(
input clk,
input clear,
input load,
input up_down, // UP/~DOWN
input[3:0] IN,
input count,
output reg[3:0] OUT
);
always @(posedge clk, negedge clear)
if (~clear) OUT <= 4'b0000;
else if(load) OUT <= IN;
else if(count)
begin
if(up_down) OUT <= OUT + 1'b1;
else OUT <= OUT - 1'b1;
end
else OUT <= OUT;
endmodule

测试平台是:

module test;
.
.
.
reg [3:0] IN;
reg [3:0] OUT;

Counter c1(clk, clear, load, up_down, IN, count, OUT);
endmodule

错误出现在 Counter c1(clk, clear, load, up_down, IN, count, OUT); 行。

最佳答案

问题是 test 模块具有以下声明:

reg [3:0] OUT;

reg 不应连接到模块output

test中的reg更改为wire,然后确保没有其他信号驱动OUT网络测试:

wire [3:0] OUT;

关于verilog - 不能由原语或连续赋值驱动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30127343/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com