Subject: RE: [sv-bc] Review Items for Chapter 7
From: Maidment, Matthew R (matthew.r.maidment@intel.com)
Date: Thu Feb 12 2004 - 14:33:58 PST
Good question, Greg.
I refer you to section 2.8:
"Replicate operators can be used to set the values for the
exact number of members. The inner pair of braces in a replication
is removed.
struct {int X,Y,Z;} XYZ = {3{1}};
typedef struct {int a,b[4];} ab_t;
int a,b,c;
ab_t v1[1:0] [2:0];
v1 = {2{{3{a,{2{b,c}}}}}};"
So for 7.14 I was merely trying to refer to the above because
of the last sentence in 7.14:
"If the type key, default key, or replication operator is used on an
expression with side effects, the number of times that expression
evaluates
is undefined."
This sentence implies that the replication operator can be used
in a structure expression.
How about this:
"A structure expression (packed or unpacked) can be built from member
expressions using braces and commas, with the members in declaration
order.
Replicate operators can be used to set the values for the exact number
of
members as described in section 2.8. Each member expression shall
be evaluated in the context of an assignment to the type of the
corresponding member in the structure. It can also be built with the
names of the members"
Or we could copy the portion of 2.8 that addresses replicate operators
to explicitly declare their validity for strucuture expressions:
"Replicate operators can be used to set the values for the
exact number of members. The inner pair of braces in a replication
is removed.
struct {int X,Y,Z;} XYZ = {3{1}};
typedef struct {int a,b[4];} ab_t;
int a,b,c;
ab_t v1[1:0] [2:0];
v1 = {2{{3{a,{2{b,c}}}}}};"
It can sometimes be useful to set structure members to a value without
having
to keep track of how many members there are, or what the names are. This
can be
done with the default keyword:"
Does this context help?
Matt
>-----Original Message-----
>From: Greg Jaxon [mailto:Greg.Jaxon@synopsys.com]
>Sent: Thursday, February 12, 2004 10:59 AM
>To: Maidment, Matthew R
>Cc: sv-bc@eda.org
>Subject: Re: [sv-bc] Review Items for Chapter 7
>
>Maidment, Matthew R wrote:
>
>> 7.14 -
>> What about changing the opening sentences:
>>
>> "A structure expression (packed or unpacked) can be built from member
>> expressions using
>> braces and commas, with the members in declaration order. Each member
>> expression shall
>> be evaluated in the context of an assignment to the type of the
>> corresponding member
>> in the structure. It can also be built with the names of the members"
>>
>> To:
>>
>> "A structure expression (packed or unpacked) can be built from member
>> expressions using
>> braces and commas, with the members in declaration order. Replicate
>> operators can be used
>> to set the values for the exact number of members. Each member
>> expression shall
>> be evaluated in the context of an assignment to the type of the
>> corresponding member
>> in the structure. It can also be built with the names of the members"
>
>struct packed {
> bit sign;
> signed bit[8:0] exponent;
> bit[53:0] mantissa;
>} my_dbl;
>
>my_dbl = { 1'b1, {2{'0}}, 142857142 };
>
>Does this RHS have the right number of elements in the list?
>Or does "exact number" imply that replication can only be used
>to produce
>the entire list?
>
>
>
This archive was generated by hypermail 2b28 : Thu Feb 12 2004 - 14:41:18 PST