Re: [sv-ec] random resizing of associative array

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Wed May 17 2006 - 08:18:14 PDT
Arturo,

If I have an associative array with (unsigned int) indices 1 and 5
and have a randomization constraint that the size of the array
is 3, what happens to index 5?  Is the implementation supposed
to clear the array and reconstruct it with indices purely
in the range 0..N-1?  Or is the implementation
supposed to "backfill" indices in the range 0..N-1 until the
size constraint is met and not end up with a dense
range?  For my example, if I constrained the size to 3, would
I end up with indices (0, 1, 5) or (0, 1, 2) or something else?

What is the implication of this if the element type of the
array is a class type?  Does it become an error to randomize
with a size constraint even if the number of elements is
correct and all elements are non-null but where the indices
are not in the range 0..N-1?

Gord.

Arturo Salz wrote:

> The intent was to allow randomizing an array's contents, not the
> indices. In that case, an associative array of integral values could be
> treated in much the same way as a dynamic array, that is, it's indices
> would indeed be in the range 0..N (not sparse) and its elements would be
> randomized. Note that one can accomplish the effect of randomized (and
> sparse) indices by creating two dynamic arrays, one of indices and one
> of values, and then use the post_randomize method to collect both of
> these into an associative array.
> 
> 	Arturo
> 
> -----Original Message-----
> From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of
> Gordon Vreugdenhil
> Sent: Tuesday, May 16, 2006 10:23 PM
> To: Ryan, Ray
> Cc: sv-ec@eda.org
> Subject: Re: [sv-ec] random resizing of associative array
> 
> I don't think that it makes sense to create entries in an
> associative array as 13.4.7 suggests.  For dynamic arrays,
> the indices are constrained to the range 0..N so just
> specifying a size is sufficient.  I think that if you want
> a randomly sized and/or randomly indexed associative array
> that you need to first construct the "shape" and then
> randomize the elements.
> 
> Gord.
> 
> Ryan, Ray wrote:
> 
> 
>>In the section 13.3 where random variable are discussed, the LRM
> 
> state:
> 
>>"The size of a dynamic array declared as rand or randc can also be
>>constrained. In that case, the array shall be resized according to the
>>size constraint, and then all the array elements shall be randomized.
>>... "
>>
>>>From this my assumption would be that this resizing only applied to
>>dynamic arrays
>>and not associative arrays or queues. 
>>
>>However in 13.4.7 (Iterative Constraints) there is the text:
>>"The size method of a dynamic or associative array can be used to
>>constrain the size of the array ... "
>>
>>This suggests that associative arrays are also re-sized by randomize. 
>>Is this the case?
>>
>>If so, what index values are used for the entries? There isn't any way
>>to specify a constraint
>>on the index value. Are all the existing entries first deleted? 
>>
>>It seems the statement in 13.4.7 may be a typo (shouldn't have
> 
> mentioned
> 
>>associative arrays).
>>
>>- Ray
>>
>>
> 
> 

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com
Received on Wed May 17 08:18:06 2006

This archive was generated by hypermail 2.1.8 : Wed May 17 2006 - 08:19:14 PDT