# How to use tlm\_analysis\_fifo?

**URL:** <https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716>\
**Category:** UVM\
**Tags:** UVM\
**Created:** [July 18, 2013, 11:08am UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716 "2013-07-18T11:08:56Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enzo\_Chi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@Enzo\_Chi](https://verificationacademy.com/forums/u/Enzo_Chi)\
**Post date:** [July 18, 2013, 11:08am UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/1 "2013-07-18T11:08:56Z")

</div>

In my case, I have a packet in monitor need to be sent to scoreboard and in the scoreboard, I would send the packet into different tlm\_analysis\_fifos depends on the content of the packet.

I am confused which ports should I use in this path on each boundary and how to connect them together. I checked the scoreboard in the cookbook, it only shows how to connect the analysis port directory the analysis export to the FIFO which is not suitable for my case.

Thanks.

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [July 18, 2013, 8:17pm UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/2 "2013-07-18T20:17:00Z")

</div>

If these FIFOs are all inside the same scoreboard, then you can instantiate the uvm\_tlm\_analysis\_fifo’s inside your scoreboard. Then have a write method in your scoreboard do the selective writes to your analysis fifos.

```auto
class my_scoreboard extends uvm_scoreboard;
`uvm_component_utils(my_scoreboard)
function new (string name, uvm_component parent);
    super.new(name, parent);
  endfunction

uvm_analysis_imp #(my_transaction1, my_scoreboard) analysis_export; // connects to monitor

// these could be the same transaction types
uvm_tlm_analysis_fifo #(my_transaction2) fifo1;
uvm_tlm_analysis_fifo #(my_transaction3) fifo2;

function build_phase(uvm_phase phase);
  analysis_export = new("analysis_imp", this);
  fifo1 = new("fifo1",this);
  fifo2 = new("fifo2",this);
endfunction

function void write (my_transaction1 t1);
  if (t1.something)
      begin 
      // might need to create or clone t2
      fifo1.write(t2)
      end
   else
   begin 
      // might need to create or clone t3
      fifo1.write(t3)
   end
endfunction

// other scoreboard code that get()s transactions from the fifos.

endclass

```

---

<div class="post-metadata">

**Author:** ![Enzo\_Chi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@Enzo\_Chi](https://verificationacademy.com/forums/u/Enzo_Chi)\
**Post date:** [July 18, 2013, 11:35pm UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/3 "2013-07-18T23:35:24Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/2):_

Hi Dave:

Thank you for you reply and great example code. Problem solved.

---

<div class="post-metadata">

**Author:** ![lilyding](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/l/919ad9/32.png) [@lilyding](https://verificationacademy.com/forums/u/lilyding)\
**Post date:** [March 31, 2015, 9:52pm UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/4 "2015-03-31T21:52:59Z")

</div>

_In reply to [Enzo Chi](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/3):_

Hi Dave,

Does this write function always get called automatically? I added a $display message there, but it seems never get into it …

I have hooked another analysis port to the analysis\_fifo in my env …

Thanks

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [April 1, 2015, 4:20am UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/5 "2015-04-01T04:20:18Z")

</div>

_In reply to [nickbayshore](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/4):_

Not sure what you mean by “automatically”

The write function in the scoreboard gets called if you have properly connected the analysis port of the monitor, and the monitor calls analysis\_port.write()

---

<div class="post-metadata">

**Author:** ![lilyding](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/l/919ad9/32.png) [@lilyding](https://verificationacademy.com/forums/u/lilyding)\
**Post date:** [April 1, 2015, 5:15am UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/6 "2015-04-01T05:15:10Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/5):_

Hi Dave,

Thanks for your reply. Here is my code like, the 1) works but 2) doesn’t work. Basically I have to add another analysis port, connect this analysis port to the monitor first, and then the write gets called, but if I connect the analysis fifo to the monitor directly, the write didn’t gets called … Does it make sense?

1. `uvm\_analysis\_imp\_decl(\_abc)

uvm\_analysis\_imp\_abc abc\_export; —\> Define another

uvm\_tlm\_analysis\_fifo abc\_fifo;

monitor.a\_port.connect(scoreboard.abc\_export); —\> Connect to this ap

function void write\_abc (input my\_transaction1 t1); —\> This one get called. Note it uses write\_abc  
if (t1.something)  
begin  
abc\_fifo.write(t2)  
end

1. uvm\_tlm\_analysis\_fifo abc\_fifo;

function void write (input my\_transaction1 t1); —\> Didn’t get called  
if (t1.something)  
begin  
abc\_fifo.write(t2)  
end

---

<div class="post-metadata">

**Author:** ![lilyding](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/l/919ad9/32.png) [@lilyding](https://verificationacademy.com/forums/u/lilyding)\
**Post date:** [April 2, 2015, 1:43am UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/7 "2015-04-02T01:43:56Z")

</div>

_In reply to [nickbayshore](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/6):_

Does anyone know why I have to add another analysis port in 1) to get it work? i.e. why can’t just connect the monitor to the analysis fifo directly? Thanks!

---

<div class="post-metadata">

**Author:** ![lilyding](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/l/919ad9/32.png) [@lilyding](https://verificationacademy.com/forums/u/lilyding)\
**Post date:** [April 2, 2015, 5:00pm UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/8 "2015-04-02T17:00:42Z")

</div>

_In reply to [nickbayshore](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/7):_

Hi Dave,

Did you get what I mean now? Do you have idea why the write() didn’t get call when connecting the monitor analysis port to the analysis fifo directly? Thanks!

---

<div class="post-metadata">

**Author:** ![baladevi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/b/ee7513/32.png) [@baladevi](https://verificationacademy.com/forums/u/baladevi)\
**Post date:** [February 8, 2018, 10:51am UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/9 "2018-02-08T10:51:18Z")

</div>

Sir,i have one doubt i am new to uvm beginer  
If the analysis port is directly connected to analysis export means what is the need of  
analysis\_imp and uvm\_analysis\_tlm\_fifo ?

---

<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:** [February 8, 2018, 2:32pm UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/10 "2018-02-08T14:32:24Z")

</div>

_In reply to [baladevi](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/9):_

On the same hierarchy Level you can connect only ports with exports. If you are changing the level you can connect ports with ports and exports with exports.  
An analysis\_imp is the last in the chain of analysis exports which has to provide the write-method.  
a uvm\_analysis\_tlm\_fifo is an unbounded TLM fifo.

---

<div class="post-metadata">

**Author:** ![piyushpatel123](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/p/e19b73/32.png) [@piyushpatel123](https://verificationacademy.com/forums/u/piyushpatel123)\
**Post date:** [September 19, 2018, 4:40am UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/11 "2018-09-19T04:40:45Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/10):_

Why we cannot connect port to port at the same hierarchy level but can connect at different hierarchy level?  
The same is valid for export also…??

---

<div class="post-metadata">

**Author:** ![Harish\_G1](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/harish_g1/32/1763_2.png) [@Harish\_G1](https://verificationacademy.com/forums/u/Harish_G1)\
**Post date:** [June 19, 2019, 1:31pm UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/12 "2019-06-19T13:31:26Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/11):_

If I declare an analysis\_export in scoreboard is it necessary to override WRITE method or is it implicitly taken care of?

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [June 19, 2019, 2:24pm UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/13 "2019-06-19T14:24:25Z")

</div>

_In reply to [piyushpatel123](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/12):_

It’s always Port connects to Export at the top level of the connection. Then it’s port-to-port or export-to-export depending on which side of the connection you’re on. Suppose your monitor was 3-levels of hierarchy and your subscriber was 2-levels down. Then your connections would be

port3→port2→port1→export1→export2

---

<div class="post-metadata">

**Author:** ![haykp](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/0ea827/32.png) [@haykp](https://verificationacademy.com/forums/u/haykp)\
**Post date:** [June 24, 2019, 1:59am UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/14 "2019-06-24T01:59:01Z")

</div>

_In reply to [nickbayshore](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/13):_

2)nd case

```verilog
1)uvm_tlm_analysis_fifo abc_fifo;
2)
3) monitor.a_port.connect(m_tbuf_scoreboard.abc_fifo.analysis_export); --> connect to the fifo directly
4)
5)function void write (input my_transaction1 t1); ---> Didn't get called
6)if (t1.something)
7)begin
8)abc_fifo.write(t2)
9)end

```

I cannot understand, why you think that 1st write function (line 5) should be called? Who is the owner of that write?  
Mainly the communication between the ports is done by following way:  
port-\>export-\>implementation  
where the port/export part can be as many as user wants.  
And port can use write task and implementation should implement that write task.  
in other words  
port.write(tlm) → imp: (function write() …)

Now in your example you connect port to export. And than use write (line 5).  
So it wont be called, because there is no imp port in that chain.  
When you connect to subscriber, it internally has imp port, which implements write functions in it.

---

<div class="post-metadata">

**Author:** ![prashantg](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/p/a9adbd/32.png) [@prashantg](https://verificationacademy.com/forums/u/prashantg)\
**Post date:** [July 17, 2024, 7:07am UTC](https://verificationacademy.com/forums/t/how-to-use-tlm-analysis-fifo/28716/15 "2024-07-17T07:07:09Z")

</div>

Hi Dave,

Do we need tlm\_analysis\_fifos here?  
Can’t queues do the job?

Regards,  
Prashant
