我一直在尝试在总是用梳子块分配输出值的过程中遇到这个问题,但是每次我编译说
时,它总是使我出错Error-[IBLHS-NT] Illegal behavioral left hand side
hits.sv, 10
Net type cannot be used on the left side of this assignment.
The offending expression is : NumHits
Source info: NumHits = 7'b0;
我不确定为什么会发生这种情况,我很确定在始终梳状块中分配输出值应该合法,有人可以帮我吗?
`default_nettype none
module checkHits
(output logic hit, [6:0] NumHits, [4:0] BiggestShipHit,
input logic bomb, [3:0] x, [3:0] y);
always_comb begin
hit = 1'b0;
NumHits = 7'b0000000;
BiggestShipHit = 5'b00000;
if (bomb == 1'b1) begin
if ((x == 4'b0001 && y == 4'b1010)) begin
hit = 1'b1;
NumHits = 7'b0000010;
BiggestShipHit = 5'b00010;
end
else if ((x == 4'b0001 && y == 4'b0001)) begin
hit = 1'b1;
NumHits = 7'b0000011;
BiggestShipHit = 5'b01000;
end
else if (x == 4'b1010 && y == 4'b0001) begin
hit = 1'b1;
NumHits = 7'b0000010;
BiggestShipHit = 5'b00001;
end
else if (x == 4'b1010 && y == 4'b1010) begin
hit = 1'b0;
end
else if (x == 4'b0001) begin
if ((x == 4'b0010 && y + 1'b1 == 4'b1010) || (x == 4'b0010 &&
y == 4'b1010) || (x == 4'b0010 && y - 1'b1 == 4'b1010) ||
(x + 1'b1 == 4'b0010 && y + 1'b1 == 4'b1010) ||
(x + 1'b1 == 4'b0010 && y == 4'b1010) ||
(x + 1'b1 == 4'b0010 && y -1'b1 == 4'b1010)) begin
hit = 1'b1;
NumHits += 1;
if (BiggestShipHit <= 5'b00010)
BiggestShipHit = 5'b00010;
答案 0 :(得分:0)
问题是您省略了为NumHits
和BiggestShipHit
指定显式数据类型,而只使用范围的方式-它们成为无法程序分配的隐式网络。请参阅1800-2017 LRM中的 23.2.2.3确定端口类型,数据类型和方向的规则。
正确的方法是添加logic
关键字。
module checkHits
(output logic hit, logic [6:0] NumHits, logic [4:0] BiggestShipHit,
input logic bomb, logic [3:0] x, y);
尽管规则不需要您输入,但我总是会在端口声明中添加显式数据类型。更加易于阅读,