Re: Use of Queues in System Verilog



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.
.



Relevant Pages

  • Re: Recordset.AddNew and the recordset objects data retaining
    ... You may be right about the transaction. ... round trip per each loop. ... with one database update trip PER RECORD is catastrophic. ... paging issues to keep the memory resources under control if you need better ...
    (microsoft.public.data.ado)
  • Re: Transactions - Infinite Loops
    ... This still doesn't sound like an infinite loop. ... > It was an unusual SQL Server response that we were unable to duplicate. ... > transaction if the wrong number of felds are being updated (i.e., ... > the query ran okay. ...
    (microsoft.public.sqlserver.programming)
  • Re: Transactions - Infinite Loops
    ... If you're really in a loop, you will not be able to enter any more commands. ... If you just forgot to commit, SQL Server cannot tell you that, as it has no ... of the same transaction. ... COMMIT TRAN. ...
    (microsoft.public.sqlserver.programming)
  • Re: SqlDataReader performance
    ... so its best to get the ordinalbefore the loop begins. ... The query performes acceptable in the Query analyzer. ... As you can see most of the time is spendt getting data from the DataReader ... What effect has a transaction on this? ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: "cant open any more tables"
    ... In a perfect world you would be right: all objects would dereference ... use them in a loop or in a query, ... Assign the workspace variable, then the transaction, ... If you do need to close a recordset, ...
    (microsoft.public.access.modulesdaovba)