Regarding the Associative arrays

Hi Dave,

  1. What is the default width of one location of the associative array(depth is infinite that is known)?(Ex: if i declare the array int aarray[*])

  2. I have one class like below
    class example_trans;
    logic [31:0]addr;
    logic [15:0]data;
    logic wr_rteady;
    logic rd_ready;
    logic wr_vld;
    logic rd_vld;
    logic [15:0]data_out;
    endclass
    can i declare the associative array like below as datatype is the example_trans
    example_trans aarray[*]; ?
    If possible then can i write the total transaction into array of particular index like below
    aarray[idx_key] = t1;(t1 is the handle of example trans and idx_key is the int data type key)
    If possible can i get the transaction like below
    t2 = aarray[idx_key];
    And for accessing the specific element of the transaction can i use the below procedure…
    t2.addr
    t2.data
    t2.data_out
    t2.wr_vld …so on

Thanks a lot,
krishna

In reply to venkataramana.nandela@concept2silicon.com:

Got the answer for this… and i am able to do this…

In reply to venkataramana.nandela@concept2silicon.com:

BTW, we recommmend that you declare the type of the array index instead of using the wildcard [*]. That way you have a defined index for constructs like foreach and find_index().

In reply to dave_59:

Thanks a lot Dave…
BTW, what is the default width of one location of associative array?

In reply to venkataramana.nandela@concept2silicon.com:

Sorry, I don’t understand your question.

There are two data types used as part of an associative array declaration, the type of each element, and the type of the index. You can use any type for both, including a class type.

“width” usually refers the number of significant bits that an integral type can represent. So if you have an associative array of bytes, the width of each element is 8, if you declare the index type as an int, the width of the index type is 32-bits. But there is no width associated with class types.

In reply to dave_59:

Hi Dave,

Thanks for the reply…What you understood was correct only…
My doubt is in case of class types how it will sit in the array?(for suppose if you take the example as the above class, addr will sit in the first location and data will sit in the another location as so on…or all the elements will sit in the single location)

I think all the elements will refer to the single location…since the index is same for all the elements of the class.
Am I right?

Thanks a lot,
Ramana