简体   繁体   English

Verilog错误:分配左侧的对象必须具有可变数据类型

[英]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的数字信号以打开或关闭阀门?

s/output openValve/output reg openValve/ s / output openValve /输出reg openValve /

Outputs default to wire ; 输出默认为wire ; you need a reg . 您需要reg See also this question. 另请参阅问题。

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.

相关问题 Verilog:作业左侧必须具有可变数据类型 - Verilog: on left-hand side of assignment must have a variable data type 错误(10219):Mux.v处的Verilog HDL连续分配错误(19):分配左侧的对象“ muxout”必须具有网络类型 - Error (10219): Verilog HDL Continuous Assignment error at Mux.v(19): object “muxout” on left-hand side of assignment must have a net type Verilog HDL错误:左侧分配非法 - Verilog HDL error: Illegal left-hand side assignment Verilog错误:连续分配左侧的寄存器非法 - Verilog error: Register is illegal in left-hand side of continuous assignment 为什么导线变量导致连续分配中的非法左侧? - Why is wire variable causing illegal left-hand side in continuous assignment? 不允许对非寄存器 shifty 进行程序分配,左侧应该是 reg/integer/time/genvar——这是我得到的错误 - Procedural assignment to a non-register shiftedy is not permitted, left-hand side should be reg/integer/time/genvar -- this is the error I am getting 左侧对象的Verilog代码错误应分配一个变量 - error in verilog code of object on left side should be assigned a variable 连续分配的左侧是非法的 - The left-hand-side of continuous assignment is illegal 封锁作业的左侧无效 - Illegal left hand side of blocking assignment Verilog错误“连续赋值output必须是网” - Verilog error "continuous assignment output must be a net"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM