In systemverilog LRM
, there is a sample code to explain casting.
When I try this code, there is an error.
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
- First, for
$bits()
function, compiler saysthe argument of the system function call was not of bit-stream type.
- Second, when assign
a[3]
with a type casting oftagbits
, it saysThe source of the target of the bit-stream casting is not of bit-stream type
My understanding is that, structure and unpacked array are also bit-stream type.
Hope to know what is a point I missed.(cadence 18.09-006)