Problem in Queue

Hi,

I am using Queue in Scoreboard in UVM.I have used analysis port ,so there are write functions in Scoreboard. Data coming from driver are saved into Driver_Queue and compared with Monitor Transactions(Packet).

Packet Driver_pkt;
..........
..........
//============Write Implementation of Analysis port from Driver Class================//
function write_driver(Packet pkt);
     Driver_Queue.push_back(pkt);          //Data saved in Driver Queue
endfunction

//============Write Implementation of Analysis port from Monitor Class================//
function write_monitor(Packet pkt);
  if(Driver_Queue.size())begin
   Driver_pkt=Driver_Queue.pop_front();      //Packet Popped out from Queue.
   Driver_pkt.print(); //Only Displays last pkt entered into Queue...Why?
...........
..........

So in the last statement I got only last transaction ,I am not getting any other transaction.Its not what I am expecting from Queue.
Meanwhile If I print the transaction in write_driver function,It works perfectly…Then what is the problem in Write_monitor…?

Hi kansagaratushar .
Problem might be you are not creating the new object or copy of object before pushing it into queue . Before pushing it into queue make a clone of of seq item for example Driver_Queue.push_back(pkt.clone()) . make sure that your clone function is implemented or use `uvm_field_utils

CHEERS
CB SINGH

Hi,

Thanks for Reply.
I tried whatever you suggested,But Still same problem was there.
Can You please elaborate whatever you said with the used of given example.

Hi.
Problem might be that you are pushing handle of same object again and again in your scoreboard queue.
thats why all object in the queue is of object last type or same type . Before writing it into analysis port in driver create a copy of that object and push that copy into your scoreboard.
How to create a copy of a object that you can see into cookbook of sequence.

Hi Kansagaratushar,

Try this in monitor code if it works.

================//
function write_monitor(Packet pkt);
if(Driver_Queue.size() != 0)begin
pkt Driver_pkt ;
Driver_pkt=Driver_Queue.pop_front(); //Packet Popped out from Queue.
Driver_pkt.print(); //Only Displays last pkt entered into Queue…Why?

Regards,
Ankita

Yes I did It.Thank you all of you for Reply.

CB SINGH You are right.Creating Objects and copied into another packet handle works perfectly.
Here is the updated code:

Packet Driver_pkt;
Packet pkt1;
..........

//============Write function of Driver Class================//
function write_driver(Packet pkt);
     pkt1=new;                               //...Object created of pkt1
     pkt1.copy(pkt);                         //....Copied object
     Driver_Queue.push_back(pkt1);          
endfunction
 
//============Write function of Monitor Class================//
function write_monitor(Packet pkt);
  if(Driver_Queue.size())begin
   Driver_pkt=Driver_Queue.pop_front();      
   Driver_pkt.print();