Associative array declaration [int][addr][queue]

I am trying to declare an associative array of datatype axi transaction whose index type needs to have following information :

  1. [int] to indicate master number

  2. [addr] to lookup transaction

  3. another index - this is the part where I am not sure how to declare - for the same address, the scoreboard needs to keep track of all the data that was written. So I need a queue structure to store all wdata to the same address and need to pop out in FIFO order for comparison, but I also need the address information.

What is the best way to declare this array?

Thanks

In reply to UVM_learner6:

axi_trans_t array[int][addr_t][$];

In reply to dave_59:

Hi Dave,

Before I saw your suggestion, I tried like this. Please correct me if am wrong in my approach.

axiTransaction trans_q[$]; //a q of axi transactions that need to be stored

axiTransaction assoc_array[addr_t][$]; //an assoc array to store the q of transaction for each addr.

When the transaction came in, I did a push_back to the trans_q. And then I stored the trans_q to the associative array.

Problem I encounter is that the q is always storing only one transaction.

          trans_q.push_back(my_trans);
          assoc_array[exp_addr] = trans_q;

– is this an incorrect way of approaching the problem?

In the method you suggested, how do I assign a queue to the associative array ?

In reply to UVM_learner6:

You only show one push_back(), so there is only one item in the queue when you do the queue copy. You should show some more code, and exactly what you expect to see.

In reply to dave_59:

Ok, I will add in more code to show the example.

Could you please show me how to push a queue of axi transactions into the associative array in the method you described?

axi_trans_t array[int][addr_t][$];

In reply to UVM_learner6:
one at a time

array[master_number][exp_addr].push_back(my_trans);

or you can copy a queue

array[master_number][exp_addr] = existing_queue_of_axi_trans;

In reply to dave_59:

Oh, thank you. I tried to push _back the entire q and that got me confused.

If I want to display the queue elements in the associative array, I can only pop them out and print or is there a way to see all the data elements for a particular address in the array?

In other words, I want to access the individual fields of the axi transaction that is stored in the queue, such as axi_Trans.address, axi_Trans.ID, etc.

In reply to dave_59:

In reply to UVM_learner6:

axi_trans_t array[int][addr_t][$];

Dave, One basic confirmation - when we declare as above, are we declare an associative array of queues or are we declaring a queue of associative arrays? Is there a difference? I think my confusion is because I thought push_back applies only to queues and for assoc array, we always do a direct assignment.

Is there a some sort of a thumb rule that can be followed when deciding which structure can be most appropriate for which scenario? If this question is too generic to be answered, pls ignore.

In reply to UVM_learner6:

associative array of queue :


//associative array of queue
axi_trans_t array[int][addr_t] [$];

//OR
typedef axi_trans_t axi_trans_q[$];
axi_trans_q array[int][addr_t];

/*...... assignment ........*/
//adding one element to the queue pointed by array[master_number][exp_addr]
array[master_number][exp_addr].push_back(my_trans);

//modifying/adding the entire queue which will be pointed by array[master_number][exp_addr]
array[master_number][exp_addr] = existing_queue_of_axi_trans;


queue of associative array :


//queue of associative array
axi_trans_t array[$]  [int][addr_t];  //array name is confusing as it is queue

//OR
typedef axi_trans_t axi_trans_aa [int][addr_t];   
axi_trans_aa array[$]  ;  //array name is confusing as it is queue

/*...... assignment ........*/
axi_trans_aa axi_trans_1;
axi_trans_1[m1][addr1] = my_trans1;
axi_trans_1[m2][add2] = my_trans2;
//....
//...
array.push_back(axi_trans_1);