Hello,
I have a queue from which I would like to delete matching entries. I have a queue as below:
Let us say, the queue that has the following data is named, int id_q[$]
Index: 0, id: 0x1b
Index: 1, id: 0x1b
Index: 2, id: 0x1b
Index: 3, id: 0x1b
Index: 4, id: 0x3
Index: 5, id: 0x1b
Index: 6, id: 0xe
Index: 7, id: 0x1c
Index: 8, id: 0x17
Index: 9, id: 0x1b
Index: 10, id: 0x1c
Index: 11, id: 0x1c
Index: 12, id: 0x16
Index: 13, id: 0x1b
Index: 14, id: 0x1b
Index: 15, id: 0x17
Index: 16, id: 0x12
Index: 17, id: 0xa
Index: 18, id: 0x17
Index: 19, id: 0x16
Index: 20, id: 0x1b
Index: 21, id: 0x19
Say, I want to delete all the entries in the queue id_q, that match a particular id. In this case, 0x1b
I tried the following methods:
int index_cu[$];
index_cu = warp_id_in_use_cu_tx.find_index(i) with (i == 0x1b);
if(index_cu.size() != 0) begin
foreach(index_cu[i]) begin
id_q.delete(index_cu[i]);
end
end
end
Now this complains as the entries are deleted from id_q (as the q_id shrinks, the index number pointed to by index_cu, doesn't exist.
alternatively, I tried, the following
foreach(id_q[i]) begin
if(id_q[i] == 0x1b) begin
id_q.delete(i);
end
end
The above method deletes only certain matching entries of 0x1b only. Doesn't delete all of them ? Why does this happen ?
Can any one explain what is the safest way to delete all the matching entries from a queue ?
[/code]