I've tried to initialize a union (in Modelsim 6.2f SE) , but it's not working.
I want the union to initialize to '0' (instead of 'X'.) I can't use a 2-state base-type (bit), because the union must be capable of capturing 4-state ('X') values.
Yes, you have two choices:
(a) initialize in procedural code (task/subprogram or other program block)
(b) since you declared the struct/union 'packed', you can simply assign it directly to a 4-state literal value -- no need for the braces {}.
Code:
typedef union packed {
logic blah7;
logic blah6;
logic blah5;
logic blah4;
} t_myunion;
t_myunion foo = 'h42;// single value, only works for packed union/struct