我需要一些帮助。
我正在尝试计算解压数组中的数量。
下面是代码。
module test_rand;
bit [7:0] mask_unpacked [0:7];
int numOnes[0:7];
initial begin
mask_unpacked[0] = 8'b00001111;
mask_unpacked[1] = 8'b00001111;
mask_unpacked[2] = 8'b00000000;
mask_unpacked[3] = 8'b00000000;
mask_unpacked[4] = 8'b00000000;
mask_unpacked[5] = 8'b00000000;
mask_unpacked[6] = 8'b00000000;
mask_unpacked[7] = 8'b00000000;
$display("*********************************");
foreach (mask_unpacked[i]) begin
$display("mask_unpacked = %p",mask_unpacked[i]);
numOnes= $countones(mask_unpacked[i]);
$display("countones = %p", numOnes[i]);
end
$display("*********************************");
end
endmodule
但是,我收到错误消息
Error-[ICTA] Incompatible complex type
testbench.sv, 16
Incompatible complex type assignment
Type of source expression is incompatible with type of target expression.
Mismatching types cannot be used in assignments, initializations and
instantiations. The type of the target is 'int$[0:7]', while the type of the
source is 'int'.
Source Expression: $countones(mask_unpacked[i])
如何解决这个问题?
我想你的意思是写:
但如果你想要整个解压数组中的总数,你可以写: