Re: [sv-bc] Question about replication in array literal


Subject: Re: [sv-bc] Question about replication in array literal
From: Dave Rich (David.Rich@synopsys.com)
Date: Tue Jan 13 2004 - 11:14:05 PST


Hi Paul,

This should answer a number of your questions. I am working on a
proposal to clarify the LRM. Here are the major points

Braces can either represent an concatenation (an integral value), or a
unpacked struct or array expression (an aggregate value), but not both
at the same time.

Nested braces in an aggregate always match it layout. An exception is
that the inner most pair of braces in an adjacently nested replication
are removed. Assuming this is an aggregate:

{2{3{a,{4{b,c}}}}} becomes
{2{3{a,{b,c,b,c,b,c,b,c}}}} or alternatively
{{a,{4{b,c}},a,{4{b,c}},a,{4{b,c}}}, {a,{4{b,c}},a,{4{b,c}},a,{4{b,c}}}}
which becomes
{{a,{b,c,b,c,b,c,b,c},a,{b,c,b,c,b,c,b,c}a,{b,c,b,c,b,c,b,c}},
{a,{b,c,b,c,b,c,b,c},a,{b,c,b,c,b,c,b,c}a,{b,c,b,c,b,c,b,c}}}

Note that the brace between 2 and 3 is not removed because it is not an
inner most brace and does get replicated

Also note that braces are always treated as concatenation for packed
types unless there is an syntactic indicator.

typedef struct packed { byte a,b;} ab_t;
bit [3:0] a,b,c;
ab_t i1= {a,b,c}; // is a concatenation expression and padded to meet
the size of ab_t.
ab_t i2 = {a:a,b:b} // is an struct expression and each element is
padded to a byte

Dave

Paul Graham wrote:

>I'm not sure I'm happy about having to distinguish between an array literal
>and an expression surrounded by curly braces. Maybe the best thing is to
>say that a multi-concat in an array literal context consists of a repeat
>count expression followed by an expression enclosed in braces. In that
>case, the above examples would be written as:
>
>1) int x[2:0][1:0] = { 3{{1, 0}} }; // extra level of braces needed
>
>
correct

>3) int x[2:0] = { 3{1} }; // no change
>
>
correct

>4a) int x[2:0][0:0] = { 3{{default:1}} }; // extra level of braces needed
>
>
 = {default:1} would also work because of the recursive decent

>4b) int x[2:0][0:0] = { 3{{0:1}} }; // extra level of braces needed
>
>
correct

>4c) int x[2:0][0:0] = { 3{{ 1{1} }} } // extra level of braces needed
>
>
incorrect - only the inner most brace is removed
= {3{1{1}}}

>Was the array literal multi-concat syntax in the original SuperLog language?
>If so, could a CoDesign veteran comment on how they were defined?
>
>Paul
>
>
>
>

-- 
--
David.Rich@Synopsys.com
Technical Marketing Consultant
http://www.SystemVerilog.org
tele:  650-584-4026
cell:  510-589-2625



This archive was generated by hypermail 2b28 : Tue Jan 13 2004 - 11:15:25 PST