Question about concat operators

  • Thread starter parag_paul@hotmail.com
  • Start date
P

parag_paul@hotmail.com

Guest
hi All,
I saw the the following example for a dynamic array initialization in
SV

string d[1:5] = '{ "a", "b", "c", "d", "e" };
string p[];
p = { d[1:3], "hello", d[4:5] };


is the concat operator correct for the array?
Should it not be the concat operator. Where do you chose to use the
plain concat operator and where do you decide to use the array literal.
 
On Sun, 23 Nov 2008 11:03:42 -0800 (PST), "parag_paul@hotmail.com"
<parag_paul@hotmail.com> wrote:

hi All,
I saw the the following example for a dynamic array initialization in
SV

string d[1:5] = '{ "a", "b", "c", "d", "e" };
string p[];
p = { d[1:3], "hello", d[4:5] };


is the concat operator correct for the array?
Should it not be the concat operator. Where do you chose to use the
plain concat operator and where do you decide to use the array literal.
Actually neither of these brace groupings define a concatenation in
the sense that concatenation generates a packed array. The above are
initializations of an aggregate type ie d is an array of 5 strings and
it gets initialized to 5 separate elements. The same is true for p.
It's an array of strings and after the initialization with an unpacked
array initializer, it gets 6 elements ie "a", "b", "c", "hello", "d",
"e".

Muzaffer Kal
http://www.dspia.com
 
On Sun, 23 Nov 2008 11:03:42 -0800 (PST), parag wrote:

I saw the the following example for a dynamic array initialization in
SV

string d[1:5] = '{ "a", "b", "c", "d", "e" };
string p[];
p = { d[1:3], "hello", d[4:5] };


is the concat operator correct for the array?
No. This was an error in the 1800-2005 LRM.

Should it not be the concat operator. Where do you chose to use the
plain concat operator and where do you decide to use the array literal.
Good question. As you say, concatenation syntax (curly braces
without the apostrophe) is normally used to construct packed
vectors - simple rows of bits.

Generally, in SV-2005, unpacked aggregate values should be
written using assignment pattern syntax '{..., ..., ...}
However, there was a weird exception - very badly documented
in the LRM - for queues; the examples, and the behaviour of
existing simulators, make it clear that you can write

int qi[$];
qi = {0, 1, 2};
qi = {qi, 3};

all of which matches what you could do with queues
in Superlog.

The last line of code uses {qi, 3} to construct a new
queue value containing the three elements of the old queue,
with a fourth element added to its end. This CANNOT be
done using assignment patterns because qi is not an int,
it's an array of ints, so this would be illegal:

qi = '{qi, 3};

although you could at least argue that the following
should be legal:

qi = '{0, 1, 2};

The ballot draft of SV-2009 contains some significant
changes in this area that legitimize the queue concatenation
syntax such as {qi, 3} and also extend it so that it can be
used to construct other unpacked array values from a collection
of sub-arrays and elements, a facility that does not exist
with assignment pattern syntax. It also clarifies the rules
about what sort of array can be copied to other sorts of
arrays in various situations. If these changes make it
through the ballot process into the published standard, then
the example in the old LRM should work correctly with the
evidently intended meaning, and (we hope) the LRM wording
will be much clearer and less ambiguous; it will also
make it much easier to work with unpacked arrays in many
practical situations.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 

Welcome to EDABoard.com

Sponsor

Back
Top