1

systemverilog LRM中,有一个示例代码来解释强制转换。当我尝试此代码时,出现错误。

typedef struct {
   bit isfloat;
   union { int i; shortreal f; } n; // anonymous type
} tagged_st; // named structure

typedef bit [$bits(tagged_st) - 1 : 0] tagbits;
tagged_st a [7:0]; // unpacked array of structures
tagbits t = tagbits'(a[3]); / convert structure to array of bits
a[4] = tagged_st'(t); // convert array of bits back to structure
  • 首先,对于$bits()函数,编译器说the argument of the system function call was not of bit-stream type.
  • a[3]其次,当使用 的类型转换进行分配时tagbits,它说 我的理解是,结构和解包数组也是比特流类型。 希望知道我错过了什么。The source of the target of the bit-stream casting is not of bit-stream type

    (cadence 18.09-006)
4

1 回答 1

2

未打包的联合不是比特流类型。从 LRM,

默认情况下,联合是解包的,这意味着联合成员的存储方式不需要表示

这意味着您无法知道代表了多少位。

于 2019-08-01T14:33:40.523 回答