# Problem with the associative array with queue (not taking data corrrectly)

**URL:** <https://verificationacademy.com/forums/t/problem-with-the-associative-array-with-queue-not-taking-data-corrrectly/37019>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, Queues, Learning-System-Verilog, associative-array\
**Created:** [January 13, 2020, 1:28pm UTC](https://verificationacademy.com/forums/t/problem-with-the-associative-array-with-queue-not-taking-data-corrrectly/37019 "2020-01-13T13:28:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [January 13, 2020, 2:59pm UTC](https://verificationacademy.com/forums/t/problem-with-the-associative-array-with-queue-not-taking-data-corrrectly/37019/2 "2020-01-13T14:59:13Z")

</div>

_In reply to [rahulraoece](https://verificationacademy.com/forums/t/problem-with-the-associative-array-with-queue-not-taking-data-corrrectly/37019):_  
Please use [code tags](https://verificationacademy.com/forums/announcements/please-format-your-code-code-and/code-tags) making your code easier to read. I have added them for you.

You are pushing the same handle (d2) to the queue, so all queue entries have the same value. You need to move the construction of d2 into the loop.

```verilog
initial begin 
    mem_h= new();
    d1=new();
    repeat(5)
      begin 
        d2=new();
        assert (d2.randomize());
        mem_h.mem[d1.index].push_back(d2);
        $display("value of q=%p,mem_address =%d",mem_h.mem,mem_h);
      end
  end

```

---

_[View the full topic](https://verificationacademy.com/forums/t/problem-with-the-associative-array-with-queue-not-taking-data-corrrectly/37019)._
