Re: [sv-bc] $fread on dynamic arrays

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Wed Oct 15 2008 - 10:12:20 PDT
Chris Spear wrote:
> Gordon,
> 
> Funny, but I looked at the example and came up with the exact opposite
> opinion.
> If you construct an array with 20 elements, you probably want to limit
> $fread to those 20 elements.

Perhaps, but it is simple enough to use explicit sizing that I
think it makes sense to make the default the more difficult to
describe dynamic behavior.

>> If not supplied, the memory shall be filled with what data are
> available

> Just like a fixed size array, the dynamic memory is filled when the last
> element is set.
> Your suggestion of continually growing the memory would require
> allocating and copying the array over and over as the file is read,
> unless you know the file size in advance.

Vendor implementations can deal with the efficiency aspects more easily than
doing so in user HDL code.  I would certainly not expect a vendor's
approach to require copying "over and over"; a vendor should certainly
be able to do this with a linear time implementation.

> On the other hand, using $fread into a queue seems like it should read
> the entire file, as a queue's size is very dynamic.
> 
> As for associative arrays ... no opinion.

Associative arrays are an interesting aspect in $fread;  $readmem
discusses associative arrays a bit (limiting supported indices
to integral types) but also doesn't directly address "new elements".
$readmem also doesn't address dynamic array expansion.  $fread
and $readmem should likely have some alignment here -- my initial
preference for associative arrays with fread is to consider that
as a readmem file with no addresses and to construct/read values
with implied indices 0..n.


Gord.

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Oct 15 10:16:26 2008

This archive was generated by hypermail 2.1.8 : Wed Oct 15 2008 - 10:16:57 PDT