[sv-bc] Question about replication in array literal


Subject: [sv-bc] Question about replication in array literal
From: Paul Graham (pgraham@cadence.com)
Date: Wed Jan 07 2004 - 13:31:13 PST


I'm not sure how this construct should be interpreted:

    int x[2:0][1:0] = { 3{1, 0} };

Is it equivalent to this:

    int x[2:0][1:0] = { {1, 0}, {1, 0}, {1, 0} };

or this:

    int x[2:0][1:0] = { 1, 0, 1, 0, 1, 0 };

The definition of a multiple concatenation in an array context suggests
that the second interpretation is the correct one:

    The syntax of multiple concatenations can be used for unpacked array
    expressions as well.

    unpackedbits = {2 {y}} ; // same as {y, y}

Syntactically, a multiple_concatenation contains a repeat count followed by
a concatenation. The definition above implies that the contents of the
concatenation are what gets replicated, not the concatenation itself.

Could you confirm my interpretation?

In that case, I would have to write:

    int x[2:0][1:0] = { 3{{1, 0}} };

Paul



This archive was generated by hypermail 2b28 : Wed Jan 07 2004 - 13:32:20 PST