RE: [sv-bc] structure literal example in standard

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Thu Jan 05 2006 - 04:04:28 PST
As I understand, you need the ' before the assignment pattern. However,
you can do a single replication operation of the pattern and put the '
before that replication. However, each replication must be preceded by
'. If you want to chain several replications, then you need the '
between them.

So in your cases, 

> obj = '{a, '{2{b,c}}};
> 
> Now if I want to assign value in 1D array obj1, I would extend
> it to ..
> 
> obj1 = '{3{'{a, '{2{b,c}}}}};

Here, you want to do 

obj1 = '{3{obj}} ;

But if you substitute the structure literal for obj, then you omit the
leading '. You can think of it as moving to precede the {3.

In the following case:

> int n[1:2][1:3] = '{2{3{y}}}}

you chain the replications, so you need the ' between them.

Similarly, 

> int a[4] = '{b, b, 2{b}};

Here also, each replication requires ' before it.
So you need

> int a[4] = '{b, b, '{2{b}}};

Shalom


> -----Original Message-----
> From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On
> Behalf Of Krishanu Debnath
> Sent: Thursday, January 05, 2006 1:46 PM
> To: sv-bc@eda.org
> Subject: Re: [sv-bc] structure literal example in standard
> 
> Shalom, I don't think I understand your point. Let me allow to
> elaborate this
> example.
> 
> </code_begin>
> 
> struct {int X,Y,Z;} XYZ = '{3{1}};
> typedef struct {int a,b[4];} ab_t;
> int a,b,c;
> 
> ab_t obj;
> ab_t obj1 [2:0];
> ab_t obj2 [1:0][2:0];
> 
> </code_end>
> 
> Now if I want to assign value in obj.b array, I would write
> following array
> literal.
> 
> obj.b = '{2{b,c}} // It should be okay because replication
> represents the
>                    // whole dimension [*]
> 
> Now if I want to assign value in obj struct, I would extend it
> to ..
> 
> obj = '{a, '{2{b,c}}};
> 
> Now if I want to assign value in 1D array obj1, I would extend
> it to ..
> 
> obj1 = '{3{'{a, '{2{b,c}}}}};
> 
> So if we think obj2 is a 1D array of element obj1 of length 2.
> 
> obj2 = '{2{'{3{'{a, '{2{b,c}}}}}}};
> 
> Now does it match with the example shown in standard?
> 
> 
> Bresticker, Shalom wrote:
> > No.
> >
> > You can see it described in 8.13.1, paragraph 2:
> >
> > A syntax resembling multiple concatenations can be used in
> array
> > assignment patterns as well. Each replication
> > represents a single dimension.
> >
> > unpackedbits = '{2 {y}} ; // same as '{y, y}
> > int n[1:2][1:3] = '{2{'{3{y}}}}; // same
> as'{'{y,y,y},'{y,y,y}}
> 
> Yes perfectly valid example. But does the verse of 8.13.1p2
> allow you to omit
> the 'apostrophe' when you are replicating the value for most
> varying dimension?
> If so then
> int n[1:2][1:3] = '{2{3{y}}}} is valid?
> 
> 
> Krishanu
> 
> [*] Sec 8.13.1p2 says ..
> "A syntax resembling multiple concatenations can be used in
> array assignment
>   patterns as well. Each replication represents a single
> dimension."
> 
> Does it also implies that you need to specify all the elements
> of that
> dimension, if you are using replication operator?
> 
> e.g
> 
> int b;
> int a[4] = '{4{b}}; // valid
> 
> but ,
> 
> int a[4] = '{b, b, 2{b}}; // is valid?
> 
> FYI, most of the tools reject the second initialization.
> 
> >
> > ==
> >
> > You can also see it in assignment_pattern syntax (Syntax 8-
> 2):
> >
> > assignment_pattern ::=
> >   '{ expression { , expression } }
> > ...
> > | '{ constant_expression { expression { , expression } } }
> >
> >
> > Shalom
> >
> >> -----Original Message-----
> >> From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On
> >> Behalf Of Krishanu Debnath
> >> Sent: Thursday, January 05, 2006 12:16 PM
> >> To: sv-bc@eda.org
> >> Subject: [sv-bc] structure literal example in standard
> >>
> >> Hello,
> >>
> >> I am not sure about the correctness of the following
> example,
> >> taken from
> >> Sec 3.8 _Structure literals_.
> >>
> >> 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}}}}}};
> >> /* expands to '{'{3{'{a,{2{b,c}}}}}, '{3{{a,'{2{b,c}}}}}} */
> >> <rest snipped>
> >>
> >> Here the array literal assign to v1 is incorrect. I think
> >> example
> >> missed the "'" after struct literal. So it should be
> >> '{2{'{3{'{a,'{2{b,c}}}}}}}. Similarly example missed the "'"
> in
> >> second element of expansion.
> >>
> >> Can anyone please confirm?
> >>
> >> Thanks,
> >> Krishanu
> >>
Received on Thu Jan 5 04:04:43 2006

This archive was generated by hypermail 2.1.8 : Thu Jan 05 2006 - 04:06:03 PST