mpeer Posted February 8, 2013 Report Share Posted February 8, 2013 Hi All, I am trying to use tlm fifo. At first putting 10 elements after that I tried getting those elements but I always get the last data from uvm_tlm_fifo. Below is the complete code and the simulation result. Please let me know how should I use it so that I can retrieve all the elements which are being fed into it. I know, I have put_port, get_port and fifo all three inside single component and have connections here itself. It is done intentionally. ===================================================================== Code Here ===================================================================== import uvm_pkg::*; class trans extends uvm_sequence_item; `uvm_object_utils(trans) rand int a; rand int b; function new(string name="trans"); super.new(name); endfunction function void do_print(uvm_printer printer); super.do_print(printer); $display("A =%0h", a); $display("B =%0h", ; endfunction endclass //-----------------------------------// //-----------------------------------// class mon extends uvm_component; `uvm_component_utils(mon) uvm_tlm_fifo #(trans) fifo; uvm_blocking_put_port #(trans) pp; uvm_blocking_get_port #(trans) gp; function new(string name = "sb", uvm_component parent = null); super.new(name, parent); endfunction function void build_phase (uvm_phase phase); super.build_phase(phase); fifo = new ("fifo", this, 100); pp = new ("put_port", this); gp = new ("get_port", this); endfunction function void connect_phase(uvm_phase phase); pp.connect(fifo.put_export); gp.connect(fifo.get_export); endfunction task run_phase(uvm_phase phase); trans t = new(); trans t2; $display("Fifo capacity is %0d", fifo.size()); $display("Putting elements.."); repeat(10) begin t.randomize(); t.print(); pp.put(t); $display("Fifo is filled with %0d element(s)", fifo.used()); end $display("Retrieving elements.."); repeat(10) begin gp.get(t2); t2.print(); $display("Fifo size after retieving one element is %0d element(s)", fifo.used()); t2 = null; end endtask endclass //-----------------------------------// //-----------------------------------// module test; class test1 extends uvm_test; `uvm_component_utils(test1) mon m; function new(string name="test1", uvm_component parent); super.new(name, parent); endfunction function void build_phase (uvm_phase phase); m = mon::type_id::create("mon", this); endfunction : build_phase endclass initial begin run_test("test1"); end endmodule ================================================================= Simulation Result: ================================================================= UVM_INFO @ 0: reporter [RNTST] Running test test1... Fifo capacity is 100 Putting elements.. A =ca343fb9 B =94149dec Fifo is filled with 1 element(s) A =13ab51b1 B =f262ab77 Fifo is filled with 2 element(s) A =76906067 B =8c595989 Fifo is filled with 3 element(s) A =a72b2dd1 B =cfc3e29a Fifo is filled with 4 element(s) A =bddac76f B =517829e8 Fifo is filled with 5 element(s) A =ec897a2a B =88742996 Fifo is filled with 6 element(s) A =f5901441 B =89d0eac5 Fifo is filled with 7 element(s) A =dd44e7b3 B =7661e07a Fifo is filled with 8 element(s) A =786cb3a3 B =2a109a17 Fifo is filled with 9 element(s) A =661c7064 B =ec640f5a Fifo is filled with 10 element(s) Retrieving elements.. A =661c7064 B =ec640f5a Fifo size after retieving one element is 9 element(s) A =661c7064 B =ec640f5a Fifo size after retieving one element is 8 element(s) A =661c7064 B =ec640f5a Fifo size after retieving one element is 7 element(s) A =661c7064 B =ec640f5a Fifo size after retieving one element is 6 element(s) A =661c7064 B =ec640f5a Fifo size after retieving one element is 5 element(s) A =661c7064 B =ec640f5a Fifo size after retieving one element is 4 element(s) A =661c7064 B =ec640f5a Fifo size after retieving one element is 3 element(s) A =661c7064 B =ec640f5a Fifo size after retieving one element is 2 element(s) A =661c7064 B =ec640f5a Fifo size after retieving one element is 1 element(s) A =661c7064 B =ec640f5a Fifo size after retieving one element is 0 element(s) Quote Link to comment Share on other sites More sharing options...
janick Posted February 8, 2013 Report Share Posted February 8, 2013 bad usage: You keep putting a reference to the same object in the FIFO. All entries point to the same object. Quote Link to comment Share on other sites More sharing options...
mpeer Posted February 8, 2013 Author Report Share Posted February 8, 2013 Thanks Janick for quick reply. Now its working fine.. Thanks Peer Mohammed Quote Link to comment Share on other sites More sharing options...
enchanter Posted February 8, 2013 Report Share Posted February 8, 2013 Thanks Janick for quick reply. Now its working fine.. Thanks Peer Mohammed Would you please share your modification to make it work? Thanks Quote Link to comment Share on other sites More sharing options...
mpeer Posted February 9, 2013 Author Report Share Posted February 9, 2013 Hi enchanter, I made change in run_phase(). I moved trans t = new() inside repeat(10); Below is the code after change. task run_phase(uvm_phase phase); // trans t = new(); // Removed from this line trans t2; $display("Fifo capacity is %0d", fifo.size()); $display("Putting elements.."); repeat(10) begin trans t = new(); // Moved here; Now for each item there will be new handle. t.randomize(); t.print(); pp.put(t); // Putting into the fifo. $display("Fifo is filled with %0d element(s)", fifo.used()); end $display("Retrieving elements.."); repeat(10) begin gp.get(t2); t2.print(); $display("Fifo size after retieving one element is %0d element(s)", fifo.used()); t2 = null; end Regards Peer Mohammed Quote Link to comment Share on other sites More sharing options...
sri.cvcblr Posted February 10, 2013 Report Share Posted February 10, 2013 Hi Peer, Make sure you use factory to create the transactions for good code. Also I usually suggest you split the declaration and allocation into 2 steps. // Moved the declaration outside the task: trans t; task run_phase(uvm_phase phase); trans t2; $display("Fifo capacity is %0d", fifo.size()); $display("Putting elements.."); repeat(10) begin this.t = trans::type_id::create(); // Use factory than new this.t.randomize(); // You should rather be checking the return value here.. HTH Srini www.cvcblr.com/blog 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.