[vhdl-200x] Associative arrays

From: Martin.J Thompson <Martin.J.Thompson@trw.com>
Date: Wed May 30 2012 - 09:00:40 PDT

Hi all,

I'm taking a look at implementing an associative array in VHDL - which raises a number of questions about the fundamental requirements, and some on possible APIs.
 
Requirements questions
================

1) Is it important that the accesses be ordered (so you can iterate over the key, value pairs in a consistent order every time)? For example, Python's (and I think Perl's) dictionaries are unordered. C++ std::map is ordered, std::hash_map is unordered.

2) Different low-level implementation options imply a performance trade-off between
    * speed of adding/deleting items and
    * speed of look-up.
What use-cases would you use an associative array for and what does that imply for this trade-off? For example, personally, I'd have used them in the past for sparse memory modelling, in which case more lookups tend to happen than insertions, and no deletions at all. I also use them for counting histograms of events, which is mainly lookup/update rather than create activity.

3) What types of data would we like to use as keys? integers, characters obviously... How about strings? Of fixed or arbitrary length? vectors of various types (and varying lengths in a single array)? reals? time? records? user-defined types?Or is the answer "make it work with as many types as possible", in which case, in what order of priority, given that some code may have to be customised for particular types?

What should the API look like?
====================

I'm envisaging a protected type with methods such as (where 'a' is a variable of our new type):

Basic methods:
----------------

a.set(key,value)
value := a.get(key)
a.clear -- to empty the array
a.erase(key) -- to remove a key,value pair completely
a.has_key(key) -- returns boolean of whether a particular key is used
a.count -- returns how many elements in array

Possibly some iterator methods
----------------------------------
would we like these? Given that "for i in a'range" isn't doable with protected types):

a.iterator_reset
a.next(key, value)-- procedure with two outputs on each call

String formatting:
--------------------

a.str -- returning a string representation

Serialisation
--------------
Would we like to be able to serialise this (and other) new data-types we create?

a.read(file)
a.write(file)
Any thoughts greatly appreciated!
 
Thanks,
Martin
 
 
Martin Thompson CEng MIET
TRW Conekt, Stratford Road, Solihull, B90 4GW. UK
+44 (0)121-627-3569 : martin.j.thompson@trw.com
http://www.conekt.co.uk/
Conekt is a trading division of TRW Limited
Registered in England, No. 872948
Registered Office Address: Stratford Road, Solihull B90 4AX

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed May 30 09:01:29 2012

This archive was generated by hypermail 2.1.8 : Wed May 30 2012 - 09:02:05 PDT