I am trying to declare an associative array of datatype axi transaction whose index type needs to have following information :
[int] to indicate master number
[addr] to lookup transaction
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.
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.
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.
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.
//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);