我试图将一些SystemVerilog代码移植到C++/SystemC,并且在一些行中我看到奇怪的数组索引。这是我看到的简化版本。索引操作对SystemVerilog中的整数类型做什么?
typedef enum bit [2:0] {enu_red, enu_blue, enu_green} typ_enum;
typedef struct packed {
bit [3:0] field1;
bit [3:0] field2;
} typ_struct;
...
var int arr_ints[typ_struct];
var int que_ints[$];
typ_struct obj_struct;
typ_enum obj_enum;
int i = 3;
// assume all the declared variables hold valid values at this point
// also assume que_ints[i] is valid
if ((!arr_ints[obj_struct][1]) // these two lines are the problem
&& (que_ints[i][obj_struct])
)
begin
// do something
end
现在经过我这个端口的代码,我得到一些编译器错误,我完全理解,因为原来的代码不完全看我的权利。在if语句的第一行中,它看起来像试图用布尔值来索引整数类型。在第二个,它看起来像试图索引一个枚举值的整数类型。然而,这个代码显然是有效的。有人可以解释它在做什么吗?
什么是'true'定义为? – dwikle
我将true替换为1.在实际代码中,它是一个用作true/false布尔值的函数,但实现为一位。我被混淆了与C++等价物,实际上使用bool类型 – Rich