[sv-bc] 7.14: type:expr in a struct literal


Subject: [sv-bc] 7.14: type:expr in a struct literal
From: Paul Graham (pgraham@cadence.com)
Date: Thu Dec 11 2003 - 12:00:51 PST


The rule for type assignment in a struct literal isn't entirely clear.
It says:

    The type:value specifies an explicit value for a field in the structure
    which exactly matches the type and has not been set by a field name
    specifier above. If the same key type is mentioned more than once, the
    last value is used.

I assume the second sentence refers to a situation like:

    { int:2, int:3 }

where the int:2 is ignored and the int:3 is used.

Suppose there are several members in a struct having the same type. Could
you do:

    { default:1, int:2 }

to say that all int members in the struct are set to 2, and remainder are
set to 1? As written, the type:value rule refers to "a field", which
implies that only one field, or member, is set.

Also, in 7:14 , this struct literal appears:

    initial s2 = {bit[31:0]:1, default:0, string:""};

The bit[31:0] is not a type_identifier, which is what the grammar requires
for a struct_member_label. Is the example wrong, or the grammar?

Apologies if I'm repeating an existing erratum!

Paul



This archive was generated by hypermail 2b28 : Thu Dec 11 2003 - 12:01:46 PST