Re: Use of Queues in System Verilog
- From: Jonathan Bromley <jonathan.bromley@xxxxxxxxxxxxx>
- Date: Mon, 05 Mar 2007 15:29:25 +0000
On 5 Mar 2007 06:25:23 -0800,
rajatkmitra@xxxxxxxxx wrote:
[...]
When I pop off the queue, I get only the last object I pushed.
Is there something I am doing wrong ????
Yes!
The guts of your "push four transactions" loop is...
initial begin
r_op = new;
for(j=0; j < 3; j++)begin
r_op.//modify data members of r_op
read_queue.push_front(r_op);
end
NOTE CAREFULLY that you invoke new() only once, BEFORE
the loop. Consequently, you have only one transaction object,
but the queue contains four separate references to it.
In general, whenever you store an object for future use, it is
a good idea (good==paranoid, since this is engineering!)
to store a *completely new copy* of the object. Give your
transaction object a copy() method that makes a clone
of itself, and then
read_queue.push_front(r_op.copy());
And now, whatever you do to r_op in future, the copy
that you saved on the queue is untouched.
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@xxxxxxxxxxxxx
http://www.MYCOMPANY.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
.
- Follow-Ups:
- Re: Use of Queues in System Verilog
- From: Ajeetha (www.noveldv.com)
- Re: Use of Queues in System Verilog
- References:
- Use of Queues in System Verilog
- From: rajatkmitra
- Use of Queues in System Verilog
- Prev by Date: Use of Queues in System Verilog
- Next by Date: Re: Use of Queues in System Verilog
- Previous by thread: Use of Queues in System Verilog
- Next by thread: Re: Use of Queues in System Verilog
- Index(es):
Relevant Pages
|