karandeep963 Posted August 19, 2014 Report Share Posted August 19, 2014 Hello All, I am facing a acute problem: Using a uvm_tlm_analysis_fifo as: class bla_bla extends uvm_component uvm_tlm_analysis_fifo (my_packet) analysis_fifo; my_packet get_my_packet ; // other code task run_phase for(int i = 0 ; i < 10; i++)begin analysis_fifo.write(my_packet<updated everytime before this>); end for(int i = 0 ; i < 10; i++)begin analysis_fifo.get(get_my_packet); get_my_packet.print(); end this displays last packet value always I have made a small test and created it for int type instead of using the packet and it works fine with it, may be I am missing something What should I need to do get the right values.? Is there any issues that it is keeping the pointer to the value written and one has to maintain that packets himself ? Note: the above is just an example of the problem I am facing , since the exact code is much bigger so created an example just to explain better, it may have some syntax issues. Thanks, Karandeep Quote Link to comment Share on other sites More sharing options...
tudor.timi Posted August 19, 2014 Report Share Posted August 19, 2014 Do you create separate instances of packets for each one you put in the FIFO? If you don't, then all entries in the FIFO pointing to the same object, which you just update every time before you write it. This means all FIFO locations will see the updated object. mramdas and karandeep963 2 Quote Link to comment Share on other sites More sharing options...
karandeep963 Posted August 19, 2014 Author Report Share Posted August 19, 2014 Thanks for the update Tudor, No I am using single packet and updating it every time, this means I have make n number of packets to handle this Do you mean to fill FIFO with 10packets , I need 10 different packets ?? If yes , this is quite bad , since creating that much of packets is quite problematic and how does it works in case of using int type , as in that only a single variable is used . This is some kind preserving the pointer of the packet, which remains always same for the same packet, what is the solution for this to use single packet ?? -Karandeep Quote Link to comment Share on other sites More sharing options...
tudor.timi Posted August 19, 2014 Report Share Posted August 19, 2014 For int, the integers get stored in the FIFO (there is not pointer type in SystemVerilog, so you couldn't save anything else anyway). But for class objects, the only thing you can save is the pointer (handle/reference - same concept). Think of it conceptually, you want to store stuff somewhere, so you have to use memory to do it. You can't just plug in all of your objects into just one instance. If you are writing and getting from your analysis FIFO on a regular basis, then it's fine, you shouldn't worry about memory consumption. karandeep963 1 Quote Link to comment Share on other sites More sharing options...
karandeep963 Posted August 19, 2014 Author Report Share Posted August 19, 2014 Yupp true , how it differentiates between the two (SV datatype and user packet) and how or where is it implemented? Thanks, Karandeep Quote Link to comment Share on other sites More sharing options...
tudor.timi Posted August 19, 2014 Report Share Posted August 19, 2014 These are basically the same semantics as when calling functions: scalar arguments are passed by value and objects are passed by reference. Not 100% sure (and can't check right now), but arrays are most certainly also passed by reference. In our case, scalars values are stored, whereas object references are stored. karandeep963 1 Quote Link to comment Share on other sites More sharing options...
dave_59 Posted August 19, 2014 Report Share Posted August 19, 2014 Everything is passed by value in a fifo. It just so happens that the value of a class variable is a handle that references a class object. Unless you construct or clone a new object each time you write to the fifo, you are writing a handle to the same object over and over again. Dave karandeep963 1 Quote Link to comment Share on other sites More sharing options...
karandeep963 Posted August 20, 2014 Author Report Share Posted August 20, 2014 Thanks Tudor and Dave for your reply !!! -Karandeep Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.