[sv-bc] question about $dimensions


Subject: [sv-bc] question about $dimensions
From: Paul Graham (pgraham@cadence.com)
Date: Tue Dec 16 2003 - 08:38:13 PST


I have a question about the definition of $dimensions in draft 2.

It says:

(1) -- $dimensions shall return the number of dimensions in the array, or 0
       for a singular object

(2) The dimensions of an array shall be numbered as follows: The slowest
    varying dimension (packed or unpacked) is dimension 1. Successively
    faster varying dimensions have sequentially higher dimension numbers.
    Intermediate type definitions are expanded first before numbering the
    dimensions.

So a packed array (which is a singular object) has $dimensions == 0:

    typedef bit [3:0][3:0] t1;
    t1 x1;
    $dimensions(x1) == 0

But what about an array of t1:

    typedef t1 t2[3:0];
    t2 x2;
    $dimensions(x2) == 1 or 3 ?

On the one hand, x2 has only one more dimension then x1, so this would
suggest that $dimensions(x2) == $dimensions(x1) + 1. On the other hand,
rule (2) above suggests that all the dimensions, packed and unpacked, are
counted, and this would mean $dimensions(x2) == 3.

Or should $dimensions include the count of packed dimensions as well? After
all, the array functions $size, etc., include packed dimensions in the
numbering scheme.

One last point: The definition of singular in 3.13 says:

    An aggregate type shall be any unpacked structure, union, or array data
    type.

I read this as meaning:

    An aggregate type shall be any unpacked structure, unpacked union, or
    unpacked array data type.

That is, "unpacked" is distributed over the following three type operands.
If this is not the correct interpretation, then a packed array is not a
singular type, and you can ignore the first part of this e-mail!

Paul



This archive was generated by hypermail 2b28 : Tue Dec 16 2003 - 08:38:59 PST