# What is the output of the tlm\_fifo model?

**URL:** <https://verificationacademy.com/forums/t/what-is-the-output-of-the-tlm-fifo-model/33231>\
**Category:** UVM\
**Tags:** TLM-FIFO-related, UVM\
**Created:** [June 21, 2017, 1:21pm UTC](https://verificationacademy.com/forums/t/what-is-the-output-of-the-tlm-fifo-model/33231 "2017-06-21T13:21:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajaraman\_R](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/rajaraman_r/32/3681_2.png) [@Rajaraman\_R](https://verificationacademy.com/forums/u/Rajaraman_R)\
**Post date:** [June 21, 2017, 1:21pm UTC](https://verificationacademy.com/forums/t/what-is-the-output-of-the-tlm-fifo-model/33231/1 "2017-06-21T13:21:36Z")

</div>

Hii,  
I am beginner of the UVM. I am try to code a producer consumer transaction via the tlm fifo. But I am not get the expected value.So how to improve my code .  
Tell your suggestion

And my code is below

```verilog
import uvm_pkg::*;
`include "uvm_macros.svh"

class tlm_seq_item extends uvm_sequence_item;
  
  rand bit a;
  rand byte b;
  rand int c;

  `uvm_object_utils_begin(tlm_seq_item)
     `uvm_field_int(a,UVM_ALL_ON)
     `uvm_field_int(b,UVM_ALL_ON)
     `uvm_field_int(c,UVM_ALL_ON)
   `uvm_object_utils_end

  function new(string name="tlm_seq_item");
     super.new(name);
   endfunction
 
 endclass

class tlm_producer extends uvm_component;
  
    `uvm_component_utils(tlm_producer)

    uvm_blocking_put_port #(tlm_seq_item) my_put_port;

    function new(string name="tlm_produce", uvm_component parent=null);
     super.new(name,parent);
     my_put_port=new("my_put_port",this);
     endfunction
 
  virtual task run_phase(uvm_phase phase);
    for(int i=0;i<5;i++)
      begin
        tlm_seq_item seq;
        seq=tlm_seq_item::type_id::create("seq",this);
        seq.randomize();
        seq.print();
          //$display("IT IS PRODUCER");
        my_put_port.put(seq);
        `uvm_info("SEND",$sformatf("the data ia i=%d %p",i,seq),UVM_LOW)
        #10;
       end

   endtask  

  endclass

class tlm_consumer extends uvm_component;
   
  `uvm_component_utils(tlm_consumer) 

   uvm_blocking_get_port #(tlm_seq_item) my_get_port;

    function new(string name="tlm_consumer",uvm_component parent=null);
       super.new(name,parent);
       my_get_port=new("my_get_port",this);
     endfunction

    virtual task run_phase(uvm_phase phase);
        for(int i=0;i<5;i++)
         begin
           tlm_seq_item seq;
           seq=tlm_seq_item::type_id::create("seq",this);
           my_get_port.get(seq);
           `uvm_info("REC",$sformatf("recieved packet i=%0d %p",i,seq),UVM_LOW)
          end
      endtask
  endclass

class tlm_env extends uvm_env;
 
   `uvm_component_utils(tlm_env)

    uvm_tlm_fifo #(tlm_seq_item) my_fifo;

    tlm_producer producer;
    tlm_consumer consumer;

    function new (string name="tlm_env",uvm_component parent=null);
       super.new(name,parent);
      endfunction

    function void buid_phase(uvm_phase phase);
       super.build_phase(phase);
       producer=tlm_producer::type_id::create("producer",this);
       consumer=tlm_consumer::type_id::create("consumer",this);
         //$display("builded or producer and consumer");
      endfunction

    function void connect_phase(uvm_phase phase);
       producer.my_put_port.connect(my_fifo.put_export);
       consumer.my_get_port.connect(my_fifo.get_export);
      endfunction

    virtual task run_phase(uvm_phase phase);
        phase.raise_objection(this);
         #1000;
        phase.drop_objection(this);
      endtask

  endclass     

module top;
    tlm_env env;
    
    initial begin
      env=new();
      $display("calling");
      run_test();
      $display("end calling");
      end
  endmodule

```

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [June 21, 2017, 2:26pm UTC](https://verificationacademy.com/forums/t/what-is-the-output-of-the-tlm-fifo-model/33231/2 "2017-06-21T14:26:33Z")

</div>

_In reply to [Rajaraman R](https://verificationacademy.com/forums/t/what-is-the-output-of-the-tlm-fifo-model/33231):_

I did not check all your code, but the question is what you get?  
For Scenarios like this there is a sequencer/driver connection adequate.  
Both have all ports and exports you need.  
See examples here: [https://verificationacademy.com/cookbook/cookbook-code-examples#UVM\_Examples:#UVM\_Examples:#UVM\_Examples:](https://verificationacademy.com/cookbook/cookbook-code-examples#UVM_Examples:#UVM_Examples:#UVM_Examples:)

BTW on the same level of hierarchy you can only connect ports with exports.

---

<div class="post-metadata">

**Author:** ![tan\_27](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/df788c/32.png) [@tan\_27](https://verificationacademy.com/forums/u/tan_27)\
**Post date:** [September 30, 2026, 5:52am UTC](https://verificationacademy.com/forums/t/what-is-the-output-of-the-tlm-fifo-model/33231/3 "2026-09-30T05:52:25Z")

</div>

May I know is it required to use TLM FIFOs when non-blocking methods(try\_put(),try\_get(),try\_peek()) are used? And which is preferrable blocking or non-blocking methods here?  
An example code snippet will also be helpful reg this topic
