Hi,
I have following code :
struct { bit [7:0] a; shortint b;
}a;
program myprog;
int b;
typedef logic[31:0] lgc_arr;
lgc_arr x;
initial begin
b = int'(a);
x = lgc_arr'(a);
end
endprogram
“Typecast fails because the use of casting unpacked objects with width
mismatch: int’($unit::a)
Trying to cast a 24 bit object to a 32 bit object.This gives error message”
However, if I make struct packed, there is no error for both casts. I am not clear why casting only unpacked objects with width mismatch should give an error while packed objects do not give error while casting, even if there is width mismatch.
Also if bit stream types can be freely converted using explicit casts, what is the additional benefit streaming operators (pack/unpack) give?
rgs,
-sunil