Delete all the entries of queue

In reply to kireeti1192:

No it’s better to empty your queue this way:

q= {};

Let say your queue is:

q = '{143bb6ae, f922dc1b, d026067f, 09cff0d9, a3d942f3, bca9699a, 1125b1bb, 73b7577c, b08ba496, 57ca744b}

It will stop at half the queue

i=0 - Queue Size=9 - Emptying test_q= '{f922dc1b, d026067f, 09cff0d9, a3d942f3, bca9699a, 1125b1bb, 73b7577c, b08ba496, 57ca744b}

i=1 - Queue Size=8 - Emptying test_q= '{f922dc1b, 09cff0d9, a3d942f3, bca9699a, 1125b1bb, 73b7577c, b08ba496, 57ca744b}

i=2 - Queue Size=7 - Emptying test_q= '{f922dc1b, 09cff0d9, bca9699a, 1125b1bb, 73b7577c, b08ba496, 57ca744b}

i=3 - Queue Size=6 - Emptying test_q= '{f922dc1b, 09cff0d9, bca9699a, 73b7577c, b08ba496, 57ca744b}

i=4 - Queue Size=5 - Emptying test_q= '{f922dc1b, 09cff0d9, bca9699a, 73b7577c, 57ca744b}

Check it with this code:


  int test_q[$];
  int val;

       // Fill in the queue
       for (i=0; i<10; i++)
          begin
            val = $urandom_range(32'hffff_ffff,0);
            if ( ( val inside {test_q} ) == 0 )
              begin
                test_q = {val , test_q};
                $displayh("test_q = %p", test_q);
              end
          end

        foreach (test_q[i])
          begin
            test_q.delete(i);
            $displayh("i=%0d - Queue Size=%0d - Emptying test_q= %p", i, test_q.size(), test_q);
          end