{Disarmed} RE: [sv-bc] Re: What is the type of a slice?

From: Steven Sharp <sharp@cadence.com>
Date: Wed Sep 16 2015 - 11:48:15 PDT
If we are going to define this, then I would argue that consistency requires the type to have a canonical range independent of the range used in the select.

Consider the case of an indexed part select with a variable index.  The range represented by this is not known statically, so the type cannot depend on the range in the select.  Consistency then calls for this to be the same if the index is not variable, and then for a normal part select that is equivalent to the indexed part select.

Some other examples: A slice of a queue is a queue, and that queue will always have a left index of 0, regardless of the range used in the slice (which could also involve variables and therefore may not be statically known).  A slice of a string is a string, and that string will always have a left index of 0, regardless of the range used in the slice (which could again involve variables).

Since these cases of slices all have types that are independent of the range used in the slice, consistency calls for all slices to have types that are independent of the range used in the slice.

There are several precedents for the canonical range of a vector expression to be [size-1:0].  One of them is the indexing of concatenations that Gord mentioned.  Another is the range of an untyped parameter whose type has been set by the vector expression assigned to it.  Another weaker precedent is the range of the built-in integral types.

For unpacked arrays, I see a somewhat weaker precedent for a canonical range of [0:size-1].  I base this on the examples of slices of queues and strings mentioned above.  I consider it weaker because it comes from a property of queues and strings rather than some precedent for unpacked array expressions in general.  But this is the only choice that allows the canonical range to be the same for queues, strings, dynamic arrays, and fixed-size arrays.


From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Brad Pierce
Sent: Wednesday, September 16, 2015 2:06 PM
To: sv-bc@eda.org
Subject: RE: [sv-bc] Re: What is the type of a slice?


[In response to http://www.eda.org/sv-bc/hm/11755.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.eda.org_sv-2Dbc_hm_11755.html&d=BQMFAg&c=aUq983L2pue2FqKFoP6PGHMJQyoJ7kl3s3GZ-_haXqY&r=noyJvII_EkgpO1SPzM_1vyAg_D-Qydh-WCJ04DZO53s&m=kRaHYovo4TuTWbNsWtLos7i1VPfj4_veU_Xd1e8SLnw&s=Q5l9PcTBUTlaitkO5RzZjcjRb0nTFBH5Z4SIHR_o-98&e=> .]



We could and should fully define the results of the type() operator. Let's decide whether in the following, (COPY select) is guaranteed to be the same as (ORIGINAL select), where select in A.8.4 stands for bit-select, part-select, indexed-part-select and field access.



            var type(ORIGINAL select) COPY;

            COPY = (ORIGINAL select);

            // (COPY select) == (ORIGINAL select) ?



For example,



            byte A[16];

            var type(A[5:7]) B;

            B = A[5:7];

            // B[5:7] == A[5:7] ?



If not, then let's agree on a canonicalization for slices, such as down to 0 or up to 0.

-- Brad


--
This message has been scanned for viruses and
dangerous content by MailScanner<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.mailscanner.info_&d=BQMFAg&c=aUq983L2pue2FqKFoP6PGHMJQyoJ7kl3s3GZ-_haXqY&r=noyJvII_EkgpO1SPzM_1vyAg_D-Qydh-WCJ04DZO53s&m=kRaHYovo4TuTWbNsWtLos7i1VPfj4_veU_Xd1e8SLnw&s=rgEBPpTpYxbm-P_snFVbcFwMWs8pq5qlhFWiESpm7xI&e=>, and is
believed to be clean.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Sep 16 11:48:41 2015

This archive was generated by hypermail 2.1.8 : Wed Sep 16 2015 - 11:48:47 PDT