verilog - 将始终块用于半加器时出错:总和不是有效的左值
问题描述
module halfadder(a,B,sum,carry);
input a,B;
output sum,carry;
always@(a,B)
begin
sum=a^B;
carry=a&B;
end
endmodule
对于上面的代码,我收到错误:
: sum is not a valid l-value in tb_halfadder.ha.
: sum is declared here as wire.
: carry is not a valid l-value in tb_halfadder.ha.
: carry is declared here as wire.
解决方案
sum
并且carry
不是有效的左值,因为它们是在一个always
块中驱动的。它们应该被声明为reg
.
reg sum, carry;
当一个端口没有用类型声明时,它会自动获得一个wire
.
推荐阅读
- dataframe - 在数据帧上使用 ipywidgets SelectMultiple
- c - C - 为什么我的代码在删除未使用的变量声明时会中断
- python - 列表项之间的无意串联
- python - 如何替换pyspark数据框中的非ASCII字符
- python - 如何抑制 * 作为通配符,而不是解释为字符?
- reactjs - 当我单击应该加载它们的链接时,我的组件没有被呈现
- html - 我无法集中注意力让孩子影响父母
- c# - 无法在 AWS cloudwatch 的计划规则中添加 lambda 目标
- javascript - (PureJS/CSS) 隐藏 div 标签之间的淡入淡出
- node.js - Crypto.decipher.final for 'aes-256-cbc' algorithm with invalid key fails with bad decrypt