[英]Verilog Error: Object on left-hand side of assignment must have a variable data type
I'm trying to write a top-level module in Verilog that will open a water valve whenever a sensor reads values below a certain number. 我正在尝试在Verilog中编写一个顶层模块,每当传感器读取的数值低于某个特定数值时,该模块就会打开水阀。
Here is my code: 这是我的代码:
module ProjectDSD(alteraClock, sensorInput, openValve);
input sensorInput, alteraClock;
output openValve;
always @(sensorInput)
begin
if(sensorInput < 100) //sensor value to irrigate at
begin
openValve <= 1; //here
end
else
begin
openValve <= 0; //here
end
end
endmodule
Im getting an error saying: 我收到一个错误消息:
Object "openValve" on left-hand side of assignment must have a variable data type
分配左侧的对象“ openValve”必须具有可变数据类型
What am I missing? 我想念什么? Also, which pins can I use on an Altera DE2-155 board to output a digital signal of only 1's and 0's for the the valve to open/close?
另外,我可以在Altera DE2-155板上使用哪些引脚来输出仅1和0的数字信号以打开或关闭阀门?
openValve
is currently inferred as a wire
. 目前将
openValve
推断为wire
。 Add reg openValve;
添加
reg openValve;
below output openValve;
下面
output openValve;
and your code will work. 这样您的代码就会起作用。
Suggestions: It looks like you are following the IEEE1364-1995 non-ANSI coding style. 建议:您似乎正在遵循IEEE1364-1995非ANSI编码样式。 Will still legal, you might want to change to the ANSI coding style, supported in IEEE1364-2001 and above.
仍然合法,您可能想要更改为IEEE1364-2001及更高版本支持的ANSI编码样式。
Non-ANSI: 非ANSI:
module ProjectDSD(alteraClock, sensorInput, openValve);
input sensorInput, alteraClock;
output openValve;
reg openValve;
ANSI: ANSI:
module ProjectDSD(
input alteraClock, sensorInput,
output reg openValve);
For combinational blocks, it is recommended to use always @*
(or the synonymous always @(*)
) instead of always @(sensorInput)
. 对于组合块,建议
always @*
使用always @*
(或同义的always @(sensorInput)
always @(*)
)而不是always @(sensorInput)
。 @*
is an auto sensitivity list also added in IEEE1364-2001 @*
是自动灵敏度列表,也在IEEE1364-2001中添加
Try output reg openValve;
尝试
output reg openValve;
. 。
For the second half of your question (which should really be a separate question) import this QSF file into your project. 对于问题的后半部分(应该是一个单独的问题), 将这个QSF文件导入到您的项目中。 Any of the GPIO can be configured as outputs, and are accessible by the 40-pin header on the side.
任何GPIO都可以配置为输出,并且可以通过侧面的40针接头进行访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.