verilog - 错误:(vlog-2110)非法引用网络“代码”
问题描述
我试过这段代码,但它显示错误:
gray_counter\gray_counter.v(2): (vlog-2110) 非法引用网络“代码”
module gray_counter(code,clk,rst,count);//module declaration
input [2:0]code=3'b000;
input clk,rst;
output reg count;
reg [2:0]conv_code;
always@(posedge clk , posedge rst)
begin
if(rst)
begin
count=0;
end
else
begin
conv_code={code[0],code[0]^code[1],code[1]^code[2]};//converting binary code to gray
case(conv_code)
3'b000:count=count+1;
3'b001:count=count+1;
3'b011:count=count+1;
3'b010:count=count+1;
3'b110:count=count+1;
3'b100:count=count+1;
3'b101:count=count+1;
3'b111:count=count+1;
default:count=count+0;
endcase
end
end
endmodule
解决方案
input
给模块内的端口赋值是非法的。改变:
input [2:0]code=3'b000;
至:
input [2:0]code;
您只能从模块外部驱动值,例如,在测试平台模块中。
一些模拟器会给你更具体的帮助。我在 VCS 中看到了这一点:
Error-[V2KIIAD] Invalid initialization at declaration
Source info: input [2:0]code=3'b000;
Non-output port 'code' cannot be initialized at declaration.
如果您在 edaplayground 上注册一个免费帐户,您可以在多个模拟器上试用您的代码。
推荐阅读
- python - 如何使用 Python 访问剑桥词典网站?
- python - 使用 pip 从 zip 安装 python 模块失败
- php - 查找下一个可用产品的 Woocommerce 税务查询(最近的属性)
- javascript - 页面正文滚动时如何滚动元素?
- java - 套接字中的 Java 客户端
- java - 无法加载配置
- jquery - 如何在角度 8 的对象数组中进行分组
- sql - 排序字母数字 ID 号
- java - 获取 net.sf.json.JSONException:java.lang.reflect.InvocationTargetException
- python - python错误:'int'对象不可下标